/** * Send a request with no payload. */ private ResponseEntity retrieveResponseFromRequest( final String method, final String uri, final int responseCode, final MediaType accept, final List<Pair<String,Predicate<String>>> headerFields ) { ClientRequest request; try { request = withHeaders( REQUEST_BUILDER ).accept( accept ).build( new URI( uri ), method ); } catch ( URISyntaxException e ) { throw new RuntimeException( e ); } return retrieveResponse( uri, responseCode, accept, headerFields, request ); }
/** * Send a request with payload. */ private ResponseEntity retrieveResponseFromRequest( final String method, final String uri, final String payload, final MediaType payloadType, final int responseCode, final MediaType accept, final List<Pair<String,Predicate<String>>> headerFields ) { ClientRequest request; try { if ( payload != null ) { request = withHeaders( REQUEST_BUILDER ).type( payloadType ).accept( accept ).entity( payload ) .build( new URI( uri ), method ); } else { request = withHeaders( REQUEST_BUILDER ).accept( accept ).build( new URI( uri ), method ); } } catch ( URISyntaxException e ) { throw new RuntimeException( e ); } return retrieveResponse( uri, responseCode, accept, headerFields, request ); }
public CollectionState newCollectionState(URI discoveryUri, Client client, String method) { ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method); if (Boolean.valueOf(System.getProperty(DONT_FOLLOW_REDIRECTS))) { request.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); } return newCollectionState(request, client.handle(request), null); }
private FamilySearchOrdinancesState(URI uri, com.sun.jersey.api.client.Client client, FamilyTreeStateFactory stateFactory) { this(ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(uri, HttpMethod.GET), client, stateFactory); }
public static ClientRequest.Builder applyFamilySearchXml(ClientRequest.Builder request) { return request.accept(AtomModel.ATOM_XML_MEDIA_TYPE).type(GedcomxConstants.GEDCOMX_XML_MEDIA_TYPE); } }
private CollectionState(URI uri, Client client, StateFactory stateFactory) { this(ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(uri, HttpMethod.GET), client, stateFactory); }
private FamilySearchNames(URI uri, Client client, FamilySearchStateFactory stateFactory) { this(ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(uri, HttpMethod.GET), client, stateFactory); }
private DiscoveryState(URI uri, Client client, FamilyTreeStateFactory stateFactory) { this(ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(uri, HttpMethod.GET), client, stateFactory); }
public RecordState newRecordState(URI discoveryUri, Client client, String method) { ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method); if (Boolean.valueOf(System.getProperty(DONT_FOLLOW_REDIRECTS))) { request.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false); } return newRecordState(request, client.handle(request), null); }
public GedcomxApplicationState post(E entity, StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); Object accept = this.request.getHeaders().getFirst("Accept"); Object contentType = this.request.getHeaders().getFirst("Content-Type"); if (accept != null) { builder = builder.accept(String.valueOf(accept)); } if (contentType != null) { builder = builder.type(String.valueOf(contentType)); } ClientRequest request = builder.entity(entity).build(getSelfUri(), HttpMethod.POST); return clone(request, invoke(request, options)); }
public PersonState newPersonState(URI discoveryUri, Client client, String method) { ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method); if (Boolean.valueOf(System.getProperty(ENABLE_JERSEY_LOGGING_ENV_NAME))) { // handles null client.addFilter(new com.sun.jersey.api.client.filter.LoggingFilter()); } return newPersonState(request, client.handle(request), null); }
public GedcomxApplicationState delete(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); Object accept = this.request.getHeaders().getFirst("Accept"); if (accept != null) { builder = builder.accept(String.valueOf(accept)); } ClientRequest request = builder.build(getSelfUri(), HttpMethod.DELETE); return clone(request, invoke(request, options)); }
public GedcomxApplicationState head(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); Object accept = this.request.getHeaders().getFirst("Accept"); if (accept != null) { builder = builder.accept(String.valueOf(accept)); } ClientRequest request = builder.build(getSelfUri(), HttpMethod.HEAD); return clone(request, invoke(request, options)); }
/** * Create a new places state with the given URI * * @param discoveryUri the discovery URI for places * @param client the client that will use the new places state * @param method the HTTP method to call * @return a new places state created with with the given URI */ public FamilySearchPlaces newPlacesState(URI discoveryUri, Client client, String method) { ClientRequest request = ClientRequest.create().accept(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE).build(discoveryUri, method); return newPlacesState(request, client.handle(request), null); }
@Override public TempleCardPrintSetState get(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); builder = builder.accept("application/pdf"); ClientRequest request = builder.build(getSelfUri(), HttpMethod.GET); ClientResponse response = invoke(request, options); return (TempleCardPrintSetState) clone(request, response); } }
@Override public TempleCardPrintSetState head(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); builder = builder.accept("application/pdf"); ClientRequest request = builder.build(getSelfUri(), HttpMethod.HEAD); ClientResponse response = invoke(request, options); return (TempleCardPrintSetState) clone(request, response); }
public GedcomxApplicationState options(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); Object accept = this.request.getHeaders().getFirst("Accept"); if (accept != null) { builder = builder.accept(String.valueOf(accept)); } ClientRequest request = builder.build(getSelfUri(), HttpMethod.OPTIONS); return clone(request, invoke(request, options)); }
public PersonMatchResultsState updateMatchStatus(Entry entry, MatchStatus status, StateTransitionOption... options) { URI updateStatusUri = UriBuilder.fromUri(getSelfUri()).replaceQueryParam(FamilySearchOptions.STATUS, status.name().toLowerCase()).build(); ClientRequest request = createAuthenticatedRequest() .type(GedcomxConstants.GEDCOMX_JSON_MEDIA_TYPE) .accept(AtomModel.ATOM_GEDCOMX_JSON_MEDIA_TYPE) .entity(new Gedcomx().person(new Person().identifier(new Identifier(entry.getId(), IdentifierType.Persistent)))) .build(updateStatusUri, HttpMethod.POST); return ((FamilySearchStateFactory)this.stateFactory).newPersonMatchResultsState(request, invoke(request, options), this.accessToken); }
public GedcomxApplicationState get(StateTransitionOption... options) { ClientRequest.Builder builder = createAuthenticatedRequest(); Object accept = this.request.getHeaders().getFirst("Accept"); if (accept != null) { builder = builder.accept(String.valueOf(accept)); } ClientRequest request = builder.build(getSelfUri(), HttpMethod.GET); ClientResponse response = invoke(request, options); return clone(request, response); }
/** * Add Accept and Content-Type headers for basic JSON; this is used when retrieving RDF data * * @param request the request to add the headers to * @return the request with Accept and Content-Type headers for basic JSON added */ public static ClientRequest.Builder applyFamilySearchJson(ClientRequest.Builder request) { return request.accept(MediaType.APPLICATION_JSON_TYPE).type(MediaType.APPLICATION_JSON_TYPE); }