Example usage for com.amazonaws.services.elastictranscoder.model CreatePipelineRequest getInputBucket

List of usage examples for com.amazonaws.services.elastictranscoder.model CreatePipelineRequest getInputBucket

Introduction

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

Prototype


public String getInputBucket() 

Source Link

Document

The Amazon S3 bucket in which you saved the media files that you want to transcode.

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  . jav  a2  s  . c  om*/

        // 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;
    }
}