Project

General

Profile

« Previous | Next » 

Revision 6179

Initial check in of the MNodeService stub methods that implement the D1 MN* interfaces. CrudService methods will be transitioned into this class. The methods follow the D1 0.6.2 API thus far.

Also changed CNodeService to reflect minor changes to the D1NodeService class.

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2000-2011 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author:  $'
7
 *     '$Date:  $'
8
 *
9
 * This program is free software; you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation; either version 2 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
22
 */
23

  
24
package edu.ucsb.nceas.metacat.dataone;
25

  
26
import java.io.InputStream;
27
import java.util.Date;
28

  
29
import org.apache.log4j.Logger;
30
import org.dataone.service.exceptions.IdentifierNotUnique;
31
import org.dataone.service.exceptions.InsufficientResources;
32
import org.dataone.service.exceptions.InvalidRequest;
33
import org.dataone.service.exceptions.InvalidSystemMetadata;
34
import org.dataone.service.exceptions.InvalidToken;
35
import org.dataone.service.exceptions.NotAuthorized;
36
import org.dataone.service.exceptions.NotFound;
37
import org.dataone.service.exceptions.NotImplemented;
38
import org.dataone.service.exceptions.ServiceFailure;
39
import org.dataone.service.exceptions.UnsupportedType;
40
import org.dataone.service.mn.tier1.MNCore;
41
import org.dataone.service.mn.tier1.MNRead;
42
import org.dataone.service.mn.tier2.MNAuthorization;
43
import org.dataone.service.mn.tier3.MNStorage;
44
import org.dataone.service.mn.tier4.MNReplication;
45
import org.dataone.service.types.AccessPolicy;
46
import org.dataone.service.types.Checksum;
47
import org.dataone.service.types.DescribeResponse;
48
import org.dataone.service.types.Event;
49
import org.dataone.service.types.Identifier;
50
import org.dataone.service.types.Log;
51
import org.dataone.service.types.MonitorList;
52
import org.dataone.service.types.Node;
53
import org.dataone.service.types.NodeReference;
54
import org.dataone.service.types.ObjectFormat;
55
import org.dataone.service.types.ObjectList;
56
import org.dataone.service.types.Permission;
57
import org.dataone.service.types.Session;
58
import org.dataone.service.types.Subject;
59
import org.dataone.service.types.SystemMetadata;
60

  
61
/**
62
 * Represents Metacat's implementation of the DataONE Member Node 
63
 * service API. Methods implement the various MN* interfaces, and methods common
64
 * to both Member Node and Coordinating Node interfaces are found in the
65
 * D1NodeService base class.
66
 */
