當前位置: 首頁>>代碼示例>>Java>>正文


Java WebTarget.queryParam方法代碼示例

本文整理匯總了Java中javax.ws.rs.client.WebTarget.queryParam方法的典型用法代碼示例。如果您正苦於以下問題:Java WebTarget.queryParam方法的具體用法?Java WebTarget.queryParam怎麽用?Java WebTarget.queryParam使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.ws.rs.client.WebTarget的用法示例。


在下文中一共展示了WebTarget.queryParam方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getEntities

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
/**
 * Returns a list of Entities of the relevant type after filtering using a path param query.
 * Example: "category", 2, 1, 3 will return 3 items in Category with ID 2,
 * beginning from item with index 1 (skipping item 0).
 * Note that the AbstractCRUDEndpoint does not offer this feature by default.
 * @param client The REST client to use.
 * @param filterURI Name of the objects to filter for. E.g., "category".
 * @param filterId Id of the Object to filter for. E.g, 2
 * @param startIndex The index of the first entity to return (index, not ID!). -1,
 * if you don't want to set an index.
 * @param limit Maximum amount of entities to return. -1, for no max.
 * @param <T> Type of entity to handle.
 * @throws NotFoundException If 404 was returned.
 * @throws TimeoutException If 408 was returned.
 * @return List of entities; empty list if non were found.
 */
public static <T> List<T> getEntities(RESTClient<T> client, String filterURI,
		long filterId, int startIndex, int limit) throws NotFoundException, TimeoutException {
	WebTarget target = client.getService().path(client.getApplicationURI())
			.path(client.getEndpointURI()).path(filterURI).path(String.valueOf(filterId));
	if (startIndex >= 0) {
		target = target.queryParam("start", startIndex);
	}
	if (limit >= 0) {
		target = target.queryParam("max", limit);
	}
	Response response = target.request(MediaType.APPLICATION_JSON).get();
	if (response.getStatus() == Status.NOT_FOUND.getStatusCode()) {
		throw new NotFoundException();
	} else if (response.getStatus() == Status.REQUEST_TIMEOUT.getStatusCode()) {
		throw new TimeoutException();
	}
	List<T> entities = new ArrayList<T>();
	if (response != null && response.getStatus() == 200) {
		try {
			entities = response.readEntity(client.getGenericListType());
		} catch (ProcessingException e) {
			e.printStackTrace();
			LOG.warn("Response did not conform to expected entity type. List expected.");
		}
	}
	if (response != null) {
		response.close();
	}
	return entities;
}
 
開發者ID:DescartesResearch,項目名稱:Pet-Supply-Store,代碼行數:47,代碼來源:NonBalancedCRUDOperations.java

示例2: QuerryBillStatus

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
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);
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:21,代碼來源:KPRest.java

示例3: QuerryBillStatus

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
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.APPLICATION_JSON).get(String.class);
}
 
開發者ID:VietOpenCPS,項目名稱:opencps-v2,代碼行數:22,代碼來源:KPJsonRest.java

