1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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