Skip to content

Commit

Permalink
no-extra-semi er skrudd av
Browse files Browse the repository at this point in the history
  • Loading branch information
beeccy committed Apr 11, 2024
2 parents 2ad3a65 + 9d18c6d commit 9d586ea
Show file tree
Hide file tree
Showing 246 changed files with 1,972 additions and 6,641 deletions.
2 changes: 1 addition & 1 deletion apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ RUN java -Djarmode=layertools -jar application.jar extract

FROM navikt/java:18

ENV MAIN_CLASS=org.springframework.boot.loader.JarLauncher
ENV MAIN_CLASS=org.springframework.boot.loader.launch.JarLauncher
ENV JAVA_OPTS="-Xmx850m \
-Djava.security.egd=file:/dev/./urandom"
COPY run-java.sh /
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/nais/backend-dev-gcp-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ ingresses:
- https://etterlevelse-api.intern.dev.nav.no
replies:
- https://etterlevelse-api.intern.dev.nav.no/oauth2/callback
- https://etterlevelse.ansatt.dev.nav.no/oauth2/callback
- https://etterlevelse.intern.dev.nav.no/oauth2/callback
- http://localhost:8080/oauth2/callback
- http://localhost:3000/oauth2/callback
teamcat_ingress: teamkatalog-api.intern.dev.nav.no
env:
- name: ETTERLEV_SECURITY_REDIRECT_URIS
value: https://etterlevelse.intern.dev.nav.no,https://etterlevelse-api.intern.dev.nav.no,http://localhost:3000
value: https://etterlevelse.ansatt.dev.nav.no,https://etterlevelse.intern.dev.nav.no,https://etterlevelse-api.intern.dev.nav.no,http://localhost:3000
- name: CLIENT_TEAMCAT_URL
value: https://teamkatalog-api.intern.dev.nav.no
- name: CLIENT_TEAMCAT_FRONTEND_URL
Expand Down
2 changes: 1 addition & 1 deletion apps/backend/nais/backend-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ spec:
cpuThresholdPercentage: 50
resources:
limits:
cpu: 1000m
memory: 2Gi
requests:
cpu: 1000m
memory: 512Mi
liveness:
path: internal/isAlive
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/nais/backend-prod-gcp-vars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ ingresses:
- https://etterlevelse-api.intern.nav.no
replies:
- https://etterlevelse.intern.nav.no/oauth2/callback
- https://etterlevelse.ansatt.nav.no/oauth2/callback
teamcat_ingress: teamkatalog-api.intern.nav.no
env:
- name: ETTERLEV_SECURITY_REDIRECT_URIS
value: https://etterlevelse.intern.nav.no
value: https://etterlevelse.ansatt.nav.no, https://etterlevelse.intern.nav.no
- name: CLIENT_TEAMCAT_URL
value: https://teamkatalog-api.intern.nav.no
- name: CLIENT_TEAMCAT_FRONTEND_URL
Expand Down
86 changes: 32 additions & 54 deletions apps/backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.8</version>
<version>3.2.4</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>no.nav.data</groupId>
Expand All @@ -17,31 +17,30 @@
<properties>
<java.version>17</java.version>

<springdoc-openapi-starter-webmvc-ui.version>2.3.0</springdoc-openapi-starter-webmvc-ui.version>
<springdoc-openapi-starter-webmvc-ui.version>2.5.0</springdoc-openapi-starter-webmvc-ui.version>
<hypersistence-utils-hibernate-63.version>3.7.3</hypersistence-utils-hibernate-63.version>
<logstash-logback-encoder.version>7.4</logstash-logback-encoder.version>
<shedlock.version>5.12.0</shedlock.version>
<shedlock.version>5.13.0</shedlock.version>
<commons-collections4.version>4.4</commons-collections4.version>
<graphql-spring-boot-starter.version>15.1.0</graphql-spring-boot-starter.version>
<graphql.version>21.0</graphql.version>
<flexmark.version>0.64.8</flexmark.version>

<microsoft-graph.version>5.80.0</microsoft-graph.version>
<msal4j.version>1.14.3</msal4j.version>
<microsoft-graph.version>6.5.1</microsoft-graph.version>
<msal4j.version>1.15.0</msal4j.version>

