Index: test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java
===================================================================
--- test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java	(revision 7852)
+++ test/edu/ucsb/nceas/metacat/dataone/MNodeServiceTest.java	(revision 7853)
@@ -28,6 +28,8 @@
 
 import gov.loc.repository.bagit.Bag;
 import gov.loc.repository.bagit.BagFactory;
+import gov.loc.repository.bagit.BagFile;
+import gov.loc.repository.bagit.Manifest;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -40,13 +42,18 @@
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
 import org.apache.commons.io.IOUtils;
+import org.dataone.client.ObjectFormatCache;
 import org.dataone.configuration.Settings;
+import org.dataone.ore.ResourceMapFactory;
 import org.dataone.service.util.TypeMarshaller;
 import org.dataone.service.exceptions.IdentifierNotUnique;
 import org.dataone.service.exceptions.InsufficientResources;
@@ -77,6 +84,7 @@
 import org.dataone.service.types.v1.Subject;
 import org.dataone.service.types.v1.SubjectInfo;
 import org.dataone.service.types.v1.SystemMetadata;
+import org.dspace.foresite.ResourceMap;
 import org.jibx.runtime.JiBXException;
 import org.junit.After;
 import org.junit.Before;
@@ -149,6 +157,7 @@
     suite.addTest(new MNodeServiceTest("testReplicate"));
     // MN packaging tests
     suite.addTest(new MNodeServiceTest("testGetPackage"));
+    suite.addTest(new MNodeServiceTest("testGetOREPackage"));
     
     
     return suite;
@@ -1112,7 +1121,7 @@
 			SystemMetadata sysmeta = createSystemMetadata(guid, session.getSubject(), object);
 			Identifier pid = MNodeService.getInstance(request).create(session, guid, object, sysmeta);
 			InputStream bagStream = MNodeService.getInstance(request).getPackage(session, pid);
-			File bagFile = File.createTempFile("bagit", ".zip");
+			File bagFile = File.createTempFile("bagit.", ".zip");
 			IOUtils.copy(bagStream, new FileOutputStream(bagFile));
 			BagFactory bagFactory = new BagFactory();
 			Bag bag = bagFactory.createBag(bagFile);
@@ -1133,7 +1142,109 @@
 			fail("Unexpected error: " + e.getMessage());
 		}
 	}
