List of usage examples for com.amazonaws AmazonServiceException getErrorMessage
public String getErrorMessage()
From source file:aws.example.s3.XferMgrDownload.java
License:Open Source License
public static void downloadFile(String bucket_name, String key_name, String file_path, boolean pause) { System.out.println("Downloading to file: " + file_path + (pause ? " (pause)" : "")); File f = new File(file_path); TransferManager xfer_mgr = new TransferManager(); try {//from w w w .j a v a2 s . co m Download xfer = xfer_mgr.download(bucket_name, key_name, f); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
From source file:aws.example.s3.XferMgrProgress.java
License:Open Source License
public static void uploadDirWithSubprogress(String dir_path, String bucket_name, String key_prefix, boolean recursive, boolean pause) { System.out/*from w ww. j a v a 2 s .c o m*/ .println("directory: " + dir_path + (recursive ? " (recursive)" : "") + (pause ? " (pause)" : "")); TransferManager xfer_mgr = new TransferManager(); try { MultipleFileUpload multi_upload = xfer_mgr.uploadDirectory(bucket_name, key_prefix, new File(dir_path), recursive); // loop with Transfer.isDone() XferMgrProgress.showMultiUploadProgress(multi_upload); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(multi_upload); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
From source file:aws.example.s3.XferMgrUpload.java
License:Open Source License
public static void uploadDir(String dir_path, String bucket_name, String key_prefix, boolean recursive, boolean pause) { System.out// w ww. ja v a2 s . c o m .println("directory: " + dir_path + (recursive ? " (recursive)" : "") + (pause ? " (pause)" : "")); TransferManager xfer_mgr = new TransferManager(); try { MultipleFileUpload xfer = xfer_mgr.uploadDirectory(bucket_name, key_prefix, new File(dir_path), recursive); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
From source file:aws.example.s3.XferMgrUpload.java
License:Open Source License
public static void uploadFileList(String[] file_paths, String bucket_name, String key_prefix, boolean pause) { System.out.println("file list: " + Arrays.toString(file_paths) + (pause ? " (pause)" : "")); // convert the file paths to a list of File objects (required by the // uploadFileList method) ArrayList<File> files = new ArrayList<File>(); for (String path : file_paths) { files.add(new File(path)); }// w w w .java 2s. com TransferManager xfer_mgr = new TransferManager(); try { MultipleFileUpload xfer = xfer_mgr.uploadFileList(bucket_name, key_prefix, new File("."), files); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
From source file:aws.example.s3.XferMgrUpload.java
License:Open Source License
public static void uploadFile(String file_path, String bucket_name, String key_prefix, boolean pause) { System.out.println("file: " + file_path + (pause ? " (pause)" : "")); String key_name = null;//from ww w.jav a 2s . co m if (key_prefix != null) { key_name = key_prefix + '/' + file_path; } else { key_name = file_path; } File f = new File(file_path); TransferManager xfer_mgr = new TransferManager(); try { Upload xfer = xfer_mgr.upload(bucket_name, key_name, f); // loop with Transfer.isDone() XferMgrProgress.showTransferProgress(xfer); // or block with Transfer.waitForCompletion() XferMgrProgress.waitForCompletion(xfer); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } xfer_mgr.shutdownNow(); }
From source file:br.com.ingenieux.mojo.cloudformation.cmd.WaitForStackCommand.java
License:Apache License
private Optional<DescribeStackEventsResult> getDescribeStackEventsResult(DescribeStackEventsRequest req) { try {//from ww w . j a va 2s . c o m return Optional.of(ctx.getClient().describeStackEvents(req)); } catch (AmazonServiceException e) { if (e.getErrorMessage().contains("does not exist")) { return Optional.empty(); } else { throw e; } } }
From source file:br.com.ingenieux.mojo.cloudformation.PushStackMojo.java
License:Apache License
private UpdateStackResult updateStack() throws Exception { UpdateStackRequest req = new UpdateStackRequest().withStackName(stackName) .withCapabilities(Capability.CAPABILITY_IAM); if (null != this.destinationS3Uri) { req.withTemplateURL(generateExternalUrl(this.destinationS3Uri)); } else {/*from w ww. j a va 2s. c o m*/ req.withTemplateBody(templateBody); } req.withNotificationARNs(notificationArns); req.withParameters(parameters); req.withResourceTypes(resourceTypes); req.withTags(tags); try { return getService().updateStack(req); } catch (AmazonServiceException exc) { if ("No updates are to be performed.".equals(exc.getErrorMessage())) { return null; } throw exc; } }
From source file:ca.paullalonde.gocd.sns_plugin.executors.StageStatusRequestExecutor.java
License:Apache License
protected void sendNotification() throws Exception { PluginSettings pluginSettings = pluginRequest.getPluginSettings(); String topic = pluginSettings.getTopic(); if ((topic != null) && !topic.isEmpty()) { AmazonSNS sns = makeSns(pluginSettings); try {/*from w w w.j a v a 2s . c o m*/ sns.publish(topic, request.toJSON()); } catch (AmazonServiceException e) { String message = String.format( "StageStatusRequestExecutor : Cannot publish to SNS topic, error code = '%s', message = '%s'.", e.getErrorCode(), e.getErrorMessage()); LOG.error(message); } catch (AmazonClientException e) { String message = String.format( "StageStatusRequestExecutor : Cannot publish to SNS topic, message = '%s'.", e.getMessage()); LOG.error(message); } } else { LOG.debug("StageStatusRequestExecutor : Cannot publish to SNS because the topic is missing."); } }
From source file:ch.cyberduck.core.iam.AmazonServiceExceptionMappingService.java
License:Open Source License
@Override public BackgroundException map(final AmazonClientException e) { final StringBuilder buffer = new StringBuilder(); if (e instanceof AmazonServiceException) { final AmazonServiceException failure = (AmazonServiceException) e; this.append(buffer, failure.getErrorMessage()); switch (failure.getStatusCode()) { case HttpStatus.SC_BAD_REQUEST: switch (failure.getErrorCode()) { case "AccessDeniedException": return new AccessDeniedException(buffer.toString(), e); case "UnrecognizedClientException": return new LoginFailureException(buffer.toString(), e); }/*from w ww .j av a 2 s.com*/ return new InteroperabilityException(buffer.toString(), e); case HttpStatus.SC_METHOD_NOT_ALLOWED: return new InteroperabilityException(buffer.toString(), e); case HttpStatus.SC_FORBIDDEN: switch (failure.getErrorCode()) { case "SignatureDoesNotMatch": return new LoginFailureException(buffer.toString(), e); case "InvalidAccessKeyId": return new LoginFailureException(buffer.toString(), e); case "InvalidClientTokenId": return new LoginFailureException(buffer.toString(), e); case "InvalidSecurity": return new LoginFailureException(buffer.toString(), e); case "MissingClientTokenId": return new LoginFailureException(buffer.toString(), e); case "MissingAuthenticationToken": return new LoginFailureException(buffer.toString(), e); } return new AccessDeniedException(buffer.toString(), e); case HttpStatus.SC_UNAUTHORIZED: return new LoginFailureException(buffer.toString(), e); case HttpStatus.SC_NOT_FOUND: return new NotfoundException(buffer.toString(), e); case HttpStatus.SC_SERVICE_UNAVAILABLE: return new ConnectionRefusedException(buffer.toString(), e); } } this.append(buffer, e.getMessage()); return this.wrap(e, buffer); }
From source file:cloudExplorer.Acl.java
License:Open Source License
void setAccess(String id, int what, String access_key, String secret_key, String endpoint, String bucket) { try {//www . ja va 2 s .c o m Collection<Grant> grantCollection = new ArrayList<Grant>(); AWSCredentials credentials = new BasicAWSCredentials(access_key, secret_key); AmazonS3 s3Client = new AmazonS3Client(credentials, new ClientConfiguration().withSignerOverride("S3SignerType")); s3Client.setEndpoint(endpoint); AccessControlList bucketAcl = s3Client.getBucketAcl(bucket); Grant grant = null; if (what == 0) { grant = new Grant(new CanonicalGrantee(id), Permission.Read); grantCollection.add(grant); } if (what == 1) { grant = new Grant(new CanonicalGrantee(id), Permission.FullControl); grantCollection.add(grant); } if (what == 3) { bucketAcl.getGrants().clear(); } bucketAcl.getGrants().addAll(grantCollection); s3Client.setBucketAcl(bucket, bucketAcl); } catch (AmazonServiceException ase) { NewJFrame.jTextArea1.append("\n\nError: " + ase.getErrorMessage()); } }