Project

General

Profile

« Previous | Next » 

Revision 5359

Added by berkley almost 14 years ago

setting up the framework for the listObjects api call

View differences:

CrudService.java
60 60
import org.dataone.service.types.Identifier;
61 61
import org.dataone.service.types.LogRecordSet;
62 62
import org.dataone.service.types.SystemMetadata;
63
import org.dataone.service.types.ObjectList;
64
import org.dataone.service.types.ObjectFormat;
63 65
import org.jibx.runtime.BindingDirectory;
64 66
import org.jibx.runtime.IBindingFactory;
65 67
import org.jibx.runtime.IMarshallingContext;
......
278 280
            throw new ServiceFailure("1030", "Error updating document in CrudService: " + e.getMessage());
279 281
        }
280 282
    }
283
    
284
    /**
285
     *  Retrieve the list of objects present on the MN that match the calling 
286
     *  parameters. This method is required to support the process of Member 
287
     *  Node synchronization. At a minimum, this method should be able to 
288
     *  return a list of objects that match:
289
     *  startTime <= SystemMetadata.dateSysMetadataModified
290
     *  but is expected to also support date range (by also specifying endTime), 
291
     *  and should also support slicing of the matching set of records by 
292
     *  indicating the starting index of the response (where 0 is the index 
293
     *  of the first item) and the count of elements to be returned.
294
     *  
295
     * @see http://mule1.dataone.org/ArchitectureDocs/mn_api_replication.html#MN_replication.listObjects
296
     * @param token
297
     * @param startTime
298
     * @param endTime
299
     * @param objectFormat
300
     * @param replicaStatus
301
     * @param start
302
     * @param count
303
     * @return ObjectList
304
     * @throws NotAuthorized
305
     * @throws InvalidRequest
306
     * @throws NotImplemented
307
     * @throws ServiceFailure
308
     * @throws InvalidToken
309
     */
310
    public ObjectList listObjects(AuthToken token, Date startTime, Date endTime, 
311
        ObjectFormat objectFormat, boolean replicaStatus, int start, int count)
312
      throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken
313
    {
314
      ObjectList ol = new ObjectList();
315
      //do an squery on metacat to return systemMetadata docs where 
316
      //sm.dateSysMetadataModified >= startTime
317
      //sm.dateSysMetadataModified <= endTime
318
      //further slice the returned dataset if replicaStatus is false.
319
      //if start != 0, return only the documents with index >= start
320
      //if the number of results is > count, return the first count docs
321
      return ol;
322
    }
323
    
324
    /**
325
     * Call listObjects with the default values for replicaStatus (true), start (0),
326
     * and count (1000).
327
     * @param token
328
     * @param startTime
329
     * @param endTime
330
     * @param objectFormat
331
     * @return
332
     * @throws NotAuthorized
333
     * @throws InvalidRequest
334
     * @throws NotImplemented
335
     * @throws ServiceFailure
336
     * @throws InvalidToken
337
     */
338
    public ObjectList listObjects(AuthToken token, Date startTime, Date endTime, 
339
        ObjectFormat objectFormat)
340
      throws NotAuthorized, InvalidRequest, NotImplemented, ServiceFailure, InvalidToken
341
    {
342
       return listObjects(token, startTime, endTime, objectFormat, true, 0, 1000);
343
    }
281 344

  
345
    /**
346
     * Delete a document.  NOT IMPLEMENTED
347
     */
282 348
    public Identifier delete(AuthToken token, Identifier guid)
283 349
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
284 350
            NotImplemented {
285 351
        throw new NotImplemented("1000", "This method not yet implemented.");
286 352
    }
287 353

  
354
    /**
355
     * describe a document.  NOT IMPLEMENTED
356
     */
288 357
    public DescribeResponse describe(AuthToken token, Identifier guid)
289 358
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
290 359
            NotImplemented {
291 360
        throw new NotImplemented("1000", "This method not yet implemented.");
292 361
    }
293 362
    
363
    /**
364
     * get a document with a specified guid.
365
     */
294 366
    public InputStream get(AuthToken token, Identifier guid)
295 367
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
296 368
            NotImplemented {
......
341 413
        }
342 414
    }
343 415

  
416
    /**
417
     * get the checksum for a document.  NOT IMPLEMENTED
418
     */
344 419
    public Checksum getChecksum(AuthToken token, Identifier guid)
345 420
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
346 421
            InvalidRequest, NotImplemented {
347 422
        throw new NotImplemented("1000", "This method not yet implemented.");
348 423
    }
349 424

  
425
    /**
426
     * get the checksum for a document.  NOT IMPLEMENTED
427
     */
350 428
    public Checksum getChecksum(AuthToken token, Identifier guid, 
351 429
            String checksumAlgorithm) throws InvalidToken, ServiceFailure, 
352 430
            NotAuthorized, NotFound, InvalidRequest, NotImplemented {
353 431
        throw new NotImplemented("1000", "This method not yet implemented.");
354 432
    }
355 433

  
434
    /**
435
     * get log records.  NOT IMPLEMENTED
436
     */
356 437
    public LogRecordSet getLogRecords(AuthToken token, Date fromDate, Date toDate)
357 438
            throws InvalidToken, ServiceFailure, NotAuthorized, InvalidRequest, 
358 439
            NotImplemented {
359 440
        throw new NotImplemented("1000", "This method not yet implemented.");
360 441
    }
361 442

  
443
    /**
444
     * get the system metadata for a document with a specified guid.
445
     */
362 446
    public SystemMetadata getSystemMetadata(AuthToken token, Identifier guid)
363 447
            throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
364 448
            InvalidRequest, NotImplemented {
......
463 547
        return scimeta;
464 548
    }
465 549

  
550
    /**
551
     * insert a data doc
552
     * @param object
553
     * @param guid
554
     * @param sessionData
555
     * @throws ServiceFailure
556
     */
466 557
    private void insertDataObject(InputStream object, Identifier guid, 
467 558
            SessionData sessionData) throws ServiceFailure {
468 559
        
......
538 629
        }
539 630
    }
540 631

  
632
    /**
633
     * write a file to a stream
634
     * @param dir
635
     * @param fileName
636
     * @param data
637
     * @return
638
     * @throws ServiceFailure
639
     */
541 640
    private File writeStreamToFile(File dir, String fileName, InputStream data) 
542 641
        throws ServiceFailure {
543 642
        
......
723 822
        return localId;
724 823
    }
725 824
    
825
    /**
826
     * serialize a system metadata doc
827
     * @param sysmeta
828
     * @return
829
     * @throws ServiceFailure
830
     */
726 831
    public static ByteArrayOutputStream serializeSystemMetadata(SystemMetadata sysmeta) 
727 832
        throws ServiceFailure {
728 833
        IBindingFactory bfact;
......
739 844
        return sysmetaOut;
740 845
    }
741 846
    
847
    /**
848
     * deserialize a system metadata doc
849
     * @param xml
850
     * @return
851
     * @throws ServiceFailure
852
     */
742 853
    public static SystemMetadata deserializeSystemMetadata(InputStream xml) 
743 854
        throws ServiceFailure {
744 855
        try {

Also available in: Unified diff