in grails-forge-api/src/main/java/org/grails/forge/api/preview/PreviewController.java [79:115]
public PreviewDTO previewApp(
ApplicationType type,
String name,
@Nullable List<String> features,
@Nullable BuildTool build,
@Nullable TestFramework test,
@Nullable GormImpl gorm,
@Nullable ServletImpl servlet,
@Nullable JdkVersion javaVersion,
@Parameter(hidden = true) RequestInfo requestInfo) throws IOException {
try {
Project project = NameUtils.parse(name);
MapOutputHandler outputHandler = new MapOutputHandler();
projectGenerator.generate(type,
project,
new Options(
test != null ? test.toTestFramework() : null,
gorm == null ? GormImpl.DEFAULT_OPTION : gorm,
servlet == null ? ServletImpl.DEFAULT_OPTION : servlet,
javaVersion == null ? JdkVersion.DEFAULT_OPTION : javaVersion,
getOperatingSystem(requestInfo.getUserAgent())),
getOperatingSystem(requestInfo.getUserAgent()),
features == null ? Collections.emptyList() : features,
outputHandler,
ConsoleOutput.NOOP);
Map<String, String> contents = outputHandler.getProject();
PreviewDTO previewDTO = new PreviewDTO(contents);
previewDTO.addLink(Relationship.CREATE, requestInfo.link(Relationship.CREATE, type));
previewDTO.addLink(Relationship.SELF, requestInfo.self());
return previewDTO;
} catch (IllegalArgumentException e) {
throw new HttpStatusException(HttpStatus.BAD_REQUEST, e.getMessage());
} catch (Exception e) {
LOG.error("Error generating application: " + e.getMessage(), e);
throw new IOException(e.getMessage(), e);
}
}