本文整理汇总了Java中javax.ws.rs.client.Invocation.Builder.post方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.post方法的具体用法?Java Builder.post怎么用?Java Builder.post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.client.Invocation.Builder
的用法示例。
在下文中一共展示了Builder.post方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createWorkFrom
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
/** Publishes the object (its MODS) as a new "work" in the ORCID profile */
MCRWork createWorkFrom(MCRObjectID objectID)
throws IOException, JDOMException, SAXException {
WebTarget target = orcid.getWebTarget().path("work");
Builder builder = buildInvocation(target);
Document workXML = buildWorkXMLFrom(objectID);
Entity<InputStream> input = buildRequestEntity(workXML);
LOGGER.info("post (create){} at {}", objectID, target.getUri());
Response response = builder.post(input);
expect(response, Response.Status.CREATED);
String putCode = getPutCode(response);
MCRWork work = new MCRWork(orcid, putCode);
work.fetchDetails();
return work;
}
示例2: insertStatusReturn
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Override
public StatusResult insertStatusReturn(WebTarget webClient, final T object,
final Map<String, Object> pathParams,
final Map<String, Object> queryParams, final Map<String, Object> builderProperties) throws Exception {
if (queryParams != null)
webClient = applyQuery(webClient, queryParams);
if (pathParams != null)
webClient = webClient.resolveTemplates(pathParams);
Builder builder = acceptMediaType(webClient.request());
if (builderProperties != null){
addBuilderProperties(builder, builderProperties);
}
Response resp = builder.post(Entity.entity(object, acceptMediaType()));
return getStatusResult(resp);
}
示例3: insert
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Override
public Response insert(WebTarget webClient, final InputStream object,
final Map<String, Object> pathParams,
final Map<String, Object> queryParams, final Map<String, Object> builderProperties) throws Exception {
if (queryParams != null)
webClient = applyQuery(webClient, queryParams);
if (pathParams != null)
webClient = webClient.resolveTemplates(pathParams);
Builder builder = acceptMediaType(webClient.request());
if (builderProperties != null){
addBuilderProperties(builder, builderProperties);
}
return builder.post(Entity.entity(object, MediaType.APPLICATION_OCTET_STREAM_TYPE));
}
示例4: evaluate
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
static ObjectNode evaluate(WebTarget endpoint,
QueryRequest request) throws QueryException {
Builder invocationBuilder = endpoint.request(MediaType.APPLICATION_JSON_TYPE);
ObjectNode result = invocationBuilder.post(Entity.entity(request,
MediaType.APPLICATION_JSON_TYPE),
ObjectNode.class);
ArrayNode errors = result.withArray("errors");
if (errors.size() > 0) {
throw new QueryException(errors);
}
return (ObjectNode) result.get("data");
}
示例5: post
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
/**
* Posts the request and returns the response.
*
* @throws MCRConfigurationException if request fails, e.g. because of misconfigured client ID and secret
*/
public MCRTokenResponse post() throws MCRConfigurationException, IOException {
Entity<Form> formEntity = Entity.entity(form, MediaType.APPLICATION_FORM_URLENCODED_TYPE);
WebTarget target = baseTarget.path("token");
Builder b = target.request().accept(MediaType.APPLICATION_JSON);
Response r = b.post(formEntity);
MCRTokenResponse response = new MCRTokenResponse(r);
if (!response.wasSuccessful()) {
throw new MCRConfigurationException(response.getStatusMessage());
}
return response;
}
示例6: will_fail_on_init
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void will_fail_on_init(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
resp.close();
}
示例7: a_post_with_expected_signature_passes_the_filter
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_expected_signature_passes_the_filter(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
resp.close();
}
示例8: a_post_with_missing_signature_fails
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_missing_signature_fails(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
final Builder request = target.request(MediaType.TEXT_PLAIN);
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
resp.close();
}
示例9: a_post_with_signature_with_wrong_password_fails
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_wrong_password_fails(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "modified-password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA1, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
resp.close();
}
示例10: a_post_with_signature_with_wrong_converter_fails
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_wrong_converter_fails(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA, XHubDigest.SHA1, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.INTERNAL_SERVER_ERROR.getStatusCode()));
resp.close();
}
示例11: a_post_with_signature_with_SH256_digest_succeed
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_SH256_digest_succeed(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA256, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
resp.close();
}
示例12: a_post_with_signature_with_SHA512_digest_succeed
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_SHA512_digest_succeed(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.SHA512, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
resp.close();
}
示例13: a_post_with_signature_with_MD5_digest_succeed
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Test
public void a_post_with_signature_with_MD5_digest_succeed(@ArquillianResteasyResource("resources/webhook") WebTarget target) {
String data = "This our important content to be sent";
String secret = "password4tests";
final Builder request = target.request(MediaType.TEXT_PLAIN);
request.header("X-Hub-Signature", XHub.generateHeaderXHubToken(XHubConverter.HEXA_LOWERCASE, XHubDigest.MD5, secret, data.getBytes()));
Response resp = request.post(Entity.text(data));
assertThat(resp, notNullValue());
assertThat(resp.getStatus(), is(Status.ACCEPTED.getStatusCode()));
resp.close();
}
示例14: post
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public <T> T post(String url, Object payload, Class<T> type) {
Client client = ClientBuilder.newClient();
WebTarget resource = client.target(url);
Builder request = resource.request();
request.accept(MediaType.APPLICATION_JSON);
return request.post(
Entity.entity(JacksonUtil.serializeToJson(payload), MediaType.APPLICATION_JSON), type
);
}
示例15: post
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
public<T> T post(String url, Object payload,Class<T> type) {
Client client = ClientBuilder.newClient();
WebTarget resource = client.target(url);
Builder request = resource.request();
request.accept(MediaType.APPLICATION_JSON);
return request.post(Entity.entity(JacksonUtil.serializeToJson(payload),MediaType.APPLICATION_JSON), type);
}