public class WorkspaceExplorerResourceDAO extends ExplorerResourcesDAO implements PluginAware
Modifier and Type | Field and Description |
---|---|
private static Pattern |
__IMAGE_FILE_PATTERN
Pattern to test images
|
protected AddOrUpdateResourceHelper |
_addOrUpdateResourceHelper
resource operation helper
|
private HTMLTransformer |
_htmlTransformer |
private WorkspaceModuleExtensionPoint |
_moduleEP |
private String |
_pluginName |
private ProjectManager |
_projectManager
The project manager
|
private ProjectRightHelper |
_projectRightHelper |
private SearcherFactory |
_searcherFactory |
private SourceResolver |
_sourceResolver |
private UserManager |
_userManager |
static String |
FILE
Constant for resource
|
static String |
FOLDER
Constant for resource collection
|
static String |
ROLE
Avalon Role
|
_cocoonContext, _context, _currentUserProvider, _explorerApplicationEP, _i18nUtils, _metadataPopulatorEP, _observationManager, _resolver, _rightManager, _threadDAO, _tikaProvider, _userHelper, RIGHTS_COLLECTION_ADD, RIGHTS_COLLECTION_DELETE, RIGHTS_COLLECTION_EDIT, RIGHTS_RESOURCE_ADD, RIGHTS_RESOURCE_COMMENT, RIGHTS_RESOURCE_DELETE, RIGHTS_RESOURCE_EDIT_DC, RIGHTS_RESOURCE_MODERATE_COMMENT, RIGHTS_RESOURCE_RENAME, RIGHTS_RESOURCE_UNLOCK_ALL
Constructor and Description |
---|
WorkspaceExplorerResourceDAO() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
_canView(Resource file)
Indicates if the current user can view the file
|
protected boolean |
_canView(ResourceCollection folder)
Indicates if the current user can view the folder
|
protected Map<String,Object> |
_extractDocumentData(AmetysObject document,
boolean excludeFolders,
boolean excludeFiles,
boolean excludeFilesInFolderHierarchy)
Internal method to extract the valuable data of a document
|
protected Map<String,Object> |
_extractFileData(Resource file)
Internal method to extract the valuable data of a file
|
protected Map<String,Object> |
_extractFileImageData(Resource file)
Internal method to extract image specific data of a file
|
protected Map<String,Object> |
_extractFileLockData(Resource file)
Internal method to extract the data relative to the lock state of a file
|
protected Map<String,Object> |
_extractFileRightData(Resource file)
Internal method to extract the data concerning the right of the current user for file
|
protected Map<String,Object> |
_extractFolderData(ResourceCollection folder,
boolean excludeFilesInFolderHierarchy)
Internal method to extract the valuable data of a folder
|
protected Map<String,Object> |
_extractFolderRightData(ResourceCollection folder)
Internal method to extract the data concerning the right of the current user for a folder
|
private Long |
_getChildDocumentsCount(ResourceCollection collection) |
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 String |
_getFilePath(Resource file) |
private String |
_getFolderPath(ResourceCollection folder) |
private Project |
_getProjectFomObject(AmetysObject ametysObject) |
private Project |
_getProjectFromRequest() |
private ResourceCollection |
_getRootFromObject(AmetysObject ametysObject) |
private ResourceCollection |
_getRootFromProject(Project project) |
private ResourceCollection |
_getRootFromRequest() |
private ResourceCollection |
_getRootIfNull(ResourceCollection document) |
private ResourceCollection |
_getRootIfNull(String documentId) |
protected boolean |
_hasChildDocuments(ResourceCollection folder,
boolean excludeFilesInFolderHierarchy)
Internal method to detect if a document has child
|
private List<String> |
_sanitizeFileTags(Collection<String> tags) |
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> |
addFile(InputStream inputStream,
String fileName,
String parentId,
boolean unarchive,
boolean allowRename,
boolean allowUpdate)
Add a file
|
Map<String,Object> |
addFile(Part part,
String parentId,
boolean unarchive,
boolean allowRename,
boolean allowUpdate)
Add a file
|
Map<String,Object> |
addFolder(String parentId,
String inputName,
String description,
Boolean renameIfExists)
Add a folder
|
Map<String,Object> |
copyFiles(List<String> ids,
String targetId)
Copy file resources
|
Map<String,Object> |
deleteFolder(String id)
Delete a folder
|
Map<String,Object> |
editCMISCollection(String id,
String name,
String url,
String login,
String password,
String repoId)
Edits a CMIS folder (see
CMISRootResourcesCollection ) |
Map<String,Object> |
editFile(String id,
String inputName,
String description,
Collection<String> tags)
Edit a file
|
Map<String,Object> |
editFolder(String id,
String inputName,
String description)
Edit a folder
|
private Map<String,Object> |
generateActionResult(ResourceCollection folder,
AddOrUpdateResourceHelper.ResourceOperationResult operationResult) |
String |
generateWebdavUri(String documentId)
Generates an uri to open a document through webdav
|
List<Map<String,Object>> |
getChildDocumentsData(ResourceCollection document,
boolean excludeFilesInFolderHierarchy)
Retrieves the children of a document and extracts its data.
|
List<Map<String,Object>> |
getChildDocumentsData(ResourceCollection document,
boolean excludeFolders,
boolean excludeFiles,
boolean excludeFilesInFolderHierarchy)
Retrieves the children of a document and extracts its data.
|
List<Map<String,Object>> |
getChildDocumentsData(String parentId,
boolean excludeFilesInFolderHierarchy)
Retrieves the children of a document and extracts its data.
|
List<Map<String,Object>> |
getChildDocumentsData(String parentId,
boolean excludeFolders,
boolean excludeFiles,
boolean excludeFilesInFolderHierarchy)
Retrieves the children of a document and extracts its data.
|
Map<String,String> |
getCMISProperties(String id)
Get the CMIS properties of collection
|
Map<String,Object> |
getDocumentData(String id,
boolean excludeFilesInFolderHierarchy)
Retrieves the set of standard data for a document (folder or resource)
|
Long |
getDocumentsCount(Project project)
Count the total of documents in the project
|
List<Map<String,Object>> |
getDocumentsData(List<String> ids,
boolean excludeFilesInFolderHierarchy)
Retrieves the set of standard data for a list of documents
|
private ModifiableResourceCollection |
getModifiableResourceCollection(String ametysId)
get a
ModifiableResourceCollection for an ID, or the root folder; |
private AddOrUpdateResourceHelper.ResourceOperationMode |
getOperationMode(boolean unarchive,
boolean allowRename,
boolean allowUpdate)
returns the
AddOrUpdateResourceHelper.ResourceOperationMode according to parameters |
boolean |
isCMISCollection(String id)
Determines if a object is a
CMISRootResourcesCollection |
Map<String,Object> |
lockResources(List<String> ids)
Lock resources
|
Map<String,Object> |
moveDocuments(List<String> ids,
String targetId)
Move documents (files or folders)
|
boolean |
resourceExists(String parentId,
String name)
Determines if a resource with given name already exists
|
Map<String,Object> |
searchFiles(String query,
String lang)
Search for files in the document module
|
void |
service(ServiceManager manager) |
void |
setPluginInfo(String pluginName,
String featureName,
String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level. |
Map<String,Object> |
unlockResources(List<String> ids)
Unlock resources
|
_canAddComment, _canDeleteComment, _canEditComment, addComment, addResourceCollection, addResourceCollection, checkLock, checkpoint, checkUserRight, contextualize, copyResource, copyResource, createResource, deleteComment, deleteObject, deleteObject, editCMISCollection, editComment, extractResourceMetadata, filterResourcesByRegExp, getComment, getComments, getDCMetadata, getDefaultInfoAsRootNode, getDefaultInfoAsRootNode, getExplorerNodeProperties, getNodesInfo, getResourceCollectionType, getResourceProperties, getResourcesRootNodes, getRootNodesInfo, getUserRight, getUserRights, hasRight, moveObject, moveObject, renameObject, renameObject, renameResource, renameResource, resourceExists, resourceHistory, restoreResource, setDCMetadata, setDCMetadata, updateResource
getLogger, setLogger
public static final String FOLDER
public static final String FILE
private static final Pattern __IMAGE_FILE_PATTERN
protected AddOrUpdateResourceHelper _addOrUpdateResourceHelper
private ProjectManager _projectManager
private HTMLTransformer _htmlTransformer
private SourceResolver _sourceResolver
private String _pluginName
private SearcherFactory _searcherFactory
private UserManager _userManager
private ProjectRightHelper _projectRightHelper
private WorkspaceModuleExtensionPoint _moduleEP
public WorkspaceExplorerResourceDAO()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
service
in class ExplorerResourcesDAO
ServiceException
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic Map<String,Object> addFolder(String parentId, String inputName, String description, Boolean renameIfExists) throws IllegalAccessException
parentId
- Identifier of the parent collection. Can be null to add folder to root folder.inputName
- The desired namedescription
- The folder descriptionrenameIfExists
- True to rename if existingIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> editFolder(String id, String inputName, String description) throws IllegalAccessException
id
- Identifier of the folder to editinputName
- The desired namedescription
- The folder descriptionIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> deleteFolder(String id) throws IllegalAccessException
id
- Identifier of the folder to deleteIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> lockResources(List<String> ids)
ids
- The id of resources to lockpublic Map<String,Object> unlockResources(List<String> ids)
ids
- The id of resources to lockpublic boolean resourceExists(String parentId, String name)
resourceExists
in class ExplorerResourcesDAO
parentId
- the id of parent collection. Can be null.name
- the name of resourcepublic Map<String,Object> editFile(String id, String inputName, String description, Collection<String> tags) throws IllegalAccessException
id
- Identifier of the file to editinputName
- The desired namedescription
- The file descriptiontags
- The file tagsIllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> copyFiles(List<String> ids, String targetId) throws RepositoryException
ids
- The list of identifiers for the resources to copytargetId
- The id of target to copy into. Can be null to copy into root folder.RepositoryException
- If there is a repository errorpublic Map<String,Object> moveDocuments(List<String> ids, String targetId) throws RepositoryException
ids
- The list of identifiers for the objects to movetargetId
- The id of target to move into. Can be null to move documents to root folder.RepositoryException
- If there is a repository errorpublic Map<String,Object> searchFiles(String query, String lang) throws Exception
query
- The search querylang
- The search languageException
- if an exception occurspublic List<Map<String,Object>> getChildDocumentsData(String parentId, boolean excludeFilesInFolderHierarchy)
parentId
- Identifier of the parent collectionexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic List<Map<String,Object>> getChildDocumentsData(String parentId, boolean excludeFolders, boolean excludeFiles, boolean excludeFilesInFolderHierarchy)
parentId
- Identifier of the parent collection. Can be null to get children of root folder.excludeFolders
- Folders will be excluded if trueexcludeFiles
- Files will be excluded if trueexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic List<Map<String,Object>> getChildDocumentsData(ResourceCollection document, boolean excludeFilesInFolderHierarchy)
document
- the documentexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic List<Map<String,Object>> getChildDocumentsData(ResourceCollection document, boolean excludeFolders, boolean excludeFiles, boolean excludeFilesInFolderHierarchy)
document
- the documentexcludeFolders
- Folders will be excluded if trueexcludeFiles
- Files will be excluded if trueexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic Map<String,Object> getDocumentData(String id, boolean excludeFilesInFolderHierarchy)
id
- the document id or null to get root documentexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic List<Map<String,Object>> getDocumentsData(List<String> ids, boolean excludeFilesInFolderHierarchy)
ids
- The list of document identifiersexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderpublic String generateWebdavUri(String documentId)
documentId
- The document identifierprivate ResourceCollection _getRootIfNull(ResourceCollection document)
private ResourceCollection _getRootIfNull(String documentId)
private ResourceCollection _getRootFromRequest()
private ResourceCollection _getRootFromObject(AmetysObject ametysObject)
private ResourceCollection _getRootFromProject(Project project)
private Project _getProjectFromRequest()
private Project _getProjectFomObject(AmetysObject ametysObject)
protected Map<String,Object> _extractDocumentData(AmetysObject document, boolean excludeFolders, boolean excludeFiles, boolean excludeFilesInFolderHierarchy)
document
- The document (file or folder)excludeFolders
- Folders will be excluded if trueexcludeFiles
- Files will be excluded if trueexcludeFilesInFolderHierarchy
- Should child files be taken into account when extracting data of a folderprotected Map<String,Object> _extractFolderData(ResourceCollection folder, boolean excludeFilesInFolderHierarchy)
folder
- The folderexcludeFilesInFolderHierarchy
- Should child files be taken into account to compute the 'hasChildDocuments' data.private String _getFolderPath(ResourceCollection folder)
protected boolean _hasChildDocuments(ResourceCollection folder, boolean excludeFilesInFolderHierarchy)
folder
- The folderexcludeFilesInFolderHierarchy
- Should child files be taken into account to compute the 'hasChildDocuments' data.protected Map<String,Object> _extractFolderRightData(ResourceCollection folder)
folder
- The folderpublic Map<String,Object> addFile(Part part, String parentId, boolean unarchive, boolean allowRename, boolean allowUpdate) throws IllegalAccessException
part
- The uploaded part corresponding to the fileparentId
- Identifier of the parent collectionunarchive
- True if the file is an archive that should be unarchived (only available for ZIP file)allowRename
- True if the file can be renamed if it already existsallowUpdate
- True if the file can be updated if it already exists (and allowRename is false)IllegalAccessException
- If the user has no sufficient rightspublic Map<String,Object> addFile(InputStream inputStream, String fileName, String parentId, boolean unarchive, boolean allowRename, boolean allowUpdate) throws IllegalAccessException
inputStream
- The uploaded input streamfileName
- desired file nameparentId
- Identifier of the parent collectionunarchive
- True if the file is an archive that should be unarchived (only available for ZIP file)allowRename
- True if the file can be renamed if it already existsallowUpdate
- True if the file can be updated if it already exists (and allowRename is false)IllegalAccessException
- If the user has no sufficient rightsprivate ModifiableResourceCollection getModifiableResourceCollection(String ametysId)
ModifiableResourceCollection
for an ID, or the root folder;ametysId
- id of the resource. Can be null to get root folder.IllegalClassException
- if id links to a node which is not a ModifiableResourceCollection
private AddOrUpdateResourceHelper.ResourceOperationMode getOperationMode(boolean unarchive, boolean allowRename, boolean allowUpdate)
AddOrUpdateResourceHelper.ResourceOperationMode
according to parametersunarchive
- unarchiveallowRename
- allowRenameallowUpdate
- allowUpdateprivate Map<String,Object> generateActionResult(ResourceCollection folder, AddOrUpdateResourceHelper.ResourceOperationResult operationResult)
protected Map<String,Object> _extractFileData(Resource file)
file
- The fileprivate String _getFilePath(Resource file)
protected Map<String,Object> _extractFileImageData(Resource file)
file
- The fileprotected Map<String,Object> _extractFileRightData(Resource file)
file
- The fileprotected Map<String,Object> _extractFileLockData(Resource file)
file
- The fileprivate List<String> _sanitizeFileTags(Collection<String> tags) throws AmetysRepositoryException
AmetysRepositoryException
protected void _setComment(JCRPost comment, String content)
ExplorerResourcesDAO
_setComment
in class ExplorerResourcesDAO
comment
- The comment to updatecontent
- The content as stringprotected String _getComment(JCRPost post) throws AmetysRepositoryException
ExplorerResourcesDAO
_getComment
in class ExplorerResourcesDAO
post
- the postAmetysRepositoryException
- if failed to parse commentprotected String _getCommentForEditing(JCRPost post) throws AmetysRepositoryException
ExplorerResourcesDAO
_getCommentForEditing
in class ExplorerResourcesDAO
post
- the postAmetysRepositoryException
- if failed to parse commentprotected boolean _canView(ResourceCollection folder)
folder
- The folder to testprotected boolean _canView(Resource file)
file
- The file to testpublic Map<String,String> getCMISProperties(String id)
ExplorerResourcesDAO
getCMISProperties
in class ExplorerResourcesDAO
id
- The id of CMIS collectionpublic Map<String,Object> addCMISCollection(String parentId, String originalName, String url, String login, String password, String repoId, boolean renameIfExists)
ExplorerResourcesDAO
CMISRootResourcesCollection
)addCMISCollection
in class ExplorerResourcesDAO
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 name, String url, String login, String password, String repoId) throws RepositoryException
CMISRootResourcesCollection
)id
- the id of CMIS foldername
- The name of the 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 repositoryRepositoryException
- If an error occurredpublic boolean isCMISCollection(String id)
ExplorerResourcesDAO
CMISRootResourcesCollection
isCMISCollection
in class ExplorerResourcesDAO
id
- The id of objectpublic Long getDocumentsCount(Project project)
project
- The projectprivate Long _getChildDocumentsCount(ResourceCollection collection)