示例4: validateIteartorPaginationTest

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
private void validateIteartorPaginationTest(String path, String datasetName, String datasetVersion) {
  WebTarget webTarget = getAPIv2().path(path);
  if (datasetName != null) {
    if (datasetVersion == null) {
      webTarget.queryParam("filter", "ds==" + datasetName);
    } else {
      webTarget.queryParam("filter", format("ds==%s;dsv==%s", datasetName, datasetVersion));
    }
  }
  JobsUI jobs = expectSuccess(getBuilder(webTarget.queryParam("limit", 1)).buildGet(), JobsUI.class);
  assertEquals(1, jobs.getJobs().size());
  assertTrue(jobs.getNext() != null);
  JobsUI jobs2 = expectSuccess(getBuilder(jobs.getNext()).buildGet(), JobsUI.class);
  assertEquals(1, jobs2.getJobs().size());
  JobsUI jobs3 = expectSuccess(getBuilder(jobs2.getNext()).buildGet(), JobsUI.class);
  assertEquals(0, jobs3.getJobs().size());
  assertTrue(jobs3.getNext() == null);
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:19,代碼來源:TestServerJobs.java

示例5: get

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
public RpcClientResult get(String path, Map<String, String> params) {
    if (null == serverUri) {
        throw new RuntimeException("service url is null");
    }
    WebTarget target = client.target(serverUri).path(path);
    if (null != params && !params.isEmpty()) {
        for (String key : params.keySet()) {
            target.queryParam(key, params.get(key));
        }
    }
    return target.request(APPLICATION_JSON).get(RpcClientResult.class);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:13,代碼來源:RestFulUtils.java

示例6: delete

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
public RpcClientResult delete(String path, Map<String, String> params) {
    if (null == serverUri) {
        throw new RuntimeException("service url is null");
    }
    WebTarget target = client.target(serverUri).path(path);
    if (null != params && !params.isEmpty()) {
        for (String key : params.keySet()) {
            target.queryParam(key, params.get(key));
        }
    }
    return target.request().delete(RpcClientResult.class);
}
 
開發者ID:nuls-io,項目名稱:nuls,代碼行數:13,代碼來源:RestFulUtils.java

示例7: getInvocationBuilder

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
protected Builder getInvocationBuilder(String url, Map<String, String> queryParameters) {
		ClientConfig clientConfig = new ClientConfig();
		if (getProxyAddress() != null) {
			clientConfig.connectorProvider(new ApacheConnectorProvider());
			clientConfig.property(ClientProperties.PROXY_URI, getProxyAddress());
		}
		Client client = ClientBuilder.newClient(clientConfig);
		client.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
		WebTarget webTarget = client.target(url);

		if (queryParameters != null) {
			for (Map.Entry<String, String> queryParameter: queryParameters.entrySet())
//				webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue().replace("_", "_1").replace("%",  "_0"));
				webTarget = webTarget.queryParam(queryParameter.getKey(), queryParameter.getValue());
		}

		
		return webTarget.request(MediaType.APPLICATION_JSON).accept("application/ld+json").header("Authorization", getCloudTokenValue());
	}
 
開發者ID:Smartlogic-Semaphore-Limited,項目名稱:Java-APIs,代碼行數:20,代碼來源:OEClientReadOnly.java

示例8: createWebResource

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
/**
 * Create a web resource with the given parameters for the given URL
 */
public WebTarget createWebResource(String serviceURL,
        Map<String, String> queryParams) {
    Client client = ClientBuilder.newClient();
    WebTarget webResource = client.target(serviceURL);
    for (String key : queryParams.keySet()) {
        webResource = webResource.queryParam(key, queryParams.get(key));
    }
    return webResource;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:13,代碼來源:RestDAO.java

示例9: createMultiValueWebResource

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
/**
 * Create a web resource with the given multi-valued parameters for the
 * given URL
 */
public WebTarget createMultiValueWebResource(String serviceURL,
        QueryParamMultiValuedMap queryParams) {
    Client client = ClientBuilder.newClient();
    WebTarget webResource = client.target(serviceURL);
    for (Map.Entry entry : queryParams.getMap().entrySet()) {
        webResource = webResource.queryParam(entry.getKey().toString(), entry.getValue());
    }
    return webResource;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:14,代碼來源:RestDAO.java

示例10: request

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
private Invocation.Builder request(String path, Map<String, String> queryParams) {
	WebTarget target = httpClient.target(getBaseUri() + BASE_PATH).path(path);
	if (queryParams != null && !queryParams.isEmpty()) {
		Set<String> keys = queryParams.keySet();
		for (String key : keys) {
			target = target.queryParam(key, queryParams.get(key));
		}
	}
	return target.request();
}
 
開發者ID:crnk-project,項目名稱:crnk-framework,代碼行數:11,代碼來源:JsonApiResponseFilterTestBase.java

示例11: configure

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
/**
 * Configure a JAX-RS {@link WebTarget} using given request definition
 * @param request Request definition
 * @return Configured WebTarget
 */
protected WebTarget configure(RequestDefinition request) {
	WebTarget target = getClient().target(request.getRequestURI());
	// template parameters
	target = target.resolveTemplates(request.getTemplateParameters());
	// query parameters
	for (Entry<String, Object[]> qp : request.getQueryParameters().entrySet()) {
		target = target.queryParam(qp.getKey(), qp.getValue());
	}
	// property set
	final WebTarget configuredTarget = target;
	request.getPropertySet().ifPresent(ps -> configuredTarget.register(new PropertyBoxReaderInterceptor(ps)));
	// done
	return configuredTarget;
}
 
開發者ID:holon-platform,項目名稱:holon-jaxrs,代碼行數:20,代碼來源:JaxrsClientRestClient.java

示例12: search

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
/**
 * Search KLADR catalog.
 *
 * @param request search request
 * @return search result
 */
public Response search(final Request request) {
    LOGGER.debug("search request: {}", request);
    WebTarget targetWithParams = target;
    for (final Map.Entry<String, String> entry: request.toMap().entrySet()) {
        targetWithParams = targetWithParams.queryParam(entry.getKey(), entry.getValue());
    }
    LOGGER.debug("search request url: {}", targetWithParams.getUri().toString());
    final Response response =  targetWithParams.request(MediaType.APPLICATION_JSON_TYPE).get(Response.class);
    LOGGER.debug("search result: {}", response);
    return response;
}
 
開發者ID:mvpotter,項目名稱:kladr-api-client,代碼行數:18,代碼來源:KladrApiClient.java

示例13: getWebTarget

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
private WebTarget getWebTarget(String[] pathItem, KeyValue[] queryParams) {
    WebTarget result = basePath;
    for (String item : pathItem) {
        result = result.path(item.replace(SERVICE_PLACEHOLDER, serviceName));
    }

    for (KeyValue param : queryParams) {
        result = result.queryParam(param.key, param.value);
    }

    return result;
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:13,代碼來源:ExternalEndpointRedirectorEnvLoader.java

示例14: getRequestForTestCase

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
private Invocation.Builder getRequestForTestCase(RedirectorTestCase redirectorTestCase, String appName) {
    WebTarget webTarget = new ServiceHelper(endpointUrlForApp(appName)).getWebTarget();
    webTarget = webTarget.queryParam(DataParamName.testInfo.name(), redirectorTestCase.getName());
    webTarget = webTarget.queryParam(Context.SESSION_ID, redirectorTestCase.getName());
    for (Parameter parameter : redirectorTestCase.getParameters()) {
        List<Value> values = parameter.getValues();
        Value value = CollectionUtils.isNotEmpty(values) ? values.get(0) : new Value("");
        webTarget = webTarget.queryParam(parameter.getName(), value);
    }

    return webTarget.request();
}
 
開發者ID:Comcast,項目名稱:redirector,代碼行數:13,代碼來源:HttpTestCasesRunner.java

示例15: buildRequest

import javax.ws.rs.client.WebTarget; //導入方法依賴的package包/類
@Override
Invocation buildRequest(WebTarget initial, ContextListener context) {
  WebTarget t = initial
      .path(resource)
      .path("_search");
  for (Entry<String,String> entry : parameters.entrySet()) {
    t = t.queryParam(entry.getKey(), entry.getValue());
  }

  context.addContext(t);
  context.addContext("Query", query);
  return t.request().header(CONTENT_TYPE, APPLICATION_JSON).build("POST", Entity.json(query));
}
 
開發者ID:dremio,項目名稱:dremio-oss,代碼行數:14,代碼來源:ElasticActions.java


注:本文中的javax.ws.rs.client.WebTarget.queryParam方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。