Project

General

Profile

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-02-17 16:00:29 -0800 (Tue, 17 Feb 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.util.TypeMarshaller;
74

    
75
import edu.ucsb.nceas.metacat.IdentifierManager;
76
import edu.ucsb.nceas.metacat.dataone.convert.LogV2toV1Converter;
77

    
78
/**
79
 * Represents Metacat's implementation of the DataONE Coordinating Node service
80
 * API. Methods implement the various CN* interfaces, and methods common to both
81
 * Member Node and Coordinating Node interfaces are found in the D1NodeService
82
 * super class.
83
 * 
84
 */
85
public class CNodeService implements CNAuthorization, CNCore, CNRead,
86
		CNReplication {
87

    
88
	// pass through to the most recent implementation
89
	private edu.ucsb.nceas.metacat.dataone.CNodeService impl = null;
90

    
91
	/* the logger instance */
92
	private Logger logMetacat = null;
93

    
94
	/**
95
	 * singleton accessor
96
	 */
97
	public static CNodeService getInstance(HttpServletRequest request) {
98
		return new CNodeService(request);
99
	}
100

    
101
	/**
102
	 * Constructor, private for singleton access
103
	 */
104
	private CNodeService(HttpServletRequest request) {
105

    
106
		logMetacat = Logger.getLogger(CNodeService.class);
107

    
108
		impl = edu.ucsb.nceas.metacat.dataone.CNodeService.getInstance(request);
109

    
110
	}
111

    
112
	@Override
113
	public boolean deleteReplicationMetadata(Identifier pid,
114
			NodeReference nodeId, long serialVersion) throws InvalidToken, InvalidRequest,
115
			ServiceFailure, NotAuthorized, NotFound, NotImplemented,
116
			VersionMismatch {
117
		return impl.deleteReplicationMetadata(null, pid, nodeId, serialVersion);
118
	}
119

    
120
	@Override
121
	@Deprecated
122
	public boolean deleteReplicationMetadata(Session session, Identifier pid,
123
			NodeReference nodeId, long serialVersion) throws InvalidToken, InvalidRequest,
124
			ServiceFailure, NotAuthorized, NotFound, NotImplemented,
125
			VersionMismatch {
126
		return impl.deleteReplicationMetadata(session, pid, nodeId, serialVersion);
127

    
128
	}
129

    
130
	@Override
131
	public boolean isNodeAuthorized(Subject targetNodeSubject, Identifier pid)
132
			throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure,
133
			NotFound, InvalidRequest {
134
		return impl.isNodeAuthorized(null, targetNodeSubject, pid);
135

    
136
	}
137

    
138
	@Override
139
	@Deprecated
140
	public boolean isNodeAuthorized(Session originatingNodeSession, Subject targetNodeSubject, Identifier pid)
141
			throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure,
142
			NotFound, InvalidRequest {
143
		return impl.isNodeAuthorized(originatingNodeSession, targetNodeSubject, pid);
144
	}
145

    
146
	@Override
147
	public boolean setReplicationPolicy(Identifier pid,
148
			ReplicationPolicy policy, long serialVersion) throws NotImplemented, NotFound,
149
			NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
150
			VersionMismatch {
151
	    String serviceFailure = "4882";
152
        String notFound = "4884";
153
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
154
                "No object could be found for given PID: "+pid.getValue());
155
		return impl.setReplicationPolicy(null, pid, policy, serialVersion);
156
	}
157

    
158
	@Override
159
	@Deprecated
160
	public boolean setReplicationPolicy(Session session, Identifier pid,
161
			ReplicationPolicy policy, long serialVersion) throws NotImplemented, NotFound,
162
			NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
163
			VersionMismatch {
164
	    String serviceFailure = "4882";
165
        String notFound = "4884";
166
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
167
                "No object could be found for given PID: "+pid.getValue());
168
		return impl.setReplicationPolicy(session, pid, policy, serialVersion);
169

    
170
	}
171

    
172
	@Override
173
	public boolean setReplicationStatus(Identifier pid,
174
			NodeReference targetNode, ReplicationStatus status, BaseException failure) 
