Skip to content

Commit

Permalink
Gjør dokarkiv-klient synlig, fjern pdl-klient (#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
jolarsen authored Oct 9, 2022
1 parent b5783c4 commit a5e2bbb
Show file tree
Hide file tree
Showing 11 changed files with 71 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import java.util.List;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Dependent;
import javax.inject.Inject;

import org.slf4j.Logger;
Expand All @@ -20,15 +20,12 @@
import no.nav.vedtak.sikkerhet.pdp.xacml.XacmlResponse;
import no.nav.vedtak.sikkerhet.pdp.xacml.XacmlResponseMapper;

@ApplicationScoped
@Dependent
public class PdpKlientImpl implements PdpKlient {

private static final Logger LOG = LoggerFactory.getLogger(PdpKlientImpl.class);

private PdpConsumer pdp;

public PdpKlientImpl() {
}
private final PdpConsumer pdp;

@Inject
public PdpKlientImpl(PdpConsumer pdp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
// Extend og annoter med endpoint+default og scopes/default + tokenConfig = AzureAD_CC
//@RestClientConfig(tokenConfig = TokenFlow.AZUREAD_CC, endpointProperty = "skjermet.person.rs.url", endpointDefault = "https://skjermede-personer-pip.intern.nav.no/skjermet",
// scopesProperty = "skjermet.person.rs.azure.scope", scopesDefault = "api://prod-gcp.nom.skjermede-personer-pip/.default")
public abstract class AbstractSkjermetPersonKlient implements Skjerming {
public abstract class AbstractSkjermetPersonGCPKlient implements Skjerming {

private static final Logger LOG = LoggerFactory.getLogger(AbstractSkjermetPersonKlient.class);
private static final Logger LOG = LoggerFactory.getLogger(AbstractSkjermetPersonGCPKlient.class);
private static final boolean TESTENV = Environment.current().isLocal();

private final RestClient client;
private final RestConfig restConfig;

protected AbstractSkjermetPersonKlient() {
protected AbstractSkjermetPersonGCPKlient() {
this(RestClient.client());
}

protected AbstractSkjermetPersonKlient(RestClient restClient) {
protected AbstractSkjermetPersonGCPKlient(RestClient restClient) {
this.client = restClient;
this.restConfig = RestConfig.forClient(this.getClass());
if (!restConfig.tokenConfig().isAzureAD()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package no.nav.vedtak.felles.integrasjon.skjerming;

import no.nav.foreldrepenger.konfig.Environment;
import no.nav.vedtak.felles.integrasjon.rest.RestClient;
import no.nav.vedtak.felles.integrasjon.rest.RestConfig;
import no.nav.vedtak.felles.integrasjon.rest.RestRequest;

// OBS på propertynavn vs GCP-versjon skjermet.person.onprem.rs.url=http://skjermede-personer-pip.nom/skjermet
// Extend og annoter med endpoint+default + tokenConfig = STS_CC
//@RestClientConfig(tokenConfig = TokenFlow.STS_CC, endpointProperty = "skjermet.person.onprem.rs.url", endpointDefault = "http://skjermede-personer-pip.nom/skjermet"
public abstract class AbstractSkjermetPersonOnPremKlient implements Skjerming {

private static final boolean TESTENV = Environment.current().isLocal();

private final RestClient client;
private final RestConfig restConfig;

protected AbstractSkjermetPersonOnPremKlient() {
this(RestClient.client());
}

protected AbstractSkjermetPersonOnPremKlient(RestClient restClient) {
this.client = restClient;
this.restConfig = RestConfig.forClient(this.getClass());
}


@Override
public boolean erSkjermet(String fnr) {
if (TESTENV || fnr == null) return false;

var request = RestRequest.newPOSTJson(new SkjermetRequestDto(fnr), restConfig.endpoint(), restConfig);

var skjermet = client.send(request, String.class);
return "true".equalsIgnoreCase(skjermet);
}

private boolean kallMedSjekk(RestRequest request) {
var skjermet = client.send(request, String.class);
return "true".equalsIgnoreCase(skjermet);
}

private record SkjermetRequestDto(String personident) {}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import no.nav.vedtak.felles.integrasjon.rest.RestRequest;

// @RestClientConfig(tokenConfig = TokenFlow.STS_CC, endpointProperty = "dokarkiv.base.url", endpointDefault = "http://dokarkiv.default/rest/journalpostapi/v1/journalpost")
class AbstractDokArkivKlient implements DokArkiv {
public class AbstractDokArkivKlient implements DokArkiv {

private static final Logger LOG = LoggerFactory.getLogger(AbstractDokArkivKlient.class);

Expand Down Expand Up @@ -77,7 +77,7 @@ public boolean ferdigstillJournalpost(String journalpostId, String enhet) {
LOG.info("DOKARKIV Ferdigstilt journalpost OK");
return true;
} catch (Exception e) {
LOG.info("DOKARKIV DOKARKIV FERDIGSTILL {} feilet for {}", journalpostId, enhet, e);
LOG.info("DOKARKIV FERDIGSTILL {} feilet for {}", journalpostId, enhet, e);
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ public Builder leggTilDokumentvariant(Dokumentvariant dokumentvarianter) {
return this;
}

public Builder leggTilDokumentvariant(Dokumentvariant.Builder dokumentvariant) {
this.dokumentvarianter.add(dokumentvariant.build());
return this;
}

public DokumentInfoOpprett build() {
if (this.dokumentvarianter == null || this.dokumentvarianter.isEmpty()) {
throw new IllegalArgumentException("Krever minst 1 dokumentvariant");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package no.nav.vedtak.felles.integrasjon.dokarkiv.dto;

import java.util.Arrays;
import java.util.Objects;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
Expand All @@ -18,15 +19,9 @@ public enum Variantformat {
PRODUKSJON_DLF,
SLADDET,
ORIGINAL;

public Builder medDokument(byte[] dokumentInnhold, Builder builder) {
builder.fysiskDokument = dokumentInnhold;
return builder;
}
}

public enum Filtype {

PDF,
PDFA,
XML,
Expand All @@ -41,41 +36,24 @@ public enum Filtype {

}

public static Builder builder() {
return new Builder();
@Override
public boolean equals(Object o) {
if (this == o) return true;
return o instanceof Dokumentvariant that && variantformat == that.variantformat && filtype == that.filtype && Arrays.equals(fysiskDokument, that.fysiskDokument);
}

public static class Builder {

private Variantformat variantformat;
private Filtype filtype;
private byte[] fysiskDokument;

private Builder() {
}

public Builder medFiltype(Filtype filtype) {
this.filtype = filtype;
return this;
}

public Builder medVariantformat(Variantformat variantformat) {
this.variantformat = variantformat;
return this;
}

public Builder medDokument(byte[] dokumentInnhold) {
this.fysiskDokument = dokumentInnhold;
return this;
}

public Dokumentvariant build() {
Objects.requireNonNull(fysiskDokument, "mangler dokumentinnhold");
Objects.requireNonNull(filtype, "mangler filtype");
Objects.requireNonNull(variantformat, "mangler variantformat");
return new Dokumentvariant(variantformat, filtype, fysiskDokument);
}
@Override
public int hashCode() {
int result = Objects.hash(variantformat, filtype);
result = 31 * result + Arrays.hashCode(fysiskDokument);
return result;
}


@Override
public String toString() {
return "Dokumentvariant{" +
"variantformat=" + variantformat +
", filtype=" + filtype +
'}';
}
}
26 changes: 0 additions & 26 deletions integrasjon/pdl-klient/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions integrasjon/pdl-klient/src/main/resources/META-INF/beans.xml

This file was deleted.

6 changes: 0 additions & 6 deletions integrasjon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<module>dokarkiv-klient</module>
<module>person-klient</module>
<module>oppgave-rest-klient</module>
<module>pdl-klient</module>
<module>ereg-klient</module>
<module>saf-klient</module>
<module>spokelse-klient</module>
Expand Down Expand Up @@ -79,11 +78,6 @@
<artifactId>felles-integrasjon-rest-klient</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>no.nav.foreldrepenger.felles.integrasjon</groupId>
<artifactId>person-klient</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>no.nav.foreldrepenger.felles.integrasjon</groupId>
<artifactId>felles-integrasjon-webservice</artifactId>
Expand Down

0 comments on commit a5e2bbb

Please sign in to comment.