public Map<String, List<StorageObject>> listObjectSegments(Region region, String container, String name) throws IOException {
Map<String, List<StorageObject>> existingSegments = new HashMap<String, List<StorageObject>>();
try {
ObjectMetadata existingMetadata = getObjectMetaData(region, container, name);
if(existingMetadata.getMetaData().containsKey(Constants.MANIFEST_HEADER)) {
/*
* We have found an existing dynamic large object, so use the prefix to get a list of
* existing objects. If we're putting up a new dlo, make sure the segment prefixes are
* different, then we can delete anything that's not in the new list if necessary.
*/
String manifestDLO = existingMetadata.getMetaData().get(Constants.MANIFEST_HEADER);
String segmentContainer = manifestDLO.substring(1, manifestDLO.indexOf('/', 1));
String segmentPath = manifestDLO.substring(manifestDLO.indexOf('/', 1), manifestDLO.length());
existingSegments.put(segmentContainer, this.listObjects(region, segmentContainer, segmentPath));
}
else if(existingMetadata.getMetaData().containsKey(Constants.X_STATIC_LARGE_OBJECT)) {
/*
* We have found an existing static large object, so grab the manifest data that
* details the existing segments - delete any later that we don't need any more
*/
boolean isSLO = "true".equals(existingMetadata.getMetaData().get(Constants.X_STATIC_LARGE_OBJECT).toLowerCase(Locale.ENGLISH));
if(isSLO) {
final JsonParser parser = new JsonParser();
URIBuilder urlBuild = new URIBuilder(region.getStorageUrl(container, name));
urlBuild.setParameter("multipart-manifest", "get");
URI url = urlBuild.build();