Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 44 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.5.15</version>
<relativePath/> <!-- lookup parent from repository -->
<version>4.0.7</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>gov.epa.ccte.api</groupId>
<artifactId>hazard</artifactId>
Expand All @@ -15,19 +16,18 @@
<description>project for hazard data</description>
<properties>
<java.version>17</java.version>
<testcontainers.version>1.17.6</testcontainers.version>
<lombok.version>1.18.30</lombok.version>
<mapstruct.version>1.5.3.Final</mapstruct.version>
<sentry.version>8.18.0</sentry.version>
<lombok.version>1.18.46</lombok.version>
<mapstruct.version>1.6.3</mapstruct.version>
<sentry.version>8.49.0</sentry.version>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/USEPA/ccte-api-hazard</url>
</repository>
</distributionManagement>
<repository>
<id>github</id>
<name>GitHub OWNER Apache Maven Packages</name>
<url>https://maven.pkg.github.com/USEPA/ccte-api-hazard</url>
</repository>
</distributionManagement>

<dependencies>

Expand All @@ -38,7 +38,7 @@

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<artifactId>spring-boot-starter-webmvc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
Expand Down Expand Up @@ -67,6 +67,11 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</dependency>
<!-- &lt;!&ndash; Exception handler - ref https://www.baeldung.com/problem-spring-web &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.zalando</groupId>-->
Expand All @@ -84,11 +89,11 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- Swagger/OpenAPI doc -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.8.8</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>3.0.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.pivotal.cfenv/java-cfenv-boot -->
<dependency>
<groupId>io.pivotal.cfenv</groupId>
Expand All @@ -98,13 +103,13 @@
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.3.Final</version>
<version>1.6.3</version>
</dependency>
<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-starter-jakarta</artifactId>
<version>${sentry.version}</version>
</dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry-spring-boot-4-starter</artifactId>
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
Expand All @@ -117,23 +122,13 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-testcontainers</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -142,9 +137,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-hibernate6</artifactId>
<version>2.15.2</version>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand All @@ -160,8 +155,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source> <!-- or higher, depending on your project -->
<target>${java.version}</target> <!-- or higher, depending on your project -->
<!-- or higher, depending on your project -->
<!-- or higher, depending on your project -->
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand All @@ -178,13 +173,19 @@
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${project.parent.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.suppressGeneratorTimestamp=true</arg>
<arg>-Amapstruct.defaultComponentModel=spring</arg>
</compilerArgs>
<release>${java.version}</release>
</configuration>
</plugin>
</plugins>
</build>
</project>
</project>
27 changes: 19 additions & 8 deletions src/main/java/gov/epa/ccte/api/hazard/HazardApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.webmvc.autoconfigure.error.ErrorMvcAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
Expand Down Expand Up @@ -79,11 +79,18 @@ private static void logApplicationStartup(Environment env) {
log.warn("The host name could not be determined, using `localhost` as fallback");
}
log.info(
"\n----------------------------------------------------------\n\t" +
"Application '{}' is running! Access URLs:\n\t" +
"Local: \t\t{}://localhost:{}{}\n\t" +
"External: \t{}://{}:{}{}\n\t" +
"Profile(s): \t{}\n----------------------------------------------------------",
"""

----------------------------------------------------------
\t\
Application '{}' is running! Access URLs:
\t\
Local: \t\t{}://localhost:{}{}
\t\
External: \t{}://{}:{}{}
\t\
Profile(s): \t{}
----------------------------------------------------------""",
env.getProperty("spring.application.name"),
protocol,
serverPort,
Expand All @@ -100,8 +107,12 @@ private static void logApplicationStartup(Environment env) {
configServerStatus = "Not found or not setup for this application";
}
log.info(
"\n----------------------------------------------------------\n\t" +
"Config Server: \t{}\n----------------------------------------------------------",
"""

----------------------------------------------------------
\t\
Config Server: \t{}
----------------------------------------------------------""",
configServerStatus
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,9 @@
package gov.epa.ccte.api.hazard.config;

import com.fasterxml.jackson.datatype.hibernate6.Hibernate6Module;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JacksonConfiguration {

/**
* Support for Java date and time API.
* @return the corresponding Jackson module.
*/
@Bean
public JavaTimeModule javaTimeModule() {
return new JavaTimeModule();
}

@Bean
public Jdk8Module jdk8TimeModule() {
return new Jdk8Module();
}

/*
* Support for Hibernate types in Jackson.
*/
@Bean
public Hibernate6Module hibernate6Module() {
return new Hibernate6Module();
}
}
// Intentionally empty: Hibernate Jackson module wiring is disabled until
// dependency versions are aligned with Spring Boot 4.x.
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gov.epa.ccte.api.hazard.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.cfg.MapperBuilder;
import gov.epa.ccte.api.hazard.config.converter.StringToImageFormatConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.support.ConfigurableConversionService;
Expand Down Expand Up @@ -49,8 +50,8 @@ public void configureHttpMessageConverters(List<HttpMessageConverter<?>> message
}

@Override
public void configureJacksonObjectMapper(ObjectMapper objectMapper) {
RepositoryRestConfigurer.super.configureJacksonObjectMapper(objectMapper);
public void configureJacksonObjectMapper(MapperBuilder<? extends ObjectMapper, ? extends MapperBuilder<?, ?>> objectMapperBuilder) {
RepositoryRestConfigurer.super.configureJacksonObjectMapper(objectMapperBuilder);
}

@Override
Expand All @@ -62,4 +63,4 @@ public AuditableBeanWrapperFactory customizeAuditableBeanWrapperFactory(Auditabl
public LinkCollector customizeLinkCollector(LinkCollector collector) {
return RepositoryRestConfigurer.super.customizeLinkCollector(collector);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.NativeQuery;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -18,7 +18,7 @@ public interface AdmeRepository extends JpaRepository<Adme, Integer>{
@Transactional(readOnly = true)
<T>List<T> findByDtxsid(String dtxsid, Class<T> type);

@Query(value = """
@NativeQuery("""
SELECT
adme.dtxsid,
adme.measured,
Expand Down Expand Up @@ -49,7 +49,7 @@ public interface AdmeRepository extends JpaRepository<Adme, Integer>{
adme.mv_ivive adme
WHERE
adme.dtxsid = :dtxsid
""", nativeQuery = true)
""")
List<CcdADME> findByDtxsidWithLabelColumn(@Param("dtxsid")String dtxsid);

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import gov.epa.ccte.api.hazard.projection.CcdGenetoxDetail;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.NativeQuery;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.transaction.annotation.Transactional;
Expand All @@ -19,7 +19,7 @@ public interface GenetoxDetailRepository extends JpaRepository<GenetoxDetail, In

<T> List<T> findByDtxsidInOrderByDtxsidAsc(String[] dtxsids, Class<T> type);

@Query(value = """
@NativeQuery("""
SELECT
genetox.dtxsid,
genetox.source,
Expand All @@ -34,6 +34,6 @@ public interface GenetoxDetailRepository extends JpaRepository<GenetoxDetail, In
toxval.mv_genetox_details genetox
WHERE
genetox.dtxsid = :dtxsid
""", nativeQuery = true)
""")
List<CcdGenetoxDetail> findByDtxsidWithConcatenatedColumn(@Param("dtxsid")String dtxsid);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gov.epa.ccte.api.hazard.security;

import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;

import gov.epa.ccte.api.hazard.web.rest.error.AuthorizationProblem;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -28,7 +30,7 @@ public class ApiKeyRequestFilter extends GenericFilterBean {

private final ConcurrentHashMap<UUID, String> keyStore;// = new ConcurrentHashMap();
private final ConcurrentHashMap<String, String> approvedOriginStore;// = new ConcurrentHashMap();
private final ObjectMapper mapper = new ObjectMapper();
private final ObjectMapper mapper = new JsonMapper();
private final String keyName;

public ApiKeyRequestFilter(ConcurrentHashMap<UUID, String> keyStore,
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/gov/epa/ccte/api/hazard/web/rest/AdmeApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import gov.epa.ccte.api.hazard.domain.Adme;
Expand Down Expand Up @@ -40,7 +39,7 @@ public interface AdmeApi {
@ApiResponse(responseCode = "200", description = "OK", content = @Content(mediaType = "application/json",
schema = @Schema(oneOf = { Adme.class, CcdADME.class}))),
})
@RequestMapping(value = "hazard/adme-ivive/search/by-dtxsid/{dtxsid}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@GetMapping(value = "hazard/adme-ivive/search/by-dtxsid/{dtxsid}", produces = MediaType.APPLICATION_JSON_VALUE)
List<?> admeDataByDtxsid(@Parameter(required = true, description = "DSSTox Substance Identifier", example = "DTXSID7020182")
@PathVariable("dtxsid") String dtxsid,
@Parameter(description = "Specifies if projection is used. Option: ccd-adme-data. " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public List<?> admeDataByDtxsid(String dtxsid, String projection) {
default -> repository.findByDtxsid(dtxsid, Adme.class);
};

if (result instanceof List<?>) {
return (List<?>) result;
if (result instanceof List<?> list) {
return list;
} else if (result != null) {
return List.of(result);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ public List<?> getGenetoxDetailsByDtxsid(String dtxsid, String projection) {
default -> detailRepository.findByDtxsidOrderBySourceAsc(dtxsid, CcdGenetoxDetail.class);
};

if (result instanceof List<?>) {
return (List<?>) result;
if (result instanceof List<?> list) {
return list;
} else if (result != null) {
return List.of(result);
} else {
Expand Down
Loading