当前位置: 首页>>代码示例>>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;未经允许,请勿转载。