175
			throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized, InvalidRequest, NotFound {
176
	    String serviceFailure = "4700";
177
        String notFound = "4740";
178
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
179
                "No object could be found for given PID: "+pid.getValue());
180
		return impl.setReplicationStatus(null, pid, targetNode, status, failure);
181
	}
182

    
183
	@Override
184
	@Deprecated
185
	public boolean setReplicationStatus(Session session, Identifier pid,
186
			NodeReference targetNode, ReplicationStatus status, BaseException failure)
187
			throws ServiceFailure, NotImplemented, InvalidToken, NotAuthorized,
188
			InvalidRequest, NotFound {
189
	    String serviceFailure = "4700";
190
        String notFound = "4740";
191
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
192
                "No object could be found for given PID: "+pid.getValue());
193
		return impl.setReplicationStatus(session, pid, targetNode, status, failure);
194
	}
195

    
196
	@Override
197
	public boolean updateReplicationMetadata(Identifier pid,
198
			Replica replica, long serialVersion) throws NotImplemented, NotAuthorized, ServiceFailure,
199
			NotFound, InvalidRequest, InvalidToken, VersionMismatch {
200
		return impl.updateReplicationMetadata(null, pid, replica, serialVersion);
201
	}
202

    
203
	@Override
204
	@Deprecated
205
	public boolean updateReplicationMetadata(Session session, Identifier pid,
206
			Replica replica, long serialVersion) throws NotImplemented, NotAuthorized,
207
			ServiceFailure, NotFound, InvalidRequest, InvalidToken,
208
			VersionMismatch {
209
		return impl.updateReplicationMetadata(session, pid, replica, serialVersion);
210
	}
211

    
212
	@Override
213
	public DescribeResponse describe(Identifier pid) throws InvalidToken,
214
			NotAuthorized, NotImplemented, ServiceFailure, NotFound {
215
	    String serviceFailure = "4931";
216
        String notFound = "4933";
217
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
218
                "No system metadata could be found for given PID: "+pid.getValue());
219
		return impl.describe(null, pid);
220
	}
221

    
222
	@Override
223
	@Deprecated
224
	public DescribeResponse describe(Session session, Identifier pid)
225
			throws InvalidToken, NotAuthorized, NotImplemented, ServiceFailure,
226
			NotFound {
227
	    String serviceFailure = "4931";
228
        String notFound = "4933";
229
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
230
                "No system metadata could be found for given PID: "+pid.getValue());
231
		return impl.describe(session, pid);
232
	}
233

    
234
	@Override
235
	public InputStream get(Identifier pid) throws InvalidToken,
236
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
237
        String serviceFailure = "1030";
238
        String notFound = "1020";
239
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
240
                "The object specified by "+pid.getValue()+" does not exist at this node");
241
		return impl.get(null, pid);
242
	}
243

    
244
	@Override
245
	@Deprecated
246
	public InputStream get(Session session, Identifier pid) throws InvalidToken,
247
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
248
	    String serviceFailure = "1030";
249
        String notFound = "1020";
250
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
251
                "The object specified by "+pid.getValue()+" does not exist at this node");
252
		return impl.get(session, pid);
253
	}
254

    
255
	@Override
256
	public Checksum getChecksum(Identifier pid) throws InvalidToken,
257
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
258
		return impl.getChecksum(null, pid);
259
	}
260

    
261
	@Override
262
	@Deprecated
263
	public Checksum getChecksum(Session session, Identifier pid)
264
			throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
265
			NotImplemented {
266
		return impl.getChecksum(session, pid);
267
	}
268

    
269
	@Override
270
	public QueryEngineDescription getQueryEngineDescription(String queryEngine)
271
			throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
272
			NotFound {
273
		return impl.getQueryEngineDescription(null, queryEngine);
274
	}
275

    
276
	@Override
277
	public SystemMetadata getSystemMetadata(Identifier pid)
278
			throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
279
			NotImplemented {
280
	    String serviceFailure = "1090";
281
        String notFound = "1060";
282
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
283
                "No system metadata could be found for given PID: "+pid.getValue());
284
		return impl.getSystemMetadata(null, pid);
285
	}
286

    
287
	@Override
288
	@Deprecated
289
	public SystemMetadata getSystemMetadata(Session session, Identifier pid)
