Index: src/edu/ucsb/nceas/metacat/MetacatHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 6711)
+++ src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 6712)
@@ -1851,7 +1851,7 @@
                   // handle inserts
                   try {
                 	// create the system metadata  
-                    sysMeta = SystemMetadataFactory.createSystemMetadata(newdocid);
+                    sysMeta = SystemMetadataFactory.createSystemMetadata(newdocid, true);
                     
                     // save it to the map
                     HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
@@ -2995,7 +2995,7 @@
                                     username, groupnames);
                             
                             // generate system metadata about the doc
-                            SystemMetadata sm = SystemMetadataFactory.createSystemMetadata(docid);
+                            SystemMetadata sm = SystemMetadataFactory.createSystemMetadata(docid, true);
 							
 					        // manage it in the store
                             HazelcastService.getInstance().getSystemMetadataMap().put(sm.getIdentifier(), sm);
Index: src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java	(revision 6711)
+++ src/edu/ucsb/nceas/metacat/dataone/SystemMetadataFactory.java	(revision 6712)
@@ -25,20 +25,28 @@
  */
 package edu.ucsb.nceas.metacat.dataone;
 
+import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.math.BigInteger;
 import java.security.NoSuchAlgorithmException;
 import java.sql.SQLException;
+import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
 import java.util.Vector;
 
 import javax.xml.parsers.ParserConfigurationException;
 import javax.xml.xpath.XPathExpressionException;
 
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
 import org.dataone.client.ObjectFormatCache;
+import org.dataone.ore.ResourceMapFactory;
 import org.dataone.service.exceptions.BaseException;
 import org.dataone.service.exceptions.NotFound;
 import org.dataone.service.types.v1.Checksum;
@@ -49,6 +57,7 @@
 import org.dataone.service.types.v1.SystemMetadata;
 import org.dataone.service.types.v1.util.ChecksumUtil;
 import org.dataone.service.util.DateTimeMarshaller;
+import org.dspace.foresite.ResourceMap;
 import org.ecoinformatics.datamanager.DataManager;
 import org.ecoinformatics.datamanager.database.DatabaseConnectionPoolInterface;
 import org.ecoinformatics.datamanager.parser.DataPackage;
@@ -61,6 +70,7 @@
 import edu.ucsb.nceas.metacat.IdentifierManager;
 import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
 import edu.ucsb.nceas.metacat.McdbException;
+import edu.ucsb.nceas.metacat.MetaCatServlet;
 import edu.ucsb.nceas.metacat.MetacatHandler;
 import edu.ucsb.nceas.metacat.accesscontrol.AccessControlException;
 import edu.ucsb.nceas.metacat.client.InsufficientKarmaException;
@@ -76,7 +86,7 @@
 public class SystemMetadataFactory {
 
 	private static Logger logMetacat = Logger.getLogger(SystemMetadataFactory.class);
-
+	
 	/**
 	 * Creates a system metadata object for insertion into metacat
 	 * 
@@ -92,7 +102,7 @@
 	 * @throws HandlerException 
 	 * @throws AccessControlException 
 	 */
-	public static SystemMetadata createSystemMetadata(String localId)
+	public static SystemMetadata createSystemMetadata(String localId, boolean includeORE)
 			throws McdbException, McdbDocNotFoundException, SQLException,
 			IOException, AccessionNumberException, ClassNotFoundException,
 			InsufficientKarmaException, ParseLSIDException,
@@ -223,6 +233,10 @@
 								+ "entities is: "
 								+ dataPackage.getEntityNumber());
 
+				// for generating the ORE map
+	            Map<Identifier, List<Identifier>> idMap = new HashMap<Identifier, List<Identifier>>();
+	            List<Identifier> dataIds = new ArrayList<Identifier>();
+				
 				// iterate through data objects described by the EML
 				for (int j = 0; j < dataPackage.getEntityList().length; j++) {
 
@@ -264,7 +278,7 @@
 							try {
 								logMetacat.debug("Creating a system metadata "
 										+ "document for " + dataDocLocalId);
-								dataSysMeta = createSystemMetadata(dataDocLocalId);
+								dataSysMeta = createSystemMetadata(dataDocLocalId, includeORE);
 
 								// now look it up again
 								dataGuidString = IdentifierManager.getInstance().getGUID(dataDocid, dataRev);
@@ -291,6 +305,9 @@
 
 								// update the values
 								HazelcastService.getInstance().getSystemMetadataMap().put(dataSysMeta.getIdentifier(), dataSysMeta);
+								
+								// part of the ORE package
+								dataIds.add(dataGuid);
 
 							} catch (McdbDocNotFoundException mdnf) {
 								mdnf.printStackTrace();
@@ -321,7 +338,30 @@
 
 					} // end if()
 
-				} // end for()
+				} // end for (data entities)
+				
+				// ORE map
+		        if (!dataIds.isEmpty()) {
+		            // generate the ORE map for this datapackage
+		            Identifier resourceMapId = new Identifier();
+		            resourceMapId.setValue("resourceMap_" + sysMeta.getIdentifier().getValue());
+		            idMap.put(sysMeta.getIdentifier(), dataIds);
+		            ResourceMap rm = ResourceMapFactory.getInstance().createResourceMap(resourceMapId, idMap);
+		            String resourceMapXML = ResourceMapFactory.getInstance().serializeResourceMap(rm);
+		            // copy most of the same system metadata as the packaging metadata
+		            SystemMetadata resourceMapSysMeta = new SystemMetadata();
+		            BeanUtils.copyProperties(resourceMapXML, sysMeta);
+		            resourceMapSysMeta.setIdentifier(resourceMapId);
+		            Checksum checksum = ChecksumUtil.checksum(new BufferedInputStream(IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING)), "MD5");
+					resourceMapSysMeta.setChecksum(checksum);
+		            ObjectFormatIdentifier formatId = ObjectFormatCache.getInstance().getFormat("http://www.openarchives.org/ore/terms").getFormatId();
+					resourceMapSysMeta.setFormatId(formatId);
+		            // TODO: other fields to update?
+		            
+					// save it locally
+					MNodeService.getInstance(null).create(null, resourceMapId, IOUtils.toInputStream(resourceMapXML, MetaCatServlet.DEFAULT_ENCODING), resourceMapSysMeta);
+		            
+		        }
 
 			} catch (ParserConfigurationException pce) {
 				logMetacat.debug("There was a problem parsing the EML document. "
@@ -340,6 +380,7 @@
 			} // end try()
 
 		} // end if()
