001/* 002 * Copyright 2024 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.plugins.workspaces.documents.jcr; 017 018import javax.jcr.Node; 019 020import org.ametys.plugins.explorer.resources.jcr.JCRResourcesCollection; 021import org.ametys.plugins.repository.AmetysObject; 022import org.ametys.plugins.repository.AmetysRepositoryException; 023import org.ametys.plugins.workspaces.project.objects.Project; 024import org.ametys.web.repository.SiteAwareAmetysObject; 025import org.ametys.web.repository.site.Site; 026 027/** 028 * Implementation of a {@link JCRResourcesCollection} that handles {@link File}s, backed by a JCR node.<br> 029 */ 030public class Folder extends JCRResourcesCollection<FolderFactory>implements SiteAwareAmetysObject 031{ 032 033 /** 034 * Creates an {@link Folder}. 035 * @param node the node backing this {@link AmetysObject} 036 * @param parentPath the parentPath in the Ametys hierarchy 037 * @param factory the DefaultAmetysObjectFactory which created the AmetysObject 038 */ 039 public Folder(Node node, String parentPath, FolderFactory factory) 040 { 041 super(node, parentPath, factory); 042 } 043 044 @Override 045 public String getResourceType() 046 { 047 return FileFactory.FILE_NODETYPE; 048 } 049 050 @Override 051 public String getCollectionType() 052 { 053 return FolderFactory.FOLDER_NODETYPE; 054 } 055 056 057 058 public String getSiteName() throws AmetysRepositoryException 059 { 060 return getSite().getName(); 061 } 062 063 public Site getSite() throws AmetysRepositoryException 064 { 065 Project project = _getFactory().getProjectManager().getParentProject(this); 066 return project.getSite(); 067 } 068}