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: tao $'
|
7
|
* '$Date: 2015-01-07 16:02:30 -0800 (Wed, 07 Jan 2015) $'
|
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.v1;
|
25
|
|
26
|
import java.io.InputStream;
|
27
|
import java.sql.SQLException;
|
28
|
import java.util.Date;
|
29
|
|
30
|
import javax.servlet.http.HttpServletRequest;
|
31
|
|
32
|
import org.apache.log4j.Logger;
|
33
|
import org.dataone.service.cn.v1.CNAuthorization;
|
34
|
import org.dataone.service.cn.v1.CNCore;
|
35
|
import org.dataone.service.cn.v1.CNRead;
|
36
|
import org.dataone.service.cn.v1.CNReplication;
|
37
|
import org.dataone.service.exceptions.BaseException;
|
38
|
import org.dataone.service.exceptions.IdentifierNotUnique;
|
39
|
import org.dataone.service.exceptions.InsufficientResources;
|
40
|
import org.dataone.service.exceptions.InvalidRequest;
|
41
|
import org.dataone.service.exceptions.InvalidSystemMetadata;
|
42
|
import org.dataone.service.exceptions.InvalidToken;
|
43
|
import org.dataone.service.exceptions.NotAuthorized;
|
44
|
import org.dataone.service.exceptions.NotFound;
|
45
|
import org.dataone.service.exceptions.NotImplemented;
|
46
|
import org.dataone.service.exceptions.ServiceFailure;
|
47
|
import org.dataone.service.exceptions.UnsupportedType;
|
48
|
import org.dataone.service.exceptions.VersionMismatch;
|
49
|
import org.dataone.service.types.v1.AccessPolicy;
|
50
|
import org.dataone.service.types.v1.Checksum;
|
51
|
import org.dataone.service.types.v1.ChecksumAlgorithmList;
|
52
|
import org.dataone.service.types.v1.DescribeResponse;
|
53
|
import org.dataone.service.types.v1.Event;
|
54
|
import org.dataone.service.types.v1.Identifier;
|
55
|
import org.dataone.service.types.v1.Log;
|
56
|
import org.dataone.service.types.v1.NodeList;
|
57
|
import org.dataone.service.types.v1.NodeReference;
|
58
|
import org.dataone.service.types.v1.ObjectFormat;
|
59
|
import org.dataone.service.types.v1.ObjectFormatIdentifier;
|
60
|
import org.dataone.service.types.v1.ObjectFormatList;
|
61
|
import org.dataone.service.types.v1.ObjectList;
|
62
|
import org.dataone.service.types.v1.ObjectLocationList;
|
63
|
import org.dataone.service.types.v1.Permission;
|
64
|
import org.dataone.service.types.v1.Replica;
|
65
|
import org.dataone.service.types.v1.ReplicationPolicy;
|
66
|
import org.dataone.service.types.v1.ReplicationStatus;
|
67
|
import org.dataone.service.types.v1.Session;
|
68
|
import org.dataone.service.types.v1.Subject;
|
69
|
import org.dataone.service.types.v1.SystemMetadata;
|
70
|
import org.dataone.service.types.v1_1.QueryEngineDescription;
|
71
|
import org.dataone.service.types.v1_1.QueryEngineList;
|
72
|
import org.dataone.service.util.TypeMarshaller;
|
73
|
|
74
|
import edu.ucsb.nceas.metacat.IdentifierManager;
|
75
|
|
76
|
/**
|
77
|
* Represents Metacat's implementation of the DataONE Coordinating Node service
|
78
|
* API. Methods implement the various CN* interfaces, and methods common to both
|
79
|
* Member Node and Coordinating Node interfaces are found in the D1NodeService
|
80
|
* super class.
|
81
|
*
|
82
|
*/
|
83
|
public class CNodeService implements CNAuthorization, CNCore, CNRead,
|
84
|
CNReplication {
|
85
|
|
86
|
// pass through to the most recent implementation
|
87
|
private edu.ucsb.nceas.metacat.dataone.CNodeService impl = null;
|
88
|
|
89
|
/* the logger instance */
|
90
|
private Logger logMetacat = null;
|
91
|
|
92
|
/**
|
93
|
* singleton accessor
|
94
|
*/
|
95
|
public static CNodeService getInstance(HttpServletRequest request) {
|
96
|
return new CNodeService(request);
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Constructor, private for singleton access
|
101
|
*/
|
102
|
private CNodeService(HttpServletRequest request) {
|
103
|
|
104
|
logMetacat = Logger.getLogger(CNodeService.class);
|
105
|
|
106
|
impl = edu.ucsb.nceas.metacat.dataone.CNodeService.getInstance(request);
|
107
|
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
public boolean deleteReplicationMetadata(Identifier pid,
|
112
|
NodeReference nodeId, long serialVersion) throws InvalidToken, InvalidRequest,
|
113
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented,
|
114
|
VersionMismatch {
|
115
|
return impl.deleteReplicationMetadata(null, pid, nodeId, serialVersion);
|
116
|
}
|
117
|
|
118
|
@Override
|
119
|
@Deprecated
|
120
|
public boolean deleteReplicationMetadata(Session session, Identifier pid,
|
121
|
NodeReference nodeId, long serialVersion) throws InvalidToken, InvalidRequest,
|
122
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented,
|
123
|
VersionMismatch {
|
124
|
return impl.deleteReplicationMetadata(session, pid, nodeId, serialVersion);
|
125
|
|
126
|
}
|
127
|
|
128
|
@Override
|
129
|
public boolean isNodeAuthorized(Subject targetNodeSubject, Identifier pid)
|
130
|
throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure,
|
131
|
NotFound, InvalidRequest {
|
132
|
return impl.isNodeAuthorized(null, targetNodeSubject, pid);
|
133
|
|
134
|
}
|
135
|
|
136
|
@Override
|
137
|
@Deprecated
|
138
|
public boolean isNodeAuthorized(Session originatingNodeSession, Subject targetNodeSubject, Identifier pid)
|
139
|
throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure,
|
140
|
NotFound, InvalidRequest {
|
141
|
return impl.isNodeAuthorized(originatingNodeSession, targetNodeSubject, pid);
|
142
|
}
|
143
|
|
144
|
@Override
|
145
|
public boolean setReplicationPolicy(Identifier pid,
|
146
|
ReplicationPolicy policy, long serialVersion) throws NotImplemented, NotFound,
|
147
|
NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
|
148
|
VersionMismatch {
|
149
|
return impl.setReplicationPolicy(null, pid, policy, serialVersion);
|
150
|
}
|
151
|
|
152
|
@Override
|
153
|
@Deprecated
|
154
|
public boolean setReplicationPolicy(Session session, Identifier pid,
|
155
|
ReplicationPolicy policy, long serialVersion) throws NotImplemented, NotFound,
|
156
|
NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
|
157
|
VersionMismatch {
|
158
|
return impl.setReplicationPolicy(session, pid, policy, serialVersion);
|
159
|
|
160
|
}
|
161
|
|
162
|
@Override
|
163
|
public boolean setReplicationStatus(Identifier pid,
|
164
|
NodeReference targetNode, ReplicationStatus status, BaseException failure)
|
165
|
throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, InvalidRequest, NotFound {
|
166
|
return impl.setReplicationStatus(null, pid, targetNode, status, failure);
|
167
|
}
|
168
|
|
169
|
@Override
|
170
|
@Deprecated
|
171
|
public boolean setReplicationStatus(Session session, Identifier pid,
|
172
|
NodeReference targetNode, ReplicationStatus status, BaseException failure)
|
173
|
throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized,
|
174
|
InvalidRequest, NotFound {
|
175
|
return impl.setReplicationStatus(session, pid, targetNode, status, failure);
|
176
|
}
|
177
|
|
178
|
@Override
|
179
|
public boolean updateReplicationMetadata(Identifier pid,
|
180
|
Replica replica, long serialVersion) throws NotImplemented, NotAuthorized, ServiceFailure,
|
181
|
NotFound, InvalidRequest, InvalidToken, VersionMismatch {
|
182
|
return impl.updateReplicationMetadata(null, pid, replica, serialVersion);
|
183
|
}
|
184
|
|
185
|
@Override
|
186
|
@Deprecated
|
187
|
public boolean updateReplicationMetadata(Session session, Identifier pid,
|
188
|
Replica replica, long serialVersion) throws NotImplemented, NotAuthorized,
|
189
|
ServiceFailure, NotFound, InvalidRequest, InvalidToken,
|
190
|
VersionMismatch {
|
191
|
return impl.updateReplicationMetadata(session, pid, replica, serialVersion);
|
192
|
}
|
193
|
|
194
|
@Override
|
195
|
public DescribeResponse describe(Identifier pid) throws InvalidToken,
|
196
|
NotAuthorized, NotImplemented, ServiceFailure, NotFound {
|
197
|
String serviceFailure = "4931";
|
198
|
String notFound = "4933";
|
199
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
200
|
"No system metadata could be found for given PID: "+pid.getValue());
|
201
|
return impl.describe(null, pid);
|
202
|
}
|
203
|
|
204
|
@Override
|
205
|
@Deprecated
|
206
|
public DescribeResponse describe(Session session, Identifier pid)
|
207
|
throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
|
208
|
NotFound {
|
209
|
String serviceFailure = "4931";
|
210
|
String notFound = "4933";
|
211
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
212
|
"No system metadata could be found for given PID: "+pid.getValue());
|
213
|
return impl.describe(session, pid);
|
214
|
}
|
215
|
|
216
|
@Override
|
217
|
public InputStream get(Identifier pid) throws InvalidToken,
|
218
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
219
|
String serviceFailure = "1030";
|
220
|
String notFound = "1020";
|
221
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
222
|
"The object specified by "+pid.getValue()+" does not exist at this node");
|
223
|
return impl.get(null, pid);
|
224
|
}
|
225
|
|
226
|
@Override
|
227
|
@Deprecated
|
228
|
public InputStream get(Session session, Identifier pid) throws InvalidToken,
|
229
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
230
|
String serviceFailure = "1030";
|
231
|
String notFound = "1020";
|
232
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
233
|
"The object specified by "+pid.getValue()+" does not exist at this node");
|
234
|
return impl.get(session, pid);
|
235
|
}
|
236
|
|
237
|
@Override
|
238
|
public Checksum getChecksum(Identifier pid) throws InvalidToken,
|
239
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
240
|
return impl.getChecksum(null, pid);
|
241
|
}
|
242
|
|
243
|
@Override
|
244
|
@Deprecated
|
245
|
public Checksum getChecksum(Session session, Identifier pid)
|
246
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
247
|
NotImplemented {
|
248
|
return impl.getChecksum(session, pid);
|
249
|
}
|
250
|
|
251
|
@Override
|
252
|
public QueryEngineDescription getQueryEngineDescription(String queryEngine)
|
253
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
254
|
NotFound {
|
255
|
return impl.getQueryEngineDescription(null, queryEngine);
|
256
|
}
|
257
|
|
258
|
@Override
|
259
|
public SystemMetadata getSystemMetadata(Identifier pid)
|
260
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
261
|
NotImplemented {
|
262
|
String serviceFailure = "1090";
|
263
|
String notFound = "1060";
|
264
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
265
|
"No system metadata could be found for given PID: "+pid.getValue());
|
266
|
return impl.getSystemMetadata(null, pid);
|
267
|
}
|
268
|
|
269
|
@Override
|
270
|
@Deprecated
|
271
|
public SystemMetadata getSystemMetadata(Session session, Identifier pid)
|
272
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
273
|
NotImplemented {
|
274
|
String serviceFailure = "1090";
|
275
|
String notFound = "1060";
|
276
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
277
|
"No system metadata could be found for given PID: "+pid.getValue());
|
278
|
return impl.getSystemMetadata(session, pid);
|
279
|
}
|
280
|
|
281
|
@Override
|
282
|
public ObjectList listObjects(Date startTime, Date endTime,
|
283
|
ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
|
284
|
Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
|
285
|
NotImplemented, ServiceFailure {
|
286
|
return impl.listObjects(null, startTime, endTime, formatid, null, replicaStatus, start, count);
|
287
|
}
|
288
|
|
289
|
@Override
|
290
|
@Deprecated
|
291
|
public ObjectList listObjects(Session session, Date startTime, Date endTime,
|
292
|
ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
|
293
|
Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
|
294
|
NotImplemented, ServiceFailure {
|
295
|
return impl.listObjects(session, startTime, endTime, formatid, null, replicaStatus, start, count);
|
296
|
}
|
297
|
|
298
|
@Override
|
299
|
public QueryEngineList listQueryEngines() throws InvalidToken,
|
300
|
ServiceFailure, NotAuthorized, NotImplemented {
|
301
|
return impl.listQueryEngines(null);
|
302
|
}
|
303
|
|
304
|
@Override
|
305
|
public InputStream query(String queryEngine, String query) throws InvalidToken,
|
306
|
ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented,
|
307
|
NotFound {
|
308
|
return impl.query(null, queryEngine, query);
|
309
|
}
|
310
|
|
311
|
@Override
|
312
|
public ObjectLocationList resolve(Identifier pid) throws InvalidToken,
|
313
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
314
|
return impl.resolve(null, pid);
|
315
|
}
|
316
|
|
317
|
@Override
|
318
|
@Deprecated
|
319
|
public ObjectLocationList resolve(Session session, Identifier pid)
|
320
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
|
321
|
NotImplemented {
|
322
|
return impl.resolve(session, pid);
|
323
|
}
|
324
|
|
325
|
@Override
|
326
|
public ObjectList search(String queryType, String query) throws InvalidToken,
|
327
|
ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented {
|
328
|
return impl.search(null, queryType, query);
|
329
|
}
|
330
|
|
331
|
@Override
|
332
|
@Deprecated
|
333
|
public ObjectList search(Session session, String queryType, String query)
|
334
|
throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest,
|
335
|
NotImplemented {
|
336
|
return impl.search(session, queryType, query);
|
337
|
}
|
338
|
|
339
|
@Override
|
340
|
public Identifier archive(Identifier pid) throws InvalidToken,
|
341
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
342
|
String serviceFailure = "4972";
|
343
|
String notFound = "4971";
|
344
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
345
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
346
|
return impl.archive(null, pid);
|
347
|
}
|
348
|
|
349
|
@Override
|
350
|
@Deprecated
|
351
|
public Identifier archive(Session session, Identifier pid)
|
352
|
throws InvalidToken, ServiceFailure, InvalidRequest, NotAuthorized,
|
353
|
NotFound, NotImplemented {
|
354
|
String serviceFailure = "4972";
|
355
|
String notFound = "4971";
|
356
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
357
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
358
|
return impl.archive(session, pid);
|
359
|
}
|
360
|
|
361
|
@Override
|
362
|
public Identifier create(Identifier pid, InputStream object,
|
363
|
SystemMetadata sysmeta) throws InvalidToken, ServiceFailure,
|
364
|
NotAuthorized, IdentifierNotUnique, UnsupportedType,
|
365
|
InsufficientResources, InvalidSystemMetadata, NotImplemented,
|
366
|
InvalidRequest {
|
367
|
return this.create(null, pid, object, sysmeta);
|
368
|
}
|
369
|
|
370
|
@Override
|
371
|
@Deprecated
|
372
|
public Identifier create(Session session, Identifier pid, InputStream object,
|
373
|
SystemMetadata sysmeta) throws InvalidToken, ServiceFailure,
|
374
|
NotAuthorized, IdentifierNotUnique, UnsupportedType,
|
375
|
InsufficientResources, InvalidSystemMetadata, NotImplemented,
|
376
|
InvalidRequest {
|
377
|
|
378
|
//convert sysmeta to newer version
|
379
|
org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
|
380
|
try {
|
381
|
v2Sysmeta = TypeMarshaller.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
|
382
|
} catch (Exception e) {
|
383
|
// report as service failure
|
384
|
ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
|
385
|
sf.initCause(e);
|
386
|
throw sf;
|
387
|
}
|
388
|
|
389
|
return impl.create(session, pid, object, v2Sysmeta);
|
390
|
}
|
391
|
|
392
|
@Override
|
393
|
public Identifier delete(Identifier pid) throws InvalidToken,
|
394
|
ServiceFailure, NotAuthorized, NotFound, NotImplemented {
|
395
|
String serviceFailure = "4962";
|
396
|
String notFound = "4961";
|
397
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
398
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
399
|
return impl.delete(null, pid);
|
400
|
}
|
401
|
|
402
|
@Override
|
403
|
@Deprecated
|
404
|
public Identifier delete(Session session, Identifier pid)
|
405
|
throws InvalidToken, ServiceFailure, InvalidRequest, NotAuthorized,
|
406
|
NotFound, NotImplemented {
|
407
|
String serviceFailure = "4962";
|
408
|
String notFound = "4961";
|
409
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
410
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
411
|
return impl.delete(session, pid);
|
412
|
}
|
413
|
|
414
|
@Override
|
415
|
public Identifier generateIdentifier(String scheme, String fragment)
|
416
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
417
|
InvalidRequest {
|
418
|
return impl.generateIdentifier(null, scheme, fragment);
|
419
|
}
|
420
|
|
421
|
@Override
|
422
|
@Deprecated
|
423
|
public Identifier generateIdentifier(Session session, String scheme, String fragment)
|
424
|
throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
|
425
|
InvalidRequest {
|
426
|
return impl.generateIdentifier(session, scheme, fragment);
|
427
|
}
|
428
|
|
429
|
@Override
|
430
|
public ObjectFormat getFormat(ObjectFormatIdentifier fmtid)
|
431
|
throws ServiceFailure, NotFound, NotImplemented, InvalidRequest {
|
432
|
return impl.getFormat(fmtid);
|
433
|
}
|
434
|
|
435
|
@Override
|
436
|
public Log getLogRecords(Date fromDate, Date toDate, Event event,
|
437
|
String pidFilter, Integer start, Integer count) throws InvalidToken, InvalidRequest,
|
438
|
ServiceFailure, NotAuthorized, NotImplemented,
|
439
|
InsufficientResources {
|
440
|
return this.getLogRecords(null, fromDate, toDate, event, pidFilter, start, count);
|
441
|
}
|
442
|
|
443
|
@Override
|
444
|
@Deprecated
|
445
|
public Log getLogRecords(Session session, Date fromDate, Date toDate, Event event,
|
446
|
String pidFilter, Integer start, Integer count) throws InvalidToken,
|
447
|
InvalidRequest, ServiceFailure, NotAuthorized, NotImplemented,
|
448
|
InsufficientResources {
|
449
|
Log retLog = new Log();
|
450
|
if(pidFilter != null && !pidFilter.equals("")) {
|
451
|
String serviceFailure = "1490";
|
452
|
String notFound = "1020";
|
453
|
Identifier pid = new Identifier();
|
454
|
pid.setValue(pidFilter);
|
455
|
try {
|
456
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
457
|
"The given PID: "+pid.getValue()+" doesn't exist in this node");
|
458
|
} catch (NotFound e) {
|
459
|
//return 0 record since the pid doesn't exist
|
460
|
logMetacat.info(e.getMessage());
|
461
|
return retLog;
|
462
|
}
|
463
|
|
464
|
}
|
465
|
String eventValue = null;
|
466
|
if(event != null) {
|
467
|
eventValue = event.xmlValue();
|
468
|
}
|
469
|
org.dataone.service.types.v2.Log log = impl.getLogRecords(session, fromDate, toDate, eventValue, pidFilter, start, count);
|
470
|
try {
|
471
|
retLog = TypeMarshaller.convertTypeFromType(log, Log.class);
|
472
|
} catch (Exception e) {
|
473
|
// report as service failure
|
474
|
ServiceFailure sf = new ServiceFailure("1490", e.getMessage());
|
475
|
sf.initCause(e);
|
476
|
throw sf;
|
477
|
}
|
478
|
return retLog;
|
479
|
}
|
480
|
|
481
|
@Override
|
482
|
public boolean hasReservation(Subject subject, Identifier pid)
|
483
|
throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
|
484
|
NotImplemented, InvalidRequest, IdentifierNotUnique {
|
485
|
return impl.hasReservation(null, subject, pid);
|
486
|
}
|
487
|
|
488
|
@Override
|
489
|
@Deprecated
|
490
|
public boolean hasReservation(Session session, Subject subject, Identifier pid)
|
491
|
throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
|
492
|
NotImplemented, InvalidRequest, IdentifierNotUnique {
|
493
|
return impl.hasReservation(session, subject, pid);
|
494
|
|
495
|
}
|
496
|
|
497
|
@Override
|
498
|
public ChecksumAlgorithmList listChecksumAlgorithms()
|
499
|
throws ServiceFailure, NotImplemented {
|
500
|
return impl.listChecksumAlgorithms();
|
501
|
}
|
502
|
|
503
|
@Override
|
504
|
public ObjectFormatList listFormats() throws ServiceFailure, NotImplemented {
|
505
|
org.dataone.service.types.v2.ObjectFormatList formats = impl.listFormats();
|
506
|
ObjectFormatList retFormats = null;
|
507
|
try {
|
508
|
retFormats = TypeMarshaller.convertTypeFromType(formats, ObjectFormatList.class);
|
509
|
} catch (Exception e) {
|
510
|
// report as service failure
|
511
|
ServiceFailure sf = new ServiceFailure("4841", e.getMessage());
|
512
|
sf.initCause(e);
|
513
|
throw sf;
|
514
|
}
|
515
|
return retFormats;
|
516
|
}
|
517
|
|
518
|
@Override
|
519
|
public NodeList listNodes() throws NotImplemented, ServiceFailure {
|
520
|
org.dataone.service.types.v2.NodeList nodes = impl.listNodes();
|
521
|
NodeList retNodes = null;
|
522
|
try {
|
523
|
retNodes = TypeMarshaller.convertTypeFromType(nodes, NodeList.class);
|
524
|
} catch (Exception e) {
|
525
|
// report as service failure
|
526
|
ServiceFailure sf = new ServiceFailure("4801", e.getMessage());
|
527
|
sf.initCause(e);
|
528
|
throw sf;
|
529
|
}
|
530
|
return retNodes;
|
531
|
}
|
532
|
|
533
|
@Override
|
534
|
public Date ping() throws NotImplemented, ServiceFailure,
|
535
|
InsufficientResources {
|
536
|
return impl.ping();
|
537
|
}
|
538
|
|
539
|
@Override
|
540
|
public Identifier registerSystemMetadata(Identifier pid,
|
541
|
SystemMetadata sysmeta) throws NotImplemented, NotAuthorized,
|
542
|
ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
|
543
|
return this.registerSystemMetadata(null, pid, sysmeta);
|
544
|
|
545
|
}
|
546
|
|
547
|
@Override
|
548
|
@Deprecated
|
549
|
public Identifier registerSystemMetadata(Session session, Identifier pid,
|
550
|
SystemMetadata sysmeta) throws NotImplemented, NotAuthorized,
|
551
|
ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
|
552
|
//convert sysmeta to newer version
|
553
|
org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
|
554
|
try {
|
555
|
v2Sysmeta = TypeMarshaller.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
|
556
|
} catch (Exception e) {
|
557
|
// report as service failure
|
558
|
ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
|
559
|
sf.initCause(e);
|
560
|
throw sf;
|
561
|
}
|
562
|
|
563
|
return impl.registerSystemMetadata(session, pid, v2Sysmeta);
|
564
|
}
|
565
|
|
566
|
@Override
|
567
|
public Identifier reserveIdentifier(Identifier pid) throws InvalidToken,
|
568
|
ServiceFailure, NotAuthorized, IdentifierNotUnique, NotImplemented,
|
569
|
InvalidRequest {
|
570
|
return impl.reserveIdentifier(null, pid);
|
571
|
}
|
572
|
|
573
|
@Override
|
574
|
@Deprecated
|
575
|
public Identifier reserveIdentifier(Session session, Identifier pid)
|
576
|
throws InvalidToken, ServiceFailure, NotAuthorized,
|
577
|
IdentifierNotUnique, NotImplemented, InvalidRequest {
|
578
|
return impl.reserveIdentifier(session, pid);
|
579
|
}
|
580
|
|
581
|
@Override
|
582
|
public boolean setObsoletedBy(Identifier pid, Identifier obsoletedByPid, long serialVersion)
|
583
|
throws NotImplemented, NotFound, NotAuthorized, ServiceFailure,
|
584
|
InvalidRequest, InvalidToken, VersionMismatch {
|
585
|
return impl.setObsoletedBy(null, pid, obsoletedByPid, serialVersion);
|
586
|
}
|
587
|
|
588
|
@Override
|
589
|
@Deprecated
|
590
|
public boolean setObsoletedBy(Session session, Identifier pid, Identifier obsoletedByPid, long serialVersion)
|
591
|
throws NotImplemented, NotFound,
|
592
|
NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
|
593
|
VersionMismatch {
|
594
|
return impl.setObsoletedBy(session, pid, obsoletedByPid, serialVersion);
|
595
|
|
596
|
}
|
597
|
|
598
|
@Override
|
599
|
public boolean isAuthorized(Identifier pid, Permission permission)
|
600
|
throws ServiceFailure, InvalidToken, NotFound, NotAuthorized,
|
601
|
NotImplemented, InvalidRequest {
|
602
|
String serviceFailure = "1760";
|
603
|
String notFound = "1800";
|
604
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
605
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
606
|
return impl.isAuthorized(null, pid, permission);
|
607
|
}
|
608
|
|
609
|
@Override
|
610
|
@Deprecated
|
611
|
public boolean isAuthorized(Session session, Identifier pid, Permission permission)
|
612
|
throws ServiceFailure, InvalidToken, NotFound, NotAuthorized,
|
613
|
NotImplemented, InvalidRequest {
|
614
|
String serviceFailure = "1760";
|
615
|
String notFound = "1800";
|
616
|
impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists", notFound,
|
617
|
"The object specified by "+pid.getValue()+" does not exist at this node.");
|
618
|
return impl.isAuthorized(session, pid, permission);
|
619
|
}
|
620
|
|
621
|
@Override
|
622
|
public boolean setAccessPolicy(Identifier pid,
|
623
|
AccessPolicy accessPolicy, long serialVersion)
|
624
|
throws InvalidToken, NotFound, NotImplemented, NotAuthorized,
|
625
|
ServiceFailure, InvalidRequest, VersionMismatch {
|
626
|
return impl.setAccessPolicy(null, pid, accessPolicy, serialVersion);
|
627
|
}
|
628
|
|
629
|
@Override
|
630
|
@Deprecated
|
631
|
public boolean setAccessPolicy(Session session, Identifier pid,
|
632
|
AccessPolicy accessPolicy, long serialVersion) throws InvalidToken, NotFound,
|
633
|
NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest,
|
634
|
VersionMismatch {
|
635
|
return impl.setAccessPolicy(session, pid, accessPolicy, serialVersion);
|
636
|
}
|
637
|
|
638
|
@Override
|
639
|
public Identifier setRightsHolder(Identifier pid, Subject userId, long serialVersion)
|
640
|
throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
|
641
|
NotImplemented, InvalidRequest, VersionMismatch {
|
642
|
return impl.setRightsHolder(null, pid, userId, serialVersion);
|
643
|
}
|
644
|
|
645
|
@Override
|
646
|
@Deprecated
|
647
|
public Identifier setRightsHolder(Session session, Identifier pid,
|
648
|
Subject userId, long serialVersion) throws InvalidToken, ServiceFailure,
|
649
|
NotFound, NotAuthorized, NotImplemented, InvalidRequest,
|
650
|
VersionMismatch {
|
651
|
return impl.setRightsHolder(session, pid, userId, serialVersion);
|
652
|
|
653
|
}
|
654
|
|
655
|
}
|