<!-- transitive versions -->
<commons-compress.version>1.26.0</commons-compress.version>
<commons-io.version>2.15.1</commons-io.version>
<guava.version>33.0.0-jre</guava.version>
<commons-compress.version>1.26.1</commons-compress.version>
<commons-io.version>2.16.1</commons-io.version>
<guava.version>33.1.0-jre</guava.version>
<jna.version>5.14.0</jna.version>
<jetbrains.annotation.version>24.1.0</jetbrains.annotation.version>

<!-- Test -->
<testcontainers.version>1.19.6</testcontainers.version>
<testcontainers.version>1.19.7</testcontainers.version>
<wiremock.version>2.27.2</wiremock.version>
<docx4j.version>11.4.9</docx4j.version>
<docx4j.version>11.4.11</docx4j.version>


</properties>

<dependencies>
Expand Down Expand Up @@ -80,7 +79,7 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>

<!-- Jwt parsing and verifying -->
<dependency>
<groupId>com.auth0</groupId>
Expand Down Expand Up @@ -109,18 +108,10 @@
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
</exclusion>
<exclusion>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
</exclusion>
<exclusion>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</exclusion>
<exclusion>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
Expand All @@ -133,38 +124,6 @@
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java-extended-scalars</artifactId>
<version>${graphql.version}</version>
<exclusions>
<exclusion>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>playground-spring-boot-starter</artifactId>
<version>11.1.0</version>
</dependency>
<dependency>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>voyager-spring-boot-starter</artifactId>
<version>11.1.0</version>
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>com.graphql-java-kickstart</groupId>
<artifactId>voyager-spring-boot-autoconfigure</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.30.2-GA</version>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>

