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