Example usage for com.amazonaws.services.elasticbeanstalk.model ApplicationVersionDescription getDateCreated

List of usage examples for com.amazonaws.services.elasticbeanstalk.model ApplicationVersionDescription getDateCreated

Introduction

In this page you can find the example usage for com.amazonaws.services.elasticbeanstalk.model ApplicationVersionDescription getDateCreated.

Prototype


public java.util.Date getDateCreated() 

Source Link

Document

The creation date of the application version.

Usage

From source file:br.com.ingenieux.mojo.beanstalk.AbstractNeedsEnvironmentMojo.java

License:Apache License

protected String lookupVersionLabel(String appName, String versionLabel) {
    if (StringUtils.isBlank(versionLabel)) {
        DescribeApplicationVersionsResult appVersionsResult = getService().describeApplicationVersions(
                new DescribeApplicationVersionsRequest().withApplicationName(appName));

        List<ApplicationVersionDescription> appVersionList = new ArrayList<ApplicationVersionDescription>(
                appVersionsResult.getApplicationVersions());

        Collections.sort(appVersionList, new Comparator<ApplicationVersionDescription>() {
            @Override//  w w w.ja  v  a2  s.  co  m
            public int compare(ApplicationVersionDescription o1, ApplicationVersionDescription o2) {
                return new CompareToBuilder().append(o2.getDateUpdated(), o1.getDateUpdated())
                        .append(o2.getDateCreated(), o1.getDateUpdated()).toComparison();
            }
        });

        if (appVersionList.isEmpty()) {
            String message = "No version label supplied **AND** no app versions available.";

            getLog().info(message);

            throw new IllegalStateException(message);
        } else {
            versionLabel = appVersionList.get(0).getVersionLabel();

            getLog().info("Using latest available application version " + versionLabel);
        }
    }

    return versionLabel;
}