290
			throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
291
			NotImplemented {
292
	    String serviceFailure = "1090";
293
        String notFound = "1060";
294
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The system metadata for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
295
                "No system metadata could be found for given PID: "+pid.getValue());
296
		return impl.getSystemMetadata(session, pid);
297
	}
298

    
299
	@Override
300
	public ObjectList listObjects(Date startTime, Date endTime,
301
			ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
302
			Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
303
			NotImplemented, ServiceFailure {
304
		return impl.listObjects(null, startTime, endTime, formatid, null, replicaStatus, start, count);
305
	}
306

    
307
	@Override
308
	@Deprecated
309
	public ObjectList listObjects(Session session, Date startTime, Date endTime,
310
			ObjectFormatIdentifier formatid, Boolean replicaStatus, Integer start,
311
			Integer count) throws InvalidRequest, InvalidToken, NotAuthorized,
312
			NotImplemented, ServiceFailure {
313
		return impl.listObjects(session, startTime, endTime, formatid, null, replicaStatus, start, count);
314
	}
315

    
316
	@Override
317
	public QueryEngineList listQueryEngines() throws InvalidToken,
318
			ServiceFailure, NotAuthorized, NotImplemented {
319
		return impl.listQueryEngines(null);
320
	}
321

    
322
	@Override
323
	public InputStream query(String queryEngine, String query) throws InvalidToken,
324
			ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented,
325
			NotFound {
326
		return impl.query(null, queryEngine, query);
327
	}
328

    
329
	@Override
330
	public ObjectLocationList resolve(Identifier pid) throws InvalidToken,
331
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
332
		return impl.resolve(null, pid);
333
	}
334

    
335
	@Override
336
	@Deprecated
337
	public ObjectLocationList resolve(Session session, Identifier pid)
338
			throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
339
			NotImplemented {
340
		return impl.resolve(session, pid);
341
	}
342

    
343
	@Override
344
	public ObjectList search(String queryType, String query) throws InvalidToken,
345
			ServiceFailure, NotAuthorized, InvalidRequest, NotImplemented {
346
		return impl.search(null, queryType, query);
347
	}
348

    
349
	@Override
350
	@Deprecated
351
	public ObjectList search(Session session, String queryType, String query)
352
			throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest,
353
			NotImplemented {
354
		return impl.search(session, queryType, query);
355
	}
356

    
357
	@Override
358
	public Identifier archive(Identifier pid) throws InvalidToken,
359
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
360
	    String serviceFailure = "4972";
361
        String notFound = "4971";
362
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
363
                "The object specified by "+pid.getValue()+" does not exist at this node.");
364
		return impl.archive(null, pid);
365
	}
366

    
367
	@Override
368
	@Deprecated
369
	public Identifier archive(Session session, Identifier pid)
370
			throws InvalidToken, ServiceFailure, InvalidRequest, NotAuthorized,
371
			NotFound, NotImplemented {
372
	    String serviceFailure = "4972";
373
        String notFound = "4971";
374
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
375
                "The object specified by "+pid.getValue()+" does not exist at this node.");
376
		return impl.archive(session, pid);
377
	}
378

    
379
	@Override
380
	public Identifier create(Identifier pid, InputStream object,
381
			SystemMetadata sysmeta) throws InvalidToken, ServiceFailure,
382
			NotAuthorized, IdentifierNotUnique, UnsupportedType,
383
			InsufficientResources, InvalidSystemMetadata, NotImplemented,
384
			InvalidRequest {
385
		return this.create(null, pid, object, sysmeta);
386
	}
387

    
388
	@Override
389
	@Deprecated
390
	public Identifier create(Session session, Identifier pid, InputStream object,
391
			SystemMetadata sysmeta) throws InvalidToken, ServiceFailure,
392
			NotAuthorized, IdentifierNotUnique, UnsupportedType,
393
			InsufficientResources, InvalidSystemMetadata, NotImplemented,
394
			InvalidRequest {
395
		
396
		//convert sysmeta to newer version
397
		org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
398
		try {
399
			v2Sysmeta = TypeMarshaller.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
400
		} catch (Exception e) {
401
			// report as service failure
402
			ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
403
			sf.initCause(e);
404
			throw sf;
405
		}
406
		
407
		return impl.create(session, pid, object, v2Sysmeta);
408
	}
