Skip to content

Commit

Permalink
Fix #7841.
Browse files Browse the repository at this point in the history
Former-commit-id: c58e07cacf16bb70a5c1d400549ee291461b3338
  • Loading branch information
dkocher committed Mar 11, 2014
1 parent 26d672d commit 631a10d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 8 deletions.
4 changes: 4 additions & 0 deletions source/ch/cyberduck/core/features/Versioning.java
Expand Up @@ -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;
Expand All @@ -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;
}
4 changes: 3 additions & 1 deletion source/ch/cyberduck/core/s3/S3AccessControlListFeature.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
8 changes: 5 additions & 3 deletions source/ch/cyberduck/core/s3/S3MultipleDeleteFeature.java
Expand Up @@ -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;
Expand All @@ -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<Path> files, final LoginCallback prompt) throws BackgroundException {
Expand Down Expand Up @@ -121,7 +122,8 @@ public void delete(final List<Path> files, final LoginCallback prompt) throws Ba
protected void delete(final Path container, final List<ObjectKeyAndVersion> 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()]),
Expand Down
4 changes: 3 additions & 1 deletion source/ch/cyberduck/core/s3/S3ObjectDetailService.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand Down
4 changes: 3 additions & 1 deletion source/ch/cyberduck/core/s3/S3ObjectListService.java
Expand Up @@ -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;
Expand Down Expand Up @@ -96,7 +97,8 @@ public AttributedList<Path> 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 {
Expand Down
4 changes: 3 additions & 1 deletion source/ch/cyberduck/core/s3/S3ReadFeature.java
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion source/ch/cyberduck/core/s3/S3VersioningFeature.java
Expand Up @@ -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,
Expand Down

0 comments on commit 631a10d

Please sign in to comment.