From ddfa331a0635831838a1014bb7798c4569ee4a8d Mon Sep 17 00:00:00 2001
From: Brandon Clayton <bclayton@usgs.gov>
Date: Wed, 15 Jan 2025 15:28:03 -0700
Subject: [PATCH] clean

---
 gradle/dependencies.gradle                      |  3 ---
 .../earthquake/nshmp/www/SwaggerController.java | 17 ++++++++---------
 .../nshmp/www/hazard/DisaggController.java      | 12 ------------
 .../nshmp/www/hazard/HazardService.java         |  8 +++-----
 4 files changed, 11 insertions(+), 29 deletions(-)

diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index dbb0fcfa..b02ef3ff 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -37,7 +37,4 @@ dependencies {
   testImplementation "io.micronaut.test:micronaut-test-junit5"
   testImplementation "io.micronaut.test:micronaut-test-spock"
   testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
-
-  spotbugs("com.github.spotbugs:spotbugs:${spotbugsVersion}")
-  spotbugsPlugins("software.amazon.lambda.snapstart:aws-lambda-snapstart-java-rules:0.2.1")
 }
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java b/src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
index b9e0e029..c46a6cbd 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/www/SwaggerController.java
@@ -4,11 +4,14 @@ import java.math.BigDecimal;
 import java.util.List;
 import java.util.logging.Logger;
 
+import org.slf4j.LoggerFactory;
+
 import gov.usgs.earthquake.nshmp.geo.Location;
 import gov.usgs.earthquake.nshmp.model.HazardModel;
 import gov.usgs.earthquake.nshmp.www.source.FeaturesService;
 
 import io.micronaut.http.HttpRequest;
+import io.micronaut.http.HttpResponse;
 import io.micronaut.http.MediaType;
 import io.micronaut.http.annotation.Controller;
 import io.micronaut.http.annotation.Get;
@@ -36,16 +39,15 @@ public class SwaggerController {
   private NshmpMicronautServlet servlet;
 
   @Get(produces = MediaType.TEXT_EVENT_STREAM)
-  public String doGet(HttpRequest<?> request) {
+  public HttpResponse<String> doGet(HttpRequest<?> request) {
     try {
       var model = ServletUtil.model();
       var openApi = getOpenAPI(request, model);
-      return Yaml.pretty(openApi);
+      return HttpResponse.ok(Yaml.pretty(openApi));
     } catch (Exception e) {
-      return e.getMessage();
-      // return ServletUtil.error(
-      // LoggerFactory.getLogger("Swagger"),
-      // e, "Swagger", request.getUri().getPath());
+      return ServletUtil.error(
+      LoggerFactory.getLogger("Swagger"),
+      e, "Swagger", request.getUri().getPath());
     }
   }
 
@@ -55,9 +57,6 @@ public class SwaggerController {
     Logger log = Logger.getAnonymousLogger();
     var openApi = new OpenAPIV3Parser().read("META-INF/swagger/nshmp-haz.yml");
     var bounds = model.bounds();
-    log.info("Swagger endpoint");
-    // SwaggerUtils.addLocationBounds(openApi, bounds.min, bounds.max);
-    log.info("b");
     var components = openApi.getComponents();
     var schemas = components.getSchemas();
     SwaggerUtils.siteClassSchema(schemas, List.copyOf(model.siteClasses().keySet()));
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/DisaggController.java b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/DisaggController.java
index 29ee464e..2019f62c 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/DisaggController.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/DisaggController.java
@@ -2,10 +2,8 @@ package gov.usgs.earthquake.nshmp.www.hazard;
 
 import static com.google.common.base.Preconditions.checkArgument;
 
-import java.util.Arrays;
 import java.util.Map;
 import java.util.Set;
-import java.util.logging.Logger;
 
 import gov.usgs.earthquake.nshmp.calc.DataType;
 import gov.usgs.earthquake.nshmp.gmm.Imt;
@@ -65,9 +63,7 @@ public class DisaggController {
           schema = @Schema(implementation = MetadataResponse.class)))
   @Get(produces = MediaType.APPLICATION_JSON)
   public HttpResponse<String> doGetMetadata(HttpRequest<?> http) {
-    Logger log = Logger.getAnonymousLogger();
     try {
-      log.info("Disagg usage");
       return DisaggService.getMetadata(http);
     } catch (Exception e) {
       return ServletUtil.error(
@@ -112,21 +108,13 @@ public class DisaggController {
           maximum = "10000") @PathVariable double returnPeriod,
       @QueryValue @Nullable Set<Imt> imt,
       @QueryValue @Nullable Set<DisaggDataType> out) {
-    Logger log = Logger.getAnonymousLogger();
     try {
-      log.info("Disagg calla sda");
       Set<Imt> imts = HazardService.readImts(http);
       Set<DataType> dataTypes = HazardService.readDataTypes(http);
       DisaggService.RequestRp request = new DisaggService.RequestRp(
           http, longitude, latitude, vs30, imts, returnPeriod, dataTypes);
       return DisaggService.getDisaggRp(request);
     } catch (Exception e) {
-      log.info("Error asdasd:");
-      log.info(e.getMessage());
-
-      log.info("Disagg stack trace: ");
-      log.info(Arrays.toString(e.getStackTrace()));
-
       return ServletUtil.error(
           DisaggService.LOG, e,
           DisaggService.NAME,
diff --git a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java
index 37b435f6..1696f487 100644
--- a/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java
+++ b/src/main/java/gov/usgs/earthquake/nshmp/www/hazard/HazardService.java
@@ -63,18 +63,17 @@ public final class HazardService {
   private static final String TOTAL_KEY = "Total";
 
   public static HttpResponse<String> getMetadata(HttpRequest<?> request) {
-    var log = java.util.logging.Logger.getAnonymousLogger();
     var url = request.getUri().getPath();
     var model = ServletUtil.model();
-    log.info(model.name());
-    var usage = new Metadata(model);
+
     var body = ResponseBody.usage()
         .name(NAME)
         .url(url)
         .metadata(new ResponseMetadata(HazVersion.appVersions(ServletUtil.model().root())))
         .request(url)
-        .response(usage)
+        .response(new Metadata(model))
         .build();
+
     var json = ServletUtil.GSON2.toJson(body);
     return HttpResponse.ok(json);
   }
@@ -138,7 +137,6 @@ public final class HazardService {
     final DoubleParameter vs30;
 
     Metadata(HazardModel model) {
-      var log = java.util.logging.Logger.getAnonymousLogger();
       this.model = new SourceModel(model);
       longitude = new DoubleParameter(
           "Longitude",
-- 
GitLab