Commits

Anonymous committed 579fa79

Simplified Fixity call

Comments (0)

Files changed (1)

ingest-src/src/main/java/org/cdlib/mrt/ingest/handlers/HandlerFixity.java

 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.Properties;
+import java.util.Vector;
 import javax.ws.rs.core.MediaType;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.DocumentBuilder;
     private static final String NAME = "HandlerFixity";
     private static final String MESSAGE = NAME + ": ";
     private static final boolean DEBUG = true;
+    private static final String CONTEXT_DELIM = "<>";
     private LoggerInf logger = null;
     private Properties conf = null;
     private boolean notify = true;	// notify admins if failure
             FileComponentContentInf rowIn = null;
             FileComponent fileComponent = null;
 	    String digestType = "sha-256";
+	    String context = null;
 	    String contextMain = "|objectid=%s|versionid=%s|fileid=%s|";
 	    String contextOwner = "|owner=%s|";
 	    String contextCollection = "|member=%s|";
             	formDataMultiPart.field("size", fileComponent.getSize() + "");
             	formDataMultiPart.field("digest-type", digestType);
             	formDataMultiPart.field("digest-value", fileComponent.getMessageDigest(digestType).getValue());
-            	formDataMultiPart.field("context", String.format(contextMain, jobState.getPrimaryID().getValue(), jobState.getVersionID().toString(),
-			fileComponent.getIdentifier()));
+
+		// context main
+            	context = String.format(contextMain, jobState.getPrimaryID().getValue(), jobState.getVersionID().toString(), fileComponent.getIdentifier());
+		// context w/ owner
+                context += CONTEXT_DELIM + String.format(contextOwner, profileState.getOwner());
+		// update context w/ members
+                Vector<String> members = profileState.getCollection();
+		for (String member: members) {
+		    context += CONTEXT_DELIM + String.format(contextCollection, member);
+		}
+            	formDataMultiPart.field("context", context);
+
             	formDataMultiPart.field("note", "");
             	formDataMultiPart.field("responseForm", "xml");		// alignment w/ fixity spec. 
             	formDataMultiPart.field("response-form", "xml");
 	            }
 		}
 
+/*
 		// another request to update owner context
                 formDataMultiPart = new FormDataMultiPart();
             	formDataMultiPart.field("url", createStorageURL(fileComponent, jobState, profileState));
 	                }
 		    }
 		}
+*/
             }
 
 	    return new HandlerResult(true, "SUCCESS: fixity request", clientResponse.getStatus());