<!-- Security -->
Expand All @@ -180,6 +139,11 @@
<groupId>com.microsoft.graph</groupId>
<artifactId>microsoft-graph</artifactId>
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.11.4</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>msal4j</artifactId>
Expand Down Expand Up @@ -252,6 +216,12 @@
<groupId>com.vladsch.flexmark</groupId>
<artifactId>flexmark-all</artifactId>
<version>${flexmark.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.vladsch.flexmark</groupId>
Expand All @@ -262,6 +232,14 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
<exclusion>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlgraphics</groupId>
<artifactId>xmlgraphics-commons</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- Prometheus metrics-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,15 @@
@Configuration
public class CommonConfig {

private static ObjectMapper omForHttpMessageConverter = JsonUtils.createObjectMapper();

@Primary
@Bean
public ObjectMapper objectMapper() {
return JsonUtils.getObjectMapper();
// ObjectMapper oppfører seg ikke-deterministisk hvis flere tråder bruker den samtidig, og der minst en av dem konfigurerer den.
// Dessuten kan forskjellige klienter konfigurere den på hver sin måte, noe som vil sabotere for andre.
// OM er kostbare å konstruere, men her skal vi ikke returnere en delt OM.
return JsonUtils.createObjectMapper();
}

@Bean
Expand All @@ -44,7 +49,7 @@ public RestTemplate externalRestTemplate(RestTemplateBuilder builder) {
@Bean
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter jsonConverter = new MappingJackson2HttpMessageConverter();
jsonConverter.setObjectMapper(objectMapper());
jsonConverter.setObjectMapper(omForHttpMessageConverter);
return jsonConverter;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.FilterProvider;
Expand Down Expand Up @@ -41,7 +42,7 @@ public class AuditVersionListener {

static {
FilterProvider filters = new SimpleFilterProvider().addFilter("relationFilter", new RelationFilter());
var om = JsonUtils.createObjectMapper();
ObjectMapper om = JsonUtils.createObjectMapper();
om.setVisibility(PropertyAccessor.ALL, Visibility.NONE);
om.setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
wr = om.writer(filters);
Expand All @@ -68,7 +69,7 @@ public void preRemove(Object entity) {

private void audit(Object entity, Action action) {
Assert.isTrue(entity instanceof Auditable, "Invalid object");
if (entity instanceof GenericStorage gs && !isAudited((gs).getType())) {
if (entity instanceof GenericStorage gs && !isAudited(gs.getType())) {
return;
}
AuditVersion auditVersion = convertAuditVersion(entity, action);
Expand All @@ -79,13 +80,11 @@ private void audit(Object entity, Action action) {

public static AuditVersion convertAuditVersion(Object entity, Action action) {
try {
String tableName;
String tableName = AuditVersion.tableNameFor(entity);
int version;
if (entity instanceof GenericStorage gs) {
tableName = gs.getType();
version = gs.getVersion() == null ? 0 : gs.getVersion() + 1;
} else {
tableName = AuditVersion.tableName(((Auditable) entity).getClass());
version = -1;
}
String id = getIdForObject(entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class AuditVersion {
@Column(name = "ACTION", nullable = false, updatable = false)
private Action action;

// This is the type of the audited entity. See tableNameFor(...) to be slightly less confused.
@Column(name = "TABLE_NAME", nullable = false, updatable = false)
private String table;

Expand Down Expand Up @@ -89,8 +90,13 @@ public AuditResponse toResponse() {
.build();
}

public static String tableName(Class<? extends Auditable> aClass) {
return aClass.getAnnotation(Table.class).name();
public static String tableNameFor(Object entity) {
if (entity instanceof GenericStorage gs) {
return gs.getType();
} else if (entity instanceof Auditable au) {
return au.getClass().getAnnotation(Table.class).name();
}
throw new IllegalArgumentException("Should not audit entities of type " + entity.getClass().getSimpleName());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
public interface MailLogRepository extends JpaRepository<GenericStorage<MailLog>, UUID> {

@Query(value = "select * from generic_storage where type = 'MailLog' order by created_date desc",
countQuery = "select count(1) from generic_storage where type = 'MailLog'"
, nativeQuery = true)
countQuery = "select count(1) from generic_storage where type = 'MailLog'",
nativeQuery = true)
Page<GenericStorage<MailLog>> findAll(Pageable pageable);

@Query(value = "select * from generic_storage where type = 'MailLog' and data ->> 'to' = ?1 order by created_date desc", nativeQuery = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

public class JsonbOMSupplier implements ObjectMapperSupplier {

private static final ObjectMapper objectMapper = JsonUtils.createObjectMapper();

@Override
public ObjectMapper get() {
return JsonUtils.getObjectMapper();
return objectMapper;
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
package no.nav.data.common.mail;

import lombok.RequiredArgsConstructor;
import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import no.nav.data.common.security.SecurityProperties;
import no.nav.data.common.storage.StorageService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@RequiredArgsConstructor
public class EmailServiceImpl implements EmailService {

private final StorageService<MailTask> storage;
private final EmailProvider emailProvider;
private final SecurityProperties securityProperties;

public EmailServiceImpl(StorageService<MailTask> storage, EmailProvider emailProvider, SecurityProperties securityProperties) {
this.storage = storage;
this.emailProvider = emailProvider;
this.securityProperties = securityProperties;
}

@Override
public void sendMail(MailTask mailTask) {
var toSend = securityProperties.isDev() ? mailTask.withSubject("[DEV] " + mailTask.getSubject()) : mailTask;
emailProvider.sendMail(toSend);
}

@Override
@Transactional
public void scheduleMail(MailTask mailTask) {
storage.save(mailTask);
}
Expand All @@ -34,10 +32,13 @@ public void scheduleMail(MailTask mailTask) {
@Scheduled(initialDelayString = "PT2M", fixedRateString = "PT1M")
public void sendMail() {
var tasks = storage.getAll(MailTask.class);

tasks.forEach(task -> {
sendMail(task);
storage.delete(task);
});
tasks.forEach(this::sendMailAndDelete);
}

@Transactional
protected void sendMailAndDelete(MailTask task) {
sendMail(task);
storage.delete(task);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class PageParameters {

@Schema(defaultValue = "0", minimum = "0")
private int pageNumber = 0;

@Schema(defaultValue = "20", minimum = "1", maximum = "250")
private int pageSize = 20;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ public interface TokenProvider {
void destroySession();

String createAuthRequestRedirectUrl(String postLoginRedirectUri, String postLoginErrorUri, String redirectUri);
}
}
Loading

0 comments on commit 9d586ea

Please sign in to comment.