Example usage for com.amazonaws.services.elastictranscoder.model PipelineOutputConfig getStorageClass

List of usage examples for com.amazonaws.services.elastictranscoder.model PipelineOutputConfig getStorageClass

Introduction

In this page you can find the example usage for com.amazonaws.services.elastictranscoder.model PipelineOutputConfig getStorageClass.

Prototype


public String getStorageClass() 

Source Link

Document

The Amazon S3 storage class, Standard or ReducedRedundancy, that you want Elastic Transcoder to assign to the video files and playlists that it stores in your Amazon S3 bucket.

Usage

From source file:org.alanwilliamson.amazon.transcoder.pipeline.Create.java

License:Open Source License

public cfData execute(cfSession _session, cfArgStructData argStruct) throws cfmRunTimeException {
    AmazonKey amazonKey = getAmazonKey(_session, argStruct);
    AmazonElasticTranscoder et = getAmazonElasticTranscoder(amazonKey);

    CreatePipelineRequest cpr = new CreatePipelineRequest();

    cpr.setName(getNamedStringParam(argStruct, "name", null));
    if (cpr.getName() == null || cpr.getName().isEmpty() || cpr.getName().length() > 40)
        throwException(_session, "please provide a valid name (40chars or less)");

    cpr.setInputBucket(getNamedStringParam(argStruct, "inputbucket", null));
    if (cpr.getInputBucket() == null || cpr.getInputBucket().isEmpty())
        throwException(_session, "please provide a valid inputbucket");

    cpr.setRole(getNamedStringParam(argStruct, "role", null));
    if (cpr.getRole() == null || cpr.getRole().isEmpty())
        throwException(_session, "please provide a valid role");

    cpr.setAwsKmsKeyArn(getNamedStringParam(argStruct, "awskey", null));
    if (cpr.getAwsKmsKeyArn() == null || cpr.getAwsKmsKeyArn().isEmpty())
        throwException(_session, "please provide a valid awskey");

    if (getNamedStringParam(argStruct, "outputbucket", null) != null) {

        cpr.setOutputBucket(getNamedStringParam(argStruct, "outputbucket", null));
        if (cpr.getOutputBucket().isEmpty())
            throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

    } else {/*from   ww  w . j av  a2 s.  c  o  m*/

        // Handle the ContentConfig
        cfStructData cc = getNamedStructParam(_session, argStruct, "contentconfig", null);
        if (cc == null)
            throwException(_session, "please provide a 'contentconfig' or a 'outputbucket'");

        PipelineOutputConfig contentConfig = new PipelineOutputConfig();

        contentConfig.setBucket(cc.getData("bucket").getString());
        if (contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty())
            throwException(_session, "please provide a 'contentconfig.bucket'");

        contentConfig.setStorageClass(cc.getData("storageclass").getString());
        if (contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty())
            throwException(_session, "please provide a 'contentconfig.storageclass'");

        Collection<Permission> permissions = getPermissions(_session, cc);
        if (!permissions.isEmpty())
            contentConfig.setPermissions(permissions);

        cpr.setContentConfig(contentConfig);

        // Handle the thumbnailconfig
        cc = getNamedStructParam(_session, argStruct, "thumbnailconfig", null);
        if (cc == null)
            throwException(_session, "please provide a 'thumbnailconfig' or a 'outputbucket'");

        contentConfig = new PipelineOutputConfig();

        contentConfig.setBucket(cc.getData("bucket").getString());
        if (contentConfig.getBucket() == null || contentConfig.getBucket().isEmpty())
            throwException(_session, "please provide a 'thumbnailconfig.bucket'");

        contentConfig.setStorageClass(cc.getData("storageclass").getString());
        if (contentConfig.getStorageClass() == null || contentConfig.getStorageClass().isEmpty())
            throwException(_session, "please provide a 'thumbnailconfig.storageclass'");

        permissions = getPermissions(_session, cc);
        if (!permissions.isEmpty())
            contentConfig.setPermissions(permissions);

        cpr.setThumbnailConfig(contentConfig);
    }

    // Now after collection all that; create the actual pipeline
    try {
        CreatePipelineResult cpres = et.createPipeline(cpr);
        return new cfStringData(cpres.getPipeline().getId());
    } catch (Exception e) {
        throwException(_session, "AmazonElasticTranscoder: " + e.getMessage());
        return cfBooleanData.TRUE;
    }
}

From source file:org.alanwilliamson.amazon.transcoder.pipeline.List.java

License:Open Source License

private cfStructData getConfig(PipelineOutputConfig config) throws cfmRunTimeException {
    cfStructData s = new cfStructData();

    s.setData("bucket", new cfStringData(config.getBucket()));
    s.setData("storageclass", new cfStringData(config.getStorageClass()));

    cfArrayData permissionArr = cfArrayData.createArray(1);
    Iterator<Permission> it = config.getPermissions().iterator();
    while (it.hasNext()) {
        Permission p = it.next();

        cfStructData ps = new cfStructData();

        ps.setData("grantee", new cfStringData(p.getGrantee()));
        ps.setData("granteetype", new cfStringData(p.getGranteeType()));

        cfArrayData accessArr = cfArrayData.createArray(1);
        Iterator<String> ait = p.getAccess().iterator();
        while (ait.hasNext())
            accessArr.addElement(new cfStringData(ait.next()));

        ps.setData("access", accessArr);
    }//from w w  w .ja v a  2s  .  co  m

    s.setData("permissions", permissionArr);

    return s;
}