From f1cf2d5069929c3558b6666373d9f6bd5330e274 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Wed, 5 Jun 2013 17:38:34 +0200 Subject: [PATCH] DATAREST-83 - Controller classes aren't annotated with @Controller anymore. This is to prevent a parallel Spring MVC setup from picking up the controller classes in addition to the custom RequestHandlerMapping we deploy. Polished some compiler warnings on the way. --- .../AbstractRepositoryRestController.java | 1 - .../data/rest/webmvc/RepositoryController.java | 4 +--- .../rest/webmvc/RepositoryEntityController.java | 3 --- .../rest/webmvc/RepositorySearchController.java | 17 +++++++---------- 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java index e83ca129f..5bdee50f0 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/AbstractRepositoryRestController.java @@ -195,7 +195,6 @@ public class AbstractRepositoryRestController implements ApplicationContextAware * @param ex * @return */ - @SuppressWarnings({"unchecked"}) @ExceptionHandler({ OptimisticLockingFailureException.class, DataIntegrityViolationException.class diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java index c09b24e65..f53997ce1 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryController.java @@ -7,7 +7,6 @@ import org.springframework.data.repository.support.Repositories; import org.springframework.data.rest.config.RepositoryRestConfiguration; import org.springframework.data.rest.config.ResourceMapping; import org.springframework.hateoas.EntityLinks; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @@ -17,14 +16,13 @@ import static org.springframework.data.rest.repository.support.ResourceMappingUt /** * @author Jon Brisbin */ -@Controller @RequestMapping("/") public class RepositoryController extends AbstractRepositoryRestController { @Autowired public RepositoryController(Repositories repositories, RepositoryRestConfiguration config, - DomainClassConverter domainClassConverter, + DomainClassConverter domainClassConverter, ConversionService conversionService, EntityLinks entityLinks) { super(repositories, diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java index 2f0e5b033..3f04873dc 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositoryEntityController.java @@ -22,7 +22,6 @@ import org.springframework.hateoas.*; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.support.TransactionCallbackWithoutResult; import org.springframework.web.HttpRequestMethodNotSupportedException; @@ -40,7 +39,6 @@ import java.util.List; /** * @author Jon Brisbin */ -@Controller @RequestMapping("/{repository}") @SuppressWarnings({"rawtypes"}) public class RepositoryEntityController extends AbstractRepositoryRestController { @@ -74,7 +72,6 @@ public class RepositoryEntityController extends AbstractRepositoryRestController return jsonSchemaConverter.convert(repoRequest.getPersistentEntity().getType()); } - @SuppressWarnings({"unchecked"}) @RequestMapping( method = RequestMethod.GET, produces = { diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java index 87d0f0ca3..6e5c14e77 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/RepositorySearchController.java @@ -24,7 +24,6 @@ import org.springframework.hateoas.Link; import org.springframework.hateoas.Resource; import org.springframework.hateoas.ResourceSupport; import org.springframework.hateoas.Resources; -import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; @@ -33,13 +32,12 @@ import org.springframework.web.bind.annotation.ResponseBody; /** * @author Jon Brisbin */ -@Controller @RequestMapping("/{repository}/search") public class RepositorySearchController extends AbstractRepositoryRestController { public RepositorySearchController(Repositories repositories, RepositoryRestConfiguration config, - DomainClassConverter domainClassConverter, + DomainClassConverter domainClassConverter, ConversionService conversionService, EntityLinks entityLinks) { super(repositories, @@ -67,7 +65,6 @@ public class RepositorySearchController extends AbstractRepositoryRestController return new Resource(Collections.emptyList(), links); } - @SuppressWarnings({"unchecked"}) @RequestMapping( value = "/{method}", method = RequestMethod.GET, @@ -137,10 +134,10 @@ public class RepositorySearchController extends AbstractRepositoryRestController Link prevLink = null; Link nextLink = null; if(result instanceof Page) { - if(((Page)result).hasPreviousPage() && pageSort.getPageNumber() > 0) { + if(((Page)result).hasPreviousPage() && pageSort.getPageNumber() > 0) { prevLink = searchLink(repoRequest, 0, method, "page.previous"); } - if(((Page)result).hasNextPage()) { + if(((Page)result).hasNextPage()) { nextLink = searchLink(repoRequest, 1, method, "page.next"); } } @@ -164,15 +161,15 @@ public class RepositorySearchController extends AbstractRepositoryRestController ResourceSupport resource = query(repoRequest, repository, method); links.addAll(resource.getLinks()); - if(resource instanceof Resources && ((Resources)resource).getContent() != null) { - for(Object obj : ((Resources)resource).getContent()) { + if(resource instanceof Resources && ((Resources) resource).getContent() != null) { + for(Object obj : ((Resources) resource).getContent()) { if(null != obj && obj instanceof Resource) { - Resource res = (Resource)obj; + Resource res = (Resource)obj; links.add(resourceLink(repoRequest, res)); } } } else if(resource instanceof Resource) { - Resource res = (Resource)resource; + Resource res = (Resource) resource; links.add(resourceLink(repoRequest, res)); }