Skip to content
Snippets Groups Projects
Commit f9a4ccf0 authored by Tucker Gary Siegel's avatar Tucker Gary Siegel
Browse files

spotlessApply

parent 9e6de316
No related branches found
No related tags found
No related merge requests found
package edu.umd.dawn.common.entities;
import edu.umd.dawn.common.exceptions.DawnException;
import edu.umd.dawn.common.exceptions.DawnExceptionParameters;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
......@@ -87,10 +85,11 @@ public class User {
locations.stream().filter(location -> !location.equals(id)).collect(Collectors.toList());
if (newList.size() == locations.size()) {
throw new DawnException(new DawnExceptionParameters(400, "BAD_REQUEST", "location id provided does not exist", ""));
throw new DawnException(
new DawnExceptionParameters(400, "BAD_REQUEST", "location id provided does not exist", ""));
}
setLocations(newList);
return id;
}
}
\ No newline at end of file
}
package edu.umd.dawn.common.enums;
import edu.umd.dawn.common.exceptions.DawnException;
import edu.umd.dawn.common.exceptions.BaseExceptions;
import edu.umd.dawn.common.exceptions.DawnException;
import java.util.Map;
public enum Product {
......
......@@ -10,15 +10,15 @@ public class BaseExceptions {
public static final DawnExceptionParameters BAD_REQUEST =
new DawnExceptionParameters(400, "BAD_REQUEST", "Invalid request submitted", "");
public static final DawnExceptionParameters INTERNAL_SERVER_ERROR =
new DawnExceptionParameters(500, "INTERNAL_SERVER_ERROR", "Internal server error", "");
public static final DawnExceptionParameters OUT_OF_BOUNDS =
new DawnExceptionParameters(500, "INTERNAL_SERVER_ERROR", "Internal server error", "out of bounds");
public static final DawnExceptionParameters UNHANDLED_INTERNAL_SERVER_ERROR =
new DawnExceptionParameters(500, "INTERNAL_SERVER_ERROR", "Internal server error", "unhandled error");
public static final DawnExceptionParameters SERVICE_UNAVAILABLE =
public static final DawnExceptionParameters SERVICE_UNAVAILABLE =
new DawnExceptionParameters(503, "SERVICE_UNAVAILABLE", "service unavailable", "");
public static final DawnExceptionParameters FORBIDDEN =
......@@ -36,6 +36,6 @@ public class BaseExceptions {
return new DawnExceptionParameters(400, "BAD_REQUEST", String.format("offset of %d is invalid", offset), "");
}
public static final DawnExceptionParameters PRODUCT_UNSUPPORTED = new DawnExceptionParameters(
400, "BAD_REQUEST", "This operation is unsupported for provided product", "");
public static final DawnExceptionParameters PRODUCT_UNSUPPORTED =
new DawnExceptionParameters(400, "BAD_REQUEST", "This operation is unsupported for provided product", "");
}
......@@ -4,7 +4,6 @@ import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.ConversionNotSupportedException;
......@@ -36,21 +35,20 @@ import org.springframework.web.servlet.NoHandlerFoundException;
public class CustomExceptionHandler {
private final Map<Class<?>, DawnExceptionParameters> MVC_EXCEPTION_MAP = Map.ofEntries(
Map.entry(HttpRequestMethodNotSupportedException.class, BaseExceptions.METHOD_NOT_ALLOWED),
Map.entry(HttpMediaTypeNotSupportedException.class, BaseExceptions.UNSUPPORTED_MEDIA_TYPE),
Map.entry(HttpMediaTypeNotAcceptableException.class, BaseExceptions.NOT_ACCEPTABLE),
Map.entry(MissingPathVariableException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(MissingServletRequestParameterException.class, BaseExceptions.BAD_REQUEST),
Map.entry(ServletRequestBindingException.class, BaseExceptions.BAD_REQUEST),
Map.entry(ConversionNotSupportedException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(TypeMismatchException.class, BaseExceptions.BAD_REQUEST),
Map.entry(HttpMessageNotReadableException.class, BaseExceptions.BAD_REQUEST),
Map.entry(HttpMessageNotWritableException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(MethodArgumentNotValidException.class, BaseExceptions.BAD_REQUEST),
Map.entry(MissingServletRequestPartException.class, BaseExceptions.BAD_REQUEST),
Map.entry(NoHandlerFoundException.class, BaseExceptions.NOT_FOUND),
Map.entry(AsyncRequestTimeoutException.class, BaseExceptions.SERVICE_UNAVAILABLE)
);
Map.entry(HttpRequestMethodNotSupportedException.class, BaseExceptions.METHOD_NOT_ALLOWED),
Map.entry(HttpMediaTypeNotSupportedException.class, BaseExceptions.UNSUPPORTED_MEDIA_TYPE),
Map.entry(HttpMediaTypeNotAcceptableException.class, BaseExceptions.NOT_ACCEPTABLE),
Map.entry(MissingPathVariableException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(MissingServletRequestParameterException.class, BaseExceptions.BAD_REQUEST),
Map.entry(ServletRequestBindingException.class, BaseExceptions.BAD_REQUEST),
Map.entry(ConversionNotSupportedException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(TypeMismatchException.class, BaseExceptions.BAD_REQUEST),
Map.entry(HttpMessageNotReadableException.class, BaseExceptions.BAD_REQUEST),
Map.entry(HttpMessageNotWritableException.class, BaseExceptions.INTERNAL_SERVER_ERROR),
Map.entry(MethodArgumentNotValidException.class, BaseExceptions.BAD_REQUEST),
Map.entry(MissingServletRequestPartException.class, BaseExceptions.BAD_REQUEST),
Map.entry(NoHandlerFoundException.class, BaseExceptions.NOT_FOUND),
Map.entry(AsyncRequestTimeoutException.class, BaseExceptions.SERVICE_UNAVAILABLE));
@Value("${config.serviceName}")
private String source;
......@@ -107,7 +105,7 @@ public class CustomExceptionHandler {
ArrayIndexOutOfBoundsException exception, WebRequest webRequest) {
return wrapExceptionAs(exception, BaseExceptions.OUT_OF_BOUNDS);
}
@ExceptionHandler(DawnException.class)
public ResponseEntity<Object> handleDawnExceptions(DawnException exception, WebRequest webRequest) {
return returnDawnException(exception);
......@@ -153,6 +151,6 @@ public class CustomExceptionHandler {
@ExceptionHandler(Throwable.class)
public ResponseEntity<Object> handleUnHandledException(Throwable exception, WebRequest webRequest) {
return wrapExceptionAs((Exception)exception, BaseExceptions.UNHANDLED_INTERNAL_SERVER_ERROR);
return wrapExceptionAs((Exception) exception, BaseExceptions.UNHANDLED_INTERNAL_SERVER_ERROR);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment