@Override public boolean find(final Path file) throws BackgroundException { if(file.isRoot()) { return true; } try { attributes.find(file); return true; } catch(NotfoundException e) { return false; } catch(AccessDeniedException e) { // Object is inaccessible to current user, but does exist. return true; } }
@Override public Map<String, String> getMetadata(final Path file) throws BackgroundException { if(file.isFile() || file.isPlaceholder()) { try { return new S3AttributesFinderFeature(session).find(file).getMetadata(); } catch(NotfoundException e) { if(file.isPlaceholder()) { // No placeholder file may exist but we just have a common prefix return Collections.emptyMap(); } throw e; } } return Collections.emptyMap(); }
@Override public String getFileid(final Path file, final ListProgressListener listener) throws BackgroundException { if(StringUtils.isNotBlank(file.attributes().getVersionId())) { return file.attributes().getVersionId(); } if(file.isRoot()) { return null; } return new S3AttributesFinderFeature(session).find(file).getVersionId(); }
/** * @param file File or bucket * @return Encryption algorithm used for file or null if not encrypted. For buckets, return setting in preferences if any. */ @Override public Algorithm getEncryption(final Path file) throws BackgroundException { if(file.isFile() || file.isPlaceholder()) { try { return new S3AttributesFinderFeature(session).find(file).getEncryption(); } catch(NotfoundException e) { if(file.isPlaceholder()) { // No placeholder file may exist but we just have a common prefix return Algorithm.NONE; } throw e; } } return Algorithm.NONE; }
@Override public String getClass(final Path file) throws BackgroundException { if(file.isFile() || file.isPlaceholder()) { try { // HEAD request provides storage class information of the object. // S3 returns this header for all objects except for Standard storage class objects. final String redundancy = new S3AttributesFinderFeature(session).find(file).getStorageClass(); if(StringUtils.isBlank(redundancy)) { return S3Object.STORAGE_CLASS_STANDARD; } return redundancy; } catch(NotfoundException e) { if(file.isPlaceholder()) { // No placeholder file may exist but we just have a common prefix return S3Object.STORAGE_CLASS_STANDARD; } throw e; } } if(containerService.isContainer(file)) { final String key = String.format("s3.storageclass.%s", containerService.getContainer(file).getName()); if(StringUtils.isNotBlank(preferences.getProperty(key))) { return preferences.getProperty(key); } } return S3Object.STORAGE_CLASS_STANDARD; }