log.debug(String.format("Write metadata %s for file %s", metadata, file)); session.getClient().updateContainerMetadata(regionService.lookup(file), containerService.getContainer(file).getName(), metadata); log.debug(String.format("Write metadata %s for file %s", metadata, file)); session.getClient().updateObjectMetadata(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), metadata);
public Region lookup(final Path file) throws BackgroundException { final Path container = containerService.getContainer(file); if(Location.unknown.equals(new SwiftLocationFeature.SwiftRegion(container.attributes().getRegion()))) { return this.lookup(location.getLocation(container)); } return this.lookup(new SwiftLocationFeature.SwiftRegion(container.attributes().getRegion())); }
try { if(StringUtils.isNotBlank(configuration.getIndexDocument())) { session.getClient().updateContainerMetadata(regionService.lookup(container), container.getName(), Collections.singletonMap("X-Container-Meta-Web-Index", configuration.getIndexDocument())); = session.getClient().getCDNContainerInfo(regionService.lookup(container), container.getName()); if(log.isDebugEnabled()) { log.debug(String.format("Found existing CDN configuration %s", info)); log.debug(String.format("Enable CDN configuration for %s", container)); session.getClient().cdnEnableContainer(regionService.lookup(container), container.getName()); log.debug(String.format("Update CDN configuration for %s", container)); session.getClient().cdnUpdateContainer(regionService.lookup(container), container.getName(), -1, configuration.isEnabled(), configuration.isLogging());
log.debug(String.format("Creating SLO manifest %s for %s", manifest, file)); session.getClient().createSLOManifestObject(regionService.lookup( containerService.getContainer(file)), containerService.getContainer(file).getName(),
final Region region = regionService.lookup(container.getKey()); final List<String> keys = container.getValue(); for(List<String> partition : new Partition<String>(keys, PreferencesFactory.get().getInteger("openstack.delete.multiple.partition"))) { session.getClient().deleteContainer(regionService.lookup(file), containerService.getContainer(file).getName());
try { try { final CDNContainer info = session.getClient().getCDNContainerInfo(regionService.lookup(container), container.getName()); final Distribution distribution = new Distribution(regionService.lookup(container).getStorageUrl(container.getName()), method, info.isEnabled()); distribution.setId(info.getName()); final ContainerMetadata metadata = session.getClient().getContainerMetaData(regionService.lookup(container), container.getName()); if(metadata.getMetaData().containsKey("X-Container-Meta-Web-Index")) { log.debug(String.format("No CDN configuration for %s", container)); final Distribution distribution = new Distribution(regionService.lookup(container).getStorageUrl(container.getName()), method, false); distribution.setStatus(LocaleFactory.localizedString("CDN Disabled", "Mosso")); return distribution;
/** * @return The ETag returned by the server for the uploaded object */ @Override public StorageObject call(final AbstractHttpEntity entity) throws BackgroundException { try { // Previous final HashMap<String, String> headers = new HashMap<>(status.getMetadata()); final String checksum = session.getClient().storeObject( regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), entity, headers, null); if(log.isDebugEnabled()) { log.debug(String.format("Saved object %s with checksum %s", file, checksum)); } final StorageObject stored = new StorageObject(containerService.getKey(file)); stored.setMd5sum(checksum); stored.setSize(status.getLength()); return stored; } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Upload {0} failed", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Upload {0} failed", e, file); } }
@Override protected Long operate(final PasswordCallback callback, final Path container) throws BackgroundException { try { return session.getClient().getContainerInfo(regionService.lookup(container), container.getName()).getTotalSize(); } catch(GenericException e) { throw new SwiftExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
final String checksum = session.getClient().createSLOManifestObject(regionService.lookup( containerService.getContainer(file)), containerService.getContainer(file).getName(),
final Path container = containerService.getContainer(file); final Map<String, List<StorageObject>> segments = session.getClient().listObjectSegments(regionService.lookup(container), container.getName(), containerService.getKey(file)); if(null == segments) {
@Override public void invalidate(final Path container, final Distribution.Method method, final List<Path> files, final LoginCallback prompt) throws BackgroundException { try { for(Path file : files) { if(containerService.isContainer(file)) { session.getClient().purgeCDNContainer(regionService.lookup(containerService.getContainer(file)), container.getName(), null); } else { session.getClient().purgeCDNObject(regionService.lookup(containerService.getContainer(file)), container.getName(), containerService.getKey(file), null); } } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot write CDN configuration", e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot write CDN configuration", e); } } }
try { checksum = session.getClient().storeObject( regionService.lookup(file), containerService.getContainer(segment).getName(), containerService.getKey(segment), entity, headers, Checksum.NONE == status.getChecksum() ? null : status.getChecksum().hash);
Region region = null; try { region = regionService.lookup(file);
session.getClient().deleteObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); session.getClient().deleteObject(regionService.lookup(segment), containerService.getContainer(segment).getName(), containerService.getKey(segment)); session.getClient().deleteContainer(regionService.lookup(file), containerService.getContainer(file).getName()); session.getClient().deleteObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file));
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { try { if(containerService.isContainer(file)) { final ContainerMetadata meta = session.getClient().getContainerMetaData(regionService.lookup(file), containerService.getContainer(file).getName()); return meta.getMetaData(); } else { final ObjectMetadata meta = session.getClient().getObjectMetaData(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file)); return meta.getMetaData(); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Failure to read attributes of {0}", e, file); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Failure to read attributes of {0}", e, file); } }
final HttpRange range = HttpRange.withStatus(status); if(-1 == range.getEnd()) { response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart()); response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file), range.getStart(), range.getLength()); response = session.getClient().getObject(regionService.lookup(file), containerService.getContainer(file).getName(), containerService.getKey(file));
final Path container = containerService.getContainer(directory); do { list = session.getClient().listObjectsStartingWith(regionService.lookup(container), container.getName(), containerService.isContainer(directory) ? StringUtils.EMPTY : containerService.getKey(directory) + Path.DELIMITER, null, limit, marker, Path.DELIMITER);
return PathAttributes.EMPTY; final Region region = regionService.lookup(file); try { if(containerService.isContainer(file)) {
@Override public Path copy(final Path source, final Path target, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { try { session.getClient().copyObject(regionService.lookup(source), containerService.getContainer(source).getName(), containerService.getKey(source), containerService.getContainer(target).getName(), containerService.getKey(target)); // Copy original file attributes return new Path(target.getParent(), target.getName(), target.getType(), new PathAttributes(source.attributes())); } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot copy {0}", e, source); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot copy {0}", e, source); } }
@Override public Path mkdir(final Path folder, final String region, final TransferStatus status) throws BackgroundException { try { if(containerService.isContainer(folder)) { // Create container at top level session.getClient().createContainer(regionService.lookup( new SwiftLocationFeature.SwiftRegion(region)), folder.getName()); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).find(folder)); } else { status.setMime("application/directory"); status.setLength(0L); final StatusOutputStream<StorageObject> out = writer.write(folder, status, new DisabledConnectionCallback()); new DefaultStreamCloser().close(out); final StorageObject metadata = out.getStatus(); return new Path(folder.getParent(), folder.getName(), folder.getType(), new SwiftAttributesFinderFeature(session, regionService).toAttributes(metadata)); } } catch(GenericException e) { throw new SwiftExceptionMappingService().map("Cannot create folder {0}", e, folder); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map("Cannot create folder {0}", e, folder); } }