Search in sources :

Example 6 with AclPermission

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;
}
Also used : Path(ch.cyberduck.core.Path) AclPermission(ch.cyberduck.core.features.AclPermission) Redundancy(ch.cyberduck.core.features.Redundancy) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Encryption(ch.cyberduck.core.features.Encryption) Touch(ch.cyberduck.core.features.Touch) MappingMimeTypeService(ch.cyberduck.core.MappingMimeTypeService) UnixPermission(ch.cyberduck.core.features.UnixPermission)

Example 7 with AclPermission

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;
}
Also used : Path(ch.cyberduck.core.Path) NotfoundException(ch.cyberduck.core.exception.NotfoundException) AccessDeniedException(ch.cyberduck.core.exception.AccessDeniedException) InteroperabilityException(ch.cyberduck.core.exception.InteroperabilityException) Redundancy(ch.cyberduck.core.features.Redundancy) AttributesFinder(ch.cyberduck.core.features.AttributesFinder) Headers(ch.cyberduck.core.features.Headers) PathAttributes(ch.cyberduck.core.PathAttributes) Encryption(ch.cyberduck.core.features.Encryption) DefaultAttributesFinderFeature(ch.cyberduck.core.shared.DefaultAttributesFinderFeature) AclPermission(ch.cyberduck.core.features.AclPermission) TransferStatus(ch.cyberduck.core.transfer.TransferStatus)

Example 8 with AclPermission

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);
}
Also used : AclPermission(ch.cyberduck.core.features.AclPermission) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Encryption(ch.cyberduck.core.features.Encryption) Directory(ch.cyberduck.core.features.Directory) UnixPermission(ch.cyberduck.core.features.UnixPermission)

Aggregations

AclPermission (ch.cyberduck.core.features.AclPermission)8 Path (ch.cyberduck.core.Path)5 UnixPermission (ch.cyberduck.core.features.UnixPermission)5 Encryption (ch.cyberduck.core.features.Encryption)4 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)4 Redundancy (ch.cyberduck.core.features.Redundancy)3 Timestamp (ch.cyberduck.core.features.Timestamp)3 MappingMimeTypeService (ch.cyberduck.core.MappingMimeTypeService)2 PathAttributes (ch.cyberduck.core.PathAttributes)2 AccessDeniedException (ch.cyberduck.core.exception.AccessDeniedException)2 BackgroundException (ch.cyberduck.core.exception.BackgroundException)2 InteroperabilityException (ch.cyberduck.core.exception.InteroperabilityException)2 NotfoundException (ch.cyberduck.core.exception.NotfoundException)2 Headers (ch.cyberduck.core.features.Headers)2 Move (ch.cyberduck.core.features.Move)2 ArrayList (java.util.ArrayList)2 Acl (ch.cyberduck.core.Acl)1 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)1 DisabledConnectionCallback (ch.cyberduck.core.DisabledConnectionCallback)1 Local (ch.cyberduck.core.Local)1