webMvcOperations.installConversionService(controller.getPackage());
List<AnnotationMetadataBuilder> annotations = null;
ClassOrInterfaceTypeDetailsBuilder cidBuilder = null;
if (existingController == null) {
final LogicalPath controllerPath = pathResolver
.getFocusedPath(Path.SRC_MAIN_JAVA);
final String resourceIdentifier = typeLocationService
.getPhysicalTypeCanonicalPath(controller, controllerPath);
final String declaredByMetadataId = PhysicalTypeIdentifier
.createIdentifier(controller,
pathResolver.getPath(resourceIdentifier));
// Create annotation @RequestMapping("/myobject/**")
final List<AnnotationAttributeValue<?>> requestMappingAttributes = new ArrayList<AnnotationAttributeValue<?>>();
requestMappingAttributes.add(new StringAttributeValue(VALUE, "/"
+ path));
annotations = new ArrayList<AnnotationMetadataBuilder>();
annotations.add(new AnnotationMetadataBuilder(REQUEST_MAPPING,
requestMappingAttributes));
// Create annotation @Controller
final List<AnnotationAttributeValue<?>> controllerAttributes = new ArrayList<AnnotationAttributeValue<?>>();
annotations.add(new AnnotationMetadataBuilder(CONTROLLER,
controllerAttributes));
// Create annotation @RooWebScaffold(path = "/test",
// formBackingObject = MyObject.class)
annotations.add(getRooWebScaffoldAnnotation(entity,
disallowedOperations, path, PATH));
cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
declaredByMetadataId, Modifier.PUBLIC, controller,
PhysicalTypeCategory.CLASS);
}
else {
cidBuilder = new ClassOrInterfaceTypeDetailsBuilder(
existingController);
annotations = cidBuilder.getAnnotations();
if (MemberFindingUtils.getAnnotationOfType(
existingController.getAnnotations(), ROO_WEB_SCAFFOLD) == null) {
annotations.add(getRooWebScaffoldAnnotation(entity,
disallowedOperations, path, PATH));
}
}
cidBuilder.setAnnotations(annotations);
typeManagementService.createOrUpdateTypeOnDisk(cidBuilder.build());
}