public class ExplorerResourcesDAO extends AbstractLogEnabled implements Serviceable, Component, Contextualizable
Modifier and Type | Class and Description |
---|---|
private static class |
ExplorerResourcesDAO.VersionInformation |
Modifier and Type | Field and Description |
---|---|
protected Context |
_cocoonContext
The cocoon context
|
protected Context |
_context
The avalon context
|
protected CurrentUserProvider |
_currentUserProvider
The current user provider.
|
protected ExplorerApplicationExtensionPoint |
_explorerApplicationEP
The explorer application EP
|
protected I18nUtils |
_i18nUtils
I18n utils
|
protected ResourceMetadataPopulatorExtensionPoint |
_metadataPopulatorEP
The metadata populator extension point.
|
protected ObservationManager |
_observationManager
Observer manager.
|
protected AmetysObjectResolver |
_resolver
Ametys resolver
|
protected RightManager |
_rightManager
The rights manager
|
protected ThreadDAO |
_threadDAO
The thread DAO
|
protected TikaProvider |
_tikaProvider
The tika provider.
|
protected UserHelper |
_userHelper
The users manager
|
static String |
RIGHTS_COLLECTION_ADD
Right id to add a folder
|
static String |
RIGHTS_COLLECTION_DELETE
Right id to delete a folder
|
static String |
RIGHTS_COLLECTION_EDIT
Right id to edit a folder
|
static String |
RIGHTS_RESOURCE_ADD
Right id to add a resource
|
static String |
RIGHTS_RESOURCE_COMMENT
Right id to comment a resource
|
static String |
RIGHTS_RESOURCE_DELETE
Right id to delete a resource
|
static String |
RIGHTS_RESOURCE_EDIT_DC
Right id to edit DC metadata of a resource
|
static String |
RIGHTS_RESOURCE_MODERATE_COMMENT
Right id to moderate comment a resource
|
static String |
RIGHTS_RESOURCE_RENAME
Right id to rename a resource
|
static String |
RIGHTS_RESOURCE_UNLOCK_ALL
Right id to unlock all resources
|
static String |
ROLE
Avalon Role
|
Constructor and Description |
---|
ExplorerResourcesDAO() |
Modifier and Type | Method and Description |
---|---|
private void |
_addLockToken(Node node) |
protected boolean |
_canAddComment(UserIdentity user,
CommentableResource resource)
Indicates if an user can add a comment of a given resource
|
protected boolean |
_canDeleteComment(UserIdentity user,
CommentableResource resource,
JCRPost comment)
Indicates if an user can delete a comment of a given resource
|
protected boolean |
_canEditComment(UserIdentity user,
CommentableResource resource,
JCRPost comment)
Indicates if an user can edit a comment of a given resource
|
private Map<String,Object> |
_comment2json(JCRPost comment,
boolean isEdition) |
protected String |
_getComment(JCRPost post)
Get the content of a comment as a String
|
protected String |
_getCommentForEditing(JCRPost post)
Get the content of a comment to edit as a String
|
private void |
_getMatchingExplorerNode(ExplorerNode explorerNode,
String value,
List<String> allowedExtensions,
List<String> matchingPaths) |
private void |
_getMatchingResource(Resource resource,
String value,
List<String> allowedExtensions,
List<String> matchingPaths) |
private void |
_saveChangesIfNeeded(ModifiableResource resource) |
protected void |
_setComment(JCRPost comment,
String content)
Update the content of a comment
|
Map<String,Object> |
addCMISCollection(String parentId,
String originalName,
String url,
String login,
String password,
String repoId,
boolean renameIfExists)
Creates a new CMIS folder (see
CMISRootResourcesCollection ) |
Map<String,Object> |
addComment(String resourceId,
String comment)
Add a comment to a resource
|
ResourceCollection |
addResourceCollection(ModifiableResourceCollection parent,
String desiredName,
Boolean renameIfExists,
List<String> errors)
Add a resource collection
|
Map<String,Object> |
addResourceCollection(String parentId,
String desiredName,
Boolean renameIfExists)
Add a resource collection
|
boolean |
checkLock(AmetysObject ao)
Check lock on a Ametys object
|
void |
checkpoint(ModifiableResource resource)
Creates a new version
|
void |
checkUserRight(AmetysObject object,
String rightId)
Check the user privilege on object
|
void |
contextualize(Context context) |
Map<String,Object> |
copyResource(List<String> ids,
ModifiableResourceCollection target)
Copy file resources
|
Map<String,Object> |
copyResource(List<String> ids,
String target)
Copy file resources
|
ModifiableResource |
createResource(ModifiableResourceCollection collection,
String name)
Creates a
ModifiableResource under current
ModifiableResourceCollection . |
Map<String,Object> |
deleteComment(String resourceId,
String commentId)
Delete the comment of a resource
|
Map<String,Object> |
deleteObject(List<String> ids)
Delete an object
|
String |
deleteObject(RemovableAmetysObject object,
List<String> errors)
Delete an object
|
Map<String,Object> |
editCMISCollection(String id,
String url,
String login,
String password,
String repoId)
Edits a CMIS folder (see
CMISRootResourcesCollection ) |
Map<String,Object> |
editComment(String resourceId,
String commentId,
String comment)
Edit the comment of a resource
|
void |
extractResourceMetadata(ModifiableResource resource,
String mimeType)
Extract the resource's metadata and populate the object accordingly.
|
List<String> |
filterResourcesByRegExp(String id,
String value,
List<String> allowedExtensions)
Get the path of pages which match filter regexp
|
Map<String,String> |
getCMISProperties(String id)
Get the CMIS properties of collection
|
Map<String,Object> |
getComment(String commentId,
boolean isEdition)
Get a comment of a resource
|
List<Map<String,Object>> |
getComments(String resourceId,
boolean isEdition)
Get the comments of a resource
|
Map<String,Object> |
getDCMetadata(String id)
Get the DublinCore metadata of a
DublinCoreAwareAmetysObject |
Map<String,Object> |
getDefaultInfoAsRootNode(ExplorerNode rootNode)
Get the necessary default info for a root node.
|
Map<String,Object> |
getDefaultInfoAsRootNode(String id)
Get the necessary default info for a root node.
|
Map<String,Object> |
getExplorerNodeProperties(ExplorerNode node)
Get the explorer node properties
|
Map<String,Object> |
getNodesInfo(List<String> ids)
Get the informations on given nodes (resources or collections)
|
String |
getResourceCollectionType()
Get the type of child resource collection
|
Map<String,Object> |
getResourceProperties(Resource resource)
Get the resource properties
|
List<ExplorerNode> |
getResourcesRootNodes()
Get the root nodes for resources
|
List<Map<String,Object>> |
getRootNodesInfo()
Retrieves the set of standard data for the explorer root node
|
boolean |
getUserRight(UserIdentity user,
String right,
AmetysObject object)
Retrieve the rights for the user
|
protected Set<String> |
getUserRights(ExplorerNode node)
Get the user rights on the resource collection
|
boolean |
hasRight(String id,
String rightId)
Check current user right on given explorer node
|
boolean |
isCMISCollection(String id)
Determines if a object is a
CMISRootResourcesCollection |
Map<String,Object> |
moveObject(List<String> ids,
JCRTraversableAmetysObject targetNode)
Move objects
|
Map<String,Object> |
moveObject(List<String> ids,
String targetId)
Move objects
|
JCRAmetysObject |
renameObject(JCRAmetysObject object,
String name,
List<String> errors)
Rename a resource, or resource collection
|
Map<String,Object> |
renameObject(String id,
String name)
Rename a resource, or resource collection
|
JCRResource |
renameResource(JCRResource resource,
String name,
List<String> errors)
Rename a resource
|
Map<String,Object> |
renameResource(String id,
String name)
Rename a resource
|
boolean |
resourceExists(String parentId,
String name)
Determines if a resource with given name already exists
|
boolean |
resourceExists(TraversableAmetysObject parent,
String name)
Determines if a resource with given name already exists
|
List<Map<String,Object>> |
resourceHistory(String id)
Get the history versions of a resource
|
void |
restoreResource(String id,
String versionName)
This action restores an old version of a
Resource . |
void |
service(ServiceManager manager) |
void |
setDCMetadata(ModifiableResource resource,
Map<String,Object> values)
Set the Dublin Core metadata of a
Resource . |
void |
setDCMetadata(String resourceId,
Map<String,Object> values)
Set the Dublin Core metadata of a
Resource . |
void |
updateResource(ModifiableResource resource,
InputStream is,
String fileName)
Updates resource input stream and metadata
|
getLogger, setLogger
public static final String RIGHTS_RESOURCE_UNLOCK_ALL
public static final String RIGHTS_RESOURCE_ADD
public static final String RIGHTS_RESOURCE_RENAME
public static final String RIGHTS_RESOURCE_DELETE
public static final String RIGHTS_RESOURCE_EDIT_DC
public static final String RIGHTS_RESOURCE_COMMENT
public static final String RIGHTS_RESOURCE_MODERATE_COMMENT
public static final String RIGHTS_COLLECTION_ADD
public static final String RIGHTS_COLLECTION_EDIT
public static final String RIGHTS_COLLECTION_DELETE
protected AmetysObjectResolver _resolver
protected RightManager _rightManager
protected ObservationManager _observationManager
protected CurrentUserProvider _currentUserProvider
protected I18nUtils _i18nUtils
protected Context _cocoonContext
protected TikaProvider _tikaProvider
protected ResourceMetadataPopulatorExtensionPoint _metadataPopulatorEP
protected UserHelper _userHelper
protected ExplorerApplicationExtensionPoint _explorerApplicationEP
protected ThreadDAO _threadDAO
public ExplorerResourcesDAO()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void contextualize(Context context) throws ContextException
contextualize
in interface Contextualizable
ContextException
public List<ExplorerNode> getResourcesRootNodes()
public List<Map<String,Object>> getRootNodesInfo()
public Map<String,Object> getDefaultInfoAsRootNode(String id)
id
- The root node idpublic Map<String,Object> getDefaultInfoAsRootNode(ExplorerNode rootNode)
rootNode
- The root nodepublic Map<String,Object> getNodesInfo(List<String> ids)
ids
- The ids of nodepublic Map<String,Object> getExplorerNodeProperties(ExplorerNode node)
node
- The explorer nodepublic Map<String,Object> getResourceProperties(Resource resource)
resource
- The resourcespublic List<String> filterResourcesByRegExp(String id, String value, List<String> allowedExtensions)
id
- The id of explorer node to start searchvalue
- the value to matchallowedExtensions
- The allowed file extensions (lower-case). Can be null or empty to not filter on file extensionsprivate void _getMatchingExplorerNode(ExplorerNode explorerNode, String value, List<String> allowedExtensions, List<String> matchingPaths)
private void _getMatchingResource(Resource resource, String value, List<String> allowedExtensions, List<String> matchingPaths)
protected Set<String> getUserRights(ExplorerNode node)
node
- The explorer nodepublic boolean hasRight(String id, String rightId)
id
- The id of the explorer noderightId
- The if of right to checkpublic boolean checkLock(AmetysObject ao)
ao
- the Ametys objectfalse
if the Ametys object is locked and can not be
edited or deletedprivate void _addLockToken(Node node)
public void checkUserRight(AmetysObject object, String rightId) throws IllegalAccessException
object
- the objectrightId
- the right idIllegalAccessException
- if the user has no sufficient rightspublic boolean getUserRight(UserIdentity user, String right, AmetysObject object)
user
- The userright
- The rightobject
- The objectpublic Map<String,Object> addResourceCollection(String parentId, String desiredName, Boolean renameIfExists)
parentId
- The identifier of the parent in which the resource
collection will be addeddesiredName
- The desired name for the resource collectionrenameIfExists
- If false, in case of existing name the resource
collection will not be created, if true it will be created and
renamedpublic ResourceCollection addResourceCollection(ModifiableResourceCollection parent, String desiredName, Boolean renameIfExists, List<String> errors)
parent
- The parent collection in which the resource collection will
be addeddesiredName
- The desired name for the resource collectionrenameIfExists
- If false, in case of existing name the resource
collection will not be created, if true it will be created and
renamederrors
- An optional list of possible error messages in case the
creation failed. Possible values are: locked, already-exist.public String getResourceCollectionType()
public Map<String,Object> renameObject(String id, String name) throws RepositoryException
id
- The id of the object to renamename
- The desired name to set to the object.RepositoryException
- If there is a repository errorpublic JCRAmetysObject renameObject(JCRAmetysObject object, String name, List<String> errors) throws RepositoryException
object
- The object to renamename
- The desired name to set to the object.errors
- An optional list of possible error messages in case the
operation failed. Possible values are: locked, already-exist.RepositoryException
- If there is a repository errorpublic Map<String,Object> deleteObject(List<String> ids)
ids
- The list of identifiers for the objects to deletepublic String deleteObject(RemovableAmetysObject object, List<String> errors)
object
- The object to deleteerrors
- An optional list of possible error messages in case the
creation failed. Possible values are: locked.public Map<String,Object> renameResource(String id, String name) throws RepositoryException
id
- The id of the resource to renamename
- The desired name to set to the resource.RepositoryException
- If there is a repository errorpublic JCRResource renameResource(JCRResource resource, String name, List<String> errors) throws RepositoryException
resource
- The resource to renamename
- The desired name to set to the resource.errors
- An optional list of possible error messages in case the
operation failed. Possible values are: locked, already-exist.RepositoryException
- If there is a repository errorpublic Map<String,Object> copyResource(List<String> ids, String target) throws RepositoryException
ids
- The list of identifiers for the resources to copytarget
- The id of target to copy intoRepositoryException
- If there is a repository errorpublic Map<String,Object> copyResource(List<String> ids, ModifiableResourceCollection target) throws RepositoryException
ids
- The list of identifiers for the resources to copytarget
- The target to copy intoRepositoryException
- If there is a repository errorpublic Map<String,Object> moveObject(List<String> ids, String targetId) throws RepositoryException
ids
- The list of identifiers for the objects to movetargetId
- The id of target to move intoRepositoryException
- If there is a repository errorpublic Map<String,Object> moveObject(List<String> ids, JCRTraversableAmetysObject targetNode) throws RepositoryException
ids
- The list of identifiers for the objects to movetargetNode
- The target to move intoRepositoryException
- If there is a repository errorpublic List<Map<String,Object>> resourceHistory(String id) throws RepositoryException
id
- the id of resourceRepositoryException
- if an error occurredpublic void restoreResource(String id, String versionName)
Resource
.id
- the id of resourceversionName
- the name of version to restorepublic boolean resourceExists(String parentId, String name)
parentId
- the id of parent collectionname
- the name of resourcepublic boolean resourceExists(TraversableAmetysObject parent, String name)
parent
- the parent collectionname
- the name of resourcepublic void setDCMetadata(String resourceId, Map<String,Object> values) throws ProcessingException
Resource
.resourceId
- the id of resourcevalues
- the DC valuesProcessingException
- if an error occurredpublic void setDCMetadata(ModifiableResource resource, Map<String,Object> values)
Resource
.resource
- the resourcevalues
- the DC valuesprivate void _saveChangesIfNeeded(ModifiableResource resource)
public Map<String,Object> getDCMetadata(String id)
DublinCoreAwareAmetysObject
id
- the id of resourcepublic Map<String,Object> addCMISCollection(String parentId, String originalName, String url, String login, String password, String repoId, boolean renameIfExists)
CMISRootResourcesCollection
)parentId
- the id of parent folderoriginalName
- the original name if CMIS folderurl
- The url of CMIS repositorylogin
- The user's login to access CMIS repositorypassword
- The user's password to access CMIS repositoryrepoId
- The id of CMIS repositoryrenameIfExists
- true to automatically renamed CMIS folder if
requested name already existspublic Map<String,Object> editCMISCollection(String id, String url, String login, String password, String repoId)
CMISRootResourcesCollection
)id
- the id of CMIS folderurl
- The url of CMIS repositorylogin
- The user's login to access CMIS repositorypassword
- The user's password to access CMIS repositoryrepoId
- The id of CMIS repositorypublic boolean isCMISCollection(String id)
CMISRootResourcesCollection
id
- The id of objectpublic Map<String,String> getCMISProperties(String id)
id
- The id of CMIS collectionpublic void updateResource(ModifiableResource resource, InputStream is, String fileName)
resource
- The resourceis
- The resource input streamfileName
- The file namepublic void extractResourceMetadata(ModifiableResource resource, String mimeType)
resource
- the resource to populate.mimeType
- the resource MIME type.public void checkpoint(ModifiableResource resource)
resource
- the resourcepublic ModifiableResource createResource(ModifiableResourceCollection collection, String name)
ModifiableResource
under current
ModifiableResourceCollection
.collection
- the parent ModifiableResourceCollection
name
- the name of the child resourceAmetysRepositoryException
- if an error occurs.RepositoryIntegrityViolationException
- if an object with the same
name already exists and same name siblings is not allowed.public Map<String,Object> addComment(String resourceId, String comment)
resourceId
- The id of the resourcecomment
- The commentprotected boolean _canAddComment(UserIdentity user, CommentableResource resource)
user
- An user identityresource
- The resource to commentpublic Map<String,Object> editComment(String resourceId, String commentId, String comment)
resourceId
- The id of the resourcecommentId
- The id of comment to editcomment
- The commentprotected boolean _canEditComment(UserIdentity user, CommentableResource resource, JCRPost comment)
user
- An user identityresource
- The resourcecomment
- The comment to editprotected void _setComment(JCRPost comment, String content)
comment
- The comment to updatecontent
- The content as stringprotected String _getComment(JCRPost post) throws AmetysRepositoryException
post
- the postAmetysRepositoryException
- if failed to parse commentprotected String _getCommentForEditing(JCRPost post) throws AmetysRepositoryException
post
- the postAmetysRepositoryException
- if failed to parse commentpublic Map<String,Object> deleteComment(String resourceId, String commentId)
resourceId
- The id of the resourcecommentId
- The id of comment to deleteprotected boolean _canDeleteComment(UserIdentity user, CommentableResource resource, JCRPost comment)
user
- An user identityresource
- The resourcecomment
- The comment to editpublic List<Map<String,Object>> getComments(String resourceId, boolean isEdition)
resourceId
- The id of the resourceisEdition
- true to get the comments in edit modepublic Map<String,Object> getComment(String commentId, boolean isEdition)
commentId
- The id of the commentisEdition
- true to get the comment in edit modeprivate Map<String,Object> _comment2json(JCRPost comment, boolean isEdition)