Example usage for org.springframework.boot.cli.command.init ProjectType getAction

List of usage examples for org.springframework.boot.cli.command.init ProjectType getAction

Introduction

In this page you can find the example usage for org.springframework.boot.cli.command.init ProjectType getAction.

Prototype

String getAction() 

Source Link

Usage

From source file:org.springframework.boot.cli.command.init.ProjectGenerationRequest.java

/**
 * Generates the URI to use to generate a project represented by this request.
 * @param metadata the metadata that describes the service
 * @return the project generation URI/* w  w w. j a  v a  2  s  . co m*/
 */
URI generateUrl(InitializrServiceMetadata metadata) {
    try {
        URIBuilder builder = new URIBuilder(this.serviceUrl);
        StringBuilder sb = new StringBuilder();
        if (builder.getPath() != null) {
            sb.append(builder.getPath());
        }

        ProjectType projectType = determineProjectType(metadata);
        this.type = projectType.getId();
        sb.append(projectType.getAction());
        builder.setPath(sb.toString());

        if (!this.dependencies.isEmpty()) {
            builder.setParameter("dependencies",
                    StringUtils.collectionToCommaDelimitedString(this.dependencies));
        }

        if (this.groupId != null) {
            builder.setParameter("groupId", this.groupId);
        }
        String resolvedArtifactId = resolveArtifactId();
        if (resolvedArtifactId != null) {
            builder.setParameter("artifactId", resolvedArtifactId);
        }
        if (this.version != null) {
            builder.setParameter("version", this.version);
        }
        if (this.name != null) {
            builder.setParameter("name", this.name);
        }
        if (this.description != null) {
            builder.setParameter("description", this.description);
        }
        if (this.packageName != null) {
            builder.setParameter("packageName", this.packageName);
        }
        if (this.type != null) {
            builder.setParameter("type", projectType.getId());
        }
        if (this.packaging != null) {
            builder.setParameter("packaging", this.packaging);
        }
        if (this.javaVersion != null) {
            builder.setParameter("javaVersion", this.javaVersion);
        }
        if (this.language != null) {
            builder.setParameter("language", this.language);
        }
        if (this.bootVersion != null) {
            builder.setParameter("bootVersion", this.bootVersion);
        }

        return builder.build();
    } catch (URISyntaxException e) {
        throw new ReportableException("Invalid service URL (" + e.getMessage() + ")");
    }
}