@Override protected StorageBucket newBucket() { return new S3Bucket(); }
@Override protected StorageBucket newBucket() { return new S3Bucket(); }
protected StorageBucket newBucket() { if (isGoogleStorageMode) { return new GSBucket(); } else { return new S3Bucket(); } }
protected StorageBucket newBucket() { if (isGoogleStorageMode) { return new GSBucket(); } else { return new S3Bucket(); } }
/** * * @param containerName * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#deleteContainer(java.lang.String) */ public void deleteContainer(String containerName) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); LOG.debug("Delete bucket '{}'", containerName); try { s3Service.deleteBucket(new S3Bucket(containerName)); } catch (S3ServiceException e) { throw new StorageCommunicationException("Bucket deletion problem", e); } }
/** * * @param containerName * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#createContainer(java.lang.String) */ public void createContainer(String containerName) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); try { s3Service.createBucket(new S3Bucket(containerName)); } catch (S3ServiceException e) { throw new StorageCommunicationException("Bucket creation problem", e); } }
/** * * @param containerName * @param objectName * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#deleteObject(java.lang.String, * java.lang.String) */ public void deleteObject(String containerName, String objectName) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); LOG.debug("Delete object '{}' in bucket '{}'", objectName, containerName); try { s3Service.deleteObject(new S3Bucket(containerName), objectName); } catch (S3ServiceException e) { throw new StorageCommunicationException("Bucket deletion problem", e); } }
/** * * @param containerName * @param objectName * @return * @throws StorageCommunicationException * @throws StorageResponseHandlingException * @see org.opencredo.cloud.storage.StorageOperations#receiveAsInputStream(java.lang.String, * java.lang.String) */ public InputStream receiveAsInputStream(String containerName, String objectName) throws StorageCommunicationException, StorageResponseHandlingException { Assert.notNull(containerName, "Bucket name cannot be null"); Assert.hasText(objectName, "Blob name must be set"); LOG.debug("Receive input-stream from bucket '{}' with key '{}'", containerName, objectName); try { return s3Service.getObject(new S3Bucket(containerName), objectName).getDataInputStream(); } catch (S3ServiceException e) { throw new StorageCommunicationException("Receiving input stream problem", e); } }
@Override public void initialize(URI uri, Configuration conf) throws IOException { S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { handleException(e); } multipartEnabled = conf.getBoolean("fs.s3n.multipart.uploads.enabled", false); multipartBlockSize = Math.min( conf.getLong("fs.s3n.multipart.uploads.block.size", 64 * 1024 * 1024), MAX_PART_SIZE); multipartCopyBlockSize = Math.min( conf.getLong("fs.s3n.multipart.copy.block.size", MAX_PART_SIZE), MAX_PART_SIZE); serverSideEncryptionAlgorithm = conf.get("fs.s3n.server-side-encryption-algorithm"); bucket = new S3Bucket(uri.getHost()); }
/** * * @param containerName * @param objectName * @param fileToSend * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#send(java.lang.String, * java.lang.String, java.io.File) */ public void send(String containerName, String objectName, File fileToSend) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name can not be null"); Assert.hasText(objectName, "Blob name must be set"); Assert.notNull(fileToSend, "File to send can not be null"); if (LOG.isDebugEnabled()) { LOG.debug("Send file '{}' to bucket '{}' with key '{}'", new Object[] { fileToSend.getAbsolutePath(), containerName, objectName }); } try { S3Object object = new S3Object(fileToSend); object.setKey(objectName); s3Service.putObject(new S3Bucket(containerName), object); } catch (S3ServiceException e) { throw new StorageCommunicationException("Sending file problem", e); } catch (NoSuchAlgorithmException e) { throw new StorageCommunicationException("No such algorithm", e); } catch (IOException e) { throw new StorageCommunicationException("Sending string IO problem", e); } }
/** * * @param containerName * @param objectName * @param stringToSend * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#send(java.lang.String, * java.lang.String, java.lang.String) */ public void send(String containerName, String objectName, String stringToSend) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); Assert.hasText(objectName, "Blob name must be set"); LOG.debug("Send string to bucket '{}' with key '{}'", containerName, objectName); try { s3Service.putObject(new S3Bucket(containerName), new S3Object(objectName, stringToSend)); } catch (S3ServiceException e) { throw new StorageCommunicationException("Sending string problem", e); } catch (NoSuchAlgorithmException e) { throw new StorageCommunicationException("No such algorithm", e); } catch (IOException e) { throw new StorageCommunicationException("Sending string IO problem", e); } }
/** * * @param containerName * @return * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#listContainerObjectDetails(java.lang.String) */ public List<BlobDetails> listContainerObjectDetails(String containerName) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); LOG.debug("Get objects list for bucket '{}'", containerName); try { S3Object[] s3Objects = this.s3Service.listObjects(new S3Bucket(containerName)); List<BlobDetails> keys = new ArrayList<BlobDetails>(s3Objects.length); for (S3Object s : s3Objects) { keys.add(new BlobDetails(s.getBucketName(), s.getKey(), s.getETag(), s.getLastModifiedDate())); } return keys; } catch (S3ServiceException e) { throw new StorageCommunicationException("Failed to get bucket " + containerName + " object details.", e); } }
/** * Adds a bucket not owned by the current S3 user to the bucket listing, after * prompting the user for the name of the bucket to add. * To be added in this way, the third-party bucket must be publicly available. * */ private void addThirdPartyBucket() { try { String bucketName = JOptionPane.showInputDialog(ownerFrame, "Name for third-party bucket:", "Add a third-party bucket", JOptionPane.QUESTION_MESSAGE); if (bucketName != null) { if (s3ServiceMulti.getS3Service().isBucketAccessible(bucketName)) { S3Bucket thirdPartyBucket = new S3Bucket(bucketName); bucketTableModel.addBucket(thirdPartyBucket, false); } else { String message = "Unable to access third-party bucket: " + bucketName; log.error(message); ErrorDialog.showDialog(ownerFrame, this, message, null); } } } catch (RuntimeException e) { throw e; } catch (Exception e) { String message = "Unable to access third-party bucket"; log.error(message, e); ErrorDialog.showDialog(ownerFrame, this, message, e); } }
/** * * @param containerName * @param objectName * @param is * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#send(java.lang.String, * java.lang.String, java.io.InputStream) */ public void send(String containerName, String objectName, InputStream is) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); Assert.hasText(objectName, "Blob name must be set"); LOG.debug("Send input-stream to bucket '{}' with key '{}'", containerName, objectName); try { S3Object s3ObjectToSend = new S3Object(objectName); s3ObjectToSend.setDataInputStream(is); s3ObjectToSend.setContentLength(is.available()); s3Service.putObject(new S3Bucket(containerName), s3ObjectToSend); } catch (IOException e) { throw new StorageCommunicationException("Sending input stream IO problem", e); } catch (S3ServiceException e) { throw new StorageCommunicationException("Sending input stream problem", e); } }
public void initialize(URI uri, Configuration conf) throws IOException { this.conf = conf; S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } bucket = new S3Bucket(uri.getHost()); this.bufferSize = conf.getInt("io.file.buffer.size", 4096); }
@Override public void initialize(URI uri, Configuration conf) throws IOException { this.conf = conf; S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } bucket = new S3Bucket(uri.getHost()); this.bufferSize = conf.getInt( S3FileSystemConfigKeys.S3_STREAM_BUFFER_SIZE_KEY, S3FileSystemConfigKeys.S3_STREAM_BUFFER_SIZE_DEFAULT ); }
public void initialize(URI uri, Configuration conf) throws IOException { S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } bucket = new S3Bucket(uri.getHost()); }
public void initialize(URI uri, Configuration conf) throws IOException { this.conf = conf; S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } bucket = new S3Bucket(uri.getHost()); createBucket(bucket.getName()); this.bufferSize = conf.getInt("io.file.buffer.size", 4096); }
/** * Action to create a new bucket in S3 after prompting the user for a bucket name. * */ private void createBucketAction() { String proposedNewName = s3ServiceMulti.getAWSCredentials().getAccessKey().toLowerCase() + "." + "bucket-name"; CreateBucketDialog dialog = new CreateBucketDialog(proposedNewName, ownerFrame, this); dialog.setVisible(true); if (!dialog.getOkClicked()) { return; } final S3Bucket newBucket = new S3Bucket(dialog.getBucketName(), dialog.getBucketLocation()); dialog.dispose(); runInBackgroundThread(new Runnable() { public void run() { if (s3ServiceMulti.createBuckets(new S3Bucket[] { newBucket })) { int modelIndex = bucketTableModel.getBucketIndexByName(newBucket.getName()); int viewIndex = bucketTableModelSorter.viewIndex(modelIndex); bucketsTable.setRowSelectionInterval(viewIndex, viewIndex); } } }); }
public void initialize(URI uri, Configuration conf) throws IOException { S3Credentials s3Credentials = new S3Credentials(); s3Credentials.initialize(uri, conf); try { AWSCredentials awsCredentials = new AWSCredentials(s3Credentials.getAccessKey(), s3Credentials.getSecretAccessKey()); this.s3Service = new RestS3Service(awsCredentials); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } bucket = new S3Bucket(uri.getHost()); createBucket(bucket.getName()); }