+	
+	
+	/**
+	 * Test getting a known object
+	 */
+	public void testGetOREPackage() {
+		printTestHeader("testGetOREPackage");
+
+		try {
+			
+			// construct the ORE package
+			Identifier resourceMapId = new Identifier();
+			//resourceMapId.setValue("doi://1234/AA/map.1.1");
+			resourceMapId.setValue("testGetOREPackage." + System.currentTimeMillis());
+			Identifier metadataId = new Identifier();
+			metadataId.setValue("doi://1234/AA/meta.1." + + System.currentTimeMillis());
+			List<Identifier> dataIds = new ArrayList<Identifier>();
+			Identifier dataId = new Identifier();
+			dataId.setValue("doi://1234/AA/data.1." + System.currentTimeMillis());
+			Identifier dataId2 = new Identifier();
+			dataId2.setValue("doi://1234/AA/data.2." + System.currentTimeMillis());
+			dataIds.add(dataId);
+			dataIds.add(dataId2);
+			Map<Identifier, List<Identifier>> idMap = new HashMap<Identifier, List<Identifier>>();
+			idMap.put(metadataId, dataIds);
+			ResourceMapFactory rmf = ResourceMapFactory.getInstance();
+			ResourceMap resourceMap = rmf.createResourceMap(resourceMapId, idMap);
+			assertNotNull(resourceMap);
+			String rdfXml = ResourceMapFactory.getInstance().serializeResourceMap(resourceMap);
+			assertNotNull(rdfXml);
+			
+			Session session = getTestSession();
+			InputStream object = null;
+			SystemMetadata sysmeta = null;
+			
+			// save the data objects (data just contains their ID)
+			InputStream dataObject1 = new ByteArrayInputStream(dataId.getValue().getBytes("UTF-8"));
+			sysmeta = createSystemMetadata(dataId, session.getSubject(), dataObject1);
+			MNodeService.getInstance(request).create(session, dataId, dataObject1, sysmeta);
+			// second data file
+			InputStream dataObject2 = new ByteArrayInputStream(dataId2.getValue().getBytes("UTF-8"));
+			sysmeta = createSystemMetadata(dataId2, session.getSubject(), dataObject2);
+			MNodeService.getInstance(request).create(session, dataId2, dataObject2, sysmeta);
+			// metadata file
+			InputStream metadataObject = new ByteArrayInputStream(metadataId.getValue().getBytes("UTF-8"));
+			sysmeta = createSystemMetadata(metadataId, session.getSubject(), metadataObject);
+			MNodeService.getInstance(request).create(session, metadataId, metadataObject, sysmeta);
+						
+			// save the ORE object
+			object = new ByteArrayInputStream(rdfXml.getBytes("UTF-8"));
+			sysmeta = createSystemMetadata(resourceMapId, session.getSubject(), object);
+			sysmeta.setFormatId(ObjectFormatCache.getInstance().getFormat("http://www.openarchives.org/ore/terms").getFormatId());
+			Identifier pid = MNodeService.getInstance(request).create(session, resourceMapId, object, sysmeta);
+			
+			// get the package we uploaded
+			InputStream bagStream = MNodeService.getInstance(request).getPackage(session, pid);
+			File bagFile = File.createTempFile("bagit.", ".zip");
+			IOUtils.copy(bagStream, new FileOutputStream(bagFile));
+			BagFactory bagFactory = new BagFactory();
+			Bag bag = bagFactory.createBag(bagFile);
+			Iterator<Manifest> manifestIter = bag.getTagManifests().iterator();
+			while (manifestIter.hasNext()) {
+				String filepath = manifestIter.next().getFilepath();
+				BagFile entryFile = bag.getBagFile(filepath);
+				InputStream result = entryFile.newInputStream();
+				// check ORE
+				if (filepath.contains(resourceMapId.getValue())) {
+					object.reset();
+					assertTrue(object.available() > 0);
+					assertTrue(result.available() > 0);
+					assertTrue(IOUtils.contentEquals(result, object));
+				}
+				// check metadata
+				if (filepath.contains(metadataId.getValue())) {
+					metadataObject.reset();
+					assertTrue(metadataObject.available() > 0);
+					assertTrue(result.available() > 0);
+					assertTrue(IOUtils.contentEquals(result, metadataObject));
+				}
+				if (filepath.contains(dataId.getValue())) {
+					dataObject1.reset();
+					assertTrue(dataObject1.available() > 0);
+					assertTrue(result.available() > 0);
+					assertTrue(IOUtils.contentEquals(result, dataObject1));
+				}
+				if (filepath.contains(dataId2.getValue())) {
+					dataObject2.reset();
+					assertTrue(dataObject2.available() > 0);
+					assertTrue(result.available() > 0);
+					assertTrue(IOUtils.contentEquals(result, dataObject2));
+				}
+				
+				
+			}
+			
+			// clean up
+			bagFile.delete();
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			fail("Unexpected error: " + e.getMessage());
+		}
+	}
+	
   
-  
-  
 }
Index: src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 7852)
+++ src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 7853)
@@ -1673,20 +1673,29 @@
 			packagePids.add(pid);
 		}
 
+		// track the pid-to-file mapping
+		StringBuffer pidMapping = new StringBuffer();
 		// loop through the package contents
 		for (Identifier entryPid: packagePids) {
 			SystemMetadata entrySysMeta = this.getSystemMetadata(session, entryPid);
 			String extension = ObjectFormatInfo.instance().getExtension(entrySysMeta.getFormatId().getValue());
 	        String prefix = entryPid.getValue();
-			File tempFile = File.createTempFile(prefix + "_bagit", extension);
+	        prefix = "entry";
+			File tempFile = File.createTempFile(prefix + ".", extension);
 			tempFiles.add(tempFile);
 			InputStream entryInputStream = this.get(session, entryPid);
 			IOUtils.copy(entryInputStream, new FileOutputStream(tempFile));
 			bag.addFileToPayload(tempFile);
+			pidMapping.append(entryPid.getValue() + "\t" + "data/" + tempFile.getName() + "\n");
 		}
 		
+		//add the the pid to data file map
+		File pidMappingFile = File.createTempFile("pid-mapping.", ".txt");
+		IOUtils.write(pidMapping.toString(), new FileOutputStream(pidMappingFile));
+		bag.addFileAsTag(pidMappingFile);
+
 		bag = bag.makeComplete();
-		File bagFile = File.createTempFile("bagit", ".zip");
+		File bagFile = File.createTempFile("bag.", ".zip");
 		// TODO: delete more confidently
 		bagFile.deleteOnExit();
 		bag.setFile(bagFile);
