Search in sources :

Example 56 with ServiceException

use of org.jets3t.service.ServiceException in project cyberduck by iterate-ch.

the class S3ExceptionMappingServiceTest method test403NoXml.

@Test
public void test403NoXml() {
    final ServiceException f = new ServiceException();
    f.setResponseCode(403);
    assertTrue(new S3ExceptionMappingService().map(f) instanceof AccessDeniedException);
}
Also used : AccessDeniedException(ch.cyberduck.core.exception.AccessDeniedException) ServiceException(org.jets3t.service.ServiceException) S3ServiceException(org.jets3t.service.S3ServiceException) Test(org.junit.Test)

Example 57 with ServiceException

use of org.jets3t.service.ServiceException in project cyberduck by iterate-ch.

the class S3ExceptionMappingServiceTest method testIAMFailure.

@Test
public void testIAMFailure() {
    assertEquals("The IAM policy must allow the action s3:GetBucketLocation on the resource arn:aws:s3:::endpoint-9a527d70-d432-4601-b24b-735e721b82c9.", new S3ExceptionMappingService().map("The IAM policy must allow the action s3:GetBucketLocation on the resource arn:aws:s3:::endpoint-9a527d70-d432-4601-b24b-735e721b82c9", new ServiceException("message")).getMessage());
    assertEquals("Message. Please contact your web hosting service provider for assistance.", new S3ExceptionMappingService().map("The IAM policy must allow the action s3:GetBucketLocation on the resource arn:aws:s3:::endpoint-9a527d70-d432-4601-b24b-735e721b82c9", new ServiceException("message")).getDetail());
}
Also used : ServiceException(org.jets3t.service.ServiceException) S3ServiceException(org.jets3t.service.S3ServiceException) Test(org.junit.Test)

Example 58 with ServiceException

use of org.jets3t.service.ServiceException in project cyberduck by iterate-ch.

the class S3ExceptionMappingServiceTest method testLoginFailure403.

@Test
public void testLoginFailure403() {
    final ServiceException f = new ServiceException("m", "<null/>");
    f.setResponseCode(403);
    f.setErrorMessage("m");
    f.setErrorCode("AccessDenied");
    assertTrue(new S3ExceptionMappingService().map(f) instanceof AccessDeniedException);
    f.setErrorCode("InvalidAccessKeyId");
    assertTrue(new S3ExceptionMappingService().map(f) instanceof LoginFailureException);
    f.setErrorCode("SignatureDoesNotMatch");
    assertTrue(new S3ExceptionMappingService().map(f) instanceof LoginFailureException);
}
Also used : AccessDeniedException(ch.cyberduck.core.exception.AccessDeniedException) LoginFailureException(ch.cyberduck.core.exception.LoginFailureException) ServiceException(org.jets3t.service.ServiceException) S3ServiceException(org.jets3t.service.S3ServiceException) Test(org.junit.Test)

Example 59 with ServiceException

use of org.jets3t.service.ServiceException in project cyberduck by iterate-ch.

the class S3ExceptionMappingServiceTest method testCustomMessage.

@Test
public void testCustomMessage() {
    assertEquals("Custom.", new S3ExceptionMappingService().map("custom", new ServiceException("message")).getMessage());
    assertEquals("Message. Please contact your web hosting service provider for assistance.", new S3ExceptionMappingService().map("custom", new ServiceException("message")).getDetail());
}
Also used : ServiceException(org.jets3t.service.ServiceException) S3ServiceException(org.jets3t.service.S3ServiceException) Test(org.junit.Test)

Example 60 with ServiceException

use of org.jets3t.service.ServiceException in project alluxio by Alluxio.

the class GCSInputStream method openStream.

/**
 * Opens a new stream at mPos if the wrapped stream mInputStream is null.
 */
private void openStream() throws IOException {
    ServiceException lastException = null;
    String errorMessage = String.format("Failed to open key: %s bucket: %s", mKey, mBucketName);
    while (mRetryPolicy.attempt()) {
        try {
            GSObject object;
            if (mPos > 0) {
                object = mClient.getObject(mBucketName, mKey, null, null, null, null, mPos, null);
            } else {
                object = mClient.getObject(mBucketName, mKey);
            }
            mInputStream = new BufferedInputStream(object.getDataInputStream());
            return;
        } catch (ServiceException e) {
            errorMessage = String.format("Failed to open key: %s bucket: %s attempts: %d error: %s", mKey, mBucketName, mRetryPolicy.getAttemptCount(), e.getMessage());
            if (e.getResponseCode() != HttpStatus.SC_NOT_FOUND) {
                throw new IOException(errorMessage, e);
            }
            // Key does not exist
            lastException = e;
        }
    }
    // Failed after retrying key does not exist
    throw new IOException(errorMessage, lastException);
}
Also used : ServiceException(org.jets3t.service.ServiceException) GSObject(org.jets3t.service.model.GSObject) BufferedInputStream(java.io.BufferedInputStream) IOException(java.io.IOException)

Aggregations

ServiceException (org.jets3t.service.ServiceException)67 S3ServiceException (org.jets3t.service.S3ServiceException)24 Path (ch.cyberduck.core.Path)22 IOException (java.io.IOException)18 S3Object (org.jets3t.service.model.S3Object)16 StorageObject (org.jets3t.service.model.StorageObject)9 Test (org.junit.Test)9 AccessDeniedException (ch.cyberduck.core.exception.AccessDeniedException)8 InteroperabilityException (ch.cyberduck.core.exception.InteroperabilityException)8 NotfoundException (ch.cyberduck.core.exception.NotfoundException)8 ArrayList (java.util.ArrayList)7 BackgroundException (ch.cyberduck.core.exception.BackgroundException)6 MultipartUpload (org.jets3t.service.model.MultipartUpload)6 PathAttributes (ch.cyberduck.core.PathAttributes)4 HostPreferences (ch.cyberduck.core.preferences.HostPreferences)4 SegmentLoadingException (io.druid.segment.loading.SegmentLoadingException)4 BufferedInputStream (java.io.BufferedInputStream)4 InputStream (java.io.InputStream)4 AttributedList (ch.cyberduck.core.AttributedList)3 DefaultIOExceptionMappingService (ch.cyberduck.core.DefaultIOExceptionMappingService)3