Skip to content

Commit

Permalink
ingore not found for person
Browse files Browse the repository at this point in the history
  • Loading branch information
janolaveide committed Feb 9, 2021
1 parent 6bddfc3 commit acac743
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static javax.ws.rs.client.Entity.json;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON_TYPE;
import static org.apache.http.HttpStatus.SC_NOT_FOUND;

import java.net.URI;
import java.util.List;
Expand Down Expand Up @@ -96,6 +97,18 @@ public Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p) {
return query(q, p, HentPersonQueryResponse.class).hentPerson();
}

@Override
public Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p, boolean ignoreNotFound) {
try {
return hentPerson(q, p);
} catch (PdlException e) {
if (e.getStatus() == SC_NOT_FOUND && ignoreNotFound) {
return null;
}
throw e;
}
}

@Override
public Identliste hentIdenter(HentIdenterQueryRequest q, IdentlisteResponseProjection p) {
return query(q, p, HentIdenterQueryResponse.class).hentIdenter();
Expand Down Expand Up @@ -130,4 +143,5 @@ private <T extends GraphQLResult<?>> T query(GraphQLRequest req, Class<T> clazz)
throw e;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public interface Pdl extends GraphQLQueryable {

Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p);

Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p, boolean ignoreNotFound);

GeografiskTilknytning hentGT(HentGeografiskTilknytningQueryRequest q, GeografiskTilknytningResponseProjection p);

private Optional<String> hentId(String id, IdentGruppe gruppe, boolean ignoreNotFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import static com.fasterxml.jackson.databind.SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS;
import static org.apache.http.HttpStatus.SC_ACCEPTED;
import static org.apache.http.HttpStatus.SC_INTERNAL_SERVER_ERROR;
import static org.apache.http.HttpStatus.SC_NOT_FOUND;
import static org.apache.http.HttpStatus.SC_NOT_MODIFIED;
import static org.apache.http.HttpStatus.SC_NO_CONTENT;

Expand Down Expand Up @@ -178,4 +179,16 @@ public String toString() {
return getClass().getSimpleName() + " [endpoint=" + endpoint + ", restKlient=" + restKlient + ", errorHandler=" + errorHandler + "]";
}

@Override
public Person hentPerson(HentPersonQueryRequest q, PersonResponseProjection p, boolean ignoreNotFound) {
try {
return hentPerson(q, p);
} catch (PdlException e) {
if (e.getStatus() == SC_NOT_FOUND && ignoreNotFound) {
return null;
}
throw e;
}
}

}

0 comments on commit acac743

Please sign in to comment.