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:

test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
275 275
			Identifier guid = new Identifier();
276 276
			guid.setValue("testReserveIdentifier." + System.currentTimeMillis());
277 277
			// reserve it
278
			Identifier retPid = CNodeService.getInstance().reserveIdentifier(session, guid, null, null);
279
			assertEquals(guid, retPid);
278
			boolean result = CNodeService.getInstance().reserveIdentifier(session, guid);
279
			assertTrue(result);
280 280
	    } catch(NotImplemented ni) {
281 281
        	// this is not implemented in Metacat
282 282
            assertTrue(true);	
src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
603 603
			logMetacat.warn("pid not specified");
604 604
		} 
605 605
		// call the implementation
606
		Identifier retPid = CNodeService.getInstance().reserveIdentifier(session, pid, scope, format);
606
		boolean result = CNodeService.getInstance().reserveIdentifier(session, pid);
607 607
		OutputStream out = response.getOutputStream();
608 608
		response.setStatus(200);
609 609
		response.setContentType("text/xml");
610
		TypeMarshaller.marshalTypeToOutputStream(retPid, out);
611
		
610
		// nothing to send back
612 611
    }
613 612
    
614 613
    /**
src/edu/ucsb/nceas/metacat/MetacatHandler.java
3666 3666
                      Identifier dataGuid = new Identifier();
3667 3667
                      dataGuid.setValue(dataGuidString);
3668 3668
                      
3669
                      // TODO: add describes for ORE
3670
                      sysMeta.addResourceMap(null);
3671
                      
3672

  
3673
                      // TODO add describedBy sysmeta ORE
3674
                      //logMetacat.debug("Setting describedBy for " + dataGuid.getValue() + " to " + identifier.getValue());
3675
                      dataSysMeta.addResourceMap(null);
3676
                      
3677 3669
                      // set object format
3678 3670
                      logMetacat.debug("Updating system metadata for " + dataGuid.getValue() + " to " + dataDocMimeType);
3679 3671
                      ObjectFormat f = ObjectFormatCache.getInstance().getFormat(dataDocMimeType);
src/edu/ucsb/nceas/metacat/dataone/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