Class FileFolderServiceImpl
java.lang.Object
org.alfresco.repo.copy.AbstractBaseCopyService
org.alfresco.repo.model.filefolder.FileFolderServiceImpl
- All Implemented Interfaces:
FileFolderService,Extensible
public class FileFolderServiceImpl
extends AbstractBaseCopyService
implements FileFolderService, Extensible
Implementation of the file/folder-specific service.
- Author:
- Derek Hulley
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classException when the type is not a valid File or Folder typeNested classes/interfaces inherited from class org.alfresco.repo.copy.AbstractBaseCopyService
AbstractBaseCopyService.AssociationCopyInfo -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCopy a source file or folder.Create a file or folder; or any valid node of type derived from file or folder.Create a file or folder; or any valid node of type derived from file or foldervoidDelete a file or folderbooleanCheck the validity of a node referencegetFileInfo(NodeRef nodeRef) Get the file info (name, folder, etc) for the given nodegetLocalizedSibling(NodeRef nodeRef) Uses the cm:name of the given node and attempts to find a sibling node with a more specific localized name.getNameOnlyPath(NodeRef rootNodeRef, NodeRef nodeRef) Get the file or folder names from the root down to and including the node provided.getNamePath(NodeRef rootNodeRef, NodeRef nodeRef) Get the file or folder information from the root down to and including the node provided.Get the reader to the file represented by the node according to the File/Folder model.<M extends Trait>
ExtendedTrait<M>Checks the type for whether it is a recognised file or folder type or is invalid for the FileFolderService.Get the writer to the file represented by the node according to the File/Folder model.voidinit()booleanbooleanLists immediate child files and folders of the given context node.org.alfresco.query.PagingResults<FileInfo>list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Lists page of immediate child files and/or folders of the given context node with pattern matching and optional filtering (exclusion of certain child file/folder subtypes) and sorting Pattern uses '*' as a wildcardorg.alfresco.query.PagingResults<FileInfo>list(NodeRef contextNodeRef, boolean files, boolean folders, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Lists page of immediate child files and/or folders of the given context node with optional filtering (exclusion of certain child file/folder subtypes) and sorting
author janvorg.alfresco.query.PagingResults<FileInfo>list(NodeRef rootNodeRef, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Lists page of immediate child objects of the given context node with specification of which types to list and optional filtering (exclusion of certain child file/folder subtypes) and sortingorg.alfresco.query.PagingResults<FileInfo>list(NodeRef rootNodeRef, Set<QName> assocTypeQNames, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, List<FilterProp> filterProps, org.alfresco.query.PagingRequest pagingRequest) Lists page of immediate child objects of the given context node with specification of which types to list and optional filtering (exclusion of certain child file/folder subtypes) and sortinglistDeepFolders(NodeRef contextNodeRef, SubFolderFilter filter) Lists all folders below the given context node, both immediate and lower levels The filter parameter allows subfolders to be excluded from the search.Lists all immediate child files of the given context node Note: this could be a long list (and will be trimmed at a pre-configured maximum).listFolders(NodeRef contextNodeRef) Lists all immediate child folders of the given context node Note: this could be a long list (and will be trimmed at a pre-configured maximum).static FileInfomakeFolders(FileFolderService service, NodeRef parentNodeRef, List<String> pathElements, QName folderTypeQName) Deprecated.Use FileFolderUtil.makeFolders rather than directly accessing this implementation class.makeFolders(NodeRef parentNodeRef, List<String> pathElements, QName folderTypeQName) Deprecated.Use FileFolderUtil.makeFolders rather than directly accessing this implementation class.Move a file or folder to a new name and/or location.Deprecated.Move a file or folder to a new name and/or location.Rename a file or folder in its current locationresolveNamePath(NodeRef rootNodeRef, List<String> pathElements) Resolve a file or folder name path from a given root node down to the final node.resolveNamePath(NodeRef rootNodeRef, List<String> pathElements, boolean mustExist) Resolve a file or folder name path from a given root node down to the final node.Searches for all files and folders with the matching name pattern, using wildcard characters * and ?.search(NodeRef contextNodeRef, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) Full search with all optionssearchSimple(NodeRef contextNodeRef, String name) Get a node ref of the node that has the name within the parent nodevoidsetBehaviourFilter(BehaviourFilter behaviourFilter) voidsetCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry<org.alfresco.query.CannedQueryFactory<NodeRef>> cannedQueryRegistry) Set the registry ofcanned queriesvoidsetContentService(ContentService contentService) voidsetCopyService(CopyService copyService) voidsetDefaultListMaxResults(int defaultListMaxResults) voidsetDictionaryService(DictionaryService dictionaryService) voidvoidsetHiddenAspect(HiddenAspect hiddenAspect) voidsetMimetypeService(MimetypeService mimetypeService) voidsetNamespaceService(NamespaceService namespaceService) voidsetNodeService(NodeService nodeService) voidsetPreserveAuditableData(boolean preserveAuditableData) voidsetSearchService(SearchService searchService) voidsetSystemPaths(List<String> systemPaths) toFileInfoList(List<NodeRef> nodeRefs) Methods inherited from class org.alfresco.repo.copy.AbstractBaseCopyService
getAssociationCopyInfo, getSystemNamespaces, setSystemNamespaces
-
Constructor Details
-
FileFolderServiceImpl
public FileFolderServiceImpl()Default constructor
-
-
Method Details
-
setNamespaceService
-
setDictionaryService
-
setNodeService
-
setCopyService
-
setSearchService
-
setContentService
-
setMimetypeService
-
setHiddenAspect
-
setCannedQueryRegistry
public void setCannedQueryRegistry(org.alfresco.util.registry.NamedObjectRegistry<org.alfresco.query.CannedQueryFactory<NodeRef>> cannedQueryRegistry) Set the registry ofcanned queries -
setSystemPaths
-
setDefaultListMaxResults
public void setDefaultListMaxResults(int defaultListMaxResults) -
setBehaviourFilter
-
setPreserveAuditableData
public void setPreserveAuditableData(boolean preserveAuditableData) -
isPreserveAuditableData
public boolean isPreserveAuditableData() -
init
public void init() -
toFileInfoList
Description copied from interface:FileFolderService- Specified by:
toFileInfoListin interfaceFileFolderService- Returns:
- list of
FileInfo
-
exists
Description copied from interface:FileFolderServiceCheck the validity of a node reference- Specified by:
existsin interfaceFileFolderService- Returns:
- returns true if the NodeRef is valid
-
getType
Description copied from interface:FileFolderServiceChecks the type for whether it is a recognised file or folder type or is invalid for the FileFolderService.- Specified by:
getTypein interfaceFileFolderService- Parameters:
typeQName- the type to check- Returns:
- - the type
-
list
Description copied from interface:FileFolderServiceLists immediate child files and folders of the given context node. Note: this could be a long list (and will be trimmed at a pre-configured maximum). You should consider using a paging request.- Specified by:
listin interfaceFileFolderService- Parameters:
contextNodeRef- the node to start searching in- Returns:
- Returns a list of matching files and folders
-
list
@Auditable(parameters={"contextNodeRef","files","folders","ignoreQNames","sortProps","pagingRequest"}) public org.alfresco.query.PagingResults<FileInfo> list(NodeRef contextNodeRef, boolean files, boolean folders, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:FileFolderServiceLists page of immediate child files and/or folders of the given context node with optional filtering (exclusion of certain child file/folder subtypes) and sorting
author janv- Specified by:
listin interfaceFileFolderService
-
list
public org.alfresco.query.PagingResults<FileInfo> list(NodeRef contextNodeRef, boolean files, boolean folders, String pattern, Set<QName> ignoreQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:FileFolderServiceLists page of immediate child files and/or folders of the given context node with pattern matching and optional filtering (exclusion of certain child file/folder subtypes) and sorting Pattern uses '*' as a wildcard- Specified by:
listin interfaceFileFolderService
-
list
public org.alfresco.query.PagingResults<FileInfo> list(NodeRef rootNodeRef, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:FileFolderServiceLists page of immediate child objects of the given context node with specification of which types to list and optional filtering (exclusion of certain child file/folder subtypes) and sorting- Specified by:
listin interfaceFileFolderService- Parameters:
rootNodeRef- NodeRefsearchTypeQNames- QNames of types to listpagingRequest- PagingRequest- Returns:
- list of node refs, never null
-
list
public org.alfresco.query.PagingResults<FileInfo> list(NodeRef rootNodeRef, Set<QName> assocTypeQNames, Set<QName> searchTypeQNames, Set<QName> ignoreAspectQNames, List<Pair<QName, Boolean>> sortProps, List<FilterProp> filterProps, org.alfresco.query.PagingRequest pagingRequest) Description copied from interface:FileFolderServiceLists page of immediate child objects of the given context node with specification of which types to list and optional filtering (exclusion of certain child file/folder subtypes) and sorting- Specified by:
listin interfaceFileFolderService- Parameters:
rootNodeRef- NodeRefassocTypeQNames- QNames of assoc types to listsearchTypeQNames- QNames of node types to listpagingRequest- PagingRequest- Returns:
- list of node refs, never null
-
listFiles
Description copied from interface:FileFolderServiceLists all immediate child files of the given context node Note: this could be a long list (and will be trimmed at a pre-configured maximum). You should consider using a paging request.- Specified by:
listFilesin interfaceFileFolderService- Parameters:
contextNodeRef- the folder nodeRef to start searching in- Returns:
- Returns a list of matching files
-
listFolders
Description copied from interface:FileFolderServiceLists all immediate child folders of the given context node Note: this could be a long list (and will be trimmed at a pre-configured maximum). You should consider using a paging request.- Specified by:
listFoldersin interfaceFileFolderService- Parameters:
contextNodeRef- the node to start searching in- Returns:
- Returns a list of matching folders
-
listDeepFolders
Description copied from interface:FileFolderServiceLists all folders below the given context node, both immediate and lower levels The filter parameter allows subfolders to be excluded from the search.- Specified by:
listDeepFoldersin interfaceFileFolderService- Parameters:
contextNodeRef- the node to start searching infilter- - may be null in which case all sub-folders will be searched
-
getLocalizedSibling
Description copied from interface:FileFolderServiceUses the cm:name of the given node and attempts to find a sibling node with a more specific localized name. The node passed in must represent the base of the possible translations i.e. the base name for the resource names will be calculated using the filename without extension. The locale used will come fromthe thread's default locale.- Specified by:
getLocalizedSiblingin interfaceFileFolderService- Parameters:
nodeRef- the node that acts as the baseline for the search- Returns:
- Returns a sibling node or the original node
-
searchSimple
Description copied from interface:FileFolderServiceGet a node ref of the node that has the name within the parent node- Specified by:
searchSimplein interfaceFileFolderService- Parameters:
contextNodeRef- the parent nodename- the name of the node to search for- Returns:
- Returns the node that has the given name - or null if not found
-
search
Description copied from interface:FileFolderServiceSearches for all files and folders with the matching name pattern, using wildcard characters * and ?. Warning: Please avoid using this method with any "namePattern" other than "*". Although it works, its performance is poor, which is why this method is deprecated.- Specified by:
searchin interfaceFileFolderService- Parameters:
contextNodeRef- the context of the search. This node will never be returned as part of the search results.namePattern- the name of the file or folder to search for, or awildcardpattern to search for.includeSubFolders- true to search the entire hierarchy below the search context- Returns:
- Returns a list of file or folder matches
- See Also:
-
search
public List<FileInfo> search(NodeRef contextNodeRef, String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders) Full search with all options- Specified by:
searchin interfaceFileFolderService- Parameters:
contextNodeRef- the context of the search. This node will never be returned as part of the search results.namePattern- the name of the file or folder to search for, or awildcardpattern to search for.fileSearch- true if file types are to be included in the search resultsfolderSearch- true if folder types are to be included in the search resultsincludeSubFolders- true to search the entire hierarchy below the search context- Returns:
- Returns a list of file or folder matches
-
rename
public FileInfo rename(NodeRef sourceNodeRef, String newName) throws FileExistsException, FileNotFoundException Description copied from interface:FileFolderServiceRename a file or folder in its current location- Specified by:
renamein interfaceFileFolderService- Parameters:
sourceNodeRef- the file or folder to renamenewName- the new name- Returns:
- Return the new file info
- Throws:
FileExistsException- if a file or folder with the new name already existsFileNotFoundException- the file or folder reference doesn't exist- See Also:
-
move
public FileInfo move(NodeRef sourceNodeRef, NodeRef targetParentRef, String newName) throws FileExistsException, FileNotFoundException Description copied from interface:FileFolderServiceMove a file or folder to a new name and/or location.If both the parent folder and name remain the same, then nothing is done.
- Specified by:
movein interfaceFileFolderService- Parameters:
sourceNodeRef- the file or folder to movetargetParentRef- the new parent node to move the node to - null means rename in situnewName- the name to change the file or folder to - null to keep the existing name- Returns:
- Returns the new file info
- Throws:
FileExistsExceptionFileNotFoundException- See Also:
-
moveOrCopy(NodeRef, NodeRef, NodeRef, String, boolean)
-
moveFrom
public FileInfo moveFrom(NodeRef sourceNodeRef, NodeRef sourceParentRef, NodeRef targetParentRef, String newName) throws FileExistsException, FileNotFoundException Description copied from interface:FileFolderServiceMove a file or folder to a new name and/or location.If both the parent folder and name remain the same, then nothing is done.
It is possible to specify which is the parent node when moving nodes; nodes can reside in multiple locations.- Specified by:
moveFromin interfaceFileFolderService- Parameters:
sourceNodeRef- the file or folder to movesourceParentRef- the source parent of node - null means move from primary parenttargetParentRef- the new parent node to move the node to - null means rename in situnewName- the name to change the file or folder to - null to keep the existing name- Returns:
- Returns the new file info
- Throws:
FileExistsExceptionFileNotFoundException- See Also:
-
moveOrCopy(NodeRef, NodeRef, NodeRef, String, boolean)
-
move
public FileInfo move(NodeRef sourceNodeRef, NodeRef sourceParentRef, NodeRef targetParentRef, String newName) throws FileExistsException, FileNotFoundException Deprecated.- Specified by:
movein interfaceFileFolderService- Throws:
FileExistsExceptionFileNotFoundException
-
copy
public FileInfo copy(NodeRef sourceNodeRef, NodeRef targetParentRef, String newName) throws FileExistsException, FileNotFoundException Description copied from interface:FileFolderServiceCopy a source file or folder. The source can be optionally renamed and optionally moved into another folder.If both the parent folder and name remain the same, then nothing is done.
- Specified by:
copyin interfaceFileFolderService- Parameters:
sourceNodeRef- the file or folder to copytargetParentRef- the new parent node to copy the node to - null means rename in situnewName- the new name, or null to keep the existing name.- Returns:
- Return the new file info
- Throws:
FileExistsExceptionFileNotFoundException- See Also:
-
moveOrCopy(NodeRef, NodeRef, NodeRef, String, boolean)
-
create
public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName) throws FileExistsException Description copied from interface:FileFolderServiceCreate a file or folder; or any valid node of type derived from file or folder.The association QName for the patch defaults to cm:filename i.e. the Content Model namespace with the filename as the local name.
- Specified by:
createin interfaceFileFolderService- Parameters:
parentNodeRef- the parent node. The parent must be a validfolder.name- the name of the nodetypeQName- the type to create- Returns:
- Returns the new node's file information
- Throws:
FileExistsException
-
create
public FileInfo create(NodeRef parentNodeRef, String name, QName typeQName, QName assocQName) throws FileExistsException Description copied from interface:FileFolderServiceCreate a file or folder; or any valid node of type derived from file or folder- Specified by:
createin interfaceFileFolderService- Parameters:
parentNodeRef- the parent node. The parent must be a validfolder.name- the name of the nodetypeQName- the type to createassocQName- the association QName to set for the path (may be null).- Returns:
- Returns the new node's file information
- Throws:
FileExistsException
-
delete
Description copied from interface:FileFolderServiceDelete a file or folder- Specified by:
deletein interfaceFileFolderService- Parameters:
nodeRef- the node to delete
-
makeFolders
public FileInfo makeFolders(NodeRef parentNodeRef, List<String> pathElements, QName folderTypeQName) Deprecated.Use FileFolderUtil.makeFolders rather than directly accessing this implementation class.Checks for the presence of, and creates as necessary, the folder structure in the provided path.An empty path list is not allowed as it would be impossible to necessarily return file info for the parent node - it might not be a folder node.
- Parameters:
parentNodeRef- the node under which the path will be createdpathElements- the folder name path to create - may not be emptyfolderTypeQName- the types of nodes to create. This must be a valid subtype ofthey folder type.- Returns:
- Returns the info of the last folder in the path.
-
makeFolders
public static FileInfo makeFolders(FileFolderService service, NodeRef parentNodeRef, List<String> pathElements, QName folderTypeQName) Deprecated.Use FileFolderUtil.makeFolders rather than directly accessing this implementation class.Checks for the presence of, and creates as necessary, the folder structure in the provided path.An empty path list is not allowed as it would be impossible to necessarily return file info for the parent node - it might not be a folder node.
- Parameters:
parentNodeRef- the node under which the path will be createdpathElements- the folder name path to create - may not be emptyfolderTypeQName- the types of nodes to create. This must be a valid subtype ofthey folder type.- Returns:
- Returns the info of the last folder in the path.
-
getNamePath
public List<FileInfo> getNamePath(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException Get the file or folder information from the root down to and including the node provided.- The root node can be of any type and is not included in the path list.
- Only the primary path is considered. If the target node is not a descendant of the root along purely primary associations, then an exception is generated.
- If an invalid type is encountered along the path, then an exception is generated.
- Specified by:
getNamePathin interfaceFileFolderService- Parameters:
rootNodeRef- the start of the returned path, or null if the store root node must be assumed.nodeRef- a reference to the file or folder- Returns:
- Returns a list of file/folder infos from the root (excluded) down to and including the destination file or folder
- Throws:
FileNotFoundException- if the node could not be found
-
getNameOnlyPath
public List<String> getNameOnlyPath(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException Get the file or folder names from the root down to and including the node provided.- The root node can be of any type and is not included in the path list.
- Only the primary path is considered. If the target node is not a descendant of the root along purely primary associations, then an exception is generated.
- If an invalid type is encountered along the path, then an exception is generated.
- Specified by:
getNameOnlyPathin interfaceFileFolderService- Parameters:
rootNodeRef- the start of the returned path, or null if the store root node must be assumed.nodeRef- a reference to the file or folder- Returns:
- Returns a list of file/folder names from the root (excluded) down to and including the destination file or folder
- Throws:
FileNotFoundException- if the node could not be found
-
resolveNamePath
public FileInfo resolveNamePath(NodeRef rootNodeRef, List<String> pathElements) throws FileNotFoundException Description copied from interface:FileFolderServiceResolve a file or folder name path from a given root node down to the final node.- Specified by:
resolveNamePathin interfaceFileFolderService- Parameters:
rootNodeRef- the start point node - a cm:folder type or subtype, e.g. the Company Home's nodeRefpathElements- a list of names in the path. Do not include the referenced rootNodeRef's path element.- Returns:
- Returns the info of the file or folder
- Throws:
FileNotFoundException- if no file or folder exists along the path
-
resolveNamePath
public FileInfo resolveNamePath(NodeRef rootNodeRef, List<String> pathElements, boolean mustExist) throws FileNotFoundException Description copied from interface:FileFolderServiceResolve a file or folder name path from a given root node down to the final node.- Specified by:
resolveNamePathin interfaceFileFolderService- Parameters:
rootNodeRef- the start point node - a cm:folder type or subtype, e.g. the Company Home's nodeRefpathElements- a list of names in the path. Do not include the referenced rootNodeRef's path element.- Returns:
- Returns the info of the file or folder or
nullifmustExistisfalseand the file does not exist - Throws:
FileNotFoundException- if no file or folder exists along the path andmustExististrue
-
getFileInfo
Description copied from interface:FileFolderServiceGet the file info (name, folder, etc) for the given node- Specified by:
getFileInfoin interfaceFileFolderService- Parameters:
nodeRef- the node to get info for- Returns:
- Returns the file info or null if the node does not represent a file or folder
-
getReader
Description copied from interface:FileFolderServiceGet the reader to the file represented by the node according to the File/Folder model. (This is not the same as the method on the ContentService)- Specified by:
getReaderin interfaceFileFolderService- Parameters:
nodeRef- the content node- Returns:
- Returns a handle to the content associated with the node
-
getWriter
Description copied from interface:FileFolderServiceGet the writer to the file represented by the node according to the File/Folder model. (This is not the same as the method on the ContentService)- Specified by:
getWriterin interfaceFileFolderService- Parameters:
nodeRef- the content node- Returns:
- Returns a handle to the content associated with the node
-
setHidden
- Specified by:
setHiddenin interfaceFileFolderService
-
isHidden
- Specified by:
isHiddenin interfaceFileFolderService
-
getTrait
- Specified by:
getTraitin interfaceExtensible
-