Skip to content

Commit

Permalink
Manglende correlation id mot oppgave (#1182)
Browse files Browse the repository at this point in the history
* Manglende correlation id mot oppgave

* Minimalistisk postJson der enpoint brukes direkte
  • Loading branch information
jolarsen authored Sep 19, 2022
1 parent 9fd04fd commit 3dce111
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
@ApplicationScoped
public class OppgaveNativeKlient implements Oppgaver {

private static final String HEADER_CORRELATION_ID = "X-Correlation-ID";
private static final String STATUSKATEGORI_AAPEN = "AAPEN";

private RestClient restKlient;
Expand All @@ -39,7 +38,8 @@ public OppgaveNativeKlient(RestClient restKlient) {

@Override
public Oppgave opprettetOppgave(OpprettOppgave oppgave) {
var request = RestRequest.newPOSTJson(oppgave, endpoint, OppgaveNativeKlient.class);
var request = RestRequest.newPOSTJson(oppgave, OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
return restKlient.send(request, Oppgave.class);
}

Expand All @@ -49,7 +49,8 @@ public List<Oppgave> finnAlleOppgaver(String aktørId, String tema, List<String>
if (tema != null)
builder.queryParam("tema", tema);
oppgaveTyper.forEach(ot -> builder.queryParam("oppgavetype", ot));
var request = RestRequest.newGET(builder.build(), OppgaveNativeKlient.class);
var request = RestRequest.newGET(builder.build(), OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
return restKlient.send(addCorrelation(request), FinnOppgaveResponse.class).oppgaver();
}

Expand All @@ -61,31 +62,35 @@ public List<Oppgave> finnAlleOppgaver(String aktørId, String tema, List<String>
if (tema != null)
builder.queryParam("tema", tema);
oppgaveTyper.forEach(ot -> builder.queryParam("oppgavetype", ot));
var request = RestRequest.newGET(builder.build(), OppgaveNativeKlient.class);
var request = RestRequest.newGET(builder.build(), OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
return restKlient.send(addCorrelation(request), FinnOppgaveResponse.class).oppgaver();
}

@Override
public void ferdigstillOppgave(String oppgaveId) {
var oppgave = hentOppgave(oppgaveId);
var patch = new PatchOppgave(oppgave.getId(), oppgave.getVersjon(), Oppgavestatus.FERDIGSTILT);
var request = RestRequest.newRequest(new RestRequest.Method(RestRequest.WebMethod.PATCH,
RestRequest.jsonPublisher(patch)), getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class);
var method = new RestRequest.Method(RestRequest.WebMethod.PATCH, RestRequest.jsonPublisher(patch));
var request = RestRequest.newRequest(method, getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
restKlient.sendExpectConflict(addCorrelation(request), String.class);
}

@Override
public void feilregistrerOppgave(String oppgaveId) {
var oppgave = hentOppgave(oppgaveId);
var patch = new PatchOppgave(oppgave.getId(), oppgave.getVersjon(), Oppgavestatus.FEILREGISTRERT);
var request = RestRequest.newRequest(new RestRequest.Method(RestRequest.WebMethod.PATCH,
RestRequest.jsonPublisher(patch)), getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class);
var method = new RestRequest.Method(RestRequest.WebMethod.PATCH, RestRequest.jsonPublisher(patch));
var request = RestRequest.newRequest(method, getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
restKlient.sendExpectConflict(addCorrelation(request), String.class);
}

@Override
public Oppgave hentOppgave(String oppgaveId) {
var request = RestRequest.newGET(getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class);
var request = RestRequest.newGET(getEndpointForOppgaveId(oppgaveId), OppgaveNativeKlient.class)
.otherCallId(NavHeaders.HEADER_NAV_CORRELATION_ID);
return restKlient.send(addCorrelation(request), Oppgave.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ public static RestRequest newGET(URI target, Class<?> clazz) {
return newRequest(Method.get(), target, clazz);
}

// Get endpoint form annotation
public static RestRequest newPOSTJson(Object body, Class<?> clazz) {
var endpoint = RestConfig.endpointFromAnnotation(clazz);
return newRequest(Method.postJson(body), endpoint, clazz);
}

public static RestRequest newPOSTJson(Object body, URI target, Class<?> clazz) {
return newRequest(Method.postJson(body), target, clazz);
}
Expand Down

0 comments on commit 3dce111

Please sign in to comment.