409

    
410
	@Override
411
	public Identifier delete(Identifier pid) throws InvalidToken,
412
			ServiceFailure, NotAuthorized, NotFound, NotImplemented {
413
	    String serviceFailure = "4962";
414
        String notFound = "4961";
415
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
416
                "The object specified by "+pid.getValue()+" does not exist at this node.");
417
		return impl.delete(null, pid);
418
	}
419

    
420
	@Override
421
	@Deprecated
422
	public Identifier delete(Session session, Identifier pid)
423
			throws InvalidToken, ServiceFailure, InvalidRequest, NotAuthorized,
424
			NotFound, NotImplemented {
425
	    String serviceFailure = "4962";
426
        String notFound = "4961";
427
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
428
                "The object specified by "+pid.getValue()+" does not exist at this node.");
429
		return impl.delete(session, pid);
430
	}
431

    
432
	@Override
433
	public Identifier generateIdentifier(String scheme, String fragment)
434
			throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
435
			InvalidRequest {
436
		return impl.generateIdentifier(null, scheme, fragment);
437
	}
438

    
439
	@Override
440
	@Deprecated
441
	public Identifier generateIdentifier(Session session, String scheme, String fragment)
442
			throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented,
443
			InvalidRequest {
444
		return impl.generateIdentifier(session, scheme, fragment);
445
	}
446

    
447
	@Override
448
	public ObjectFormat getFormat(ObjectFormatIdentifier fmtid)
449
			throws ServiceFailure, NotFound, NotImplemented, InvalidRequest {
450
		return impl.getFormat(fmtid);
451
	}
452

    
453
	@Override
454
	public Log getLogRecords(Date fromDate, Date toDate, Event event,
455
			String pidFilter, Integer start, Integer count) throws InvalidToken, InvalidRequest,
456
			ServiceFailure, NotAuthorized, NotImplemented,
457
			InsufficientResources {
458
		return this.getLogRecords(null, fromDate, toDate, event, pidFilter, start, count);
459
	}
460

    
461
	@Override
462
	@Deprecated
463
	public Log getLogRecords(Session session, Date fromDate, Date toDate, Event event,
464
			String pidFilter, Integer start, Integer count) throws InvalidToken,
465
			InvalidRequest, ServiceFailure, NotAuthorized, NotImplemented,
466
			InsufficientResources {
467
	    Log retLog = new Log();
468
        if(pidFilter != null && !pidFilter.trim().equals("")) {
469
            String serviceFailure = "1490";
470
            String notFound = "1020";
471
            Identifier pid = new Identifier();
472
            pid.setValue(pidFilter);
473
            try {
474
                impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
475
                        "The given PID: "+pid.getValue()+" doesn't exist in this node");
476
            } catch (NotFound e) {
477
                //return 0 record since the pid doesn't exist
478
                logMetacat.info(e.getMessage());
479
                return retLog;
480
            }
481
            
482
        }
483
	    String eventValue = null;
484
        if(event != null) {
485
            eventValue = event.xmlValue();
486
        }
487
		org.dataone.service.types.v2.Log log = impl.getLogRecords(session, fromDate, toDate, eventValue, pidFilter, start, count);
488
		try {
489
			//retLog = TypeMarshaller.convertTypeFromType(log, Log.class);
490
            LogV2toV1Converter converter = new LogV2toV1Converter();
491
            retLog = converter.convert(log);
492
		} catch (Exception e) {
493
			// report as service failure
494
			ServiceFailure sf = new ServiceFailure("1490", e.getMessage());
495
			sf.initCause(e);
496
			throw sf;
497
		}
498
		return retLog;
499
	}
500

    
501
	@Override
502
	public boolean hasReservation(Subject subject, Identifier pid)
503
			throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
504
			NotImplemented, InvalidRequest, IdentifierNotUnique {
505
		return impl.hasReservation(null, subject, pid);
506
	}
507

    
508
	@Override
509
	@Deprecated
510
	public boolean hasReservation(Session session, Subject subject, Identifier pid)
511
			throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
