Java Code Examples for org.jets3t.service.ServiceException#getCause()
The following examples show how to use
org.jets3t.service.ServiceException#getCause() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Jets3tFileSystemStore.java From hadoop with Apache License 2.0 | 5 votes |
private void handleServiceException(ServiceException e) throws IOException { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { if(LOG.isDebugEnabled()) { LOG.debug("Got ServiceException with Error code: " + e.getErrorCode() + ";and Error message: " + e.getErrorMessage()); } } }
Example 2
Source File: Jets3tFileSystemStore.java From big-c with Apache License 2.0 | 5 votes |
private void handleServiceException(ServiceException e) throws IOException { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } else { if(LOG.isDebugEnabled()) { LOG.debug("Got ServiceException with Error code: " + e.getErrorCode() + ";and Error message: " + e.getErrorMessage()); } } }
Example 3
Source File: S3ExceptionMappingService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
@Override public BackgroundException map(final ServiceException e) { if(e.getCause() instanceof ServiceException) { return this.map((ServiceException) e.getCause()); } final StringBuilder buffer = new StringBuilder(); if(StringUtils.isNotBlank(e.getErrorMessage())) { // S3 protocol message parsed from XML this.append(buffer, StringEscapeUtils.unescapeXml(e.getErrorMessage())); } else { this.append(buffer, e.getResponseStatus()); this.append(buffer, e.getMessage()); } switch(e.getResponseCode()) { case HttpStatus.SC_FORBIDDEN: if(StringUtils.isNotBlank(e.getErrorCode())) { switch(e.getErrorCode()) { case "SignatureDoesNotMatch": case "InvalidAccessKeyId": case "InvalidClientTokenId": case "InvalidSecurity": case "MissingClientTokenId": case "MissingAuthenticationToken": return new LoginFailureException(buffer.toString(), e); } } case HttpStatus.SC_BAD_REQUEST: if(StringUtils.isNotBlank(e.getErrorCode())) { switch(e.getErrorCode()) { case "RequestTimeout": return new ConnectionTimeoutException(buffer.toString(), e); case "ExpiredToken": case "InvalidToken": return new ExpiredTokenException(buffer.toString(), e); } } } if(e.getCause() instanceof IOException) { return new DefaultIOExceptionMappingService().map((IOException) e.getCause()); } if(e.getCause() instanceof SAXException) { return new InteroperabilityException(buffer.toString(), e); } if(-1 == e.getResponseCode()) { return new InteroperabilityException(buffer.toString(), e); } return new DefaultHttpResponseExceptionMappingService().map(new HttpResponseException(e.getResponseCode(), buffer.toString())); }
Example 4
Source File: RequestEntityRestStorageService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
@Override protected StorageObjectsChunk listObjectsInternal( String bucketName, String prefix, String delimiter, long maxListingLength, boolean automaticallyMergeChunks, String priorLastKey) throws ServiceException { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("encoding-type", "url"); if(prefix != null) { parameters.put("prefix", prefix); } if(delimiter != null) { parameters.put("delimiter", delimiter); } if(maxListingLength > 0) { parameters.put("max-keys", String.valueOf(maxListingLength)); } List<StorageObject> objects = new ArrayList<StorageObject>(); List<String> commonPrefixes = new ArrayList<String>(); boolean incompleteListing = true; int ioErrorRetryCount = 0; while(incompleteListing) { if(priorLastKey != null) { parameters.put("marker", priorLastKey); } else { parameters.remove("marker"); } HttpResponse httpResponse = performRestGet(bucketName, null, parameters, null); XmlResponsesSaxParser.ListBucketHandler listBucketHandler; try { listBucketHandler = getXmlResponseSaxParser() .parseListBucketResponse( new HttpMethodReleaseInputStream(httpResponse)); ioErrorRetryCount = 0; } catch(ServiceException e) { if(e.getCause() instanceof IOException && ioErrorRetryCount < 5) { ioErrorRetryCount++; log.warn("Retrying bucket listing failure due to IO error", e); continue; } else { throw e; } } StorageObject[] partialObjects = listBucketHandler.getObjects(); if(log.isDebugEnabled()) { log.debug("Found " + partialObjects.length + " objects in one batch"); } objects.addAll(Arrays.asList(partialObjects)); String[] partialCommonPrefixes = listBucketHandler.getCommonPrefixes(); if(log.isDebugEnabled()) { log.debug("Found " + partialCommonPrefixes.length + " common prefixes in one batch"); } commonPrefixes.addAll(Arrays.asList(partialCommonPrefixes)); incompleteListing = listBucketHandler.isListingTruncated(); if(incompleteListing) { priorLastKey = listBucketHandler.getMarkerForNextListing(); if(log.isDebugEnabled()) { log.debug("Yet to receive complete listing of bucket contents, " + "last key for prior chunk: " + priorLastKey); } } else { priorLastKey = null; } if(!automaticallyMergeChunks) { break; } } if(automaticallyMergeChunks) { if(log.isDebugEnabled()) { log.debug("Found " + objects.size() + " objects in total"); } return new StorageObjectsChunk( prefix, delimiter, objects.toArray(new StorageObject[objects.size()]), commonPrefixes.toArray(new String[commonPrefixes.size()]), null); } else { return new StorageObjectsChunk( prefix, delimiter, objects.toArray(new StorageObject[objects.size()]), commonPrefixes.toArray(new String[commonPrefixes.size()]), priorLastKey); } }