Project

General

Profile

« Previous | Next » 

Revision 6378

latest D1 jars - changes include:
updateSystemMetadata() impl for CN
new identifier methods (generate is its own method)
removal of the resourceMap pointer from system metadata

View differences:

CNodeService.java
547 547
	}
548 548

  
549 549
	/**
550
	 * Provides a mechanism for updating system metadata independently of its 
551
	 * associated object
552
 	 * 
553
	 * @param session - the Session object containing the credentials for the Subject
554
	 * @param pid - The identifier of the system metadata
555
	 * @param sysmeta - The system metadata to be registered
556
	 * 
557
	 * @return true if the update succeeds
558
	 * 
559
	 * @throws NotImplemented
560
	 * @throws NotAuthorized
561
	 * @throws ServiceFailure
562
	 * @throws InvalidRequest
563
	 * @throws InvalidSystemMetadata
564
	 * @throws NotFound
565
	 */
566
	@Override
567
	public boolean updateSystemMetadata(Session session, Identifier guid,
568
	  SystemMetadata sysmeta) 
569
	  throws NotImplemented, NotAuthorized, ServiceFailure, InvalidRequest, 
570
	  InvalidSystemMetadata, NotFound {
571

  
572
		// TODO: control who can call this?
573
	      if (session == null) {
574
	          //TODO: many of the thrown exceptions do not use the correct error codes
575
	          //check these against the docs and correct them
576
	          throw new NotAuthorized("4861", "No Session - could not authorize for update." +
577
	                  "  If you are not logged in, please do so and retry the request.");
578
	      }
579
	      
580
	      // verify that guid == SystemMetadata.getIdentifier()
581
	      logMetacat.debug("Comparing guid|sysmeta_guid: " + guid.getValue() + "|" + sysmeta.getIdentifier().getValue());
582
	      if (!guid.getValue().equals(sysmeta.getIdentifier().getValue())) {
583
	          throw new InvalidRequest("4863", 
584
	              "GUID in method call (" + guid.getValue() + ") does not match GUID in system metadata (" +
585
	              sysmeta.getIdentifier().getValue() + ").");
586
	      }
587

  
588
	      logMetacat.debug("Checking if identifier exists...");
589
	      // Check that the identifier exists
590
	      if (!IdentifierManager.getInstance().identifierExists(guid.getValue())) {
591
	          throw new NotFound("000", 
592
	              "GUID does not exist");
593
	      }
594

  
595
	      // update the system metadata into the object store
596
	      logMetacat.debug("Starting to update SystemMetadata...");
597
	      sysmeta.setDateSysMetadataModified(new Date());
598
	      try {
599
			    IdentifierManager.getInstance().updateSystemMetadata(sysmeta);
600
			    // force replication of this record
601
			    ForceReplicationSystemMetadataHandler forceReplication = 
602
			    	new ForceReplicationSystemMetadataHandler(guid.getValue(), null);
603
		    } catch (Exception e) {
604
	          throw new ServiceFailure("4862", "Error updating system metadata: " + e.getClass() + ": " + e.getMessage());
605
		    }
606
	      
607
	      logMetacat.debug("Returning from updateSystemMetadata");
608
	      EventLog.getInstance().log(null, session.getSubject().getValue(), guid.getValue(), "updateSystemMetadata");
609
	      return true;
610
	}
611
	
612
	/**
550 613
   * Given an optional scope and format, reserves and returns an identifier 
551 614
   * within that scope and format that is unique and will not be 
552 615
   * used by any other sessions. 
......
574 637
	 * @throws NotImplemented
575 638
	 */
576 639
	@Override
577
	public Identifier reserveIdentifier(Session session, Identifier pid,
578
	  String scope, String format) 
579
	  throws InvalidToken, ServiceFailure, NotAuthorized, IdentifierNotUnique, 
580
	  NotImplemented, InvalidRequest {
640
	public boolean reserveIdentifier(Session session, Identifier pid)
641
	throws InvalidToken, ServiceFailure,
642
        NotAuthorized, IdentifierNotUnique, NotImplemented, InvalidRequest {
581 643

  
582 644
		throw new NotImplemented("4191", "reserveIdentifier not implemented on this node");
583 645
	}
584 646
	
647
	@Override
648
	public Identifier generateIdentifier(Session session, String scheme, String fragment)
649
	throws InvalidToken, ServiceFailure,
650
        NotAuthorized, NotImplemented, InvalidRequest {
651
		throw new NotImplemented("4191", "generateIdentifier not implemented on this node");
652
	}
653
	
585 654
	/**
586 655
 	 * Checks whether the pid is reserved by the subject in the session param
587 656
 	 * If the reservation is held on the pid by the subject, we return true.

Also available in: Unified diff