/
Node.java
378 lines (328 loc) · 13.6 KB
/
Node.java
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
package org.wyona.yarep.core;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;
/**
* This class represents a repository node.
* A repository node may be either a collection ("directory") or a resource ("file").
* If it is a resource, it has an associated data content, which may be accessed by using
* getInputStream()/getOutputStream().
* To store textual data, the reader/writer methods should be used instead of the stream
* methods to allow the implementation to handle textual data differently from binary data.
*
* @see org.wyona.yarep.core.Repository
*/
public interface Node {
/**
* Gets the name of this node, which is the last part of the path.
* @return name
* @throws RepositoryException repository error
*/
public String getName() throws RepositoryException;
/**
* Gets the parent node of this node.
* @return parent node or null if this is the root node
* @throws RepositoryException repository error
*/
public Node getParent() throws RepositoryException;
/**
* Deletes this node and all subnodes.
* The root node cannot be deleted.
* @throws RepositoryException if this node is the root node or if a repository error occurs.
*/
public void delete() throws RepositoryException;
/**
* Gets the complete repository path of this node.
* @return path
* @throws RepositoryException repository error
*/
public String getPath() throws RepositoryException;
/**
* Gets the UUID of this node.
* @return uuid
* @throws RepositoryException repository error
*/
public String getUUID() throws RepositoryException;
/**
* Gets the type of this node (collection or resource).
* @return type
* @throws RepositoryException repository error
* @see org.wyona.yarep.core.NodeType
*/
public int getType() throws RepositoryException;
/**
* Indicates whether this node is of type "resource".
* @return true if type is resource
* @throws RepositoryException repository error
*/
public boolean isResource() throws RepositoryException;
/**
* Indicates whether this node is of type "collection".
* @return true if type is collection
* @throws RepositoryException repository error
*/
public boolean isCollection() throws RepositoryException;
/**
* Indicates whether the content of this node is binary or textual.
* Useful only if this node is a resource.
* @return true if the content of this node is binary
* @throws RepositoryException repository error
*/
//public boolean isBinary() throws RepositoryException;
/**
* Creates a new node and adds it as a direct child to this node.
* @param name name of the child node
* @param type node type of the child node (e.g. collection or resource, see NodeType)
* @return the new child node
* @throws RepositoryException if this node is not a collection or if a repository error occurs
*/
public Node addNode(String name, int type) throws RepositoryException;
/**
* Gets the child node with the given name. Must be a direct child.
* @param name name of the child node
* @return child node
* @throws NoSuchNodeException if no child node with this name exists.
* @throws RepositoryException if node is not a collection or if a repository error occurs
*/
public Node getNode(String name) throws NoSuchNodeException, RepositoryException;
/**
* Gets all child nodes.
*
* There is no guarantee that the nodes in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
*
* @return child nodes or empty array if there are no child nodes.
* @throws RepositoryException if node is not a collection or if a repository error occurs
*/
public Node[] getNodes() throws RepositoryException;
/**
* Indicates whether this node has a direct child node with the given name.
* @param name
* @return true if child node exists with the given id, false otherwise
* @throws RepositoryException if node is not a collection or if a repository error occurs
*/
public boolean hasNode(String name) throws RepositoryException;
/**
* Gets the property with the given name.
* @param name Name of property
* @return property or null if the property does not exist
* @throws RepositoryException repository error
*/
public Property getProperty(String name) throws RepositoryException;
/**
* Get all properties of this node
* @return array of properties of this node or empty array if there are no properties.
* @throws RepositoryException other error
*/
public Property[] getProperties() throws RepositoryException;
/**
* Indicates whether this node has a property with the given name.
* @param name
* @return true if a property exists with the given name, false otherwise
* @throws RepositoryException repository error
*/
public boolean hasProperty(String name) throws RepositoryException;
//public boolean hasProperties() throws RepositoryException;
/**
* Removes the property with the given name.
* Does nothing if no property with the given name exists.
* @param name
* @throws RepositoryException repository error
*/
public void removeProperty(String name) throws RepositoryException;
/**
* Sets a property of type boolean or creates it if it does not exist yet.
* @param name
* @param value
* @return the set property
* @throws RepositoryException repository error
*/
public Property setProperty(String name, boolean value) throws RepositoryException;
/**
* Sets a property of type date or creates it if it does not exist yet.
* @param name
* @param value
* @return the set property
* @throws RepositoryException repository error
*/
public Property setProperty(String name, Date value) throws RepositoryException;
/**
* Sets a property of type double or creates it if it does not exist yet.
* @param name
* @param value
* @return the set property
* @throws RepositoryException repository error
*/
public Property setProperty(String name, double value) throws RepositoryException;
//public Property setProperty(String name, InputStream value) throws RepositoryException;
/**
* Sets a property of type long or creates it if it does not exist yet.
* @param name
* @param value
* @return the set property
* @throws RepositoryException repository error
*/
public Property setProperty(String name, long value) throws RepositoryException;
/**
* Sets a property of type string or creates it if it does not exist yet.
* @param name
* @param value
* @return the set property
* @throws RepositoryException repository error
*/
public Property setProperty(String name, String value) throws RepositoryException;
/**
* Sets a property or creates it if it does not exist yet.
* @param property
* @throws RepositoryException repository error
*/
public void setProperty(Property property) throws RepositoryException;
//public Property getDefaultProperty() throws RepositoryException;
/**
* Gets an input stream of the binary data content of this node.
* Useful only for nodes of type resource.
* @return input stream
* @throws RepositoryException repository error
*/
public InputStream getInputStream() throws RepositoryException;
//public void setInputStream(InputStream inputStream) throws RepositoryException;
/**
* Gets an output stream of the binary data content of this node.
* Useful only for nodes of type resource.
* Don't forget to close the stream because some implementations may
* require that.
* @return output stream
* @throws RepositoryException repository error
*/
public OutputStream getOutputStream() throws RepositoryException;
/**
* Puts this node into checked-in state and creates a new revision.
* @return the new revision
* @throws NodeStateException if node is not in checked out state
* @throws RepositoryException repository error
*/
public Revision checkin() throws NodeStateException, RepositoryException;
/**
* Puts this node into checked-in state and creates a new revision.
* @param comment a comment to add to the new revision.
* @return the new revision
* @throws NodeStateException if node is not in checked out state
* @throws RepositoryException repository error
*/
public Revision checkin(String comment) throws NodeStateException, RepositoryException;
/**
* Puts this node into checked-out state.
* @throws NodeStateException if node is in checked out state already
* @throws RepositoryException repository error
*/
public void checkout(String userID) throws NodeStateException, RepositoryException;
/**
* Cancels a checkout, i.e. performs a checkin without creating a new revision.
* @throws NodeStateException
* @throws NodeStateException if node is not in checked out state
* @throws RepositoryException
*/
public void cancelCheckout() throws NodeStateException, RepositoryException;
/**
* Indicates whether this node is checked out.
* @return true if checked out, false otherwise
* @throws RepositoryException repository error
*/
public boolean isCheckedOut() throws RepositoryException;
/**
* Gets the userID which was supplied when calling checkout(userID).
* @return userID
* @throws NodeStateException if node is not checked out.
* @throws RepositoryException
*/
public String getCheckoutUserID() throws NodeStateException, RepositoryException;
/**
* Gets the date when this node was checked out.
* @return checkout date
* @throws NodeStateException if node is not checked out.
* @throws RepositoryException
*/
public Date getCheckoutDate() throws NodeStateException, RepositoryException;
/**
* Gets the date when this node was checked in.
* @return checkin date
* @throws NodeStateException if node is not checked in.
* @throws RepositoryException
*/
public Date getCheckinDate() throws NodeStateException, RepositoryException;
/**
* Gets all revisions of this node.
* Oldest revision at the first array position, newest at the last position.
* @return array of revisions, or empty array if there are no revisions
* @throws RepositoryException
*/
public Revision[] getRevisions() throws RepositoryException;
/**
* Gets the revision with the given name.
* @param revisionName
* @return revision
* @throws NoSuchRevisionException if the revision does not exist
* @throws RepositoryException
*/
public Revision getRevision(String revisionName) throws NoSuchRevisionException, RepositoryException;
/**
* Gets the revision with the given tag.
* If multiple revisions have the same tag, the oldest one will be returned.
* @param tag
* @return revision
* @throws NoSuchRevisionException if the revision does not exist
* @throws RepositoryException
*/
public Revision getRevisionByTag(String tag) throws NoSuchRevisionException, RepositoryException;
/**
* Indicates whether this node has a revision with the given tag.
* If multiple revisions have the same tag, the oldest one will be returned.
* @param tag
* @return true if a revision with the given tag exists, false otherwise
* @throws RepositoryException
*/
public boolean hasRevisionWithTag(String tag) throws RepositoryException;
/**
* Restores the revision with the given name.
* @param revisionName
* @throws NoSuchRevisionException if the revision does not exist
* @throws RepositoryException
*/
public void restore(String revisionName) throws NoSuchRevisionException, RepositoryException;
/**
* Gets the last modified date of this node in ms.
* Changing a property should update the last modified date.
* @return last modified date in ms
* @throws RepositoryException
*/
public long getLastModified() throws RepositoryException;
/**
* Gets the size of the data content of this node if this node is of type resource.
* @return size in bytes
* @throws RepositoryException
*/
public long getSize() throws RepositoryException;
/**
* Gets the mimetype of the data content of this node if this node is of type resource.
* @return mimetype
* @throws RepositoryException
*/
public String getMimeType() throws RepositoryException;
/**
* Sets the mimetype of the data content of this node if this node is of type resource.
* @param mimeType
* @throws RepositoryException
*/
public void setMimeType(String mimeType) throws RepositoryException;
/**
* Gets the encoding of the data content of this node if this node is of type resource.
* @return encoding
* @throws RepositoryException
*/
public String getEncoding() throws RepositoryException;
/**
* Sets the encoding of the data content of this node if this node is of type resource.
* @param encoding
* @throws RepositoryException
*/
public void setEncoding(String encoding) throws RepositoryException;
}