DATAREST-182 - Removed obsolete wirings from AbstractRepositoryRestController.

Removed the wirings for PlatformTransactionManager and ValidationExceptionHandler from AbstractRepositoryRestController. Removed the latter entirely as it doesn't seem to be used anywhere anyway.
This commit is contained in:
Oliver Gierke
2014-06-24 23:38:16 +02:00
parent dc695eecd1
commit 8618b7df8e
3 changed files with 0 additions and 44 deletions

View File

@@ -25,7 +25,6 @@ import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.context.MessageSourceAware;
import org.springframework.context.support.MessageSourceAccessor;
@@ -37,7 +36,6 @@ import org.springframework.data.rest.core.RepositoryConstraintViolationException
import org.springframework.data.rest.core.mapping.ResourceMetadata;
import org.springframework.data.rest.webmvc.support.ExceptionMessage;
import org.springframework.data.rest.webmvc.support.RepositoryConstraintViolationExceptionMessage;
import org.springframework.data.rest.webmvc.support.ValidationExceptionHandler;
import org.springframework.data.web.PagedResourcesAssembler;
import org.springframework.hateoas.Link;
import org.springframework.hateoas.Resource;
@@ -47,7 +45,6 @@ import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -61,9 +58,6 @@ class AbstractRepositoryRestController implements MessageSourceAware {
private static final Logger LOG = LoggerFactory.getLogger(AbstractRepositoryRestController.class);
@Autowired(required = false) private ValidationExceptionHandler handler;
@Autowired(required = false) private PlatformTransactionManager txMgr;
private final PagedResourcesAssembler<Object> pagedResourcesAssembler;
private MessageSourceAccessor messageSourceAccessor;

View File

@@ -35,7 +35,6 @@ import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.Lazy;
import org.springframework.context.support.MessageSourceAccessor;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
@@ -81,7 +80,6 @@ import org.springframework.data.rest.webmvc.support.DefaultedPageableHandlerMeth
import org.springframework.data.rest.webmvc.support.HttpMethodHandlerMethodArgumentResolver;
import org.springframework.data.rest.webmvc.support.JpaHelper;
import org.springframework.data.rest.webmvc.support.RepositoryEntityLinks;
import org.springframework.data.rest.webmvc.support.ValidationExceptionHandler;
import org.springframework.data.util.AnnotatedTypeScanner;
import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver;
import org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver;
@@ -131,8 +129,6 @@ import com.fasterxml.jackson.databind.SerializationFeature;
@Import(SpringDataJacksonConfiguration.class)
public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebConfiguration {
private static final boolean IS_JAVAX_VALIDATION_AVAILABLE = ClassUtils.isPresent(
"javax.validation.ConstraintViolationException", RepositoryRestMvcConfiguration.class.getClassLoader());
private static final boolean IS_JPA_AVAILABLE = ClassUtils.isPresent("javax.persistence.EntityManager",
RepositoryRestMvcConfiguration.class.getClassLoader());
@@ -206,16 +202,6 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon
return listener;
}
@Bean
@Lazy
public ValidationExceptionHandler validationExceptionHandler() {
if (IS_JAVAX_VALIDATION_AVAILABLE) {
return new ValidationExceptionHandler();
} else {
return null;
}
}
@Bean
public JpaHelper jpaHelper() {
if (IS_JPA_AVAILABLE) {

View File

@@ -1,24 +0,0 @@
package org.springframework.data.rest.webmvc.support;
import java.util.Locale;
import javax.validation.ConstraintViolationException;
import org.springframework.context.MessageSource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
/**
* @author Jon Brisbin
*/
public class ValidationExceptionHandler {
public ResponseEntity<?> handleValidationException(RuntimeException ex, MessageSource msgsrc, Locale locale) {
Assert.isAssignable(ConstraintViolationException.class, ex.getClass());
return new ResponseEntity<ConstraintViolationExceptionMessage>(new ConstraintViolationExceptionMessage(
(ConstraintViolationException) ex, msgsrc, locale), HttpStatus.BAD_REQUEST
);
}
}