public void endElement(String uri, String name, String qName) { if (qName.equals("ID")) { // owner stuff currentOwner = new CanonicalUser(currentText.toString().trim()); } else if (qName.equals("DisplayName")) { currentOwner.setDisplayName(currentText.toString().trim()); } else if (qName.equals("Bucket")) { buckets.add(new BucketMetadata(currentName, currentCreationDate, currentOwner)); } else if (qName.equals("Name")) { currentName = currentText.toString().trim(); } else if (qName.equals("CreationDate")) { currentCreationDate = dateParser.iso8601DateParse(currentText.toString().trim()); } currentText = new StringBuilder(); }
private Location getLocation(BucketMetadata from) { try { Set<? extends Location> locations = this.locations.get(); final String region = client.getBucketLocation(from.getName()); assert region != null : String.format("could not get region for %s", from.getName()); if (region != null) { try { return Iterables.find(locations, new Predicate<Location>() { @Override public boolean apply(Location input) { return input.getId().equalsIgnoreCase(region.toString()); } }); } catch (NoSuchElementException e) { logger.error("could not get location for region %s in %s", region, locations); } } else { logger.error("could not get region for %s", from.getName()); } } catch (ContainerNotFoundException e) { logger.error(e, "could not get region for %s, as service suggests the bucket doesn't exist", from.getName()); } return null; } }
public StorageMetadata apply(BucketMetadata from) { MutableStorageMetadata to = new MutableStorageMetadataImpl(); to.setName(from.getName()); to.setType(StorageType.CONTAINER); to.setLocation(onlyLocation != null ? onlyLocation : getLocation(from)); return to; }