67
public class MNodeService extends D1NodeService implements MNAuthorization,
68
  MNCore, MNRead, MNReplication, MNStorage {
69

  
70
	/* the instance of the MNodeService object */
71
  private static MNodeService instance = null;
72
  
73
  /* the logger instance */
74
  private Logger logMetacat = null;
75

  
76
  /**
77
   * singleton accessor
78
   */
79
  public static MNodeService getInstance() 
80
  {
81
    if (instance == null) {
82
      instance = new MNodeService();
83
    }
84
    
85
    return instance;
86
  }
87
  
88
  /**
89
   * Constructor, private for singleton access
90
   */
91
  private MNodeService() {
92
  	super();
93
    logMetacat = Logger.getLogger(MNodeService.class);
94
        
95
  }
96
    
97
	/**
98
	 * Adds a new object to the Member Node, where the object is either a data 
99
	 * object or a science metadata object. This method is called by clients 
100
	 * to create new data objects on Member Nodes
101
	 * 
102
	 * @param session - the Session object containing the credentials for the Subject
103
	 * @param pid - The object identifier to be created
104
	 * @param object - the object bytes
105
	 * @param sysmeta - the system metadata that describes the object  
106
	 * 
107
	 * @return pid - the object identifier created
108
	 * 
109
	 * @throws InvalidToken
110
	 * @throws ServiceFailure
111
	 * @throws NotAuthorized
112
	 * @throws IdentifierNotUnique
113
	 * @throws UnsupportedType
114
	 * @throws InsufficientResources
115
	 * @throws InvalidSystemMetadata
116
	 * @throws NotImplemented
117
	 * @throws InvalidRequest
118
	 */
119
  @Override
120
	public Identifier create(Session session, Identifier pid, InputStream object,
121
	  SystemMetadata sysmeta) 
122
    throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
123
    UnsupportedType, InsufficientResources, InvalidSystemMetadata, 
124
    NotImplemented, InvalidRequest {
125

  
126
		return null;
127
	}
128

  
129
	/**
130
	 * Deletes an object from the Member Node, where the object is either a 
131
	 * data object or a science metadata object.
132
	 * 
133
	 * @param session - the Session object containing the credentials for the Subject
134
	 * @param pid - The object identifier to be deleted
135
	 * 
136
	 * @return pid - the identifier of the object used for the deletion
137
	 * 
138
	 * @throws InvalidToken
139
	 * @throws ServiceFailure
140
	 * @throws NotAuthorized
141
	 * @throws NotFound
142
	 * @throws NotImplemented
143
	 * @throws InvalidRequest
144
	 */
145
  @Override
146
	public Identifier delete(Session session, Identifier pid) 
147
    throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
148
    NotImplemented, InvalidRequest {
149

  
150
		return null;
151
	}
152

  
153
  /**
154
   * Updates an existing object by creating a new object identified by 
155
   * newPid on the Member Node which explicitly obsoletes the object 
156
   * identified by pid through appropriate changes to the SystemMetadata 
157
   * of pid and newPid
158
   * 
159
	 * @param session - the Session object containing the credentials for the Subject
160
	 * @param pid - The identifier of the object to be updated
161
	 * @param object - the new object bytes
162
	 * @param sysmeta - the new system metadata describing the object
163
	 * 
164
	 * @return newPid - the identifier of the new object
165
	 * 
166
	 * @throws InvalidToken
167
	 * @throws ServiceFailure
168
	 * @throws NotAuthorized
169
	 * @throws NotFound
170
	 * @throws NotImplemented
171
	 * @throws IdentifierNotUnique
172
	 * @throws UnsupportedType
173
	 * @throws InsufficientResources
174
	 * @throws InvalidSystemMetadata
175
	 * @throws InvalidRequest
176
   */
177
  @Override
178
	public Identifier update(Session session, Identifier pid, InputStream object,
179
	  Identifier newPid, SystemMetadata sysmeta) 
180
    throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
181
    UnsupportedType, InsufficientResources, NotFound, InvalidSystemMetadata, 
182
    NotImplemented, InvalidRequest {
183

  
184
		return null;
185
	}
186

  
187
  /**
188
   * Called by a Coordinating Node to request that the Member Node create a 
189
   * copy of the specified object by retrieving it from another Member 
190
   * Node and storing it locally so that it can be made accessible to 
191
   * the DataONE system.
192
   * 
193
	 * @param session - the Session object containing the credentials for the Subject
194
	 * @param sysmeta - Copy of the CN held system metadata for the object
195
	 * @param sourceNode - A reference to node from which the content should be 
196
	 *                     retrieved. The reference should be resolved by 
197
	 *                     checking the CN node registry.
198
	 * 
199
	 * @return true if the replication succeeds
200
	 * 
201
	 * @throws ServiceFailure
202
	 * @throws NotAuthorized
203
	 * @throws NotImplemented
204
	 * @throws UnsupportedType
205
	 * @throws InsufficientResources
206
	 * @throws InvalidRequest
207
   */
208
  @Override
209
	public boolean replicate(Session session, SystemMetadata sysmeta, 
210
	  NodeReference sourceNode)
211
	  throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest,
212
	  InsufficientResources, UnsupportedType {
213

  
214
		return false;
215
	}
216

  
217
  /**
218
   * This method provides a lighter weight mechanism than 
219
   * MN_read.getSystemMetadata() for a client to determine basic 
220
   * properties of the referenced object.
221
   * 
222
	 * @param session - the Session object containing the credentials for the Subject
223
	 * @param pid - the identifier of the object to be described
224
	 * 
225
	 * @return describeResponse - A set of values providing a basic description 
226
	 *                            of the object.
227
	 * 
228
	 * @throws InvalidToken
229
	 * @throws ServiceFailure
230
	 * @throws NotAuthorized
231
	 * @throws NotFound
232
	 * @throws NotImplemented
233
	 * @throws InvalidRequest
234
   */
235
  @Override
236
	public DescribeResponse describe(Session session, Identifier pid)
237
	  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
238
	  NotImplemented, InvalidRequest {
239

  
240
		return null;
241
	}
242

  
243
	/**
244
	 * Return the object identified by the given object identifier
245
	 * 
246
	 * @param session - the Session object containing the credentials for the Subject
247
	 * @param pid - the object identifier for the given object
248
	 * 
249
	 * @return inputStream - the input stream of the given object
250
	 * 
251
	 * @throws InvalidToken
252
	 * @throws ServiceFailure
253
	 * @throws NotAuthorized
254
	 * @throws InvalidRequest
255
	 * @throws NotImplemented
256
	 */
257
  @Override
258
	public InputStream get(Session session, Identifier pid) 
259
	  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
260
	  NotImplemented, InvalidRequest {
261
  	
262
		return super.get(session, pid);
263
		
264
	}
265

  
266
	/**
267
	 * Returns a Checksum for the specified object using an accepted hashing algorithm
268
	 * 
269
	 * @param session - the Session object containing the credentials for the Subject
270
	 * @param pid - the object identifier for the given object
271
	 * @param algorithm -  the name of an algorithm that will be used to compute 
272
	 *                     a checksum of the bytes of the object
273
	 * 
274
	 * @return inputStream - the input stream of the given object
275
	 * 
276
	 * @throws InvalidToken
277
	 * @throws ServiceFailure
278
	 * @throws NotAuthorized
279
	 * @throws NotFound
280
	 * @throws InvalidRequest
281
	 * @throws NotImplemented
282
	 */
283
  @Override
284
	public Checksum getChecksum(Session session, Identifier pid, String algorithm)
285
	  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
286
	  InvalidRequest, NotImplemented {
287

  
288
		return null;
289
	}
290

  
291
	/**
292
	 * Return the system metadata for a given object
293
	 * 
294
	 * @param session - the Session object containing the credentials for the Subject
295
	 * @param pid - the object identifier for the given object
296
	 * 
297
	 * @return inputStream - the input stream of the given system metadata object
298
	 * 
299
	 * @throws InvalidToken
300
	 * @throws ServiceFailure
301
	 * @throws NotAuthorized
302
	 * @throws NotFound
303
	 * @throws InvalidRequest
304
	 * @throws NotImplemented
305
	 */
306
  @Override
307
	public SystemMetadata getSystemMetadata(Session session, Identifier pid)
308
	    throws InvalidToken, ServiceFailure, NotAuthorized, NotFound,
309
	    InvalidRequest, NotImplemented {
310

  
311
		return super.getSystemMetadata(session, pid);
312
	}
313

  
314
	/**
315
	 * Retrieve the list of objects present on the MN that match the calling parameters
316
	 * 
317
	 * @param session - the Session object containing the credentials for the Subject
318
	 * @param startTime - Specifies the beginning of the time range from which 
319
	 *                    to return object (>=)
320
	 * @param endTime - Specifies the beginning of the time range from which 
321
	 *                  to return object (>=)
322
	 * @param objectFormat - Restrict results to the specified object format
323
	 * @param replicaStatus - Indicates if replicated objects should be returned in the list
324
	 * @param start - The zero-based index of the first value, relative to the 
325
	 *                first record of the resultset that matches the parameters.
326
	 * @param count - The maximum number of entries that should be returned in 
327
	 *                the response. The Member Node may return less entries 
328
	 *                than specified in this value.
329
	 * 
330
	 * @return objectList - the list of objects matching the criteria
331
	 * 
332
	 * @throws InvalidToken
333
	 * @throws ServiceFailure
334
	 * @throws NotAuthorized
335
	 * @throws InvalidRequest
336
	 * @throws NotImplemented
337
	 */
338
  @Override
339
	public ObjectList listObjects(Session session, Date startTime, Date endTime,
340
	  ObjectFormat objectFormat, Boolean replicaStatus, Integer start, Integer count)
341
	  throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure,
342
	  InvalidToken {
343

  
344
		return null;
345
	}
346

  
347
	/**
348
	 * Retrieve the list of objects present on the MN that match the calling parameters
349
	 * 
350
	 * @return node - the technical capabilities of the Member Node
351
	 * 
352
	 * @throws ServiceFailure
353
	 * @throws NotAuthorized
354
	 * @throws InvalidRequest
355
	 * @throws NotImplemented
356
	 */
357
  @Override
358
	public Node getCapabilities() throws NotImplemented, NotAuthorized,
359
	    ServiceFailure, InvalidRequest {
360
		// TODO Auto-generated method stub
361
		return null;
362
	}
363

  
364
	/**
365
	 * Return the log records associated with a given event between the start and 
366
	 * end dates listed given a particular Subject listed in the Session
367
	 * 
368
	 * @param session - the Session object containing the credentials for the Subject
369
	 * @param fromDate - the start date of the desired log records
370
	 * @param event - Return only log records for the specified type of event. Default is all.
371
	 * @param start - zero based offset from the first record in the 
372
	 *                set of matching log records. Used to assist with 
373
	 *                paging the response.
374
	 * @param count - maximum number of log records to return in the response. 
375
	 *                Used to assist with paging the response.
376
	 *                
377
	 * @return log - the log records requested
378
	 * 
379
	 * @throws InvalidToken
380
	 * @throws ServiceFailure
381
	 * @throws NotAuthorized
382
	 * @throws InvalidRequest
383
	 * @throws NotImplemented
384
	 */
385
  @Override
386
	public Log getLogRecords(Session session, Date fromDate, Date toDate, Event event,
387
	  Integer start, Integer count)
388
    throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest, 
389
    NotImplemented {
390

  
391
		return null;
392
	}
393

  
394
	/**
395
	 * Returns the number of operations that have been serviced by the node 
396
	 * over time periods of one and 24 hours.
397
	 * 
398
	 * @param session - the Session object containing the credentials for the Subject
399
	 * @param period - An ISO8601 compatible DateTime range specifying the time 
400
	 *                 range for which to return operation statistics.
401
	 * @param requestor - Limit to operations performed by given requestor identity.
402
	 * @param event -  Enumerated value indicating the type of event being examined
403
	 * @param format - Limit to events involving objects of the specified format
404
	 * 
405
	 * @return the desired log records
406
	 * 
407
	 * @throws InvalidToken
408
	 * @throws ServiceFailure
409
	 * @throws NotAuthorized
410
	 * @throws InvalidRequest
411
	 * @throws NotImplemented
412
	 */
413
  @Override
414
	public MonitorList getOperationStatistics(Session session, Integer period,
415
	  Subject requestor, Event event, ObjectFormat format) 
416
    throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, 
417
    InsufficientResources, UnsupportedType {
418

  
419
		return null;
420
	}
421

  
422
  /**
423
   * Low level “are you alive” operation. A valid ping response is 
424
   * indicated by a HTTP status of 200.
425
   * 
426
   * @return true if the service is alive
427
   * 
428
	 * @throws InvalidToken
429
	 * @throws ServiceFailure
430
	 * @throws NotAuthorized
431
	 * @throws InvalidRequest
432
	 * @throws NotImplemented
433
   */
434
	@Override
435
	public boolean ping() 
436
	  throws NotImplemented, ServiceFailure, NotAuthorized, InvalidRequest, 
437
	  InsufficientResources, UnsupportedType {
438

  
439
		return false;
440
	}
441

  
442
	/**
443
   * Test if the user identified by the provided token has authorization 
444
   * for operation on the specified object.
445
 	 * 
446
	 * @param session - the Session object containing the credentials for the Subject
447
	 * @param pid - The identifier of the resource for which access is being checked
448
	 * @param action - The type of permission which is being requested for the given pid
449
	 *
450
	 * @return true if the action is allowed
451
	 * 
452
	 * @throws ServiceFailure
453
	 * @throws InvalidToken
454
	 * @throws NotFound
455
	 * @throws NotAuthorized
456
	 * @throws NotImplemented
457
	 * @throws InvalidRequest
458
	 */	
459
	@Override
460
	public boolean isAuthorized(Session session, Identifier pid, Permission operation)
461
	  throws ServiceFailure, InvalidRequest, InvalidToken, NotFound,
462
	  NotAuthorized, NotImplemented {
463

  
464
		return false;
465
	}
466

  
467
	/**
468
	 * Set access for a given object using the object identifier and a Subject
469
	 * under a given Session.
470
	 * 
471
	 * @param session - the Session object containing the credentials for the Subject
472
	 * @param pid - the object identifier for the given object to apply the policy
473
	 * @param policy - the access policy to be applied
474
	 * 
475
	 * @return true if the application of the policy succeeds
476
	 * 
477
	 * @throws InvalidToken
478
	 * @throws ServiceFailure
479
	 * @throws NotFound
480
	 * @throws NotAuthorized
481
	 * @throws NotImplemented
482
	 * @throws InvalidRequest
483
	 */
484
	@Override
485
	public boolean setAccessPolicy(Session session, Identifier pid,
486
	  AccessPolicy accessPolicy) 
487
	  throws InvalidToken, ServiceFailure, NotFound, NotAuthorized, 
488
	  NotImplemented, InvalidRequest {
489

  
490
		return false;
491
	}
492

  
493
}
0 494

  
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
68 68

  
69 69
/**
70 70
 * Represents Metacat's implementation of the DataONE Coordinating Node 
71
 * service API. Methods override the various CN* interfaces, and methods common
71
 * service API. Methods implement the various CN* interfaces, and methods common
72 72
 * to both Member Node and Coordinating Node interfaces are found in the
73 73
 * D1NodeService super class.
74 74
 *
......
168 168
	 * @throws NotFound
169 169
	 */
