Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jetty12 #18

Merged
merged 5 commits into from
Nov 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.util.UUID;
import java.util.stream.Collectors;

import org.apache.hc.core5.http.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -333,7 +332,7 @@ public void lagreOverstyrtOppgittOpptjening(Long behandlingId, OppgittOpptjening

try {
abakusTjeneste.lagreOverstyrtOppgittOpptjening(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Lagre oppgitt opptjening i abakus: " + e.getMessage(), e).toException();
}

Expand Down Expand Up @@ -373,7 +372,7 @@ public void lagreInntektsmeldinger(Saksnummer saksnummer, Long behandlingId, Col

try {
abakusTjeneste.lagreInntektsmeldinger(inntektsmeldingerMottattRequest);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Lagre mottatte inntektsmeldinger i abakus: " + e.getMessage(), e).toException();
}

Expand Down Expand Up @@ -411,15 +410,15 @@ private InntektArbeidYtelseGrunnlag mapOgCacheGrunnlag(InntektArbeidYtelseGrunnl
private InntektsmeldingerDto hentUnikeInntektsmeldinger(InntektsmeldingerRequest request) {
try {
return abakusTjeneste.hentUnikeUnntektsmeldinger(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke hente inntektsmeldinger fra Abakus: " + e.getMessage(), e).toException();
}
}

private InntektArbeidYtelseGrunnlagDto hentGrunnlag(InntektArbeidYtelseGrunnlagRequest request) {
try {
return abakusTjeneste.hentGrunnlag(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke hente grunnlag fra Abakus: " + e.getMessage(), e).toException();
}

Expand All @@ -428,7 +427,7 @@ private InntektArbeidYtelseGrunnlagDto hentGrunnlag(InntektArbeidYtelseGrunnlagR
private InntektArbeidYtelseGrunnlagSakSnapshotDto hentGrunnlagSnapshot(InntektArbeidYtelseGrunnlagRequest request) {
try {
return abakusTjeneste.hentGrunnlagSnapshot(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke hente grunnlag snapshot fra Abakus: " + e.getMessage(), e).toException();
}
}
Expand Down Expand Up @@ -566,7 +565,7 @@ private UUID lagreOverstyrt(OverstyrtInntektArbeidYtelseDto dto) {
try {
abakusTjeneste.lagreOverstyrt(dto);
return dto.getGrunnlagReferanse();
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke lagre overstyrt arbeid i Abakus: " + e.getMessage(), e).toException();
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import no.nav.ung.sak.behandlingslager.fagsak.FagsakProsesstaskRekkefølge;
import no.nav.ung.sak.behandlingslager.task.UnderBehandlingProsessTask;
import no.nav.ung.sak.domene.abakus.AbakusTjeneste;
import org.apache.hc.core5.http.ParseException;

@ApplicationScoped
@ProsessTask(AsyncAbakusKopierGrunnlagTask.TASKTYPE)
Expand Down Expand Up @@ -69,7 +68,7 @@ protected void doProsesser(ProsessTaskData input, Behandling tilBehandling) {

try {
abakusTjeneste.kopierGrunnlag(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw new IllegalStateException(String.format("Kunne ikke kopiere abakus grunnlag: fra [%s] til [%s], dataset: %s", fraBehandlingId, tilBehandling.getId(), dataset), e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import java.util.List;
import java.util.Objects;

import org.apache.hc.core5.http.ParseException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -96,7 +95,7 @@ private void lagreOppgittOpptjening(ProsessTaskData input, boolean erFrisinn) {
} else {
abakusTjeneste.lagreOppgittOpptjeningV2(request);
}
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw new IllegalStateException("Kunne ikke lagre abakus oppgitt opptjening", e);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package no.nav.ung.sak.økonomi.simulering.klient;

import org.apache.http.impl.client.CloseableHttpClient;

import no.nav.k9.felles.integrasjon.rest.RestClientConfig;
import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;

import java.util.concurrent.TimeUnit;

public class K9OppdragRestClientConfig extends RestClientConfig {

Expand All @@ -13,7 +11,7 @@ public class K9OppdragRestClientConfig extends RestClientConfig {
private static final int TIMEOUT_SEKUNDER = 60; //simuleringer med veldig mange perioder tar 20+ sekunder, så må øke fra default

public K9OppdragRestClientConfig() {
super(RestClientConfig.defaultRequestConfig().setConnectionRequestTimeout(TIMEOUT_SEKUNDER, TimeUnit.SECONDS),
super(RestClientConfig.defaultRequestConfig().setSocketTimeout(TIMEOUT_SEKUNDER * 1000),
MAX_TOTAL, DEFAULT_MAX_PER_ROUTE);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.net.URISyntaxException;
import java.util.Optional;

import org.apache.hc.core5.net.URIBuilder;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<felles.version>4.0.4</felles.version>
<felles.version>4.0.5</felles.version>
<swagger.version>2.2.25</swagger.version>
<junit.version>5.11.3</junit.version>
<k9format.version>9.7.1</k9format.version>
Expand Down Expand Up @@ -125,7 +125,7 @@
<dependency>
<groupId>no.nav.k9.prosesstask</groupId>
<artifactId>prosesstask-root</artifactId>
<version>2.6.0</version>
<version>2.6.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
6 changes: 6 additions & 0 deletions web/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@
</exclusions>
</dependency>

<!-- For Status side -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>

<!-- Server -->
<dependency>
<groupId>org.eclipse.jetty.ee9</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.function.Consumer;
import java.util.stream.Collectors;

import org.apache.http.client.utils.URIBuilder;

import no.nav.k9.kodeverk.behandling.aksjonspunkt.Venteårsak;
import no.nav.ung.sak.behandlingslager.BaseEntitet;
import no.nav.ung.sak.behandlingslager.behandling.Behandling;
Expand All @@ -23,7 +25,6 @@
import no.nav.ung.sak.kontrakt.behandling.BehandlingÅrsakDto;
import no.nav.ung.sak.web.app.ApplicationConfig;
import no.nav.ung.sak.web.server.jetty.JettyWebKonfigurasjon;
import org.apache.hc.core5.net.URIBuilder;

public class BehandlingDtoUtil {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
package no.nav.ung.sak.web.app.tjenester.behandling.personopplysning;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

import org.apache.http.HttpStatus;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.util.EntityUtils;

import com.fasterxml.jackson.annotation.JsonProperty;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import no.nav.k9.felles.feil.Feil;
Expand All @@ -13,17 +24,6 @@
import no.nav.k9.felles.konfigurasjon.konfig.KonfigVerdi;
import no.nav.ung.sak.domene.typer.tid.JsonObjectMapper;
import no.nav.ung.sak.typer.AktørId;
import org.apache.hc.client5.http.classic.methods.HttpPost;
import org.apache.hc.core5.http.ContentType;
import org.apache.hc.core5.http.HttpStatus;
import org.apache.hc.core5.http.ParseException;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.hc.core5.http.io.entity.StringEntity;
import org.apache.hc.core5.http.message.StatusLine;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

@ApplicationScoped
@ScopedRestIntegration(scopeKey = "k9fordel.scope", defaultScope = "api://prod-fss.k9saksbehandling.k9fordel/.default")
Expand Down Expand Up @@ -54,19 +54,19 @@ public class AktørBytteFordelKlient {
}
httpPost.setEntity(new StringEntity(json, ContentType.APPLICATION_JSON));
try (var httpResponse = restClient.execute(httpPost)) {
int responseCode = httpResponse.getCode();
int responseCode = httpResponse.getStatusLine().getStatusCode();
if (!isOk(responseCode)) {
if (responseCode != HttpStatus.SC_NO_CONTENT && responseCode != HttpStatus.SC_ACCEPTED) {
String responseBody = EntityUtils.toString(httpResponse.getEntity());
String feilmelding = "Kunne ikke utføre kall til k9-fordel,"
+ " endpoint=" + httpPost.getRequestUri()
+ ", HTTP status=" + new StatusLine(httpResponse)
+ " endpoint=" + httpPost.getURI()
+ ", HTTP status=" + httpResponse.getStatusLine()
+ ". HTTP Errormessage=" + responseBody;
throw RestTjenesteFeil.FEIL.feilVedKallTilFordel(endpoint, feilmelding).toException();
}
}
return Integer.parseInt(EntityUtils.toString(httpResponse.getEntity()));
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw RestTjenesteFeil.FEIL.feilVedKallTilFordel(endpoint, e.getMessage()).toException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import no.nav.ung.sak.domene.iay.modell.InntektsmeldingAggregat;
import no.nav.ung.sak.typer.AktørId;
import no.nav.ung.sak.typer.Saksnummer;
import org.apache.hc.core5.http.ParseException;

@Dependent
@Default
Expand Down Expand Up @@ -98,15 +97,15 @@ private Set<Inntektsmelding> hentUnikeInntektsmeldingerForSak(Saksnummer saksnum
private InntektsmeldingerDto hentUnikeInntektsmeldinger(InntektsmeldingerRequest request) {
try {
return abakusTjeneste.hentUnikeUnntektsmeldinger(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke hente inntektsmeldinger fra Abakus: " + e.getMessage(), e).toException();
}
}

private InntektArbeidYtelseGrunnlagDto hentGrunnlag(InntektArbeidYtelseGrunnlagRequest request) {
try {
return abakusTjeneste.hentGrunnlag(request);
} catch (IOException | ParseException e) {
} catch (IOException e) {
throw AbakusInntektArbeidYtelseTjenesteFeil.FEIL.feilVedKallTilAbakus("Kunne ikke hente grunnlag fra Abakus: " + e.getMessage(), e).toException();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
package no.nav.ung.sak.web.app.tjenester.register;

import static no.nav.k9.abac.BeskyttetRessursKoder.FAGSAK;
import static no.nav.k9.felles.sikkerhet.abac.BeskyttetRessursActionAttributt.READ;

import java.io.IOException;
import java.net.URI;

import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.message.BasicHeader;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
Expand All @@ -22,15 +32,6 @@
import no.nav.ung.sak.domene.person.tps.TpsTjeneste;
import no.nav.ung.sak.kontrakt.behandling.SaksnummerDto;
import no.nav.ung.sak.web.server.abac.AbacAttributtSupplier;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.classic.methods.HttpUriRequestBase;
import org.apache.hc.core5.http.message.BasicHeader;

import java.io.IOException;
import java.net.URI;

import static no.nav.k9.abac.BeskyttetRessursKoder.FAGSAK;
import static no.nav.k9.felles.sikkerhet.abac.BeskyttetRessursActionAttributt.READ;

@ApplicationScoped
@Transactional
Expand Down Expand Up @@ -82,7 +83,7 @@ public Response getAktoerInfo(

var uri = URI.create(arbeidOgInntektBaseURL + "/api/v2/redirect/sok/arbeidstaker");

HttpUriRequestBase request = new HttpGet(uri);
HttpUriRequest request = new HttpGet(uri);
request.addHeader(new BasicHeader("Nav-Personident", personIdent.getIdent()));
try {
var respons = restClient.execute(request, new OidcRestClientResponseHandler.StringResponseHandler(uri));
Expand Down Expand Up @@ -111,7 +112,7 @@ public Response getAInntektUrl(
var personIdent = tpsTjeneste.hentFnrForAktør(fagsak.getAktørId());

var uri = URI.create(arbeidOgInntektBaseURL + "/api/v2/redirect/sok/a-inntekt");
HttpUriRequestBase request = new HttpGet(uri);
HttpUriRequest request = new HttpGet(uri);
request.addHeader(new BasicHeader("Nav-Personident", personIdent.getIdent()));
try {
var respons = restClient.execute(request, new OidcRestClientResponseHandler.StringResponseHandler(uri));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ private static void taNedApplikasjonVedError() {
private void start(AppKonfigurasjon appKonfigurasjon) throws Exception {
// https://jetty.org/docs/jetty/12/programming-guide/arch/threads.html
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setVirtualThreadsExecutor(new VirtualThreadPool());

Server server = new Server(threadPool);
server.setConnectors(createConnectors(appKonfigurasjon, server).toArray(new Connector[]{}));

WebAppContext webAppContext = createContext(appKonfigurasjon, server);
server.setHandler(new Handler.Sequence(
new ClearMdcHandler(),
Expand Down Expand Up @@ -251,6 +251,8 @@ protected Resource createResourceCollection(Server server) {
ResourceFactory.of(server).newClassLoaderResource("/web"));
}



/**
* brukes for å slette tilstand i MDC på starten av en request
*/
Expand Down
Loading