@Override public Acl getPermission(final Path file) { if(containerService.isContainer(file)) { return containerService.getContainer(file).attributes().getAcl(); } return Acl.EMPTY; }
protected String createPrefix(final Path directory) { // Keys can be listed by prefix. By choosing a common prefix // for the names of related keys and marking these keys with // a special character that delimits hierarchy, you can use the list // operation to select and browse keys hierarchically String prefix = StringUtils.EMPTY; if(!containerService.isContainer(directory)) { // Restricts the response to only contain results that begin with the // specified prefix. If you omit this optional argument, the value // of Prefix for your query will be the empty string. // In other words, the results will be not be restricted by prefix. prefix = containerService.getKey(directory); if(!prefix.endsWith(String.valueOf(Path.DELIMITER))) { prefix += Path.DELIMITER; } } return prefix; } }
private Map<Path, Boolean> getRoomEncryptionStatus(final Map<TransferItem, TransferStatus> files) throws BackgroundException { final Map<Path, Boolean> rooms = new HashMap<>(); for(Map.Entry<TransferItem, TransferStatus> entry : files.entrySet()) { // Get top level room final Path container = new PathContainerService().getContainer(entry.getKey().remote); if(rooms.containsKey(container)) { continue; } rooms.put(container, nodeid.isEncrypted(entry.getKey().remote)); } return rooms; }
/** * Properly URI encode and prepend the bucket name. * * @param scheme Protocol * @return URL to be displayed in browser */ protected DescriptiveUrl toUrl(final Path file, final Scheme scheme) { final StringBuilder url = new StringBuilder(scheme.name()); url.append("://"); if(file.isRoot()) { url.append(session.getHost().getHostname()); } else { final String hostname = this.getHostnameForContainer(containerService.getContainer(file)); if(hostname.startsWith(containerService.getContainer(file).getName())) { url.append(hostname); if(!containerService.isContainer(file)) { url.append(Path.DELIMITER); url.append(URIEncoder.encode(containerService.getKey(file))); } } else { url.append(session.getHost().getHostname()); url.append(URIEncoder.encode(file.getAbsolute())); } } return new DescriptiveUrl(URI.create(url.toString()), DescriptiveUrl.Type.http, MessageFormat.format(LocaleFactory.localizedString("{0} URL"), scheme.name().toUpperCase(Locale.ROOT))); }
protected String copy(final Path source, final S3Object destination, final TransferStatus status) throws BackgroundException { try { // Copying object applying the metadata of the original final Map<String, Object> stringObjectMap = session.getClient().copyVersionedObject(source.attributes().getVersionId(), containerService.getContainer(source).getName(), containerService.getKey(source), destination.getBucketName(), destination, false); final Map complete = (Map) stringObjectMap.get(Constants.KEY_FOR_COMPLETE_METADATA); return (String) complete.get(Constants.AMZ_VERSION_ID); } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Cannot copy {0}", e, source); } }
@Override public boolean isSupported(final Path source, final Path target) { return !containerService.isContainer(source) && !containerService.isContainer(target); } }
protected Set<Path> getContainers(final List<Path> files) { final Set<Path> containers = new HashSet<>(); for(Path file : files) { containers.add(containerService.getContainer(file)); } return containers; }
public DefaultPathPredicate(final Path file) { final Path.Type type = file.isSymbolicLink() ? Path.Type.symboliclink : file.isFile() ? Path.Type.file : Path.Type.directory; String qualifier = StringUtils.EMPTY; if(StringUtils.isNotBlank(file.attributes().getRegion())) { if(new PathContainerService().isContainer(file)) { qualifier += file.attributes().getRegion(); } } if(file.isFile()) { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { qualifier += file.attributes().getVersionId(); } } final String path = file.getAbsolute(); reference = "[" + type + "]" + "-" + qualifier + path; }
@Override public String getKey(final Path file) { final String key = super.getKey(file); if(!file.isRoot() && !this.isContainer(file) && file.isDirectory()) { return key.concat(String.valueOf(Path.DELIMITER)).concat(PLACEHOLDER); } return key; } }
public SwiftHomeFinderService(final SwiftSession session) { super(session, new PathContainerService()); } }
@Override public void setMetadata(final Path file, final Map<String, String> metadata) throws BackgroundException { try { if(containerService.isContainer(file)) { for(Map.Entry<String, String> entry : file.attributes().getMetadata().entrySet()) { containerService.getContainer(file).getName(), metadata); containerService.getContainer(file).getName(), containerService.getKey(file), metadata);
final String manifest = segmentService.manifest(containerService.getContainer(file).getName(), completed); if(log.isDebugEnabled()) { log.debug(String.format("Creating SLO manifest %s for %s", manifest, file)); containerService.getContainer(file)), containerService.getContainer(file).getName(), overall.getMime(), containerService.getKey(file), manifest, Collections.emptyMap());
@Override public boolean isSupported(final Path source, final Path target) { return !containerService.isContainer(source) && !containerService.isContainer(target); } }
@Override public DescriptiveUrlBag toUrl(final Path file) { if(distributions.containsKey(containerService.getContainer(file))) { return new DistributionUrlProvider(distributions.get(containerService.getContainer(file))).toUrl(file); } return DescriptiveUrlBag.empty(); }
@Override public PathAttributes find(final Path file) throws BackgroundException { if(file.isRoot()) { return PathAttributes.EMPTY; } if(new PathContainerService().isContainer(file)) { return PathAttributes.EMPTY; } final AttributedList<Path> list = new FileidDriveListService(session, fileid, file).list(file.getParent(), new DisabledListProgressListener()); final Path found = list.find(new DriveFileidProvider.IgnoreTrashedPathPredicate(file)); if(null == found) { throw new NotfoundException(file.getAbsolute()); } return found.attributes(); }
/** * @param file File in origin container * @param origin Distribution URL * @return URL to file in distribution */ private URI toUrl(final Path file, final URI origin) { final StringBuilder b = new StringBuilder(String.format("%s://%s", origin.getScheme(), origin.getHost())); if(distribution.getMethod().equals(Distribution.CUSTOM)) { b.append(Path.DELIMITER).append(URIEncoder.encode(PathRelativizer.relativize(origin.getRawPath(), file.getAbsolute()))); } else { if(StringUtils.isNotEmpty(origin.getRawPath())) { b.append(origin.getRawPath()); } if(StringUtils.isNotEmpty(containerService.getKey(file))) { b.append(Path.DELIMITER).append(URIEncoder.encode(containerService.getKey(file))); } } return URI.create(b.toString()).normalize(); }
final AttributedList<Path> objects = new AttributedList<Path>(); Marker marker; if(containerService.isContainer(directory)) { marker = new Marker(null, null); marker = new Marker(String.format("%s%s", containerService.getKey(directory), Path.DELIMITER), null); final String containerId = fileid.getFileid(containerService.getContainer(directory), new DisabledListProgressListener()); containerId, marker.nextFilename, marker.nextFileId, chunksize, containerService.isContainer(directory) ? null : String.format("%s%s", containerService.getKey(directory), String.valueOf(Path.DELIMITER)), String.valueOf(Path.DELIMITER)); marker = this.parse(directory, objects, response, revisions);
@Override public Algorithm getEncryption(final Path file) throws BackgroundException { if(containerService.isContainer(file)) { final String key = String.format("s3.encryption.key.%s", containerService.getContainer(file).getName()); if(StringUtils.isNotBlank(preferences.getProperty(key))) { return Algorithm.fromString(preferences.getProperty(key)); } } return super.getEncryption(file); }
@Override public InputStream open() throws IOException { try { return session.getClient().getObjectImpl( false, containerService.getContainer(file).getName(), containerService.getKey(file), null, null, null, null, null, null, file.attributes().getVersionId(), new HashMap<String, Object>(), chunk.getParameters()) .getDataInputStream(); } catch(ServiceException e) { throw new IOException(e.getMessage(), e); } } });
@Override public boolean isSupported(final Path source, final Path target) { return !containerService.isContainer(source) && !containerService.isContainer(target); } }