org.alfresco.service.cmr.model
Interface FileFolderService

All Known Implementing Classes:
FileFolderServiceImpl

@PublicService
public interface FileFolderService

Provides methods specific to manipulating files and folders.

See Also:
ContentModel

Method Summary
 FileInfo copy(NodeRef sourceNodeRef, NodeRef targetParentRef, java.lang.String newName)
          Copy a source file or folder.
 FileInfo create(NodeRef parentNodeRef, java.lang.String name, QName typeQName)
          Create a file or folder; or any valid node of type derived from file or folder.
 FileInfo create(NodeRef parentNodeRef, java.lang.String name, QName typeQName, QName assocQName)
          Create a file or folder; or any valid node of type derived from file or folder
 void delete(NodeRef nodeRef)
          Delete a file or folder
 boolean exists(NodeRef nodeRef)
          Check the validity of a node reference
 FileInfo getFileInfo(NodeRef nodeRef)
          Get the file info (name, folder, etc) for the given node
 java.util.List getNamePath(NodeRef rootNodeRef, NodeRef nodeRef)
          Get the file or folder names from the root down to and including the node provided.
 ContentReader getReader(NodeRef nodeRef)
          Get the reader to the file represented by the node according to the File/Folder model.
 FileFolderServiceType getType(QName typeQName)
          Checks the type for whether it is a recognised file or folder type or is invalid for the FileFolderService.
 ContentWriter getWriter(NodeRef nodeRef)
          Get the writer to the file represented by the node according to the File/Folder model.
 java.util.List list(NodeRef contextNodeRef)
          Lists immediate child files and folders of the given context node
 java.util.List listFiles(NodeRef folderNodeRef)
          Lists all immediate child files of the given context node
 java.util.List listFolders(NodeRef contextNodeRef)
          Lists all immediate child folders of the given context node
 FileInfo makeFolders(NodeRef parentNodeRef, java.util.List pathElements, QName folderTypeQName)
          Deprecated. - See the static helper method FileFolderServiceImpl.makeFolders
 FileInfo move(NodeRef sourceNodeRef, NodeRef targetParentRef, java.lang.String newName)
          Move a file or folder to a new name and/or location.
 FileInfo rename(NodeRef fileFolderRef, java.lang.String newName)
          Rename a file or folder in its current location
 FileInfo resolveNamePath(NodeRef rootNodeRef, java.util.List pathElements)
          Resolve a file or folder name path from a given root node down to the final node.
 java.util.List search(NodeRef contextNodeRef, java.lang.String namePattern, boolean includeSubFolders)
          Deprecated. for shallow search use list, listFolders, listFiles, searchSimple, alternatives for deep search will be provided in later releases. Avoid calling this method with any name pattern except for "*".
 java.util.List search(NodeRef contextNodeRef, java.lang.String namePattern, boolean fileSearch, boolean folderSearch, boolean includeSubFolders)
          Deprecated. for shallow search use list, listFolders, listFiles, searchSimple, alternatives for deep search will be provided in later releases. Avoid calling this method with any name pattern except for "*".
 NodeRef searchSimple(NodeRef contextNodeRef, java.lang.String name)
          Get a simple list of nodes that have the given name within the parent node
 

Method Detail

list

@Auditable(key=ARG_0,
           parameters="contextNodeRef")
java.util.List list(NodeRef contextNodeRef)
Lists immediate child files and folders of the given context node

Parameters:
contextNodeRef - the node to start searching in
Returns:
Returns a list of matching files and folders

listFiles

@Auditable(key=ARG_0,
           parameters="folderNodeRef")
java.util.List listFiles(NodeRef folderNodeRef)
Lists all immediate child files of the given context node

Parameters:
folderNodeRef - the folder to start searching in
Returns:
Returns a list of matching files

listFolders

@Auditable(key=ARG_0,
           parameters="contextNodeRef")
java.util.List listFolders(NodeRef contextNodeRef)
Lists all immediate child folders of the given context node

Parameters:
contextNodeRef - the node to start searching in
Returns:
Returns a list of matching folders

searchSimple

@Auditable(key=ARG_0,
           parameters={"contextNodeRef", "name"})
NodeRef searchSimple(NodeRef contextNodeRef,
                                                 java.lang.String name)
Get a simple list of nodes that have the given name within the parent node

Parameters:
contextNodeRef - the parent node
name - the name of the node to search for
Returns:
Returns the node that has the given name - or null if not found

search

@Auditable(key=ARG_0,
           parameters={"contextNodeRef", "namePattern", "includeSubFolders"})
java.util.List search(NodeRef contextNodeRef,
                                                  java.lang.String namePattern,
                                                  boolean includeSubFolders)
Deprecated. for shallow search use list, listFolders, listFiles, searchSimple, alternatives for deep search will be provided in later releases. Avoid calling this method with any name pattern except for "*".

Searches 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.

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 a wildcard pattern 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:
FileFolderService.search(NodeRef, String, boolean, boolean, boolean)

search

@Auditable(key=ARG_0,
           parameters={"contextNodeRef", "namePattern", "fileSearch", "folderSearch", "includeSubFolders"})
java.util.List search(NodeRef contextNodeRef,
                                                  java.lang.String namePattern,
                                                  boolean fileSearch,
                                                  boolean folderSearch,
                                                  boolean includeSubFolders)
Deprecated. for shallow search use list, listFolders, listFiles, searchSimple, alternatives for deep search will be provided in later releases. Avoid calling this method with any name pattern except for "*".

