Anonymous avatar Anonymous committed 0c39da6

sync w/ production

Comments (0)

Files changed (3)

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

                                     }
                                 }
 			    } 
+			    value = sanitize(value);
                             jobState.setLocalID(trimLeft(trimRight(value)));
                             if (DEBUG) System.out.println("[info]" + MESSAGE + "Found local ID(s) in metadata file: " + value);
 			}
         return s.replaceAll("\\s+$", "");
     }
 
+    public String sanitize(String s) {
+	String rebuild = "";
+	boolean first = true;
+	for (String p: s.split(";")) {
+	    p = p.trim();
+	    if (! rebuild.contains(p)) {
+		if (first) {
+		    rebuild = p;
+		    first = false;
+		} else
+		    rebuild += "; " + p;
+	    }
+	}
+	if (first) rebuild = s;
+        System.out.println("[info] " + MESSAGE + "sanitized localid: " + s + " ---> " + rebuild);
+
+        return rebuild;
+    }
+
     public String getName() {
 	return NAME;
     }

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

     private String getVerboseMsg(JobState jobState) {
 
 	String id = null;
+	String completionDate = "null";
         try {
 	    id = jobState.getLocalID().getValue();
 	} catch (Exception e) {
 	    id = jobState.getPrimaryID().getValue();
 	}
+        try {
+	    completionDate = jobState.getCompletionDate().toString();
+	} catch (Exception e) {
+	    completionDate = "unknown";
+	}
 
 	String msg = 
-	    "The dataset \"" + jobState.getObjectTitle() + "\" was successfully uploaded at " + jobState.getCompletionDate().toString() + ".\n"
+	    "The dataset \"" + jobState.getObjectTitle() + "\" was successfully uploaded at " + completionDate + ".\n"
 	  + "The identifier associated with this dataset is " + id + ". Please retain\n"
 	  + "this email for your records.\n\n"
 	  + "To access this dataset and associated metadata, use the following URL: \n"

ingest-src/src/main/java/org/cdlib/mrt/ingest/handlers/queue/HandlerNotification.java

     public HandlerResult handle(ProfileState profileState, IngestRequest ingestRequest, BatchState batchState) 
 	throws TException 
     {
-   MultiPartEmail email = new MultiPartEmail();
+   	MultiPartEmail email = new MultiPartEmail();
         FormatterUtil formatterUtil = new FormatterUtil();
         FormatType formatType = null;
         String batchID = batchState.getBatchID().getValue();
+	boolean verbose = false;
 
 	try {
 	    try {
 	        if (profileState.getNotificationType().equalsIgnoreCase("verbose")) {
-                    if (DEBUG) System.out.println("[info] " + MESSAGE + "Detected 'verbose' format type.  Skipping notification.");
-                    return new HandlerResult(true, "SUCCESS: " + NAME + " no notification required", 0);
+                    if (DEBUG) System.out.println("[info] " + MESSAGE + "Detected 'verbose' format type.");
+		    verbose = true;
 	        }
 	    } catch (Exception e) {}
 
   	    email.setHostName("localhost");	// production machines are SMTP enabled
-	    for (Notification recipient : profileState.getContactsEmail()) {
-		try {
-  	    	    email.addTo(recipient.getContactEmail());
-		} catch (Exception e) { 
-		    e.printStackTrace();
-		    notify(e.getMessage() + " - " + recipient.getContactEmail(), profileState, ingestRequest); 
-		}
+	    if (! verbose) {
+	        for (Notification recipient : profileState.getContactsEmail()) {
+		    try {
+  	    	        email.addTo(recipient.getContactEmail());
+		    } catch (Exception e) { 
+		        e.printStackTrace();
+		        notify(e.getMessage() + " - " + recipient.getContactEmail(), profileState, ingestRequest); 
+		    }
+	        }
+	    } else {
+                if (DEBUG) System.out.println("[info] " + MESSAGE + "recipients will not receive Queue notification.");
 	    }
             if (profileState.getAdmin() != null) {
                 for (Iterator<String> admin = profileState.getAdmin().iterator(); admin.hasNext(); ) {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.