use of ch.cyberduck.core.features.AclPermission in project cyberduck by iterate-ch.
the class TouchWorker method run.
@Override
public Path run(final Session<?> session) throws BackgroundException {
final Touch feature = session.getFeature(Touch.class);
if (log.isDebugEnabled()) {
log.debug(String.format("Run with feature %s", feature));
}
final TransferStatus status = new TransferStatus().withTimestamp(System.currentTimeMillis()).hidden(!SearchFilterFactory.HIDDEN_FILTER.accept(file)).exists(false).withLength(0L).withMime(new MappingMimeTypeService().getMime(file.getName())).withLockId(this.getLockId(file));
final Encryption encryption = session.getFeature(Encryption.class);
if (encryption != null) {
status.setEncryption(encryption.getDefault(file));
}
final Redundancy redundancy = session.getFeature(Redundancy.class);
if (redundancy != null) {
status.setStorageClass(redundancy.getDefault());
}
status.setTimestamp(System.currentTimeMillis());
if (PreferencesFactory.get().getBoolean("touch.permissions.change")) {
final UnixPermission permission = session.getFeature(UnixPermission.class);
if (permission != null) {
status.setPermission(permission.getDefault(EnumSet.of(Path.Type.file)));
}
final AclPermission acl = session.getFeature(AclPermission.class);
if (acl != null) {
status.setAcl(acl.getDefault(EnumSet.of(Path.Type.file)));
}
}
final Path result = feature.touch(file, status);
if (result.attributes() == PathAttributes.EMPTY) {
return result.withAttributes(session.getFeature(AttributesFinder.class).find(result));
}
return result;
}
use of ch.cyberduck.core.features.AclPermission in project cyberduck by iterate-ch.
the class AbstractCopyFilter method prepare.
@Override
public TransferStatus prepare(final Path file, final Local n, final TransferStatus parent, final ProgressListener progress) throws BackgroundException {
final TransferStatus status = new TransferStatus().hidden(!hidden.accept(file)).withLockId(parent.getLockId());
if (parent.isExists()) {
final Path target = files.get(file);
if (find.find(target)) {
// Do not attempt to create a directory that already exists
status.setExists(true);
// Read remote attributes
status.setRemote(attribute.find(target));
}
}
// Read remote attributes from source
final PathAttributes attributes = sourceSession.getFeature(AttributesFinder.class, new DefaultAttributesFinderFeature(sourceSession)).find(file);
if (file.isFile()) {
// Content length
status.setLength(attributes.getSize());
}
if (file.isDirectory()) {
status.setLength(0L);
}
if (options.permissions) {
status.setPermission(attributes.getPermission());
}
if (options.acl) {
final AclPermission sourceFeature = sourceSession.getFeature(AclPermission.class);
if (sourceFeature != null) {
progress.message(MessageFormat.format(LocaleFactory.localizedString("Getting permission of {0}", "Status"), file.getName()));
try {
status.setAcl(sourceFeature.getPermission(file));
} catch (NotfoundException | AccessDeniedException | InteroperabilityException e) {
final AclPermission targetFeature = targetSession.getFeature(AclPermission.class);
if (targetFeature != null) {
status.setAcl(targetFeature.getDefault(file.getType()));
}
}
} else {
final AclPermission targetFeature = targetSession.getFeature(AclPermission.class);
if (targetFeature != null) {
status.setAcl(targetFeature.getDefault(file.getType()));
}
}
}
if (options.timestamp) {
status.setTimestamp(attributes.getModificationDate());
}
if (options.metadata) {
final Headers sourceFeature = sourceSession.getFeature(Headers.class);
if (sourceFeature != null) {
progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), file.getName()));
try {
status.setMetadata(sourceFeature.getMetadata(file));
} catch (NotfoundException | AccessDeniedException | InteroperabilityException e) {
// Ignore
}
}
}
if (options.encryption) {
final Encryption sourceFeature = sourceSession.getFeature(Encryption.class);
if (sourceFeature != null) {
progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), file.getName()));
try {
status.setEncryption(sourceFeature.getEncryption(file));
} catch (NotfoundException | AccessDeniedException | InteroperabilityException e) {
final Encryption targetFeature = targetSession.getFeature(Encryption.class);
if (targetFeature != null) {
status.setEncryption(targetFeature.getDefault(file));
}
}
} else {
final Encryption targetFeature = targetSession.getFeature(Encryption.class);
if (targetFeature != null) {
status.setEncryption(targetFeature.getDefault(file));
}
}
}
if (options.redundancy) {
if (file.isFile()) {
final Redundancy sourceFeature = sourceSession.getFeature(Redundancy.class);
if (sourceFeature != null) {
progress.message(MessageFormat.format(LocaleFactory.localizedString("Reading metadata of {0}", "Status"), file.getName()));
try {
status.setStorageClass(sourceFeature.getClass(file));
} catch (NotfoundException | AccessDeniedException | InteroperabilityException e) {
final Redundancy targetFeature = targetSession.getFeature(Redundancy.class);
if (targetFeature != null) {
status.setStorageClass(targetFeature.getDefault());
}
}
} else {
final Redundancy targetFeature = targetSession.getFeature(Redundancy.class);
if (targetFeature != null) {
status.setStorageClass(targetFeature.getDefault());
}
}
}
}
if (options.checksum) {
// Save checksum and pass to transfer status when copying from file
status.setChecksum(file.attributes().getChecksum());
}
return status;
}
use of ch.cyberduck.core.features.AclPermission in project cyberduck by iterate-ch.
the class CreateDirectoryWorker method run.
@Override
public Path run(final Session<?> session) throws BackgroundException {
final Directory feature = session.getFeature(Directory.class);
if (log.isDebugEnabled()) {
log.debug(String.format("Run with feature %s", feature));
}
final TransferStatus status = new TransferStatus();
final Encryption encryption = session.getFeature(Encryption.class);
if (encryption != null) {
status.setEncryption(encryption.getDefault(folder));
}
status.setTimestamp(System.currentTimeMillis());
if (PreferencesFactory.get().getBoolean("touch.permissions.change")) {
final UnixPermission permission = session.getFeature(UnixPermission.class);
if (permission != null) {
status.setPermission(permission.getDefault(EnumSet.of(Path.Type.directory)));
}
final AclPermission acl = session.getFeature(AclPermission.class);
if (acl != null) {
status.setAcl(acl.getDefault(EnumSet.of(Path.Type.directory)));
}
}
status.setRegion(region);
return feature.mkdir(folder, status);
}
Aggregations