Skip to content

Commit

Permalink
changes getServiceURI method to non-templated URI
Browse files Browse the repository at this point in the history
standard form is $serviceURI + $collectionRoot + $collectionID + $objektId + $resourceContainer + $filename.jp2
  • Loading branch information
christopher-johnson committed Mar 10, 2017
1 parent d1d1290 commit c914994
Showing 1 changed file with 7 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,31 +152,19 @@ private InputStream getResourceMetadata(Map<String, BagInfoField> map, String fi
}

private String getServiceURI(Map<String, BagInfoField> map, String filename) {
String separator = "_";
String serviceURI = getMapValue(map, ProfileOptions.IIIF_SERVICE_KEY);
String collectionID = substringBeforeLast(getMapValue(map, ProfileOptions.COLLECTION_ID_KEY), "/");
String objektID = substringBeforeLast(getMapValue(map, ProfileOptions.OBJEKT_ID_KEY), "/");
return serviceURI + collectionID + "_" + objektID + "_"
+ getMapValue(map, ProfileOptions.RESOURCE_CONTAINER_KEY) + "_" + filename;
String path = getMapValue(map, ProfileOptions.COLLECTION_ROOT_KEY) + separator + getMapValue(map,
ProfileOptions.COLLECTION_ID_KEY)
+ separator + getMapValue(map, ProfileOptions.OBJEKT_ID_KEY) + separator + getMapValue(map,
ProfileOptions.RESOURCE_CONTAINER_KEY)
+ separator + filename;
return serviceURI + path.replace("tif", "jp2");
}

private String getMapValue(Map<String, BagInfoField> map, String key) {
BagInfoField IIIFProfileKey = map.get(key);
return IIIFProfileKey.getValue();
}

private static String substringBeforeLast(String str, String separator) {
if (isEmpty(str) || isEmpty(separator)) {
return str;
}
int pos = str.lastIndexOf(separator);
if (pos == -1) {
return str;
}
return str.substring(0, pos);
}

private static boolean isEmpty(String str) {
return str == null || str.length() == 0;
}

}

0 comments on commit c914994

Please sign in to comment.