+		
 
 		// create the checksum
 		inputStream = MetacatHandler.read(localId);
Index: src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6711)
+++ src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6712)
@@ -38,7 +38,6 @@
 import org.dataone.service.exceptions.NotFound;
 import org.dataone.service.exceptions.NotImplemented;
 import org.dataone.service.exceptions.ServiceFailure;
-import org.dataone.service.types.v1.Session;
 import org.dataone.service.types.v1.SystemMetadata;
 
 import edu.ucsb.nceas.metacat.AccessionNumberException;
@@ -56,9 +55,10 @@
 	
     public boolean upgrade() throws AdminException {
         boolean success = true;
-        
+        // include ORE?
+        boolean includeOre = true;
         try {
-			generateMissingSystemMetadata(null);
+			generateMissingSystemMetadata(includeOre);
 		} catch (Exception e) {
 			String msg = "Problem generating missing system metadata: " + e.getMessage();
 			log.error(msg, e);
@@ -74,6 +74,7 @@
      * exempt.  This is a utility method for migration of existing object 
      * stores to DataONE where SystemMetadata is required for all objects.  See 
      * https://trac.dataone.org/ticket/591
+     * @param includeOre 
      * 
      * @param token an authtoken with appropriate permissions to read all 
      * documents in the object store.  To work correctly, this should probably
@@ -90,7 +91,7 @@
      * @throws McdbDocNotFoundException 
      * @throws ServiceFailure 
      */
-    public void generateMissingSystemMetadata(Session session) 
+    public void generateMissingSystemMetadata(boolean includeOre) 
     throws ServiceFailure, McdbDocNotFoundException, PropertyNotFoundException, InvalidToken, NotAuthorized, 
     NotFound, NotImplemented, InvalidRequest, NoSuchAlgorithmException, AccessionNumberException, SQLException 
     {
@@ -99,7 +100,7 @@
         for (String localId : idList) { 
             //for each id, add a system metadata doc
         	try {
-        		generateMissingSystemMetadata(session, localId);
+        		generateMissingSystemMetadata(localId, includeOre);
         	} catch (Exception e) {
 				log.error("Error generating system metadata for: " + localId, e);
 			}
@@ -116,6 +117,7 @@
      *        documents in the object store.  To work correctly, this should
      *        be an adminstrative credential.
      * @param localId the identifier of the object to be processed
+     * @param includeOre 
      * @throws ServiceFailure 
      * @throws SQLException 
      * @throws AccessionNumberException 
@@ -128,7 +130,7 @@
      * @throws PropertyNotFoundException 
      * @throws McdbDocNotFoundException 
      */
-    public void generateMissingSystemMetadata(Session session, String localId) 
+    public void generateMissingSystemMetadata(String localId, boolean includeOre) 
     throws ServiceFailure, McdbDocNotFoundException, PropertyNotFoundException, InvalidToken, NotAuthorized,
     NotFound, NotImplemented, InvalidRequest, NoSuchAlgorithmException, AccessionNumberException, SQLException 
     {
@@ -138,7 +140,7 @@
 
         //generate required system metadata fields from the document
         try {
-        	sm = SystemMetadataFactory.createSystemMetadata(localId);
+        	sm = SystemMetadataFactory.createSystemMetadata(localId, includeOre);
         } catch (Exception e1) {
         	e1.printStackTrace();
         	ServiceFailure sf = new ServiceFailure("00","Exception in generateMissingSystemMetadata: " +
Index: src/edu/ucsb/nceas/metacat/IdentifierManager.java
===================================================================
--- src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6711)
+++ src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6712)
@@ -43,7 +43,6 @@
 import org.dataone.service.types.v1.Checksum;
 import org.dataone.service.types.v1.Identifier;
 import org.dataone.service.types.v1.NodeReference;
-import org.dataone.service.types.v1.ObjectFormat;
 import org.dataone.service.types.v1.ObjectFormatIdentifier;
 import org.dataone.service.types.v1.ObjectInfo;
 import org.dataone.service.types.v1.ObjectList;
