From 631a10d7e104869ee241644171227056e27f7755 Mon Sep 17 00:00:00 2001 From: David Kocher Date: Tue, 11 Mar 2014 16:21:31 +0000 Subject: [PATCH] Fix #7841. Former-commit-id: c58e07cacf16bb70a5c1d400549ee291461b3338 --- source/ch/cyberduck/core/features/Versioning.java | 4 ++++ .../ch/cyberduck/core/s3/S3AccessControlListFeature.java | 4 +++- source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java | 8 +++++--- source/ch/cyberduck/core/s3/S3ObjectDetailService.java | 4 +++- source/ch/cyberduck/core/s3/S3ObjectListService.java | 4 +++- source/ch/cyberduck/core/s3/S3ReadFeature.java | 4 +++- source/ch/cyberduck/core/s3/S3VersioningFeature.java | 3 ++- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/source/ch/cyberduck/core/features/Versioning.java b/source/ch/cyberduck/core/features/Versioning.java index b8370724450..3854c014526 100644 --- a/source/ch/cyberduck/core/features/Versioning.java +++ b/source/ch/cyberduck/core/features/Versioning.java @@ -18,9 +18,11 @@ * feedback@cyberduck.ch */ +import ch.cyberduck.core.Credentials; import ch.cyberduck.core.LoginCallback; import ch.cyberduck.core.Path; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.exception.ConnectionCanceledException; import ch.cyberduck.core.s3.VersioningConfiguration; import java.util.Map; @@ -37,4 +39,6 @@ public interface Versioning { void setConfiguration(Path container, LoginCallback prompt, VersioningConfiguration configuration) throws BackgroundException; void revert(Path file) throws BackgroundException; + + Credentials getToken(LoginCallback controller) throws ConnectionCanceledException; } diff --git a/source/ch/cyberduck/core/s3/S3AccessControlListFeature.java b/source/ch/cyberduck/core/s3/S3AccessControlListFeature.java index c6023182569..dddb0e79024 100644 --- a/source/ch/cyberduck/core/s3/S3AccessControlListFeature.java +++ b/source/ch/cyberduck/core/s3/S3AccessControlListFeature.java @@ -24,6 +24,7 @@ import ch.cyberduck.core.exception.AccessDeniedException; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.AclPermission; +import ch.cyberduck.core.features.Versioning; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -72,7 +73,8 @@ public Acl getPermission(final Path file) throws BackgroundException { } else if(file.isFile() || file.attributes().isPlaceholder()) { org.jets3t.service.acl.AccessControlList list; - if(new S3VersioningFeature(session).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { + if(session.getFeature(Versioning.class) != null + && session.getFeature(Versioning.class).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { list = session.getClient().getVersionedObjectAcl(file.attributes().getVersionId(), containerService.getContainer(file).getName(), containerService.getKey(file)); } diff --git a/source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java b/source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java index 015ab3fa71d..37fe9da2493 100644 --- a/source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java +++ b/source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java @@ -26,6 +26,7 @@ import ch.cyberduck.core.collections.Partition; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Delete; +import ch.cyberduck.core.features.Versioning; import org.jets3t.service.ServiceException; import org.jets3t.service.model.MultipleDeleteResult; @@ -48,11 +49,11 @@ public class S3MultipleDeleteFeature implements Delete { private PathContainerService containerService = new PathContainerService(); - private S3VersioningFeature versioning; + private Versioning versioning; public S3MultipleDeleteFeature(final S3Session session) { this.session = session; - this.versioning = new S3VersioningFeature(session); + this.versioning = session.getFeature(Versioning.class); } public void delete(final List files, final LoginCallback prompt) throws BackgroundException { @@ -121,7 +122,8 @@ public void delete(final List files, final LoginCallback prompt) throws Ba protected void delete(final Path container, final List keys, final LoginCallback prompt) throws BackgroundException { try { - if(versioning.getConfiguration(container).isMultifactor()) { + if(versioning != null + && versioning.getConfiguration(container).isMultifactor()) { final Credentials factor = versioning.getToken(prompt); final MultipleDeleteResult result = session.getClient().deleteMultipleObjectsWithMFA(container.getName(), keys.toArray(new ObjectKeyAndVersion[keys.size()]), diff --git a/source/ch/cyberduck/core/s3/S3ObjectDetailService.java b/source/ch/cyberduck/core/s3/S3ObjectDetailService.java index 9ecf908884e..d9fab3f21a6 100644 --- a/source/ch/cyberduck/core/s3/S3ObjectDetailService.java +++ b/source/ch/cyberduck/core/s3/S3ObjectDetailService.java @@ -21,6 +21,7 @@ import ch.cyberduck.core.PathContainerService; import ch.cyberduck.core.exception.AccessDeniedException; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.Versioning; import org.apache.log4j.Logger; import org.jets3t.service.ServiceException; @@ -55,7 +56,8 @@ public S3ObjectDetailService(final S3Session session) { public StorageObject getDetails(final Path file) throws BackgroundException { final String container = containerService.getContainer(file).getName(); try { - if(new S3VersioningFeature(session).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { + if(session.getFeature(Versioning.class) != null + && session.getFeature(Versioning.class).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { return session.getClient().getVersionedObjectDetails(file.attributes().getVersionId(), container, containerService.getKey(file)); } diff --git a/source/ch/cyberduck/core/s3/S3ObjectListService.java b/source/ch/cyberduck/core/s3/S3ObjectListService.java index 45cbb9a8689..6944b8d48e1 100644 --- a/source/ch/cyberduck/core/s3/S3ObjectListService.java +++ b/source/ch/cyberduck/core/s3/S3ObjectListService.java @@ -27,6 +27,7 @@ import ch.cyberduck.core.PathNormalizer; import ch.cyberduck.core.Preferences; import ch.cyberduck.core.exception.BackgroundException; +import ch.cyberduck.core.features.Versioning; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -96,7 +97,8 @@ public AttributedList list(final Path directory, final ListProgressListene children.addAll(this.listObjects(container, directory, prefix, String.valueOf(Path.DELIMITER), listener)); if(Preferences.instance().getBoolean("s3.revisions.enable")) { - if(new S3VersioningFeature(session).withCache(versioning).getConfiguration(container).isEnabled()) { + if(session.getFeature(Versioning.class) != null + && session.getFeature(Versioning.class).withCache(versioning).getConfiguration(container).isEnabled()) { String priorLastKey = null; String priorLastVersionId = null; do { diff --git a/source/ch/cyberduck/core/s3/S3ReadFeature.java b/source/ch/cyberduck/core/s3/S3ReadFeature.java index 41651228c51..3292e08874a 100644 --- a/source/ch/cyberduck/core/s3/S3ReadFeature.java +++ b/source/ch/cyberduck/core/s3/S3ReadFeature.java @@ -22,6 +22,7 @@ import ch.cyberduck.core.PathContainerService; import ch.cyberduck.core.exception.BackgroundException; import ch.cyberduck.core.features.Read; +import ch.cyberduck.core.features.Versioning; import ch.cyberduck.core.transfer.TransferStatus; import org.apache.log4j.Logger; @@ -54,7 +55,8 @@ public S3ReadFeature(final S3Session session) { public InputStream read(final Path file, final TransferStatus status) throws BackgroundException { try { final S3Object object; - if(new S3VersioningFeature(session).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { + if(session.getFeature(Versioning.class) != null + && session.getFeature(Versioning.class).withCache(versioning).getConfiguration(containerService.getContainer(file)).isEnabled()) { object = session.getClient().getVersionedObject(file.attributes().getVersionId(), containerService.getContainer(file).getName(), containerService.getKey(file), null, // ifModifiedSince diff --git a/source/ch/cyberduck/core/s3/S3VersioningFeature.java b/source/ch/cyberduck/core/s3/S3VersioningFeature.java index 6a3ce4579c4..44a50ab8792 100644 --- a/source/ch/cyberduck/core/s3/S3VersioningFeature.java +++ b/source/ch/cyberduck/core/s3/S3VersioningFeature.java @@ -182,7 +182,8 @@ public void revert(final Path file) throws BackgroundException { * @throws ch.cyberduck.core.exception.ConnectionCanceledException * Prompt dismissed */ - protected Credentials getToken(final LoginCallback controller) throws ConnectionCanceledException { + @Override + public Credentials getToken(final LoginCallback controller) throws ConnectionCanceledException { final Credentials credentials = new MultifactorCredentials(); // Prompt for multi factor authentication credentials. controller.prompt(session.getHost().getProtocol(), credentials,