512
			NotImplemented, InvalidRequest, IdentifierNotUnique {
513
		return impl.hasReservation(session, subject, pid);
514

    
515
	}
516

    
517
	@Override
518
	public ChecksumAlgorithmList listChecksumAlgorithms()
519
			throws ServiceFailure, NotImplemented {
520
		return impl.listChecksumAlgorithms();
521
	}
522

    
523
	@Override
524
	public ObjectFormatList listFormats() throws ServiceFailure, NotImplemented {
525
		org.dataone.service.types.v2.ObjectFormatList formats = impl.listFormats();
526
		ObjectFormatList retFormats = new ObjectFormatList();
527
		try {
528
		    if(formats != null) {
529
		        List<org.dataone.service.types.v2.ObjectFormat> objectFormatList = formats.getObjectFormatList();
530
		        if(objectFormatList != null) {
531
		            for(org.dataone.service.types.v2.ObjectFormat format : objectFormatList) {
532
	                    ObjectFormat v1Format = TypeMarshaller.convertTypeFromType(format, ObjectFormat.class);
533
	                    retFormats.addObjectFormat(v1Format);
534
	                }
535
		        }
536
		        
537
		    }
538
			//retFormats = TypeMarshaller.convertTypeFromType(formats, ObjectFormatList.class);
539
		} catch (Exception e) {
540
			// report as service failure
541
			ServiceFailure sf = new ServiceFailure("4841", e.getMessage());
542
			sf.initCause(e);
543
			throw sf;
544
		}
545
		return retFormats;
546
	}
547

    
548
	@Override
549
	public NodeList listNodes() throws NotImplemented, ServiceFailure {
550
		org.dataone.service.types.v2.NodeList nodes = impl.listNodes();
551
		NodeList retNodes = null;
552
		try {
553
			retNodes = TypeMarshaller.convertTypeFromType(nodes, NodeList.class);
554
		} catch (Exception e) {
555
			// report as service failure
556
			ServiceFailure sf = new ServiceFailure("4801", e.getMessage());
557
			sf.initCause(e);
558
			throw sf;
559
		}
560
		return retNodes;
561
	}
562

    
563
	@Override
564
	public Date ping() throws NotImplemented, ServiceFailure,
565
			InsufficientResources {
566
		return impl.ping();
567
	}
568

    
569
	@Override
570
	public Identifier registerSystemMetadata(Identifier pid,
571
			SystemMetadata sysmeta) throws NotImplemented, NotAuthorized,
572
			ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
573
		return this.registerSystemMetadata(null, pid, sysmeta);
574
		
575
	}
576

    
577
	@Override
578
	@Deprecated
579
	public Identifier registerSystemMetadata(Session session, Identifier pid,
580
			SystemMetadata sysmeta) throws NotImplemented, NotAuthorized,
581
			ServiceFailure, InvalidRequest, InvalidSystemMetadata, InvalidToken {
582
		//convert sysmeta to newer version
583
		org.dataone.service.types.v2.SystemMetadata v2Sysmeta = null;
584
		try {
585
			v2Sysmeta = TypeMarshaller.convertTypeFromType(sysmeta, org.dataone.service.types.v2.SystemMetadata.class);
586
		} catch (Exception e) {
587
			// report as service failure
588
			ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
589
			sf.initCause(e);
590
			throw sf;
591
		}
592
		
593
		return impl.registerSystemMetadata(session, pid, v2Sysmeta);
594
	}
595

    
596
	@Override
597
	public Identifier reserveIdentifier(Identifier pid) throws InvalidToken,
598
			ServiceFailure, NotAuthorized, IdentifierNotUnique, NotImplemented,
599
			InvalidRequest {
600
		return impl.reserveIdentifier(null, pid);
601
	}
602

    
603
	@Override
604
	@Deprecated
605
	public Identifier reserveIdentifier(Session session, Identifier pid)
606
			throws InvalidToken, ServiceFailure, NotAuthorized,
607
			IdentifierNotUnique, NotImplemented, InvalidRequest {
608
		return impl.reserveIdentifier(session, pid);
609
	}
610

    
611
	@Override
612
	public boolean setObsoletedBy(Identifier pid, Identifier obsoletedByPid, long serialVersion)
