Search in sources :

Example 96 with ObjectMetadata

use of com.talend.shaded.com.amazonaws.services.s3.model.ObjectMetadata in project ice by Netflix.

the class BasicS3ApplicationGroupService method saveApplicationGroup.

public boolean saveApplicationGroup(ApplicationGroup appgroup) {
    Map<String, ApplicationGroup> appgroups = getApplicationGroups();
    appgroups.put(appgroup.name, appgroup);
    try {
        String json = getJson(appgroups);
        s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "appgroups", IOUtils.toInputStream(json), new ObjectMetadata());
        s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "copy_appgroups", IOUtils.toInputStream(json), new ObjectMetadata());
        BasicS3ApplicationGroupService.logger.info("saved appgroup " + appgroup);
        return true;
    } catch (JSONException e) {
        logger.error("Error saving appgroup " + appgroup, e);
        return false;
    }
}
Also used : ApplicationGroup(com.netflix.ice.reader.ApplicationGroup) JSONException(org.json.JSONException) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)

Example 97 with ObjectMetadata

use of com.talend.shaded.com.amazonaws.services.s3.model.ObjectMetadata in project ice by Netflix.

the class BasicS3ApplicationGroupService method deleteApplicationGroup.

public boolean deleteApplicationGroup(String name) {
    Map<String, ApplicationGroup> appgroups = getApplicationGroups();
    ApplicationGroup appgroup = appgroups.remove(name);
    try {
        String json = getJson(appgroups);
        s3Client.putObject(config.workS3BucketName, config.workS3BucketPrefix + "appgroups", new ByteArrayInputStream(json.getBytes()), new ObjectMetadata());
        BasicS3ApplicationGroupService.logger.info("delete appgroup " + name + " " + appgroup);
        return true;
    } catch (JSONException e) {
        logger.error("Error deleting appgroup " + appgroup, e);
        return false;
    }
}
Also used : ApplicationGroup(com.netflix.ice.reader.ApplicationGroup) ByteArrayInputStream(java.io.ByteArrayInputStream) JSONException(org.json.JSONException) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)

Example 98 with ObjectMetadata

use of com.talend.shaded.com.amazonaws.services.s3.model.ObjectMetadata in project exhibitor by soabase.

the class S3Utils method simpleUploadFile.

public static ObjectMetadata simpleUploadFile(S3Client client, byte[] bytes, String bucket, String key) throws Exception {
    byte[] md5 = md5(bytes, bytes.length);
    ObjectMetadata metadata = new ObjectMetadata();
    metadata.setContentLength(bytes.length);
    metadata.setLastModified(new Date());
    metadata.setContentMD5(S3Utils.toBase64(md5));
    PutObjectRequest putObjectRequest = new PutObjectRequest(bucket, key, new ByteArrayInputStream(bytes), metadata);
    PutObjectResult putObjectResult = client.putObject(putObjectRequest);
    if (!putObjectResult.getETag().equals(S3Utils.toHex(md5))) {
        throw new Exception("Unable to match MD5 for config");
    }
    return metadata;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) PutObjectResult(com.amazonaws.services.s3.model.PutObjectResult) ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata) Date(java.util.Date) PutObjectRequest(com.amazonaws.services.s3.model.PutObjectRequest)

Example 99 with ObjectMetadata

use of com.talend.shaded.com.amazonaws.services.s3.model.ObjectMetadata in project uPortal by Jasig.

the class AwsS3DynamicSkinService method innerSkinCssFileExists.

@Override
protected boolean innerSkinCssFileExists(DynamicSkinInstanceData data) {
    final String objectKey = this.getCssObjectKey(data);
    log.info(ATTEMPTING_TO_GET_FILE_METADATA_FROM_AWS_S3_LOG_MSG, this.awsS3BucketConfig.getBucketName(), objectKey);
    final ObjectMetadata metadata = this.getMetadataFromAwsS3Bucket(objectKey);
    log.info(FILE_METADATA_RETRIEVED_FROM_AWS_S3_LOG_MSG, this.awsS3BucketConfig.getBucketName(), objectKey);
    if (metadata == null) {
        return false;
    } else {
        final String uniqueTokenFromS3 = metadata.getUserMetaDataOf(SKIN_UNIQUE_TOKEN_METADATA_KEY);
        return this.getUniqueToken(data).equals(uniqueTokenFromS3);
    }
}
Also used : ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)

Example 100 with ObjectMetadata

use of com.talend.shaded.com.amazonaws.services.s3.model.ObjectMetadata in project uPortal by Jasig.

the class AwsS3DynamicSkinService method createObjectMetadata.

private ObjectMetadata createObjectMetadata(final String content, final DynamicSkinInstanceData data) {
    final ObjectMetadata metadata = new ObjectMetadata();
    this.addContentMetadata(metadata, content);
    this.addUserMetatadata(metadata);
    this.addPortletPreferenceMetadata(metadata, data.getPortletRequest().getPreferences());
    this.addDynamicSkinMetadata(metadata, data);
    return metadata;
}
Also used : ObjectMetadata(com.amazonaws.services.s3.model.ObjectMetadata)

Aggregations

ObjectMetadata (com.amazonaws.services.s3.model.ObjectMetadata)163 PutObjectRequest (com.amazonaws.services.s3.model.PutObjectRequest)76 ByteArrayInputStream (java.io.ByteArrayInputStream)52 Test (org.junit.Test)47 IOException (java.io.IOException)33 File (java.io.File)27 AmazonClientException (com.amazonaws.AmazonClientException)25 AmazonServiceException (com.amazonaws.AmazonServiceException)22 S3FileTransferRequestParamsDto (org.finra.herd.model.dto.S3FileTransferRequestParamsDto)21 InputStream (java.io.InputStream)20 DataStoreException (org.apache.jackrabbit.core.data.DataStoreException)18 PutObjectResult (com.amazonaws.services.s3.model.PutObjectResult)15 Upload (com.amazonaws.services.s3.transfer.Upload)15 CopyObjectRequest (com.amazonaws.services.s3.model.CopyObjectRequest)11 AmazonS3Client (com.amazonaws.services.s3.AmazonS3Client)10 Date (java.util.Date)9 BusinessObjectDataKey (org.finra.herd.model.api.xml.BusinessObjectDataKey)9 Copy (com.amazonaws.services.s3.transfer.Copy)8 S3Object (com.amazonaws.services.s3.model.S3Object)7 InterruptedIOException (java.io.InterruptedIOException)7