From f9a4ccf00d16143bfeab3af0342fd0ae5b57b80c Mon Sep 17 00:00:00 2001
From: Tucker Siegel <tgsiegel@terpmail.umd.edu>
Date: Mon, 17 Apr 2023 15:26:24 -0400
Subject: [PATCH] spotlessApply

---
 .../edu/umd/dawn/common/entities/User.java    |  7 ++--
 .../edu/umd/dawn/common/enums/Product.java    |  2 +-
 .../common/exceptions/BaseExceptions.java     | 10 +++---
 .../exceptions/CustomExceptionHandler.java    | 34 +++++++++----------
 4 files changed, 25 insertions(+), 28 deletions(-)

diff --git a/src/main/java/edu/umd/dawn/common/entities/User.java b/src/main/java/edu/umd/dawn/common/entities/User.java
index 7a7eedc..1262fe1 100644
--- a/src/main/java/edu/umd/dawn/common/entities/User.java
+++ b/src/main/java/edu/umd/dawn/common/entities/User.java
@@ -1,9 +1,7 @@
 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
+}
diff --git a/src/main/java/edu/umd/dawn/common/enums/Product.java b/src/main/java/edu/umd/dawn/common/enums/Product.java
index 94083a9..aa4440b 100644
--- a/src/main/java/edu/umd/dawn/common/enums/Product.java
+++ b/src/main/java/edu/umd/dawn/common/enums/Product.java
@@ -1,7 +1,7 @@
 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 {
diff --git a/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java b/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java
index 141384b..09ed60f 100644
--- a/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java
+++ b/src/main/java/edu/umd/dawn/common/exceptions/BaseExceptions.java
@@ -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", "");
 }
diff --git a/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java b/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java
index 33e711a..4a5a593 100644
--- a/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java
+++ b/src/main/java/edu/umd/dawn/common/exceptions/CustomExceptionHandler.java
@@ -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);
     }
 }
-- 
GitLab