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

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

Introduction

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

Prototype


public String getBucket() 

Source Link

Document

The Amazon S3 bucket in which you want Elastic Transcoder to save the transcoded files.

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 {/*  w w w .j  a  va  2s  . co  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   ww w . j ava2  s .c om

    s.setData("permissions", permissionArr);

    return s;
}