613
			throws NotImplemented, NotFound, NotAuthorized, ServiceFailure,
614
			InvalidRequest, InvalidToken, VersionMismatch {
615
	    /*String serviceFailure = "4941";
616
        String notFound = "4944";
617
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
618
                "No object could be found for given PID: "+obsoletedByPid.getValue());*/
619
		return impl.setObsoletedBy(null, pid, obsoletedByPid, serialVersion);
620
	}
621

    
622
	@Override
623
	@Deprecated
624
	public boolean setObsoletedBy(Session session, Identifier pid, Identifier obsoletedByPid, long serialVersion) 
625
			throws NotImplemented, NotFound,
626
			NotAuthorized, ServiceFailure, InvalidRequest, InvalidToken,
627
			VersionMismatch {
628
	    /*String serviceFailure = "4941";
629
        String notFound = "4944";
630
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
631
                "No object could be found for given PID: "+obsoletedByPid.getValue());*/
632
		return impl.setObsoletedBy(session, pid, obsoletedByPid, serialVersion);
633

    
634
	}
635

    
636
	@Override
637
	public boolean isAuthorized(Identifier pid, Permission permission)
638
			throws ServiceFailure, InvalidToken, NotFound, NotAuthorized,
639
			NotImplemented, InvalidRequest {
640
	    String serviceFailure = "1760";
641
        String notFound = "1800";
642
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
643
                "The object specified by "+pid.getValue()+" does not exist at this node.");
644
		return impl.isAuthorized(null, pid, permission);
645
	}
646

    
647
	@Override
648
	@Deprecated
649
	public boolean isAuthorized(Session session, Identifier pid, Permission permission)
650
			throws ServiceFailure, InvalidToken, NotFound, NotAuthorized,
651
			NotImplemented, InvalidRequest {
652
	    String serviceFailure = "1760";
653
        String notFound = "1800";
654
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object specified by "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
655
                "The object specified by "+pid.getValue()+" does not exist at this node.");
656
		return impl.isAuthorized(session, pid, permission);
657
	}
658

    
659
	@Override
660
	public boolean setAccessPolicy(Identifier pid,
661
			AccessPolicy accessPolicy, long serialVersion)
662
			throws InvalidToken, NotFound, NotImplemented, NotAuthorized,
663
			ServiceFailure, InvalidRequest, VersionMismatch {
664
	    String serviceFailure = "4430";
665
        String notFound = "4400";
666
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
667
                "No object could be found for given PID: "+pid.getValue());
668
		return impl.setAccessPolicy(null, pid, accessPolicy, serialVersion);
669
	}
670

    
671
	@Override
672
	@Deprecated
673
	public boolean setAccessPolicy(Session session, Identifier pid,
674
			AccessPolicy accessPolicy, long serialVersion) throws InvalidToken, NotFound,
675
			NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest,
676
			VersionMismatch {
677
	    String serviceFailure = "4430";
678
        String notFound = "4400";
679
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
680
                "No object could be found for given PID: "+pid.getValue());
681
		return impl.setAccessPolicy(session, pid, accessPolicy, serialVersion);
682
	}
683

    
684
	@Override
685
	public Identifier setRightsHolder(Identifier pid, Subject userId, long serialVersion)
686
			throws InvalidToken, ServiceFailure, NotFound, NotAuthorized,
687
			NotImplemented, InvalidRequest, VersionMismatch {
688
	    String serviceFailure = "4490";
689
        String notFound = "4460";
690
        impl.checkV1SystemMetaPidExist(pid, serviceFailure, "The object for given PID "+pid.getValue()+" couldn't be identified if it exists",  notFound, 
691
                "No object could be found for given PID: "+pid.getValue());
692
		return impl.setRightsHolder(null, pid, userId, serialVersion);
693
	}
694

    
695
	@Override
696
	@Deprecated
697
	public Identifier setRightsHolder(Session session, Identifier pid,
698
			Subject userId, long serialVersion) throws InvalidToken, ServiceFailure,
699
			NotFound, NotAuthorized, NotImplemented, InvalidRequest,
700
			VersionMismatch {
701
		return impl.setRightsHolder(session, pid, userId, serialVersion);
702

    
703
	}
704

    
705
}
(1-1/2)