Skip to content

Commit

Permalink
Small fixes in graphql requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dragutin-nav committed Mar 7, 2024
1 parent 2205238 commit e0cf507
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package no.nav.veilarbvedtaksstotte.client.dokarkiv;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class JournalpostData {

public Journalpost data;

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ public interface SafClient extends HealthCheck {

List<Journalpost> hentJournalposter(Fnr fnr);

Journalpost hentJournalpost(String journalpostId);
JournalpostData hentJournalpost(String journalpostId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public List<Journalpost> hentJournalposter(Fnr fnr) {
}

@SneakyThrows
public Journalpost hentJournalpost(String journalpostId) {
public JournalpostData hentJournalpost(String journalpostId) {
GraphqlRequest<QueryVariables> graphqlRequest = new GraphqlRequest<>(createJournalpostGqlStr(), new QueryVariables(journalpostId));

Request request = new Request.Builder()
Expand All @@ -81,10 +81,7 @@ public Journalpost hentJournalpost(String journalpostId) {

try (Response response = RestClient.baseClient().newCall(request).execute()) {
RestUtils.throwIfNotSuccessful(response);
assert response.body() != null;
Response body = response;
log.info(body.body().string());
return RestUtils.parseJsonResponseOrThrow(body, Journalpost.class);
return RestUtils.parseJsonResponseOrThrow(response, JournalpostData.class);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import no.nav.common.types.identer.AktorId;
import no.nav.common.types.identer.Fnr;
import no.nav.veilarbvedtaksstotte.client.dokarkiv.Journalpost;
import no.nav.veilarbvedtaksstotte.client.dokarkiv.JournalpostData;
import no.nav.veilarbvedtaksstotte.client.dokarkiv.OpprettetJournalpostDTO;
import no.nav.veilarbvedtaksstotte.client.dokarkiv.SafClient;
import no.nav.veilarbvedtaksstotte.client.veilederogenhet.Veileder;
Expand Down Expand Up @@ -190,12 +190,12 @@ public void oppdaterUtkast(long vedtakId, OppdaterUtkastDTO vedtakDTO) {

private void oppdatereDokumentIdforJournalfortOyeblikksbilde(String journalpostId) {
try {
Journalpost journalpost = safClient.hentJournalpost(journalpostId);
JournalpostData journalpost = safClient.hentJournalpost(journalpostId);
log.info("JOURNALPOST: " + new ObjectMapper().writeValueAsString(journalpost));
log.info("JOURNALPOST: " + journalpostId);
Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.brevkode));
Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.tittel));
Arrays.stream(journalpost.dokumenter).forEach(x -> log.info(x.dokumentInfoId));
Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.brevkode));
Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.tittel));
Arrays.stream(journalpost.data.dokumenter).forEach(x -> log.info(x.dokumentInfoId));
} catch (Exception e) {
log.error("Error oppdatereDokumentIdforJournalfortOyeblikksbilde " + e, e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ public List<Journalpost> hentJournalposter(Fnr fnr) {
}

@Override
public Journalpost hentJournalpost(String journalpostId) {
public JournalpostData hentJournalpost(String journalpostId) {
return null;
}

Expand Down

0 comments on commit e0cf507

Please sign in to comment.