- Change to start using bootstrap grid

This commit is contained in:
Paulo Gustavo Veiga
2012-09-10 23:51:53 -03:00
parent 6efc068a6c
commit 3fb746f79b
23 changed files with 316 additions and 375 deletions

View File

@@ -18,9 +18,7 @@
package com.wisemapping.rest;
import com.wisemapping.exceptions.AccessDeniedSecurityException;
import com.wisemapping.exceptions.ClientException;
import com.wisemapping.filter.UserAgent;
import com.wisemapping.mail.NotificationService;
import com.wisemapping.model.User;
import com.wisemapping.rest.model.RestErrors;
@@ -69,10 +67,11 @@ public class BaseController {
return ex.getMessage();
}
@ExceptionHandler(ValidationException.class)
@ExceptionHandler(JsonHttpMessageNotReadableException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public RestErrors handleValidationErrors(@NotNull ValidationException ex) {
return new RestErrors(ex.getErrors(), messageSource);
public String handleValidationErrors(@NotNull JsonHttpMessageNotReadableException ex) {
return "Request could not be saved. Message is not valid";
}
@ExceptionHandler(java.lang.reflect.UndeclaredThrowableException.class)

View File

@@ -12,7 +12,7 @@ import java.io.InputStream;
public class DebugMappingJacksonHttpMessageConverter extends MappingJacksonHttpMessageConverter {
@Override
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException {
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws IOException, JsonHttpMessageNotReadableException {
final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody());
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders());
@@ -21,20 +21,14 @@ public class DebugMappingJacksonHttpMessageConverter extends MappingJacksonHttpM
return super.readInternal(clazz, wrap);
} catch (org.springframework.http.converter.HttpMessageNotReadableException e) {
throw new HttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
throw new JsonHttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
}
catch (IOException e) {
throw new HttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
throw new JsonHttpMessageNotReadableException("Request Body:\n" + new String(bytes, "UTF-8"), e);
}
}
}
class HttpMessageNotReadableException extends org.springframework.http.converter.HttpMessageNotReadableException {
public HttpMessageNotReadableException(String msg, Exception cause) {
super(msg, cause);
}
}
class WrapHttpInputMessage implements HttpInputMessage {
private InputStream body;

View File

@@ -0,0 +1,8 @@
package com.wisemapping.rest;
class JsonHttpMessageNotReadableException extends org.springframework.http.converter.HttpMessageNotReadableException {
public JsonHttpMessageNotReadableException(String msg, Exception cause) {
super(msg, cause);
}
}

View File

@@ -1,27 +0,0 @@
package com.wisemapping.rest;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import java.util.List;
@EnableWebMvc
@Configuration
public class RestMvcConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureMessageConverters(@NotNull final List<HttpMessageConverter<?>> converters) {
converters.add(converter());
super.configureMessageConverters(converters);
}
@Bean
MappingJacksonHttpMessageConverter converter() {
return new DebugMappingJacksonHttpMessageConverter();
}
}