Project

General

Profile

« Previous | Next » 

Revision 6622

upgrade to 1.0.1-SNAPSHOT DataONE jars

View differences:

CNodeService.java
355 355
   * @throws ServiceFailure
356 356
   * @throws NotAuthorized
357 357
   * @throws NotFound
358
   * @throws InvalidRequest
359 358
   * @throws NotImplemented
360 359
   */
361 360
  @Override
362 361
  public Checksum getChecksum(Session session, Identifier pid)
363 362
    throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, 
364
    InvalidRequest, NotImplemented {
363
    NotImplemented {
365 364
        
366 365
    if (!isAuthorized(session, pid, Permission.READ)) {
367 366
        throw new NotAuthorized("1400", Permission.READ + " not allowed on " + pid.getValue());  
......
396 395
   * 
397 396
   * @return objectLocationList - the list of nodes known to contain the object
398 397
   * 
399
   * @throws InvalidRequest
400 398
   * @throws InvalidToken
401 399
   * @throws ServiceFailure
402 400
   * @throws NotAuthorized
......
405 403
   */
406 404
  @Override
407 405
  public ObjectLocationList resolve(Session session, Identifier pid)
408
    throws InvalidRequest, InvalidToken, ServiceFailure, NotAuthorized,
406
    throws InvalidToken, ServiceFailure, NotAuthorized,
409 407
    NotFound, NotImplemented {
410 408

  
411 409
    throw new NotImplemented("4131", "resolve not implemented");
......
511 509
   * 
512 510
   * @return objectFormat - the object format requested
513 511
   * 
514
   * @throws InvalidRequest
515 512
   * @throws ServiceFailure
516 513
   * @throws NotFound
517 514
   * @throws InsufficientResources
......
519 516
   */
520 517
  @Override
521 518
  public ObjectFormat getFormat(ObjectFormatIdentifier fmtid)
522
    throws InvalidRequest, ServiceFailure, NotFound, InsufficientResources,
519
    throws ServiceFailure, NotFound, InsufficientResources,
523 520
    NotImplemented {
524 521
     
525 522
      return ObjectFormatService.getInstance().getFormat(fmtid);
......
533 530
   * @return objectFormatList - The list of object formats registered in 
534 531
   *                            the DataONE Object Format Vocabulary
535 532
   * 
536
   * @throws InvalidRequest
537 533
   * @throws ServiceFailure
538 534
   * @throws NotImplemented
539
   * @throws NotFound
540 535
   * @throws InsufficientResources
541 536
   */
542 537
  @Override
543 538
  public ObjectFormatList listFormats() 
544
    throws InvalidRequest, ServiceFailure, NotFound, InsufficientResources, 
539
    throws ServiceFailure, InsufficientResources, 
545 540
    NotImplemented {
546 541

  
547 542
    return ObjectFormatService.getInstance().listFormats();
......
635 630
          pid.getValue(), "registerSystemMetadata");
636 631
      return pid;
637 632
  }
638

  
639
  /**
640
   * Provides a mechanism for updating system metadata independently of its 
641
   * associated object
642
    * 
643
   * @param session - the Session object containing the credentials for the Subject
644
   * @param pid - The identifier of the system metadata
645
   * @param sysmeta - The system metadata to be registered
646
   * 
647
   * @return true if the update succeeds
648
   * 
649
   * @throws NotImplemented
650
   * @throws NotAuthorized
651
   * @throws ServiceFailure
652
   * @throws InvalidRequest
653
   * @throws InvalidSystemMetadata
654
   * @throws NotFound
655
   */
656
  @Override
657
  public boolean updateSystemMetadata(Session session, Identifier guid,
658
      SystemMetadata sysmeta) 
659
      throws NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest, 
660
      InvalidSystemMetadata, NotFound {
661

  
662
      // TODO: control who can call this?
663
      if (session == null) {
664
          //TODO: many of the thrown exceptions do not use the correct error codes
665
          //check these against the docs and correct them
666
          throw new NotAuthorized("4861", "No Session - could not authorize for update." +
667
                  "  If you are not logged in, please do so and retry the request.");
668
      }
669
      
670
      // verify that guid == SystemMetadata.getIdentifier()
671
      logMetacat.debug("Comparing guid|sysmeta_guid: " + guid.getValue() + "|" + 
672
          sysmeta.getIdentifier().getValue());
673
      if (!guid.getValue().equals(sysmeta.getIdentifier().getValue())) {
674
          throw new InvalidRequest("4863", 
675
              "GUID in method call (" + guid.getValue() + 
676
              ") does not match GUID in system metadata (" +
677
              sysmeta.getIdentifier().getValue() + ").");
678
      }
679

  
680
      logMetacat.debug("Checking if identifier exists...");
681
      // Check that the identifier exists
682
      if (!IdentifierManager.getInstance().identifierExists(guid.getValue())) {
683
          throw new NotFound("000", 
684
              "GUID does not exist");
685
      }
686

  
687
      // update the system metadata into the object store
688
      logMetacat.debug("Starting to update SystemMetadata...");
689
      
690
      // update system metadata
691
      try {
692
    	    HazelcastService.getInstance().getSystemMetadataMap().lock(sysmeta.getIdentifier());
693
          SystemMetadata currentSysMeta = 
694
              HazelcastService.getInstance().getSystemMetadataMap().get(sysmeta.getIdentifier());
695
          
696
          // only update if the requester has the most current system metadata
697
          if (sysmeta.getSerialVersion().compareTo(currentSysMeta.getSerialVersion()) != 0 ) {
698
              String msg = "The serial version of the system metadata " + 
699
                  "to be updated does not equal the serial version of the current " +
700
                  "system metadata for identifier " + guid + ". Ensure that the " +
701
                  "copy is the most current before updating.";
702
              logMetacat.warn(msg);
703
              HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
704
              throw new InvalidRequest("4913", msg);
705
              
706
          }
707
          
708
          sysmeta.setSerialVersion(currentSysMeta.getSerialVersion().add(BigInteger.ONE));
709
          sysmeta.setDateSysMetadataModified(Calendar.getInstance().getTime());
710
          HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
711
    	    HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
712
    	    
713
      } catch (Exception e) {
714
    	throw new ServiceFailure("4852", e.getMessage());
715
    	
716
    	} finally {
717
    	    HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
718
    	  
719
    	}
720
      
721
      logMetacat.debug("Returning from updateSystemMetadata");
722
      EventLog.getInstance().log(request.getRemoteAddr(), 
723
                                 request.getHeader("User-Agent"), 
724
                                 session.getSubject().getValue(), 
725
                                 guid.getValue(), "updateSystemMetadata");
726
      return true;
727
  }
728 633
  
729 634
  /**
730 635
   * Given an optional scope and format, reserves and returns an identifier 
......
754 659
   * @throws NotImplemented
755 660
   */
756 661
  @Override
757
  public boolean reserveIdentifier(Session session, Identifier pid)
662
  public Identifier reserveIdentifier(Session session, Identifier pid)
758 663
  throws InvalidToken, ServiceFailure,
759 664
        NotAuthorized, IdentifierNotUnique, NotImplemented, InvalidRequest {
760 665

  
......
1185 1090
      return true;
1186 1091
      
1187 1092
  }
1093
  
1094
  	@Override
1095
  	public ObjectList listObjects(Session session, Date startTime, 
1096
            Date endTime, ObjectFormatIdentifier formatid, Boolean replicaStatus,
1097
            Integer start, Integer count)
1098
			throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented,
1099
			ServiceFailure {
1100
  		
1101
  		ObjectList objectList = null;
1102
        try {
1103
            objectList = IdentifierManager.getInstance().querySystemMetadata(startTime, endTime, formatid, replicaStatus, start, count);
1104
        } catch (Exception e) {
1105
            throw new ServiceFailure("1580", "Error querying system metadata: " + e.getMessage());
1106
        }
1107

  
1108
        return objectList;
1109
	}
1188 1110
}

Also available in: Unified diff