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);
}
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());
}
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);
}
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());
}
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);
}
Aggregations