Project

General

Profile

« Previous | Next » 

Revision 8141

copy the original systemMetadata when publishing a revision in order to avoid overwriting the original values - the shared map is listening! https://projects.ecoinformatics.org/ecoinfo/issues/6014

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
51 51

  
52 52
import javax.servlet.http.HttpServletRequest;
53 53

  
54
import org.apache.commons.beanutils.BeanUtils;
54 55
import org.apache.commons.io.IOUtils;
55 56
import org.apache.log4j.Logger;
56 57
import org.dataone.client.CNode;
......
1568 1569
	 */
1569 1570
	public Identifier publish(Session session, Identifier originalIdentifier) throws InvalidToken, ServiceFailure, NotAuthorized, NotImplemented, InvalidRequest, NotFound, IdentifierNotUnique, UnsupportedType, InsufficientResources, InvalidSystemMetadata {
1570 1571
		
1572
		
1573
		// get the original SM
1574
		SystemMetadata originalSystemMetadata = this.getSystemMetadata(session, originalIdentifier);
1575

  
1576
		// make copy of it
1577
		SystemMetadata sysmeta = new SystemMetadata();
1578
		try {
1579
			BeanUtils.copyProperties(sysmeta, originalSystemMetadata);
1580
		} catch (Exception e) {
1581
			// report as service failure
1582
			ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
1583
			sf.initCause(e);
1584
			throw sf;
1585
		}
1586

  
1571 1587
		// mint a DOI for the new revision
1572 1588
		Identifier newIdentifier = this.generateIdentifier(session, MNodeService.DOI_SCHEME, null);
1573
		
1574
		// get the original SM and update the values
1575
		SystemMetadata sysmeta = this.getSystemMetadata(session, originalIdentifier);
1589
				
1590
		// set new metadata values
1576 1591
		sysmeta.setIdentifier(newIdentifier);
1577 1592
		sysmeta.setObsoletes(originalIdentifier);
1578 1593
		sysmeta.setObsoletedBy(null);
......
1615 1630
				String resourceMapString = ResourceMapFactory.getInstance().serializeResourceMap(resourceMap);
1616 1631
				
1617 1632
				// get the original ORE SM and update the values
1618
				SystemMetadata oreSysMeta = this.getSystemMetadata(session, potentialOreIdentifier);
1633
				SystemMetadata originalOreSysMeta = this.getSystemMetadata(session, potentialOreIdentifier);
1634
				SystemMetadata oreSysMeta = new SystemMetadata();
1635
				try {
1636
					BeanUtils.copyProperties(oreSysMeta, originalOreSysMeta);
1637
				} catch (Exception e) {
1638
					// report as service failure
1639
					ServiceFailure sf = new ServiceFailure("1030", e.getMessage());
1640
					sf.initCause(e);
1641
					throw sf;
1642
				}
1643

  
1619 1644
				oreSysMeta.setIdentifier(newOreIdentifier);
1620 1645
				oreSysMeta.setObsoletes(potentialOreIdentifier);
1621 1646
				oreSysMeta.setObsoletedBy(null);

Also available in: Unified diff