1
|
/**
|
2
|
* '$RCSfile$'
|
3
|
* Copyright: 2000-2011 Regents of the University of California and the
|
4
|
* National Center for Ecological Analysis and Synthesis
|
5
|
*
|
6
|
* '$Author: $'
|
7
|
* '$Date: $'
|
8
|
*
|
9
|
* This program is free software; you can redistribute it and/or modify
|
10
|
* it under the terms of the GNU General Public License as published by
|
11
|
* the Free Software Foundation; either version 2 of the License, or
|
12
|
* (at your option) any later version.
|
13
|
*
|
14
|
* This program is distributed in the hope that it will be useful,
|
15
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17
|
* GNU General Public License for more details.
|
18
|
*
|
19
|
* You should have received a copy of the GNU General Public License
|
20
|
* along with this program; if not, write to the Free Software
|
21
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
22
|
*/
|
23
|
|
24
|
package edu.ucsb.nceas.metacat.dataone;
|
25
|
|
26
|
import java.io.InputStream;
|
27
|
import java.util.Date;
|
28
|
|
29
|
import org.apache.log4j.Logger;
|
30
|
import org.dataone.service.exceptions.IdentifierNotUnique;
|
31
|
import org.dataone.service.exceptions.InsufficientResources;
|
32
|
import org.dataone.service.exceptions.InvalidRequest;
|
33
|
import org.dataone.service.exceptions.InvalidSystemMetadata;
|
34
|
import org.dataone.service.exceptions.InvalidToken;
|
35
|
import org.dataone.service.exceptions.NotAuthorized;
|
36
|
import org.dataone.service.exceptions.NotFound;
|
37
|
import org.dataone.service.exceptions.NotImplemented;
|
38
|
import org.dataone.service.exceptions.ServiceFailure;
|
39
|
import org.dataone.service.exceptions.SynchronizationFailed;
|
40
|
import org.dataone.service.exceptions.UnsupportedType;
|
41
|
import org.dataone.service.mn.tier1.MNCore;
|
42
|
import org.dataone.service.mn.tier1.MNRead;
|
43
|
import org.dataone.service.mn.tier2.MNAuthorization;
|
44
|
import org.dataone.service.mn.tier3.MNStorage;
|
45
|
import org.dataone.service.mn.tier4.MNReplication;
|
46
|
import org.dataone.service.types.AccessPolicy;
|
47
|
import org.dataone.service.types.Checksum;
|
48
|
import org.dataone.service.types.DescribeResponse;
|
49
|
import org.dataone.service.types.Event;
|
50
|
import org.dataone.service.types.Identifier;
|
51
|
import org.dataone.service.types.Log;
|
52
|
import org.dataone.service.types.MonitorList;
|
53
|
import org.dataone.service.types.Node;
|
54
|
import org.dataone.service.types.NodeReference;
|
55
|
import org.dataone.service.types.ObjectFormat;
|
56
|
import org.dataone.service.types.ObjectList;
|
57
|
import org.dataone.service.types.Permission;
|
58
|
import org.dataone.service.types.Session;
|
59
|
import org.dataone.service.types.Subject;
|
60
|
import org.dataone.service.types.SystemMetadata;
|
61
|
|
62
|
/**
|
63
|
* Represents Metacat's implementation of the DataONE Member Node
|
64
|
* service API. Methods implement the various MN* interfaces, and methods common
|
65
|
* to both Member Node and Coordinating Node interfaces are found in the
|
66
|
* D1NodeService base class.
|
67
|
*/
|
68
|
public class MNodeService extends D1NodeService implements MNAuthorization,
|
69
|
MNCore, MNRead, MNReplication, MNStorage {
|
70
|
|
71
|
/* the instance of the MNodeService object */
|
72
|
private static MNodeService instance = null;
|
73
|
|
74
|
/* the logger instance */
|
75
|
private Logger logMetacat = null;
|
76
|
|
77
|
/**
|
78
|
* singleton accessor
|
79
|
*/
|
80
|
public static MNodeService getInstance()
|
81
|
{
|
82
|
if (instance == null) {
|
83
|
instance = new MNodeService();
|
84
|
}
|
85
|
|
86
|
return instance;
|
87
|
}
|
88
|
|
89
|
/**
|
90
|
* Constructor, private for singleton access
|
91
|
*/
|
92
|
private MNodeService() {
|
93
|
super();
|
94
|
logMetacat = Logger.getLogger(MNodeService.class);
|
95
|
|
96
|
}
|
97
|
|
98
|
/**
|
99
|
* Adds a new object to the Member Node, where the object is either a data
|
100
|
* object or a science metadata object. This method is called by clients
|
101
|
* to create new data objects on Member Nodes
|
102
|
*
|
103
|
* @param session - the Session object containing the credentials for the Subject
|
104
|
* @param pid - The object identifier to be created
|
105
|
* @param object - the object bytes
|
106
|
* @param sysmeta - the system metadata that describes the object
|
107
|
*
|
108
|
* @return pid - the object identifier created
|
109
|
*
|
110
|
* @throws InvalidToken
|
111
|
* @throws ServiceFailure
|
112
|
* @throws NotAuthorized
|
113
|
* @throws IdentifierNotUnique
|
114
|
* @throws UnsupportedType
|
115
|
* @throws InsufficientResources
|
116
|
* @throws InvalidSystemMetadata
|
117
|
* @throws NotImplemented
|
118
|
* @throws InvalidRequest
|
119
|
*/
|
120
|
@Override
|
121
|
public Identifier create(Session session, Identifier pid, InputStream object,
|
122
|
SystemMetadata sysmeta)
|
123
|
throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique,
|
124
|
UnsupportedType, InsufficientResources, InvalidSystemMetadata,
|
125
|
NotImplemented, InvalidRequest {
|
126
|
|
127
|
return null;
|
128
|
}
|
129
|
|
130
|
/**
|
131
|
* Deletes an object from the Member Node, where the object is either a
|
132
|
* data object or a science metadata object.
|
133
|
*
|
134
|
* @param session - the Session object containing the credentials for the Subject
|
135
|
* @param pid - The object identifier to be deleted
|
136
|
*
|
137
|
* @return pid - the identifier of the object used for the deletion
|
138
|
*
|
139
|
* @throws InvalidToken
|
140
|
* @throws ServiceFailure
|
141
|
* @throws NotAuthorized
|
142
|
* @throws NotFound
|
143
|
* @throws NotImplemented
|
144
|
* @throws InvalidRequest
|
145
|
*/
|
146
|
@Override
|
147
|
public Identifier delete(Session session, Identifier pid)
|
148
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
149
|
NotImplemented, InvalidRequest {
|
150
|
|
151
|
return null;
|
152
|
}
|
153
|
|
154
|
/**
|
155
|
* Updates an existing object by creating a new object identified by
|
156
|
* newPid on the Member Node which explicitly obsoletes the object
|
157
|
* identified by pid through appropriate changes to the SystemMetadata
|
158
|
* of pid and newPid
|
159
|
*
|
160
|
* @param session - the Session object containing the credentials for the Subject
|
161
|
* @param pid - The identifier of the object to be updated
|
162
|
* @param object - the new object bytes
|
163
|
* @param sysmeta - the new system metadata describing the object
|
164
|
*
|
165
|
* @return newPid - the identifier of the new object
|
166
|
*
|
167
|
* @throws InvalidToken
|
168
|
* @throws ServiceFailure
|
169
|
* @throws NotAuthorized
|
170
|
* @throws NotFound
|
171
|
* @throws NotImplemented
|
172
|
* @throws IdentifierNotUnique
|
173
|
* @throws UnsupportedType
|
174
|
* @throws InsufficientResources
|
175
|
* @throws InvalidSystemMetadata
|
176
|
* @throws InvalidRequest
|
177
|
*/
|
178
|
@Override
|
179
|
public Identifier update(Session session, Identifier pid, InputStream object,
|
180
|
Identifier newPid, SystemMetadata sysmeta)
|
181
|
throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique,
|
182
|
UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata,
|
183
|
NotImplemented, InvalidRequest {
|
184
|
|
185
|
return null;
|
186
|
}
|
187
|
|
188
|
/**
|
189
|
* Called by a Coordinating Node to request that the Member Node create a
|
190
|
* copy of the specified object by retrieving it from another Member
|
191
|
* Node and storing it locally so that it can be made accessible to
|
192
|
* the DataONE system.
|
193
|
*
|
194
|
* @param session - the Session object containing the credentials for the Subject
|
195
|
* @param sysmeta - Copy of the CN held system metadata for the object
|
196
|
* @param sourceNode - A reference to node from which the content should be
|
197
|
* retrieved. The reference should be resolved by
|
198
|
* checking the CN node registry.
|
199
|
*
|
200
|
* @return true if the replication succeeds
|
201
|
*
|
202
|
* @throws ServiceFailure
|
203
|
* @throws NotAuthorized
|
204
|
* @throws NotImplemented
|
205
|
* @throws UnsupportedType
|
206
|
* @throws InsufficientResources
|
207
|
* @throws InvalidRequest
|
208
|
*/
|
209
|
@Override
|
210
|
public boolean replicate(Session session, SystemMetadata sysmeta,
|
211
|
NodeReference sourceNode)
|
212
|
throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest,
|
213
|
InsufficientResources, UnsupportedType {
|
214
|
|
215
|
return false;
|
216
|
}
|
217
|
|
218
|
/**
|
219
|
* This method provides a lighter weight mechanism than
|
220
|
* MN_read.getSystemMetadata() for a client to determine basic
|
221
|
* properties of the referenced object.
|
222
|
*
|
223
|
* @param session - the Session object containing the credentials for the Subject
|
224
|
* @param pid - the identifier of the object to be described
|
225
|
*
|
226
|
* @return describeResponse - A set of values providing a basic description
|
227
|
* of the object.
|
228
|
*
|
229
|
* @throws InvalidToken
|
230
|
* @throws ServiceFailure
|
231
|
* @throws NotAuthorized
|
232
|
* @throws NotFound
|
233
|
* @throws NotImplemented
|
234
|
* @throws InvalidRequest
|
235
|
*/
|
236
|
@Override
|
237
|
public DescribeResponse describe(Session session, Identifier pid)
|
238
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
239
|
NotImplemented, InvalidRequest {
|
240
|
|
241
|
return null;
|
242
|
}
|
243
|
|
244
|
/**
|
245
|
* Return the object identified by the given object identifier
|
246
|
*
|
247
|
* @param session - the Session object containing the credentials for the Subject
|
248
|
* @param pid - the object identifier for the given object
|
249
|
*
|
250
|
* @return inputStream - the input stream of the given object
|
251
|
*
|
252
|
* @throws InvalidToken
|
253
|
* @throws ServiceFailure
|
254
|
* @throws NotAuthorized
|
255
|
* @throws InvalidRequest
|
256
|
* @throws NotImplemented
|
257
|
*/
|
258
|
@Override
|
259
|
public InputStream get(Session session, Identifier pid)
|
260
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
261
|
NotImplemented, InvalidRequest {
|
262
|
|
263
|
return super.get(session, pid);
|
264
|
|
265
|
}
|
266
|
|
267
|
/**
|
268
|
* Returns a Checksum for the specified object using an accepted hashing algorithm
|
269
|
*
|
270
|
* @param session - the Session object containing the credentials for the Subject
|
271
|
* @param pid - the object identifier for the given object
|
272
|
* @param algorithm - the name of an algorithm that will be used to compute
|
273
|
* a checksum of the bytes of the object
|
274
|
*
|
275
|
* @return inputStream - the input stream of the given object
|
276
|
*
|
277
|
* @throws InvalidToken
|
278
|
* @throws ServiceFailure
|
279
|
* @throws NotAuthorized
|
280
|
* @throws NotFound
|
281
|
* @throws InvalidRequest
|
282
|
* @throws NotImplemented
|
283
|
*/
|
284
|
@Override
|
285
|
public Checksum getChecksum(Session session, Identifier pid, String algorithm)
|
286
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
287
|
InvalidRequest, NotImplemented {
|
288
|
|
289
|
return null;
|
290
|
}
|
291
|
|
292
|
/**
|
293
|
* Return the system metadata for a given object
|
294
|
*
|
295
|
* @param session - the Session object containing the credentials for the Subject
|
296
|
* @param pid - the object identifier for the given object
|
297
|
*
|
298
|
* @return inputStream - the input stream of the given system metadata object
|
299
|
*
|
300
|
* @throws InvalidToken
|
301
|
* @throws ServiceFailure
|
302
|
* @throws NotAuthorized
|
303
|
* @throws NotFound
|
304
|
* @throws InvalidRequest
|
305
|
* @throws NotImplemented
|
306
|
*/
|
307
|
@Override
|
308
|
public SystemMetadata getSystemMetadata(Session session, Identifier pid)
|
309
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
310
|
InvalidRequest, NotImplemented {
|
311
|
|
312
|
return super.getSystemMetadata(session, pid);
|
313
|
}
|
314
|
|
315
|
/**
|
316
|
* Retrieve the list of objects present on the MN that match the calling parameters
|
317
|
*
|
318
|
* @param session - the Session object containing the credentials for the Subject
|
319
|
* @param startTime - Specifies the beginning of the time range from which
|
320
|
* to return object (>=)
|
321
|
* @param endTime - Specifies the beginning of the time range from which
|
322
|
* to return object (>=)
|
323
|
* @param objectFormat - Restrict results to the specified object format
|
324
|
* @param replicaStatus - Indicates if replicated objects should be returned in the list
|
325
|
* @param start - The zero-based index of the first value, relative to the
|
326
|
* first record of the resultset that matches the parameters.
|
327
|
* @param count - The maximum number of entries that should be returned in
|
328
|
* the response. The Member Node may return less entries
|
329
|
* than specified in this value.
|
330
|
*
|
331
|
* @return objectList - the list of objects matching the criteria
|
332
|
*
|
333
|
* @throws InvalidToken
|
334
|
* @throws ServiceFailure
|
335
|
* @throws NotAuthorized
|
336
|
* @throws InvalidRequest
|
337
|
* @throws NotImplemented
|
338
|
*/
|
339
|
@Override
|
340
|
public ObjectList listObjects(Session session, Date startTime, Date endTime,
|
341
|
ObjectFormat objectFormat, Boolean replicaStatus, Integer start, Integer count)
|
342
|
throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure,
|
343
|
InvalidToken {
|
344
|
|
345
|
return null;
|
346
|
}
|
347
|
|
348
|
/**
|
349
|
* Retrieve the list of objects present on the MN that match the calling parameters
|
350
|
*
|
351
|
* @return node - the technical capabilities of the Member Node
|
352
|
*
|
353
|
* @throws ServiceFailure
|
354
|
* @throws NotAuthorized
|
355
|
* @throws InvalidRequest
|
356
|
* @throws NotImplemented
|
357
|
*/
|
358
|
@Override
|
359
|
public Node getCapabilities() throws NotImplemented, NotAuthorized,
|
360
|
ServiceFailure, InvalidRequest {
|
361
|
|
362
|
return null;
|
363
|
}
|
364
|
|
365
|
/**
|
366
|
* Returns the number of operations that have been serviced by the node
|
367
|
* over time periods of one and 24 hours.
|
368
|
*
|
369
|
* @param session - the Session object containing the credentials for the Subject
|
370
|
* @param period - An ISO8601 compatible DateTime range specifying the time
|
371
|
* range for which to return operation statistics.
|
372
|
* @param requestor - Limit to operations performed by given requestor identity.
|
373
|
* @param event - Enumerated value indicating the type of event being examined
|
374
|
* @param format - Limit to events involving objects of the specified format
|
375
|
*
|
376
|
* @return the desired log records
|
377
|
*
|
378
|
* @throws InvalidToken
|
379
|
* @throws ServiceFailure
|
380
|
* @throws NotAuthorized
|
381
|
* @throws InvalidRequest
|
382
|
* @throws NotImplemented
|
383
|
*/
|
384
|
@Override
|
385
|
public MonitorList getOperationStatistics(Session session, Integer period,
|
386
|
Subject requestor, Event event, ObjectFormat format)
|
387
|
throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest,
|
388
|
InsufficientResources, UnsupportedType {
|
389
|
|
390
|
return null;
|
391
|
}
|
392
|
|
393
|
/**
|
394
|
* Low level “are you alive” operation. A valid ping response is
|
395
|
* indicated by a HTTP status of 200.
|
396
|
*
|
397
|
* @return true if the service is alive
|
398
|
*
|
399
|
* @throws InvalidToken
|
400
|
* @throws ServiceFailure
|
401
|
* @throws NotAuthorized
|
402
|
* @throws InvalidRequest
|
403
|
* @throws NotImplemented
|
404
|
*/
|
405
|
@Override
|
406
|
public boolean ping()
|
407
|
throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest,
|
408
|
InsufficientResources, UnsupportedType {
|
409
|
|
410
|
return false;
|
411
|
}
|
412
|
|
413
|
/**
|
414
|
* A callback method used by a CN to indicate to a MN that it cannot
|
415
|
* complete synchronization of the science metadata identified by pid
|
416
|
*
|
417
|
* @param session
|
418
|
* @param syncFailed
|
419
|
*
|
420
|
* @throws ServiceFailure
|
421
|
* @throws NotAuthorized
|
422
|
* @throws InvalidRequest
|
423
|
* @throws NotImplemented
|
424
|
*/
|
425
|
@Override
|
426
|
public void synchronizationFailed(Session session, SynchronizationFailed syncFailed)
|
427
|
throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest {
|
428
|
|
429
|
|
430
|
}
|
431
|
|
432
|
}
|