Index: src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/restservice/MNResourceHandler.java	(revision 6384)
@@ -572,7 +572,7 @@
         response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().xmlValue());
         response.addHeader("content_length", dr.getContent_Length() + "");
         response.addHeader("last_modified", dateFormat.format(dr.getLast_Modified()));
-        response.addHeader("format", dr.getDataONE_ObjectFormat().toString());
+        response.addHeader("format", dr.getDataONE_ObjectFormatIdentifier().getValue());
        
     }
     
@@ -663,19 +663,19 @@
             SystemMetadata sm = MNodeService.getInstance().getSystemMetadata(session, id);
             
             //set the content type
-            if (sm.getObjectFormat().getFmtid().getValue().trim().equals(
+            if (sm.getFmtid().getValue().trim().equals(
             		ObjectFormatCache.getInstance().getFormat("text/csv").getFmtid().getValue()))
             {
                 response.setContentType("text/csv");
                 response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".csv");
             }
-            else if (sm.getObjectFormat().getFmtid().getValue().trim().equals(
+            else if (sm.getFmtid().getValue().trim().equals(
             		ObjectFormatCache.getInstance().getFormat("text/plain").getFmtid().getValue()))
             {
                 response.setContentType("text/plain");
                 response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".txt");
             } 
-            else if (sm.getObjectFormat().getFmtid().getValue().trim().equals(
+            else if (sm.getFmtid().getValue().trim().equals(
             		ObjectFormatCache.getInstance().getFormat("application/octet-stream").getFmtid().getValue()))
             {
                 response.setContentType("application/octet-stream");
Index: src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/restservice/ResourceHandler.java	(revision 6384)
@@ -827,7 +827,7 @@
             response.addHeader("checksum_algorithm", dr.getDataONE_Checksum().getAlgorithm().xmlValue());
             response.addHeader("content_length", dr.getContent_Length() + "");
             response.addHeader("last_modified", dateFormat.format(dr.getLast_Modified()));
-            response.addHeader("format", dr.getDataONE_ObjectFormat().toString());
+            response.addHeader("format", dr.getDataONE_ObjectFormatIdentifier().getValue());
         }
         catch(InvalidRequest ir)
         {
@@ -1123,19 +1123,19 @@
                     SystemMetadata sm = MNodeService.getInstance().getSystemMetadata(session, id);
                     
                     //set the content type
-                    if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+                    if(sm.getFmtid().getValue().trim().equals(
                     		ObjectFormatCache.getInstance().getFormat("text/csv").getFmtid().getValue()))
                     {
                         response.setContentType("text/csv");
                         response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".csv");
                     }
-                    else if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+                    else if(sm.getFmtid().getValue().trim().equals(
                     		ObjectFormatCache.getInstance().getFormat("text/plain").getFmtid().getValue()))
                     {
                         response.setContentType("text/plain");
                         response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".txt");
                     } 
-                    else if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+                    else if(sm.getFmtid().getValue().trim().equals(
                     		ObjectFormatCache.getInstance().getFormat("application/octet-stream").getFmtid().getValue()))
                     {
                         response.setContentType("application/octet-stream");
Index: src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/restservice/CNResourceHandler.java	(revision 6384)
@@ -406,19 +406,19 @@
         SystemMetadata sm = CNodeService.getInstance().getSystemMetadata(session, id);
         
         //set the content type
-        if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+        if(sm.getFmtid().getValue().trim().equals(
         		ObjectFormatCache.getInstance().getFormat("text/csv").getFmtid().getValue()))
         {
             response.setContentType("text/csv");
             response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".csv");
         }
-        else if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+        else if(sm.getFmtid().getValue().trim().equals(
         		ObjectFormatCache.getInstance().getFormat("text/plain").getFmtid().getValue()))
         {
             response.setContentType("text/plain");
             response.setHeader("Content-Disposition", "inline; filename=" + id.getValue() + ".txt");
         } 
-        else if(sm.getObjectFormat().getFmtid().getValue().trim().equals(
+        else if(sm.getFmtid().getValue().trim().equals(
         		ObjectFormatCache.getInstance().getFormat("application/octet-stream").getFmtid().getValue()))
         {
             response.setContentType("application/octet-stream");
Index: src/edu/ucsb/nceas/metacat/MetacatHandler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/MetacatHandler.java	(revision 6384)
@@ -41,6 +41,7 @@
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.math.BigInteger;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.security.NoSuchAlgorithmException;
@@ -81,6 +82,7 @@
 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.Subject;
 import org.dataone.service.types.v1.SystemMetadata;
 import org.dataone.service.types.v1.util.ChecksumUtil;
@@ -3575,11 +3577,11 @@
       Hashtable<String, Object> docInfo = IdentifierManager.getInstance().getDocumentInfo(localId);
       //set the default object format
       String doctype = (String) docInfo.get("doctype");
-      ObjectFormat format = null;
+      ObjectFormatIdentifier fmtid = null;
       
       // set the object format, fall back to defaults
       try {
-	      format = ObjectFormatCache.getInstance().getFormat(doctype);
+	      fmtid = ObjectFormatCache.getInstance().getFormat(doctype).getFmtid();
 
       } catch (NotFound nfe) {
         
@@ -3586,10 +3588,11 @@
         try {
         	// format is not registered, use default
 	        if (doctype.trim().equals("BIN")) {
-	        	format = ObjectFormatCache.getInstance().getFormat("application/octet-stream");
+	        	fmtid = ObjectFormatCache.getInstance().getFormat(
+	        			"application/octet-stream").getFmtid();
 	        
 	        } else {
-	        	format = ObjectFormatCache.getInstance().getFormat("text/plain");
+	        	fmtid = ObjectFormatCache.getInstance().getFormat("text/plain").getFmtid();
 	        }
         
         } catch (NotFound nf) {
@@ -3600,15 +3603,15 @@
 
       }
       
-      sysMeta.setObjectFormat(format);
-      logMetacat.debug("The ObjectFormat for " + localId + " is " + format.toString());
+      sysMeta.setFmtid(fmtid);
+      logMetacat.debug("The ObjectFormat for " + localId + " is " + fmtid.getValue());
       
       // further parse EML documents to get data object format,
       // describes and describedBy information
-      if ( format == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.0") ||
-           format == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.1") ||
-           format == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0") ||
-           format == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.1") ) {
+      if ( fmtid == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.0").getFmtid() ||
+           fmtid == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.0.1").getFmtid() ||
+           fmtid == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.0").getFmtid() ||
+           fmtid == ObjectFormatCache.getInstance().getFormat("eml://ecoinformatics.org/eml-2.1.1").getFmtid() ) {
         
         try {
         	
@@ -3668,11 +3671,18 @@
                       
                       // set object format
                       logMetacat.debug("Updating system metadata for " + dataGuid.getValue() + " to " + dataDocMimeType);
-                      ObjectFormat f = ObjectFormatCache.getInstance().getFormat(dataDocMimeType);
-                      if (f == null) {
-                    	  f = ObjectFormatCache.getInstance().getFormat("application/octet-stream");
+                      try {
+	                      ObjectFormatIdentifier fmt = 
+	                      ObjectFormatCache.getInstance().getFormat(dataDocMimeType).getFmtid();
+	                      dataSysMeta.setFmtid(fmt);
+                      
+                      } catch (NotFound nfe) {
+                      	logMetacat.debug("Couldn't find format identifier for: " +
+                      			dataDocMimeType + ". Setting it to application/octet-stream.");
+                        ObjectFormatIdentifier newFmtid = new ObjectFormatIdentifier();
+                        newFmtid.setValue("application/octet-stream");
+                      	
                       }
-                      dataSysMeta.setObjectFormat(f);
                   
             		  // update the values
             		  IdentifierManager.getInstance().updateSystemMetadata(dataSysMeta);
@@ -3735,8 +3745,10 @@
       
       //set the size
       inputStream = this.read(localId);
-      sysMeta.setSize(sizeOfStream(inputStream));
+      String sizeStr = new Long(sizeOfStream(inputStream)).toString();
+      sysMeta.setSize(new BigInteger(sizeStr));
       
+      
       //submitter
       Subject subject = new Subject();
       subject.setValue((String) docInfo.get("user_owner"));
Index: src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/dataone/MNodeService.java	(revision 6384)
@@ -496,7 +496,7 @@
     
     SystemMetadata sysmeta = getSystemMetadata(session, pid);
     DescribeResponse describeResponse = 
-      new DescribeResponse(sysmeta.getObjectFormat(), 
+      new DescribeResponse(sysmeta.getFmtid(), 
       sysmeta.getSize(), sysmeta.getDateSysMetadataModified(), sysmeta.getChecksum());
     
     return describeResponse;
@@ -858,7 +858,7 @@
 			  // if we are filtering by format
 			  if (formatId != null) {
 				  SystemMetadata sysmeta = IdentifierManager.getInstance().getSystemMetadata(pid.getValue());
-				  if (!sysmeta.getObjectFormat().getFmtid().getValue().equals(formatId.getValue())) {
+				  if (!sysmeta.getFmtid().getValue().equals(formatId.getValue())) {
 					  // does not match
 					  continue;
 				  }
@@ -959,4 +959,15 @@
 
   }
 
+  /**
+   * TODO: Implement this for D1 Tier 4 functionality
+   */
+	@Override
+  public InputStream getReplica(Session session, Identifier pid)
+    throws InvalidRequest, InvalidToken, NotAuthorized, NotImplemented,
+    ServiceFailure, NotFound {
+
+		throw new NotImplemented("4870", "isReplicationAuthorized not implemented");
+  }
+
 }
Index: src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/CNodeService.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/dataone/CNodeService.java	(revision 6384)
@@ -728,4 +728,32 @@
 		return pid;
 	}
 
+	/**
+	 * Verify that a replication task is authorized by comparing the target node's
+	 * Subject (from the X.509 certificate-derived Session) with the list of 
+	 * subjects in the known, pending replication tasks map.
+	 * 
+	 * @param originatingNodeSession - Session information that contains the 
+	 *                                 identity of the calling user
+	 * @param targetNodeSubject - Subject identifying the target node
+	 * @param pid - the identifier of the object to be replicated
+	 * @param replicatePermission - the execute permission to be granted
+	 * 
+	 * @throws ServiceFailure
+	 * @throws NotImplemented
+	 * @throws InvalidToken
+	 * @throws NotAuthorized
+	 * @throws InvalidRequest
+	 * @throws NotFound
+	 */
+	@Override
+  public boolean isReplicationAuthorized(Session originatingNodeSession, 
+    Subject targetNodeSubject, Identifier pid, Permission replicatePermission) 
+	  throws NotImplemented, NotAuthorized, InvalidToken, ServiceFailure, 
+	  NotFound, InvalidRequest {
+
+		throw new NotImplemented("4870", "isReplicationAuthorized not implemented");
+		
+  }
+
 }
Index: src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java	(revision 6384)
@@ -666,7 +666,7 @@
     boolean isScienceMetadata = false;
     
     try {
-      objectFormat = ObjectFormatCache.getInstance().getFormat(sysmeta.getObjectFormat().getFmtid());
+      objectFormat = ObjectFormatCache.getInstance().getFormat(sysmeta.getFmtid());
       isScienceMetadata = objectFormat.isScienceMetadata();
       
     } catch (InvalidRequest e) {
Index: src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java
===================================================================
--- src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/admin/upgrade/GenerateSystemMetadata.java	(revision 6384)
@@ -39,7 +39,7 @@
 import org.dataone.service.exceptions.NotFound;
 import org.dataone.service.exceptions.NotImplemented;
 import org.dataone.service.exceptions.ServiceFailure;
-import org.dataone.service.types.AuthToken;
+import org.dataone.service.types.v1.Session;
 import org.dataone.service.types.v1.SystemMetadata;
 
 import edu.ucsb.nceas.metacat.AccessionNumberException;
@@ -93,7 +93,7 @@
      * @throws McdbDocNotFoundException 
      * @throws ServiceFailure 
      */
-    public void generateMissingSystemMetadata(AuthToken token) 
+    public void generateMissingSystemMetadata(Session session) 
     throws ServiceFailure, McdbDocNotFoundException, PropertyNotFoundException, InvalidToken, NotAuthorized, 
     NotFound, NotImplemented, InvalidRequest, NoSuchAlgorithmException, AccessionNumberException, SQLException 
     {
@@ -103,7 +103,7 @@
         for (String localId : idList) { 
             //for each id, add a system metadata doc
         	try {
-        		generateMissingSystemMetadata(token, localId);
+        		generateMissingSystemMetadata(session, localId);
         	} catch (Exception e) {
 				log.error("Error generating system metadata for: " + localId, e);
 			}
@@ -132,7 +132,7 @@
      * @throws PropertyNotFoundException 
      * @throws McdbDocNotFoundException 
      */
-    public void generateMissingSystemMetadata(AuthToken token, String localId) 
+    public void generateMissingSystemMetadata(Session session, String localId) 
     throws ServiceFailure, McdbDocNotFoundException, PropertyNotFoundException, InvalidToken, NotAuthorized,
     NotFound, NotImplemented, InvalidRequest, NoSuchAlgorithmException, AccessionNumberException, SQLException 
     {
Index: src/edu/ucsb/nceas/metacat/IdentifierManager.java
===================================================================
--- src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6383)
+++ src/edu/ucsb/nceas/metacat/IdentifierManager.java	(revision 6384)
@@ -24,6 +24,7 @@
 
 package edu.ucsb.nceas.metacat;
 
+import java.math.BigInteger;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
@@ -108,7 +109,7 @@
     public SystemMetadata asSystemMetadata(Date dateUploaded, String rightsHolder,
             String checksum, String checksumAlgorithm, String originMemberNode,
             String authoritativeMemberNode, Date dateModified, String submitter, 
-            String guid, String fmtidStr, long size) {
+            String guid, String fmtidStr, BigInteger size) {
         SystemMetadata sysMeta = new SystemMetadata();
 
         Identifier sysMetaId = new Identifier();
@@ -133,16 +134,15 @@
         submitterSubject.setValue(submitter);
         sysMeta.setSubmitter(submitterSubject);
         try {
-	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(fmtidStr));
+        	ObjectFormatIdentifier fmtid = 
+        		ObjectFormatCache.getInstance().getFormat(fmtidStr).getFmtid();
+        	sysMeta.setFmtid(fmtid);
         } catch (NotFound nfe) {
           logMetacat.error("The objectFormat " + fmtidStr +
-          	" is not registered. Setting the default format.");
-          ObjectFormat of = new ObjectFormat();
+          	" is not registered. Setting the default format id.");
           ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
           fmtid.setValue("application/octet-stream");
-          of.setFmtid(fmtid);
-          of.setFormatName("Octet Stream");
-          sysMeta.setObjectFormat(of);
+          sysMeta.setFmtid(fmtid);
         }
         sysMeta.setSize(size);
         
@@ -270,7 +270,7 @@
                 Timestamp dateModified = rs.getTimestamp(8);
                 String submitter = rs.getString(9);
                 String fmtidStr = rs.getString(10);
-                long size = new Long(rs.getString(11)).longValue();
+                BigInteger size = new BigInteger(rs.getString(11));
                 String obsoletes = rs.getString(12);
                 String obsoletedBy = rs.getString(13);
 
@@ -297,16 +297,15 @@
                 submitterSubject.setValue(submitter);
                 sysMeta.setSubmitter(submitterSubject);
                 try {
-        	        sysMeta.setObjectFormat(ObjectFormatCache.getInstance().getFormat(fmtidStr));
+                	ObjectFormatIdentifier fmtid = 
+                		ObjectFormatCache.getInstance().getFormat(fmtidStr).getFmtid();
+                	sysMeta.setFmtid(fmtid);
                 } catch (NotFound nfe) {
                   logMetacat.error("The objectFormat " + fmtidStr +
-                  	" is not registered. Setting the default format.");
-                  ObjectFormat of = new ObjectFormat();
+                  	" is not registered. Setting the default format id.");
                   ObjectFormatIdentifier fmtid = new ObjectFormatIdentifier();
                   fmtid.setValue("application/octet-stream");
-                  of.setFmtid(fmtid);
-                  of.setFormatName("Octet Stream");
-                  sysMeta.setObjectFormat(of);
+                  sysMeta.setFmtid(fmtid);
                 }
                 sysMeta.setSize(size);
                 Identifier obsoletesId = new Identifier();
@@ -970,7 +969,7 @@
     private void updateSystemMetadataFields(long dateUploaded, String rightsHolder,
             String checksum, String checksumAlgorithm, String originMemberNode,
             String authoritativeMemberNode, long modifiedDate, String submitter, 
-            String guid, String objectFormat, long size, boolean replicationAllowed,
+            String guid, String objectFormat, BigInteger size, boolean replicationAllowed,
             int numberReplicas, String obsoletes, String obsoletedBy)
     {
         DBConnection dbConn = null;
@@ -1000,7 +999,7 @@
             stmt.setTimestamp(7, new java.sql.Timestamp(modifiedDate));
             stmt.setString(8, submitter);
             stmt.setString(9, objectFormat);
-            stmt.setString(10, new Long(size).toString());
+            stmt.setString(10, size.toString());
             stmt.setBoolean(11, replicationAllowed);
             stmt.setInt(12, numberReplicas);
             stmt.setString(13, obsoletes);
@@ -1146,13 +1145,13 @@
 				sm.getAuthoritativeMemberNode() == null ? null: sm.getAuthoritativeMemberNode().getValue(), 
 				sm.getDateSysMetadataModified() == null ? null: sm.getDateSysMetadataModified().getTime(),
 				sm.getSubmitter() == null ? null: sm.getSubmitter().getValue(), 
-                sm.getIdentifier().getValue(),
-                sm.getObjectFormat() == null ? null: sm.getObjectFormat().getFmtid().getValue(),
-                sm.getSize(),
-                replicationAllowed, 
-                numberReplicas,
-                sm.getObsoletes() == null ? null:sm.getObsoletes().getValue(),
-                sm.getObsoletedBy() == null ? null: sm.getObsoletedBy().getValue());
+        sm.getIdentifier().getValue(),
+        sm.getFmtid() == null ? null: sm.getFmtid().getValue(),
+        sm.getSize(),
+        replicationAllowed, 
+        numberReplicas,
+        sm.getObsoletes() == null ? null:sm.getObsoletes().getValue(),
+        sm.getObsoletedBy() == null ? null: sm.getObsoletedBy().getValue());
         
         String guid = sm.getIdentifier().getValue();
         
@@ -1449,10 +1448,10 @@
                 //String submitter = rs.getString(9);
                 String fmtidStr = rs.getString(10);
                 String sz = rs.getString(11);
-                long size = 0;
+                BigInteger size = new BigInteger("0");
                 
                 if (sz != null && !sz.trim().equals("")) {
-                    size = new Long(rs.getString(11)).longValue();
+                    size = new BigInteger(rs.getString(11));
                 }
                 
                 ObjectInfo oi = new ObjectInfo();
@@ -1476,9 +1475,10 @@
                 oi.setChecksum(cs);
                 
                 try {
-	                oi.setObjectFormat(ObjectFormatCache.getInstance().getFormat(fmtidStr));
+	                oi.setFmtid(ObjectFormatCache.getInstance().getFormat(fmtidStr).getFmtid());
                 } catch (NotFound e) {
                 	logMetacat.warn("could not find object format: " + fmtidStr, e);
+
 				}
                                 
                 oi.setSize(size);
