Project

General

Profile

« Previous | Next » 

Revision 6713

optionally include ORE generation/insertion into Metacat when generating SystemMetadata
https://redmine.dataone.org/issues/2056

View differences:

src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java
341 341
				} // end for (data entities)
342 342
				
343 343
				// ORE map
344
		        if (!dataIds.isEmpty()) {
345
		            // generate the ORE map for this datapackage
346
		            Identifier resourceMapId = new Identifier();
347
		            resourceMapId.setValue("resourceMap_" + sysMeta.getIdentifier().getValue());
348
		            idMap.put(sysMeta.getIdentifier(), dataIds);
349
		            ResourceMap rm = ResourceMapFactory.getInstance().createResourceMap(resourceMapId, idMap);
350
		            String resourceMapXML = ResourceMapFactory.getInstance().serializeResourceMap(rm);
351
		            // copy most of the same system metadata as the packaging metadata
352
		            SystemMetadata resourceMapSysMeta = new SystemMetadata();
353
		            BeanUtils.copyProperties(resourceMapXML, sysMeta);
354
		            resourceMapSysMeta.setIdentifier(resourceMapId);
355
		            Checksum checksum = ChecksumUtil.checksum(new BufferedInputStream(IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING)), "MD5");
356
					resourceMapSysMeta.setChecksum(checksum);
357
		            ObjectFormatIdentifier formatId = ObjectFormatCache.getInstance().getFormat("http://www.openarchives.org/ore/terms").getFormatId();
358
					resourceMapSysMeta.setFormatId(formatId);
359
		            // TODO: other fields to update?
360
		            
361
					// save it locally
362
					MNodeService.getInstance(null).create(null, resourceMapId, IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING), resourceMapSysMeta);
363
		            
364
		        }
344
				if (includeORE) {
345
			        if (!dataIds.isEmpty()) {
346
			            // generate the ORE map for this datapackage
347
			            Identifier resourceMapId = new Identifier();
348
			            resourceMapId.setValue("resourceMap_" + sysMeta.getIdentifier().getValue());
349
			            idMap.put(sysMeta.getIdentifier(), dataIds);
350
			            ResourceMap rm = ResourceMapFactory.getInstance().createResourceMap(resourceMapId, idMap);
351
			            String resourceMapXML = ResourceMapFactory.getInstance().serializeResourceMap(rm);
352
			            // copy most of the same system metadata as the packaging metadata
353
			            SystemMetadata resourceMapSysMeta = new SystemMetadata();
354
			            BeanUtils.copyProperties(resourceMapXML, sysMeta);
355
			            resourceMapSysMeta.setIdentifier(resourceMapId);
356
			            Checksum checksum = ChecksumUtil.checksum(new BufferedInputStream(IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING)), "MD5");
357
						resourceMapSysMeta.setChecksum(checksum);
358
			            ObjectFormatIdentifier formatId = ObjectFormatCache.getInstance().getFormat("http://www.openarchives.org/ore/terms").getFormatId();
359
						resourceMapSysMeta.setFormatId(formatId);
360
			            // TODO: other fields to update?
361
			            
362
						// save it locally
363
						MNodeService.getInstance(null).create(
364
								null, 
365
								resourceMapId, 
366
								IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING), 
367
								resourceMapSysMeta);
368
			        }
369
				}
365 370

  
366 371
			} catch (ParserConfigurationException pce) {
367 372
				logMetacat.debug("There was a problem parsing the EML document. "

Also available in: Unified diff