changeset 98:452d02798054

more error checking for UpdateMpiwgDigitalizations.
author Robert Casties <casties@mpiwg-berlin.mpg.de>
date Wed, 17 Oct 2018 18:44:59 +0200
parents 2c49ddbe95ac
children 5380bdeb7457
files src/main/java/org/mpi/openmind/scripts/UpdateMpiwgDigitalizations.java
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/mpi/openmind/scripts/UpdateMpiwgDigitalizations.java	Wed Oct 17 18:44:25 2018 +0200
+++ b/src/main/java/org/mpi/openmind/scripts/UpdateMpiwgDigitalizations.java	Wed Oct 17 18:44:59 2018 +0200
@@ -17,6 +17,9 @@
  * MPIWG library directory names and access information ("free", or other)
  * and updates DIGITALIZATION objects with matching public_manifest_url 
  * Attribute.
+ * 
+ * CSV file name: mcgill-mpiwg-mapping.csv
+ * CSV columns: "mcgilldir, mpiwgdir, access"
  *  
  * @author casties
  *
@@ -44,6 +47,10 @@
 			List<AttributeFilter> filterList = new ArrayList<AttributeFilter>();
 			filterList.add(new AttributeFilter("name", mcgillDir, "DIGITALIZATION"));
 			Map<Entity, Attribute> resultMap = ws.searchEntityByAttributeFilter(filterList, 1);
+			if (resultMap.isEmpty()) {
+				System.out.println("WARNING: DIGITALIZATION not found for " + mcgillDir);
+				continue;
+			}
 			Entity digi = resultMap.keySet().iterator().next();
 			/*
 			// find CODEX
@@ -57,7 +64,7 @@
             if (digi != null) {
                 ws.getEntityContent(digi);
                 String pubUrl = null;
-                String privUrl = null;
+                //String privUrl = null;
                 // set public url
                 if (access.equalsIgnoreCase("free")) {
                     pubUrl = "https://digilib.mpiwg-berlin.mpg.de/digitallibrary/Manifester/IIIF/permanent!library!"
@@ -68,7 +75,11 @@
                         pubUrlAtt = new Attribute(PUB_URL_ATT_NAME, "text", pubUrl);
                         digi.addAttribute(pubUrlAtt);
                     } else {
-                        pubUrlAtt.setValue(pubUrl);
+                    	String oldUrl = pubUrlAtt.getValue();
+                    	if (!pubUrl.equals(oldUrl)) {
+                    		System.out.println("WARNING: URL changed! old="+oldUrl+" new="+pubUrl);
+                            pubUrlAtt.setValue(pubUrl);                    		
+                    	}
                     }
                 }
                 // save