Java Code Examples for javax.ws.rs.client.WebTarget#path()
The following examples show how to use
javax.ws.rs.client.WebTarget#path() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMasterDown.java From dremio-oss with Apache License 2.0 | 6 votes |
private static void initMasterClient() { JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); ObjectMapper objectMapper = JSONUtil.prettyMapper(); JSONUtil.registerStorageTypes(objectMapper, DremioTest.CLASSPATH_SCAN_RESULT, ConnectionReader.of(DremioTest.CLASSPATH_SCAN_RESULT, DremioTest.DEFAULT_SABOT_CONFIG)); objectMapper.registerModule( new SimpleModule() .addDeserializer(JobDataFragment.class, new JsonDeserializer<JobDataFragment>() { @Override public JobDataFragment deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException { return jsonParser.readValueAs(DataPOJO.class); } } ) ); provider.setMapper(objectMapper); masterClient = ClientBuilder.newBuilder().register(provider).register(MultiPartFeature.class).build(); WebTarget rootTarget = masterClient.target("http://localhost:" + masterDremioDaemon.getWebServer().getPort()); masterApiV2 = rootTarget.path(API_LOCATION); }
Example 2
Source File: CKANCreation.java From aliada-tool with GNU General Public License v3.0 | 6 votes |
/** * Gets the organization information from CKAN Datahub. * * @param datasetName the dataset name. * @return the {@link eu.aliada.ckancreation.model.CKANDatasetResponse} * which contains the information of the dataset in CKAN. * @since 2.0 */ public CKANDatasetResponse getDatasetCKAN(final String datasetName){ final Client client = getClientForSSL(); final WebTarget webTarget = client.target(jobConf.getCkanApiURL()); //GET final WebTarget resourceWebTarget = webTarget.path("/package_show"); final Response getResponse = resourceWebTarget .queryParam("id", datasetName) .request().header("Authorization", jobConf.getCkanApiKey()).get(); final String datasetShowResp = getResponse.readEntity(String.class); //Convert JSON representation to Java Object with JACKSON libraries CKANDatasetResponse cResponse = new CKANDatasetResponse(); final ObjectMapper mapper = new ObjectMapper(); try { cResponse = mapper.readValue(datasetShowResp, CKANDatasetResponse.class); } catch (Exception exception) { cResponse.setSuccess("false"); LOGGER.error(MessageCatalog._00032_OBJECT_CONVERSION_FAILURE, exception); } return cResponse; }
Example 3
Source File: ElasticTestActions.java From dremio-oss with Apache License 2.0 | 6 votes |
@Override public Result getResult(WebTarget target) { WebTarget t = target; target.path(Joiner.on(",").join(indexes)).path("_mapping"); if (indexes.size() > 0) { t = t.path(Joiner.on(",").join(indexes)); } t = t.path("_mapping"); if (types.size() > 0) { t = t.path(Joiner.on(",").join(types)); } try { return new JsonResult(t.request().buildGet().invoke(byte[].class)); } catch (WebApplicationException e) { return new FailureResult(e.getResponse().getStatus(), e.getMessage()); } }
Example 4
Source File: KPRest.java From opencps-v2 with GNU Affero General Public License v3.0 | 6 votes |
public String QuerryBillStatus(String merchant_trans_id, String good_code, String trans_id, String merchant_code, String secure_hash) throws ClientErrorException { WebTarget resource = webTarget; if (merchant_code != null) { resource = resource.queryParam("merchant_code", merchant_code); } if (good_code != null) { resource = resource.queryParam("good_code", good_code); } if (merchant_trans_id != null) { resource = resource.queryParam("merchant_trans_id", merchant_trans_id); } if (secure_hash != null) { resource = resource.queryParam("secure_hash", secure_hash); } if (trans_id != null) { resource = resource.queryParam("trans_id", trans_id); } resource = resource.path("QuerryBillStatus"); return resource.request(javax.ws.rs.core.MediaType.TEXT_PLAIN).get(String.class); }
Example 5
Source File: FHIRClientImpl.java From FHIR with Apache License 2.0 | 5 votes |
@Override public FHIRResponse search(String resourceType, FHIRParameters parameters, FHIRRequestHeader... headers) throws Exception { if (resourceType == null) { throw new IllegalArgumentException("The 'resourceType' argument is required but was null."); } WebTarget endpoint = getWebTarget(); endpoint = endpoint.path(resourceType); endpoint = addParametersToWebTarget(endpoint, parameters); Invocation.Builder builder = endpoint.request(getDefaultMimeType()); builder = addRequestHeaders(builder, headers); Response response = builder.get(); return new FHIRResponseImpl(response); }
Example 6
Source File: ApiHandler.java From riotapi with Apache License 2.0 | 5 votes |
/** * Create a new ApiHandler object * * @param shard The target region * @param token The api key */ public ApiHandler(Shard shard, String token) { if (token == null || token.isEmpty()) { throw new IllegalArgumentException("Need token"); } String region = shard.name; Client c = ClientBuilder.newClient(); if (shard.isGarena) { log.warn("Garena doesn't support a public API. Only static-data is supported for this shard."); currentGameHandler = null; featuredGamesHandler = null; } else { WebTarget defaultTarget = c.target(shard.apiUrl).queryParam("api_key", token).path(region); WebTarget spectatorTarget = c.target(String.format(SPECTATOR_API_URL, shard.name)).queryParam("api_key", token); championInfoTarget = defaultTarget.path("v1.2").path("champion"); gameInfoTarget = defaultTarget.path("v1.3").path("game/by-summoner"); leagueInfoTarget = defaultTarget.path("v2.5").path("league"); matchInfoTarget = defaultTarget.path("v2.2").path("match"); matchHistoryInfoTarget = defaultTarget.path("v2.2").path("matchlist/by-summoner"); statsTarget = defaultTarget.path("v1.3").path("stats/by-summoner"); summonerInfoTarget = defaultTarget.path("v1.4").path("summoner"); teamInfoTarget = defaultTarget.path("v2.4").path("team"); this.currentGameHandler = new CurrentGame("v1.0", spectatorTarget.path("consumer")); this.featuredGamesHandler = new FeaturedGamesHandler("v1.0", spectatorTarget.path("featured")); } WebTarget defaultStaticTarget = c.target(API_GLOBAL_URL).queryParam("api_key", token).path("static-data").path(region); statusTarget = c.target("http://status.leagueoflegends.com").path("shards"); staticDataTarget = defaultStaticTarget.path("v1.2"); }
Example 7
Source File: StoreServiceClient.java From geowave with Apache License 2.0 | 5 votes |
private static WebTarget addPathFromAnnotation(final AnnotatedElement ae, WebTarget target) { final Path p = ae.getAnnotation(Path.class); if (p != null) { target = target.path(p.value()); } return target; }
Example 8
Source File: WebResourceFactory.java From rx-jersey with MIT License | 5 votes |
private static WebTarget addPathFromAnnotation(final AnnotatedElement ae, WebTarget target) { final Path p = ae.getAnnotation(Path.class); if (p != null) { target = target.path(p.value()); } return target; }
Example 9
Source File: ImportOperationTest.java From FHIR with Apache License 2.0 | 5 votes |
public Response doGet(String path, String mimeType) { WebTarget target = getWebTarget(); target = target.path(path); return target.request(mimeType) .header("X-FHIR-TENANT-ID", tenantName) .header("X-FHIR-DSID", dataStoreId) .get(Response.class); }
Example 10
Source File: DefaultDockerClient.java From docker-client with Apache License 2.0 | 5 votes |
private WebTarget resource() { final WebTarget target = client.target(uri); if (!isNullOrEmpty(apiVersion)) { return target.path(apiVersion); } return target; }
Example 11
Source File: CloudantStore.java From todo-apps with Apache License 2.0 | 5 votes |
/** * Creates a CloudantStore. * @param target The target (URL) for the CloudantStore. * @throws ToDoStoreException */ public CloudantStore(WebTarget target) throws ToDoStoreException { //Uncomment to enable HTTP logging in Jersey //target = target.register(new LoggingFilter(LOG, true)); createDB(target); this.target = target.path("bluemix-todo"); createDesignDoc(this.target); }
Example 12
Source File: JerseyRemoteProcessGroupClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyRemoteProcessGroupClient(final WebTarget baseTarget, final Map<String, String> headers) { super(headers); this.processGroupTarget = baseTarget.path("/process-groups/{pgId}"); this.rpgTarget = baseTarget.path("/remote-process-groups/{id}"); }
Example 13
Source File: JerseyPoliciesClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyPoliciesClient(final WebTarget baseTarget, final Map<String, String> headers) { super(headers); this.policiesTarget = baseTarget.path("/policies"); }
Example 14
Source File: JerseyParamContextClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyParamContextClient(final WebTarget baseTarget, final Map<String,String> headers) { super(headers); this.flowTarget = baseTarget.path("/flow"); this.paramContextTarget = baseTarget.path("/parameter-contexts"); }
Example 15
Source File: JerseyProcessGroupClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyProcessGroupClient(final WebTarget baseTarget, final Map<String,String> headers) { super(headers); this.processGroupsTarget = baseTarget.path("/process-groups"); }
Example 16
Source File: JerseyCountersClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyCountersClient(final WebTarget baseTarget, final Map<String,String> headers) { super(headers); this.countersTarget = baseTarget.path("/counters"); }
Example 17
Source File: JerseyReportingTasksClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyReportingTasksClient(final WebTarget baseTarget, final Map<String, String> headers) { super(headers); this.reportingTasksTarget = baseTarget.path("/reporting-tasks"); }
Example 18
Source File: ElasticActions.java From dremio-oss with Apache License 2.0 | 4 votes |
@Override Invocation buildRequest(WebTarget initial, ContextListener context) { WebTarget target = initial.path("_search/scroll"); context.addContext(target); return target.request().header(CONTENT_TYPE, APPLICATION_JSON).buildPost(Entity.json(this)); }
Example 19
Source File: JerseyTemplatesClient.java From nifi with Apache License 2.0 | 4 votes |
public JerseyTemplatesClient(final WebTarget baseTarget, final Map<String, String> headers) { super(headers); this.templatesTarget = baseTarget.path("/templates"); }
Example 20
Source File: RTransactionImpl.java From jcypher with Apache License 2.0 | 4 votes |
@Override public List<JcError> close() { List<JcError> errors; if (isClosed()) throw new RuntimeException(ERR_CLOSED); if (!isMyThread()) throw new RuntimeException(ERR_THREAD); RemoteDBAccess rdba = getRDBAccess(); rdba.removeTx(); if (this.invocationBuilder_open != null) { Builder iBuilder; if (failed) { iBuilder = createNextInvocationBuilder(); } else { WebTarget serverRootTarget = rdba.getRestClient().target(rdba.getServerRootUri()); WebTarget transactionalTarget = serverRootTarget.path(this.txLocation.concat(txCommit)); iBuilder = transactionalTarget.request(MediaType.APPLICATION_JSON_TYPE); if (rdba.getAuth() != null) iBuilder = iBuilder.header(RemoteDBAccess.authHeader, rdba.getAuth()); } Response response = null; Throwable exception = null; try { if (failed) response = iBuilder.delete(); else response = iBuilder.post(Entity.entity(emptyJSON, MediaType.APPLICATION_JSON_TYPE)); } catch(Throwable e) { exception = e; } errors = DBUtil.buildErrorList(response, exception); } else errors = new ArrayList<JcError>(); if (errors.size() > 0) failure(); setClosed(); return errors; }