Perform a search against the name of the files or folders within a hierarchy. Wildcard characters are * 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.

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 a wildcard pattern to search for.
fileSearch - true if file types are to be included in the search results
folderSearch - true if folder types are to be included in the search results
includeSubFolders - true to search the entire hierarchy below the search context
Returns:
Returns a list of file or folder matches

rename

@Auditable(key=ARG_0,
           parameters={"fileFolderRef", "newName"})
FileInfo rename(NodeRef fileFolderRef,
                                            java.lang.String newName)
                throws FileExistsException,
                       FileNotFoundException
Rename a file or folder in its current location

Parameters:
fileFolderRef - the file or folder to rename
newName - the new name
Returns:
Return the new file info
Throws:
FileExistsException - if a file or folder with the new name already exists
FileNotFoundException - the file or folder reference doesn't exist

move

@Auditable(key=ARG_0,
           parameters={"sourceNodeRef", "targetParentRef", "newName"})
FileInfo move(NodeRef sourceNodeRef,
                                          NodeRef targetParentRef,
                                          java.lang.String newName)
              throws FileExistsException,
                     FileNotFoundException
Move 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.

Parameters:
sourceNodeRef - the file or folder to move
targetParentRef - the new parent node to move the node to - null means rename in situ
newName - the name to change the file or folder to - null to keep the existing name
Returns:
Returns the new file info
Throws:
FileExistsException
FileNotFoundException

copy

@Auditable(key=ARG_0,
           parameters={"sourceNodeRef", "targetParentRef", "newName"})
FileInfo copy(NodeRef sourceNodeRef,
                                          NodeRef targetParentRef,
                                          java.lang.String newName)
              throws FileExistsException,
                     FileNotFoundException
Copy 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.

Parameters:
sourceNodeRef - the file or folder to copy
targetParentRef - the new parent node to copy the node to - null means rename in situ
newName - the new name, or null to keep the existing name.
Returns:
Return the new file info
Throws:
FileExistsException
FileNotFoundException

create

@Auditable(key=ARG_0,
           parameters={"parentNodeRef", "name", "typeQName"})
FileInfo create(NodeRef parentNodeRef,
                                            java.lang.String name,
                                            QName typeQName)
                throws FileExistsException
Create 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.

Parameters:
parentNodeRef - the parent node. The parent must be a valid folder.
name - the name of the node
typeQName - the type to create
Returns:
Returns the new node's file information
Throws:
FileExistsException
See Also:
#create(NodeRef, String, QName, QName)}

create

@Auditable(key=ARG_0,
           parameters={"parentNodeRef", "name", "typeQName"})
FileInfo create(NodeRef parentNodeRef,
                                            java.lang.String name,
                                            QName typeQName,
                                            QName assocQName)
                throws FileExistsException
Create a file or folder; or any valid node of type derived from file or folder

Parameters:
parentNodeRef - the parent node. The parent must be a valid folder.
name - the name of the node
typeQName - the type to create
assocQName - the association QName to set for the path (may be null).
Returns:
Returns the new node's file information
Throws:
FileExistsException

delete

@Auditable(key=ARG_0,
           parameters="nodeRef")
void delete(NodeRef nodeRef)
Delete a file or folder

Parameters:
nodeRef - the node to delete

makeFolders

@Auditable(key=ARG_0,
           parameters={"parentNodeRef", "pathElements", "folderTypeQName"})
FileInfo makeFolders(NodeRef parentNodeRef,
                                                 java.util.List pathElements,
                                                 QName folderTypeQName)
Deprecated. - See the static helper method FileFolderServiceImpl.makeFolders

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 created
pathElements - the folder name path to create - may not be empty
folderTypeQName - the types of nodes to create. This must be a valid subtype of they folder type.
Returns:
Returns the info of the last folder in the path.

getNamePath

@Auditable(key=ARG_0,
           parameters={"rootNodeRef", "nodeRef"})
java.util.List getNamePath(NodeRef rootNodeRef,
                                                       NodeRef nodeRef)
                           throws FileNotFoundException
Get the file or folder names from the root down to and including the node provided.

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

resolveNamePath

@Auditable(key=ARG_0,
           parameters={"rootNodeRef", "pathElements"})
FileInfo resolveNamePath(NodeRef rootNodeRef,
                                                     java.util.List pathElements)
                         throws FileNotFoundException
Resolve a file or folder name path from a given root node down to the final node.

Parameters:
rootNodeRef - the start point node - a cm:folder type or subtype, e.g. the Company Home's nodeRef
pathElements - 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

getFileInfo

@Auditable(key=ARG_0,
           parameters="nodeRef")
FileInfo getFileInfo(NodeRef nodeRef)
Get the file info (name, folder, etc) for the given node

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

@Auditable(key=ARG_0,
           parameters="nodeRef")
ContentReader getReader(NodeRef nodeRef)
Get 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)

Parameters:
nodeRef - the content node
Returns:
Returns a handle to the content associated with the node

getWriter

@Auditable(key=ARG_0,
           parameters="nodeRef")
ContentWriter getWriter(NodeRef nodeRef)
Get 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)

Parameters:
nodeRef - the content node
Returns:
Returns a handle to the content associated with the node

exists

@Auditable(key=ARG_0,
           parameters="nodeRef")
boolean exists(NodeRef nodeRef)
Check the validity of a node reference

Returns:
returns true if the NodeRef is valid

getType

@Auditable(parameters="typeQName")
FileFolderServiceType getType(QName typeQName)
Checks the type for whether it is a recognised file or folder type or is invalid for the FileFolderService.

Parameters:
typeQName - the type to check
Returns:
- the type


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.