Java Code Examples for com.amazonaws.services.s3.model.ObjectMetadata.setUserMetadata()

The following are Jave code examples for showing how to use setUserMetadata() of the com.amazonaws.services.s3.model.ObjectMetadata class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: ibm-cos-sdk-java   File: CopyCallable.java   Source Code and License Vote up 6 votes
private void populateMetadataWithEncryptionParams(ObjectMetadata source, ObjectMetadata destination) {
    Map<String, String> userMetadataSource = source.getUserMetadata();
    Map<String, String> userMetadataDestination = destination.getUserMetadata();

    String[] headersToCopy = { Headers.CRYPTO_CEK_ALGORITHM,
            Headers.CRYPTO_IV, Headers.CRYPTO_KEY, Headers.CRYPTO_KEY_V2,
            Headers.CRYPTO_KEYWRAP_ALGORITHM, Headers.CRYPTO_TAG_LENGTH,
            Headers.MATERIALS_DESCRIPTION,
            Headers.UNENCRYPTED_CONTENT_LENGTH,
            Headers.UNENCRYPTED_CONTENT_MD5 };

    if (userMetadataSource != null) {
        if(userMetadataDestination == null){
            userMetadataDestination= new HashMap<String,String>();
            destination.setUserMetadata(userMetadataDestination);
        }

        String headerValue;
        for(String header : headersToCopy){
            headerValue = userMetadataSource.get(header);
            if(headerValue != null){
                userMetadataDestination.put(header, headerValue);
            }
        }
    }
}