Class ResourceHelper
java.lang.Object
org.ametys.plugins.explorer.resources.ResourceHelper
Helper class that provides utility methods to work with resources.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JCRResourcesCollectiongetOrCreateResourcesCollection(AmetysObjectResolver ametysObjectResolver, String path) Get or create resources collections by path.static TraversableAmetysObjectgetResourceRoot(Resource resource) Get the resource root of a resource.static TraversableAmetysObjectgetResourceRoot(ResourceCollection collection) Get the resource root of a resource collection.static CMISRootResourcesCollectionrestoreCMISCollection(CMISRootResourcesCollection cmisResourcesCollectionToRestore, JCRResourcesCollection parentResourcesCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode) Restore a CMIS root resources collection.static JCRResourcerestoreResource(JCRResource resourceToRestore, JCRResourcesCollection parentResourcesCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode, ExplorerResourcesDAO resourcesDAO) Restore a resource from the trash into a resource collection.static JCRResourcesCollectionrestoreResourcesCollection(JCRResourcesCollection resourcesCollectionToRestore, JCRResourcesCollection parentResourceCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode, ExplorerResourcesDAO resourcesDAO) Clone or merge the resource collection to the given parent node keeping the identifiers.
-
Method Details
-
getResourceRoot
Get the resource root of a resource.- Parameters:
resource- The resource.- Returns:
- The resource root.
-
getResourceRoot
Get the resource root of a resource collection.- Parameters:
collection- The resource collection.- Returns:
- The resource root.
-
getOrCreateResourcesCollection
public static JCRResourcesCollection getOrCreateResourcesCollection(AmetysObjectResolver ametysObjectResolver, String path) Get or create resources collections by path. Try to retrieve a resources collection with his path. If resources collections are missing, create them.- Parameters:
ametysObjectResolver- the ametys object resolverpath- the parent path- Returns:
- the resources collection related to the path or null if the path cannot be created
-
restoreResourcesCollection
public static JCRResourcesCollection restoreResourcesCollection(JCRResourcesCollection resourcesCollectionToRestore, JCRResourcesCollection parentResourceCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode, ExplorerResourcesDAO resourcesDAO) throws ConflictingNameException, AmetysRepositoryException Clone or merge the resource collection to the given parent node keeping the identifiers. To be able to do that, parent resource collection should be in another workspace than the resource collection to restore. This method does not save the parent node.- Parameters:
resourcesCollectionToRestore- The resource collection to restoreparentResourceCollection- The parent resource collection where the element will be restoredmergeComputationMode- The merge computation mode (ERROR, RENAME or UPDATE)resourcesDAO- The resources DAO- Returns:
- the created or merged resource collection
- Throws:
ConflictingNameException- if a conflicting name is found and mode is ERROR or nullAmetysRepositoryException- if a repository error occurs
-
restoreCMISCollection
public static CMISRootResourcesCollection restoreCMISCollection(CMISRootResourcesCollection cmisResourcesCollectionToRestore, JCRResourcesCollection parentResourcesCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode) throws ConflictingNameException, AmetysRepositoryException Restore a CMIS root resources collection.- Parameters:
cmisResourcesCollectionToRestore- The CMIS resources collection to restoreparentResourcesCollection- The parent resource collection where the element will be restoredmergeComputationMode- The merge computation mode (ERROR, RENAME or UPDATE)- Returns:
- the restored CMIS resource collection
- Throws:
ConflictingNameException- if a conflicting name is found and mode is ERROR or nullAmetysRepositoryException- if a repository error occurs
-
restoreResource
public static JCRResource restoreResource(JCRResource resourceToRestore, JCRResourcesCollection parentResourcesCollection, TrashableAmetysObject.MergeComputationMode mergeComputationMode, ExplorerResourcesDAO resourcesDAO) throws ConflictingNameException, AmetysRepositoryException Restore a resource from the trash into a resource collection.- Parameters:
resourceToRestore- The resource from the trash to restoreparentResourcesCollection- The target resource collection to restore intomergeComputationMode- The merge computation mode (ERROR, RENAME or UPDATE)resourcesDAO- The resources DAO- Returns:
- the restored resource
- Throws:
ConflictingNameException- if a conflicting name is found and mode is ERROR or nullAmetysRepositoryException- if a repository error occurs
-