View Javadoc

1   /*
2    * <cvs:source>$Source: /devel/astrogrid/filemanager/client/src/java/org/astrogrid/filemanager/client/FileManagerNode.java,v $</cvs:source>
3    * <cvs:author>$Author: clq2 $</cvs:author>
4    * <cvs:date>$Date: 2005/01/28 10:43:57 $</cvs:date>
5    * <cvs:version>$Revision: 1.5 $</cvs:version>
6    * <cvs:log>
7    *   $Log: FileManagerNode.java,v $
8    *   Revision 1.5  2005/01/28 10:43:57  clq2
9    *   dave_dev_200501141257 (filemanager)
10   *
11   *   Revision 1.4.2.6  2005/01/26 12:24:19  dave
12   *   Removed type from add(), replaced with addNode() and addFile() ...
13   *
14   *   Revision 1.4.2.5  2005/01/21 14:41:57  dave
15   *   Added importData(URL url) to the API (needs implementation and tests).
16   *
17   *   Revision 1.4.2.4  2005/01/21 13:07:37  dave
18   *   Added exportURL to the node API ...
19   *
20   *   Revision 1.4.2.3  2005/01/21 12:18:54  dave
21   *   Changed input() and output() to exportStream() and importStream() ...
22   *
23   *   Revision 1.4.2.2  2005/01/19 11:39:26  dave
24   *   Added combined create and modify date ...
25   *
26   *   Revision 1.4.2.1  2005/01/15 08:25:20  dave
27   *   Added file create and modify dates to manager and client API ...
28   *
29   *   Revision 1.4  2005/01/13 17:23:15  jdt
30   *   merges from dave-dev-200412201250
31   *
32   *   Revision 1.3.4.2  2005/01/12 14:20:57  dave
33   *   Replaced tabs with spaces ....
34   *
35   *   Revision 1.3.4.1  2005/01/07 12:18:00  dave
36   *   Added StoreClientWrapperTest
37   *   Added StoreFileWrapper
38   *
39   *   Revision 1.3  2004/12/16 17:25:49  jdt
40   *   merge from dave-dev-200410061224-200412161312
41   *
42   *   Revision 1.1.2.10  2004/12/14 10:32:17  dave
43   *   Added copy to node API ....
44   *
45   *   Revision 1.1.2.9  2004/12/10 05:21:25  dave
46   *   Added node and iterator to client API ...
47   *
48   *   Revision 1.1.2.8  2004/12/08 17:54:55  dave
49   *   Added update to FileManager client and server side ...
50   *
51   *   Revision 1.1.2.7  2004/12/08 01:56:04  dave
52   *   Added filestore location to move ...
53   *
54   *   Revision 1.1.2.6  2004/11/29 18:05:07  dave
55   *   Refactored methods names ....
56   *   Added stubs for delete, copy and move.
57   *
58   *   Revision 1.1.2.5  2004/11/25 13:41:14  dave
59   *   Added export stream handling to node ...
60   *
61   *   Revision 1.1.2.4  2004/11/24 19:23:29  dave
62   *   Started to add input and output streams to node ...
63   *
64   *   Revision 1.1.2.3  2004/11/24 16:15:08  dave
65   *   Added node functions to client ...
66   *
67   *   Revision 1.1.2.2  2004/11/16 03:26:14  dave
68   *   Added initial tests for adding accounts, containers and files ...
69   *
70   *   Revision 1.1.2.1  2004/11/13 01:41:26  dave
71   *   Created initial client API ....
72   *
73   * </cvs:log>
74   *
75   */
76  package org.astrogrid.filemanager.client ;
77  
78  import java.net.URL ;
79  
80  import java.util.Date ;
81  
82  import java.io.IOException;
83  import java.io.InputStream;
84  import java.io.OutputStream;
85  
86  import org.astrogrid.store.Ivorn;
87  
88  import org.astrogrid.filemanager.common.FileManagerProperties;
89  import org.astrogrid.filemanager.common.exception.NodeNotFoundException;
90  import org.astrogrid.filemanager.common.exception.DuplicateNodeException;
91  import org.astrogrid.filemanager.common.exception.FileManagerIdentifierException;
92  import org.astrogrid.filemanager.common.exception.FileManagerServiceException;
93  import org.astrogrid.filemanager.common.exception.FileManagerPropertiesException;
94  
95  /***
96   * The public API for a FileManager node.
97   * @todo Mime type, create date etc ....
98   *
99   *
100  *
101  */
102 public interface FileManagerNode
103     {
104 
105     /***
106      * The node type for a file.
107      *
108     public static final String FILE_NODE = FileManagerProperties.DATA_NODE_TYPE ;
109      */
110 
111     /***
112      * The node type for a container.
113      *
114     public static final String CONTAINER_NODE = FileManagerProperties.CONTAINER_NODE_TYPE ;
115      */
116 
117     /***
118      * Get the node ivorn.
119      * @return The ivorn identifier for this node.
120      * @throws FileManagerIdentifierException If the ivorn is invalid.
121      *
122      */
123     public Ivorn ivorn()
124         throws FileManagerIdentifierException;
125 
126     /***
127      * Get the node name.
128      * @return The current name of the node.
129      *
130      */
131     public String name();
132 
133     /***
134      * Get the parent node.
135      * @return The parent node, or null for a root node.
136      * @throws NodeNotFoundException If the node is not in the database.
137      * @throws FileManagerServiceException If a problem occurs when handling the request.
138      *
139      */
140     public FileManagerNode parent()
141         throws NodeNotFoundException, FileManagerServiceException;
142 
143     /***
144      * Delete this node.
145      * @throws NodeNotFoundException If the node is not in the database.
146      * @throws FileManagerServiceException If a problem occurs when handling the request.
147      *
148      */
149     public void delete()
150         throws NodeNotFoundException, FileManagerServiceException;
151 
152     /***
153      * Check if this node represents a file.
154      * @return true if this node represents a file.
155      *
156      */
157     public boolean isFile() ;
158 
159     /***
160      * Check if this node represents a container.
161      * @return true if this node represents a container.
162      *
163      */
164     public boolean isContainer() ;
165 
166     /***
167      * Create a copy of this node.
168      * If the node already has stored data, then this will create a copy of the data.
169      * @return A reference to the new node.
170      * @param name  The name of the new Node.
171      * @param node  The new parent Node in the metadata tree (null to create the new node in the same location in the tree).
172      * @param store The Ivorn of the FileStore for new Node (null to store the copy at the same location).
173      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
174      * @throws NodeNotFoundException If the current node is no longer in the database.
175      * @throws NodeNotFoundException If the new parent node is no longer in the database.
176      * @throws FileManagerServiceException If a problem occurs when handling the request.
177      *
178      */
179     public FileManagerNode copy(String name, FileManagerNode parent, Ivorn location)
180         throws DuplicateNodeException, NodeNotFoundException, FileManagerServiceException;
181 
182     /***
183      * Move this node to a new location.
184      * If the node already has stored data, then this may involve transfering the data to a new location.
185      * @param name  The name of the new Node.
186      * @param node  The new parent Node in the metadata tree (null to leave the node in the same location in the tree).
187      * @param store The Ivorn of the FileStore location (null to leave the data at the same location).
188      * @throws DuplicateNodeException If a node with the same name already exists in the metadata tree.
189      * @throws NodeNotFoundException If the current node is no longer in the database.
190      * @throws NodeNotFoundException If the new parent node is no longer in the database.
191      * @throws FileManagerServiceException If a problem occurs when handling the request.
192      *
193      */
194     public void move(String name, FileManagerNode parent, Ivorn location)
195         throws DuplicateNodeException, NodeNotFoundException, FileManagerServiceException;
196 
197     /***
198      * Add a new child node.
199      * @param name The node name.
200      * @return A new node for the container.
201      * @throws UnsupportedOperationException If this node represents a file.
202      * @throws DuplicateNodeException If a node with the same name already exists.
203      * @throws NodeNotFoundException If the current node is no longer in the database.
204      * @throws FileManagerServiceException If a problem occurs when handling the request.
205      *
206      */
207     public FileManagerNode addNode(String name)
208         throws UnsupportedOperationException, NodeNotFoundException, DuplicateNodeException , FileManagerServiceException;
209 
210     /***
211      * Add a new file node.
212      * @param name The node name.
213      * @return A new node for the file.
214      * @throws UnsupportedOperationException If this node represents a file.
215      * @throws DuplicateNodeException If a node with the same name already exists.
216      * @throws NodeNotFoundException If the current node is no longer in the database.
217      * @throws FileManagerServiceException If a problem occurs when handling the request.
218      *
219      */
220     public FileManagerNode addFile(String name)
221         throws UnsupportedOperationException, NodeNotFoundException, DuplicateNodeException , FileManagerServiceException;
222 
223     /***
224      * Get a child node by path.
225      * @param path The path to the child node.
226      * @return A reference to the child node.
227      * @throws UnsupportedOperationException If this node represents a file.
228      * @throws NodeNotFoundException If the node is not in the database.
229      * @throws FileManagerServiceException If a problem occurs when handling the request.
230      *
231      */
232     public FileManagerNode child(String path)
233         throws UnsupportedOperationException, NodeNotFoundException, FileManagerServiceException;
234 
235     /***
236      * Open a java OutputStream to send (import) data into the node.
237      * @return An OutputStream connected directly to the node store.
238      * @throws IOException If a problem occurs openning the stream.
239      * @throws UnsupportedOperationException If the node represents a container.
240      * @throws NodeNotFoundException If the node is not in the database.
241      * @throws FileManagerServiceException If a problem occurs when handling the request.
242      *
243      */
244     public OutputStream importStream()
245         throws IOException, UnsupportedOperationException, NodeNotFoundException, FileManagerServiceException;
246 
247     /***
248      * Open a java InputStream to read (export) data from the node.
249      * @return An InputStream connected directly to the node store.
250      * @throws IOException If a problem occurs openning the stream.
251      * @throws UnsupportedOperationException If the node represents a container.
252      * @throws NodeNotFoundException If the node is not in the database.
253      * @throws FileManagerServiceException If a problem occurs when handling the request.
254      *
255      */
256     public InputStream exportStream()
257         throws IOException, UnsupportedOperationException, NodeNotFoundException, FileManagerServiceException;
258 
259     /***
260      * Get a URL to access the node data from.
261      * @return A URL which connects directly to the node store.
262      * @throws UnsupportedOperationException If the node represents a container.
263      * @throws NodeNotFoundException If the node is not in the database.
264      * @throws FileManagerServiceException If a problem occurs when handling the request.
265      *
266      */
267     public URL exportURL()
268         throws UnsupportedOperationException, NodeNotFoundException, FileManagerServiceException;
269 
270     /***
271      * Import data from a URL.
272      * @throws UnsupportedOperationException If the node represents a container.
273      * @throws NodeNotFoundException If the node is not in the database.
274      * @throws FileManagerServiceException If a problem occurs when handling the request.
275      *
276      */
277     public void importData(URL url)
278         throws UnsupportedOperationException, NodeNotFoundException, FileManagerServiceException;
279 
280     /***
281      * Get the ivorn identifier of the FileStore for the node data.
282      * @return The Ivorn for the FileStore where the data is stored.
283      * @throws UnsupportedOperationException If the node represents a container (although future extensions may allow this).
284      * @throws FileManagerIdentifierException If the location Ivorn is not valid.
285      *
286      */
287     public Ivorn location()
288         throws UnsupportedOperationException, FileManagerIdentifierException;
289 
290     /***
291      * Refresh the node properties after a file transfer has completed.
292      * If the node has stored data, this will trigger a call to the FileStore to refresh the data properties.
293      * @throws NodeNotFoundException If the node no longer exists in the server database.
294      * @throws FileManagerServiceException If a problem occurs when handling the request. 
295      *
296      */
297     public void refresh()
298         throws NodeNotFoundException, FileManagerServiceException;
299 
300     /***
301      * Get the content size for a data node.
302      * @return The size of the stored data for a data node, or -1 for a container node.
303      *
304      */
305     public long size() ;
306 
307     /***
308      * Get the data file create date.
309      * This is the create date of the imported data in the filestore.
310      * To get the general create date, use <code>getCreateDate()</code>.
311      * @return The file create date, if the node has stored data, or null if the node does not contains any data.
312      *
313      */
314     public Date getFileCreateDate();
315 
316     /***
317      * Get the data file modified date.
318      * This is the modified date of the imported data in the filestore.
319      * To get the general modified date, use <code>getModifyDate()</code>.
320      * @return The file modified date, if the node has stored data, or null if the node does not contains any data.
321      *
322      */
323     public Date getFileModifyDate();
324 
325     /***
326      * Get the node create date.
327      * This is the create date of the metadata node in the filemanager.
328      * To get the general create date, use <code>getCreateDate()</code>.
329      * @return The node create date.
330      *
331      */
332     public Date getNodeCreateDate();
333 
334     /***
335      * Get the node modified date.
336      * This is the modified date of the metadata node in the filemanager.
337      * To get the general modified date, use <code>getModifyDate()</code>.
338      * @return The node modified date.
339      *
340      */
341     public Date getNodeModifyDate();
342 
343     /***
344      * Get the create date.
345      * @return The create date.
346      *
347      */
348     public Date getCreateDate();
349 
350     /***
351      * Get the modified date.
352      * @return The modified date.
353      *
354      */
355     public Date getModifyDate();
356 
357     /***
358      * An iterator for child nodes.
359      *
360      */
361     public interface NodeIterator
362         {
363         /***
364          * Check if the there are more nodes in the iteration.
365          *
366          */
367         public boolean hasNext() ;
368 
369         /***
370          * Get the next node in the iteration.
371          * @throws NodeNotFoundException If the node is no longer in the server database (this can happen if another client deletes the node after this iterator was created).
372          * @throws FileManagerServiceException If a problem occurs when handling the request.
373          *
374          */
375         public FileManagerNode next()
376             throws NodeNotFoundException, FileManagerServiceException ;
377 
378         }
379 
380     /***
381      * Get an iterator for the child nodes of this node.
382      * @throws NodeNotFoundException If this node is no longer in the server database.
383      * @throws FileManagerServiceException If a problem occurs when handling the request.
384      * @throws UnsupportedOperationException If the node does not represent a container.
385      *
386      */
387     public NodeIterator iterator()
388         throws NodeNotFoundException, FileManagerServiceException ;
389 
390     }
391 
392 
393 
394 
395