-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Lagt til SAF rest tjeneste og fjernet avhengigeter i core avhengighet i pom fordi parent har allerede denne avhengigeten. * Legger til journalRepository i Rest Context og skiller modellene * Legger til journalRepository i Rest Context og skiller modellene * Legger til et forslag på GraphQLkontroller. Lagt inn TODOs. * NOJIRA Implementerer GraphQLTjenesten * NOJIRA Lagt til rutine for å generere Java-klassene graphql-modellen v.h.a plugin. * Videre arbeid SAF-mock * Oppdaterer POM med manglende dependencies * Saf-mock: Lagt til README.md * Fjerner genererated sources fra kildekontroll, genererer som del av maven bygg og legger det til generated sources i target * Endrer mapping-plugin for å kunne mappe. * Videre * Implementerer respons for dokumentoversiktFagsak (WIP) * Legger til manglende versjonvariabel for graphql-plugin * Returnerer nå brevkode for Inntektsmelding * Implementerer dummyrespons for hentDokument Co-authored-by: Espen Waaga <[email protected]> Co-authored-by: olovholm <[email protected]> Co-authored-by: Tore Sletten <[email protected]> Co-authored-by: s149212 <[email protected]>
- Loading branch information
1 parent
82b2dfc
commit 500a7c8
Showing
27 changed files
with
1,652 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Saf mock | ||
======== | ||
|
||
# Tjenester | ||
Følgende tjenester finnes på SAF: | ||
|
||
|Tjeneste |Mock-status|Beskrivelse | | ||
|-------- |-----------|----------- | | ||
|Query: dokumentoversiktBruker | |Lar et fagsystem søke opp metadata for alle dokumenter tilknyttet en gitt bruker.| | ||
|Query: dokumentoversiktFagsak | |Lar et fagsystem søke opp metadata for alle dokumenter tilknyttet en fagsak i et fagsystem. Tjenesten vil kunne returnere dokumenter tilhørende ulike brukere, og på ulike tema, dersom fagsaken har dette.| | ||
|saf - REST hentdokument | |Returnerer selve dokumentfila, med dokumentId, journalpostID og variantFormat som nøkkel| | ||
|Query: journalpost | |Returnerer "all" informasjon på en journalpost (uavhengig av journalposttype), med journalpostId som nøkkel.| | ||
|Query: tilknyttedeJournalposter | |Returnerer liste over journalposter som er knyttet til dokumentinfoId som oppgis| | ||
|Query: dokumentoversiktJournalstatus | |Tillater søk på journalpoststatus i Joark. Foreløpig er kun statusene Utgår og Ukjent bruker støttet. Ta kontakt på slack (#saf) dersom dere trenger å søke på andre kanaler.| | ||
|
||
|
||
### SAF-lenker | ||
https://confluence.adeo.no/display/BOA/saf+-+Tjenester | ||
|
||
|
||
# Opprette testdata | ||
* Opprett testdata ved å ..... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>mocks</artifactId> | ||
<groupId>no.nav.foreldrepenger.vtp</groupId> | ||
<version>${revision}${sha1}${changelist}</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>saf-mock</artifactId> | ||
<name>VTP ::saf-mock</name> | ||
<packaging>jar</packaging> | ||
|
||
<properties> | ||
<apigen.version>5.0.0</apigen.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-jaxrs</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.swagger</groupId> | ||
<artifactId>swagger-jaxrs</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.vintage</groupId> | ||
<artifactId>junit-vintage-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.graphql-java</groupId> | ||
<artifactId>graphql-java</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mockito</groupId> | ||
<artifactId>mockito-core</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.distelli.graphql</groupId> | ||
<artifactId>graphql-apigen-deps</artifactId> | ||
<version>${apigen.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.graphql-java</groupId> | ||
<artifactId>graphql-java-extended-scalars</artifactId> | ||
<version>1.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>no.nav.foreldrepenger.vtp</groupId> | ||
<artifactId>testmodell</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>no.nav.foreldrepenger.vtp</groupId> | ||
<artifactId>core</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.github.kobylynskyi</groupId> | ||
<artifactId>graphql-codegen-maven-plugin</artifactId> | ||
<version>1.4.2</version> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<configuration> | ||
<graphqlSchemaPaths>${project.basedir}/src/main/resources/schemas/saf.graphql</graphqlSchemaPaths> | ||
<outputDir>${project.build.directory}/generated-sources/graphql</outputDir> | ||
<packageName>no.nav.saf</packageName> | ||
<customTypesMapping> | ||
<DateTime>java.util.Date</DateTime> | ||
<!-- <Price.amount>java.math.BigDecimal</Price.amount> --> | ||
</customTypesMapping> | ||
<customAnnotationsMapping> | ||
<EpochMillis>com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.json.EpochMillisScalarDeserializer.class</EpochMillis> | ||
</customAnnotationsMapping> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
package no.nav.saf; | ||
|
||
import static javax.ws.rs.core.HttpHeaders.AUTHORIZATION; | ||
|
||
import graphql.ExecutionResult; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import no.nav.foreldrepenger.vtp.testmodell.dokument.modell.DokumentModell; | ||
import no.nav.foreldrepenger.vtp.testmodell.repo.JournalRepository; | ||
import no.nav.foreldrepenger.vtp.testmodell.repo.impl.JournalRepositoryImpl; | ||
import no.nav.saf.graphql.GraphQLRequest; | ||
import no.nav.saf.graphql.GraphQLTjeneste; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import javax.ws.rs.*; | ||
import javax.ws.rs.core.Context; | ||
import javax.ws.rs.core.HttpHeaders; | ||
import javax.ws.rs.core.MediaType; | ||
import javax.ws.rs.core.Response; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
@Api(tags = {"saf"}) | ||
@Path("/api/saf") | ||
public class SafMock { | ||
|
||
private static final Logger LOG = LoggerFactory.getLogger(SafMock.class); | ||
|
||
private static final String X_CORRELATION_ID = "X-Correlation-ID"; | ||
private static final String NAV_CALLID = "Nav-Callid"; | ||
private static final String NAV_CONSUMER_ID = "Nav-Consumer-Id"; | ||
|
||
private static final String JOURNALPOST_ID = "journalpostId"; | ||
private static final String DOKUMENT_INFO_ID = "dokumentInfoId"; | ||
private static final String VARIANT_FORMAT = "variantFormat"; | ||
|
||
@Context | ||
private JournalRepository journalRepository; | ||
|
||
private GraphQLTjeneste graphQLTjeneste; | ||
|
||
|
||
public SafMock() { | ||
this.graphQLTjeneste = GraphQLTjeneste.getInstance(); | ||
this.journalRepository = JournalRepositoryImpl.getInstance(); | ||
} | ||
|
||
|
||
@POST | ||
@Path("/graphql") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@Consumes(MediaType.APPLICATION_JSON) | ||
@ApiOperation(value = "", notes = "Henter journalpost") | ||
public Map<String, Object> graphQLRequest(@HeaderParam(AUTHORIZATION) String authorizationHeader, | ||
@HeaderParam(X_CORRELATION_ID) String xCorrelationId, | ||
@HeaderParam(NAV_CALLID) String navCallid, | ||
@HeaderParam(NAV_CONSUMER_ID) String navConsumerId, | ||
GraphQLRequest request) { | ||
|
||
ExecutionResult executionResult = graphQLTjeneste.executeStatement(request, journalRepository); | ||
return executionResult.toSpecification(); | ||
} | ||
|
||
|
||
@GET | ||
@Path("/rest/hentdokument/{journalpostId}/{dokumentInfoId}/{variantFormat}") | ||
@Produces(MediaType.APPLICATION_JSON) | ||
@ApiOperation(value = "", notes = "Henter dokument", response = Response.class) | ||
public Response hentDokument( @PathParam(JOURNALPOST_ID) String journalpostId, | ||
@PathParam(DOKUMENT_INFO_ID) String dokumentInfoId, | ||
@PathParam(VARIANT_FORMAT) String variantFormat ) { | ||
|
||
Optional<DokumentModell> dokumentModell = journalRepository.finnDokumentMedDokumentId(dokumentInfoId); | ||
if (dokumentModell.isPresent()) { | ||
LOG.info("Henter dokument på følgende dokumentId: " + dokumentModell.get().getDokumentId()); | ||
String innhold = dokumentModell.get().getInnhold(); | ||
return Response | ||
.status(Response.Status.OK) | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=" + dokumentInfoId + "_" + variantFormat) | ||
.entity(innhold.getBytes()) | ||
.build(); | ||
} else if (journalpostId != null) { // TODO: Fjern når SafMock ikke er WIP | ||
try (InputStream is = getClass().getResourceAsStream("/dokumenter/foreldrepenger_soknad.pdf")) { | ||
return Response | ||
.status(Response.Status.OK) | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=" + dokumentInfoId + "_" + variantFormat) | ||
.entity(is.readAllBytes()) | ||
.build(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(String.format("Kunne ikke lese dummyrespons for " + | ||
"journalpostId=%s, dokumentInfoId=%s, variantFormat=%s", journalpostId, dokumentInfoId, variantFormat)); | ||
} | ||
|
||
} else { | ||
throw new RuntimeException(String.format("Kunne ikke finne dokument for " + | ||
"journalpostId=%s, dokumentInfoId=%s, variantFormat=%s", journalpostId, dokumentInfoId, variantFormat)); | ||
} | ||
} | ||
} |
Oops, something went wrong.