170 170
	@Override
171
	/*public boolean updateNodeCapabilities(Session session, NodeReference nodeid, Node node) */
171 172
	public boolean addNodeCapabilities(Session session, NodeReference nodeid, Node node)
172 173
	  throws NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest,
173 174
	  NotFound {
......
629 630
	 * @param fromDate - Starting time for records in response
630 631
	 * @param toDate - End time for records in response. If not specified, then defaults to now.
631 632
	 * @param event - Return only log records for the specified type of event. Default is all.
632
	 * 
633
	 * @param start - zero based offset from the first record in the 
634
	 *                set of matching log records. Used to assist with 
635
	 *                paging the response.
636
	 * @param count - maximum number of log records to return in the response. 
637
	 *                Used to assist with paging the response.
638
	 *                
633 639
	 * @return log - the log records requested
634 640
	 * 
635 641
	 * @throws InvalidRequest
......
639 645
	 * @throws NotImplemented
640 646
	 */
641 647
	@Override
648
	/* TODO: update this when the API in d1_common adds the arguments */
649
	/*public Log getLogRecords(Session session, Date fromDate, Date toDate, 
650
	 *  Event event, Integer start, Integer count) */
642 651
	public Log getLogRecords(Session session, Date fromDate, Date toDate, Event event)
643 652
	  throws InvalidToken, InvalidRequest, ServiceFailure, NotAuthorized,
644 653
	  NotImplemented {
645 654

  
646
		return super.getLogRecords(session, fromDate, toDate, event);
655
		/* return super.getLogRecords(session, fromDate, toDate, event, start, count); */
656
		return super.getLogRecords(session, fromDate, toDate, event, 0, 1000);
647 657
	}
648 658

  
649 659
	/**
......
761 771
	 * @throws InvalidRequest
762 772
	 */	
763 773
	@Override
764
	public boolean isAuthorized(Session session, Identifier pid, Event operation)
774
	public boolean isAuthorized(Session session, Identifier pid, Event action)
765 775
	  throws ServiceFailure, InvalidToken, NotFound, NotAuthorized,
766 776
	  NotImplemented, InvalidRequest {
767 777

  
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
52 52
	 * @param session - the Session object containing the credentials for the Subject
53 53
	 * @param fromDate - the start date of the desired log records
54 54
	 * @param toDate - the end date of the desired log records
55
	 * @param event - restrict log records of a specific event type
56
	 * @param start - zero based offset from the first record in the 
57
	 *                set of matching log records. Used to assist with 
58
	 *                paging the response.
59
	 * @param count - maximum number of log records to return in the response. 
60
	 *                Used to assist with paging the response.
55 61
	 * 
56 62
	 * @return the desired log records
57 63
	 * 
......
62 68
	 * @throws NotImplemented
63 69
	 */
64 70
	public Log getLogRecords(Session session, Date fromDate, Date toDate, 
65
      Event event) throws InvalidToken, ServiceFailure,
71
      Event event, Integer start, Integer count) throws InvalidToken, ServiceFailure,
66 72
	    NotAuthorized, InvalidRequest, NotImplemented {
67 73

  
68 74
		return null;
......
127 133
	 * @param pid - the object identifier for the given object to apply the policy
128 134
	 * @param policy - the access policy to be applied
129 135
	 * 
130
	 * @return true or false
136
	 * @return true if the application of the policy succeeds
131 137
	 * @throws InvalidToken
132 138
	 * @throws ServiceFailure
133 139
	 * @throws NotFound
......
136 142
	 * @throws InvalidRequest
137 143
	 */
138 144
	public boolean setAccessPolicy(Session session, Identifier pid, 
139
    AccessPolicy policy) 
145
    AccessPolicy accessPolicy) 
140 146
	  throws InvalidToken, ServiceFailure, NotFound, NotAuthorized, 
141 147
	  NotImplemented, InvalidRequest {
142 148

  

Also available in: Unified diff