@CliOption(key = { "class", "" }, mandatory = true, help = "The path and name of the controller object to be created") final JavaType controller,
@CliOption(key = "backingType", mandatory = false, optionContext = PROJECT, unspecifiedDefaultValue = "*", help = "The name of the form backing type which the controller exposes to the web tier") final JavaType backingType,
@CliOption(key = "path", mandatory = false, help = "The base path under which the controller listens for RESTful requests (defaults to the simple name of the form backing object)") String path,
@CliOption(key = "disallowedOperations", mandatory = false, help = "A comma separated list of operations (only create, update, delete allowed) that should not be generated in the controller") final String disallowedOperations) {
final ClassOrInterfaceTypeDetails cid = typeLocationService
.getTypeDetails(backingType);
if (cid == null) {
LOGGER.warning("The specified entity can not be resolved to a type in your project");
return;
}
if (controller.getSimpleTypeName().equalsIgnoreCase(
backingType.getSimpleTypeName())) {
LOGGER.warning("Controller class name needs to be different from the class name of the form backing object (suggestion: '"
+ backingType.getSimpleTypeName() + "Controller')");
return;
}
final Set<String> disallowedOperationSet = new HashSet<String>();
if (!"".equals(disallowedOperations)) {
final String[] disallowedOperationsTokens = new StrTokenizer(
disallowedOperations, ",").getTokenArray();
for (final String operation : disallowedOperationsTokens) {
if (!("create".equals(operation) || "update".equals(operation) || "delete"
.equals(operation))) {
LOGGER.warning("-disallowedOperations options can only contain 'create', 'update', 'delete': -disallowedOperations update,delete");
return;
}
disallowedOperationSet.add(operation.toLowerCase());
}
}
if (StringUtils.isBlank(path)) {
final LogicalPath targetPath = PhysicalTypeIdentifier.getPath(cid
.getDeclaredByMetadataId());
final PluralMetadata pluralMetadata = (PluralMetadata) metadataService
.get(PluralMetadata.createIdentifier(backingType,
targetPath));
Validate.notNull(pluralMetadata,