KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > service > cmr > model > FileFolderService


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.service.cmr.model;
18
19 import java.util.List JavaDoc;
20
21 import org.alfresco.service.cmr.repository.ContentReader;
22 import org.alfresco.service.cmr.repository.ContentWriter;
23 import org.alfresco.service.cmr.repository.NodeRef;
24 import org.alfresco.service.namespace.QName;
25
26 /**
27  * Provides methods specific to manipulating {@link org.alfresco.model.ContentModel#TYPE_CONTENT files}
28  * and {@link org.alfresco.model.ContentModel#TYPE_FOLDER folders}.
29  *
30  * @see org.alfresco.model.ContentModel
31  *
32  * @author Derek Hulley
33  */

34 public interface FileFolderService
35 {
36     /**
37      * Lists immediate child files and folders of the given context node
38      *
39      * @param contextNodeRef the node to start searching in
40      * @return Returns a list of matching files and folders
41      */

42     public List JavaDoc<FileInfo> list(NodeRef contextNodeRef);
43     
44     /**
45      * Lists all immediate child files of the given context node
46      *
47      * @param folderNodeRef the folder to start searching in
48      * @return Returns a list of matching files
49      */

50     public List JavaDoc<FileInfo> listFiles(NodeRef folderNodeRef);
51     
52     /**
53      * Lists all immediate child folders of the given context node
54      *
55      * @param contextNodeRef the node to start searching in
56      * @return Returns a list of matching folders
57      */

58     public List JavaDoc<FileInfo> listFolders(NodeRef contextNodeRef);
59
60     /**
61      * Searches for all files and folders with the matching name pattern,
62      * using wildcard characters <b>*</b> and <b>?</b>.
63      *
64      * @param contextNodeRef the context of the search. This node will never be returned
65      * as part of the search results.
66      * @param namePattern the name of the file or folder to search for, or a
67      * {@link org.alfresco.util.SearchLanguageConversion#DEF_LUCENE wildcard} pattern
68      * to search for.
69      * @param includeSubFolders true to search the entire hierarchy below the search context
70      * @return Returns a list of file or folder matches
71      *
72      * @see #search(NodeRef, String, boolean, boolean, boolean)
73      */

74     public List JavaDoc<FileInfo> search(
75             NodeRef contextNodeRef,
76             String JavaDoc namePattern,
77             boolean includeSubFolders);
78     
79     /**
80      * Perform a search against the name of the files or folders within a hierarchy.
81      * Wildcard characters are <b>*</b> and <b>?</b>.
82      *
83      * @param contextNodeRef the context of the search. This node will never be returned
84      * as part of the search results.
85      * @param namePattern the name of the file or folder to search for, or a
86      * {@link org.alfresco.util.SearchLanguageConversion#DEF_LUCENE wildcard} pattern
87      * to search for.
88      * @param fileSearch true if file types are to be included in the search results
89      * @param folderSearch true if folder types are to be included in the search results
90      * @param includeSubFolders true to search the entire hierarchy below the search context
91      * @return Returns a list of file or folder matches
92      */

93     public List JavaDoc<FileInfo> search(
94             NodeRef contextNodeRef,
95             String JavaDoc namePattern,
96             boolean fileSearch,
97             boolean folderSearch,
98             boolean includeSubFolders);
99     
100     /**
101      * Rename a file or folder in its current location
102      *
103      * @param fileFolderRef the file or folder to rename
104      * @param newName the new name
105      * @return Return the new file info
106      * @throws FileExistsException if a file or folder with the new name already exists
107      * @throws FileNotFoundException the file or folder reference doesn't exist
108      */

109     public FileInfo rename(NodeRef fileFolderRef, String JavaDoc newName) throws FileExistsException, FileNotFoundException;
110     
111     /**
112      * Move a file or folder to a new name and/or location.
113      * <p>
114      * If both the parent folder and name remain the same, then nothing is done.
115      *
116      * @param sourceNodeRef the file or folder to move
117      * @param targetParentRef the new parent node to move the node to - null means rename in situ
118      * @param newName the name to change the file or folder to - null to keep the existing name
119      * @return Returns the new file info
120      * @throws FileExistsException
121      * @throws FileNotFoundException
122      */

123     public FileInfo move(NodeRef sourceNodeRef, NodeRef targetParentRef, String JavaDoc newName)
124             throws FileExistsException, FileNotFoundException;
125
126     /**
127      * Copy a source file or folder. The source can be optionally renamed and optionally
128      * moved into another folder.
129      * <p>
130      * If both the parent folder and name remain the same, then nothing is done.
131      *
132      * @param sourceNodeRef the file or folder to copy
133      * @param targetParentRef the new parent node to copy the node to - null means rename in situ
134      * @param newName the new name, or null to keep the existing name.
135      * @return Return the new file info
136      * @throws FileExistsException
137      * @throws FileNotFoundException
138      */

139     public FileInfo copy(NodeRef sourceNodeRef, NodeRef targetParentRef, String JavaDoc newName)
140             throws FileExistsException, FileNotFoundException;
141
142     /**
143      * Create a file or folder; or any valid node of type derived from file or folder
144      *
145      * @param parentNodeRef the parent node. The parent must be a valid
146      * {@link org.alfresco.model.ContentModel#TYPE_CONTAINER container}.
147      * @param name the name of the node
148      * @param typeQName the type to create
149      * @return Returns the new node's file information
150      * @throws FileExistsException
151      */

152     public FileInfo create(NodeRef parentNodeRef, String JavaDoc name, QName typeQName) throws FileExistsException;
153     
154     /**
155      * Delete a file or folder
156      *
157      * @param nodeRef the node to delete
158      */

159     public void delete(NodeRef nodeRef);
160     
161     /**
162      * Checks for the presence of, and creates as necessary, the folder structure in the provided path.
163      * <p>
164      * An empty path list is not allowed as it would be impossible to necessarily return file info
165      * for the parent node - it might not be a folder node.
166      *
167      * @param parentNodeRef the node under which the path will be created
168      * @param pathElements the folder name path to create - may not be empty
169      * @param folderTypeQName the types of nodes to create. This must be a valid subtype of
170      * {@link org.alfresco.model.ContentModel#TYPE_FOLDER they folder type}.
171      * @return Returns the info of the last folder in the path.
172      */

173     public FileInfo makeFolders(NodeRef parentNodeRef, List JavaDoc<String JavaDoc> pathElements, QName folderTypeQName);
174     
175     /**
176      * Get the file or folder names from the root down to and including the node provided.
177      * <ul>
178      * <li>The root node can be of any type and is not included in the path list.</li>
179      * <li>Only the primary path is considered. If the target node is not a descendent of the
180      * root along purely primary associations, then an exception is generated.</li>
181      * <li>If an invalid type is encoutered along the path, then an exception is generated.</li>
182      * </ul>
183      *
184      * @param rootNodeRef the start of the returned path, or null if the <b>store</b> root
185      * node must be assumed.
186      * @param nodeRef a reference to the file or folder
187      * @return Returns a list of file/folder infos from the root (excluded) down to and
188      * including the destination file or folder
189      * @throws FileNotFoundException if the node could not be found
190      */

191     public List JavaDoc<FileInfo> getNamePath(NodeRef rootNodeRef, NodeRef nodeRef) throws FileNotFoundException;
192     
193     /**
194      * Resolve a file or folder name path from a given root node down to the final node.
195      *
196      * @param rootNodeRef the start of the path given, i.e. the '/' in '/A/B/C' for example
197      * @param pathElements a list of names in the path
198      * @return Returns the info of the file or folder
199      * @throws FileNotFoundException if no file or folder exists along the path
200      */

201     public FileInfo resolveNamePath(NodeRef rootNodeRef, List JavaDoc<String JavaDoc> pathElements) throws FileNotFoundException;
202     
203     /**
204      * Get the file info (name, folder, etc) for the given node
205      *
206      * @param nodeRef the node to get info for
207      * @return Returns the file info or null if the node does not represent a file or folder
208      */

209     public FileInfo getFileInfo(NodeRef nodeRef);
210     
211     public ContentReader getReader(NodeRef nodeRef);
212     
213     public ContentWriter getWriter(NodeRef nodeRef);
214 }
215
Popular Tags