本文整理汇总了Java中javax.ws.rs.client.Invocation.Builder.put方法的典型用法代码示例。如果您正苦于以下问题:Java Builder.put方法的具体用法?Java Builder.put怎么用?Java Builder.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.ws.rs.client.Invocation.Builder
的用法示例。
在下文中一共展示了Builder.put方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
/**
* Generic PUT call.
*/
public <T> T put(final String path, final String bodyContent,
final String contentType, final Class<T> type,
final RestParameter... parameters) throws ImClientException {
try {
// Avoid sending null as body content
String normalizedBodyContent = normalizeBodyContent(bodyContent);
logCallInfo(HttpMethods.PUT, path);
logCallContent(HttpMethods.PUT, normalizedBodyContent);
Entity<String> content =
Entity.entity(normalizedBodyContent, contentType);
Builder clientConfigured = configureClient(path, parameters);
return clientConfigured.put(content, type);
} catch (WebApplicationException exception) {
throw new ImClientErrorException(createReponseError(exception));
}
}
示例2: updateFileContents
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@PUT
@Path(FILEPATH_PFX)
public Response updateFileContents(@PathParam(FILEPATH_PARAM) String filePathStr,
@QueryParam(ProtocolConstants.PARM_SOURCE) String source,
@HeaderParam(HttpHeaders.CONTENT_TYPE) String contentType, InputStream contents) throws IOException,
URISyntaxException {
PathInfo filePath = splitWorkspacePath(filePathStr);
Builder cheReqBuilder = getFileTarget(filePath.workspaceId, filePath.path).request();
// Pick the content stream
InputStream contentStream;
String effContentType;
if (source != null) {
URLConnection urlConn = new URL(source).openConnection();
effContentType = urlConn.getContentType();
contentStream = urlConn.getInputStream();
} else {
effContentType = contentType;
contentStream = contents;
}
Response cheResp = cheReqBuilder.put(Entity.entity(contentStream, effContentType));
assertValidResponse(cheResp);
return Response.ok().build();
}
示例3: actualizaArchivoServerXmlRemoto
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
/**
* Makes a HTTP PUT method for update the port number of a server.xml file inside a Tomcat instance on a remote slave server.
* @param pServerUrl Remote server where the agent is hosted.
* @param pUbicacionInstancia Path of tomcat instance inside the remote server.
* @param pServerXml Object ServerXml.class containing the new port configuration.
* @return True if success, otherwise false.
*/
public boolean actualizaArchivoServerXmlRemoto(String pServerUrl, String pStandarInstancePath, String pInstanceName, ServerXml pServerXml){
System.out.println(" Startup Service: "+pServerUrl+"/instance/update/serverxml");
WebTarget myTarget = client.target(pServerUrl+"/instance/update/serverxml");
Builder invocationBuilder = myTarget.request().header("instancePath", pStandarInstancePath+"/"+pInstanceName);
Response response = invocationBuilder.put(Entity.entity(pServerXml, MediaType.APPLICATION_JSON_TYPE));
if( response.getStatus() == 200){
System.out.println("Update succed.");
String responseMessageFromServer = response.getStatusInfo().getReasonPhrase();
System.out.println("ResponseMessageFromServer: " + responseMessageFromServer);
return(true);
}else{
System.out.println("ERROR, HTTP code <" + response.getStatus() + "> message:"+response.readEntity(String.class));
return(false);
}
}
示例4: update
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Override
public T update(WebTarget webClient, final T object, final String idName, final Long id,
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 (id != null && idName != null)
webClient = webClient.resolveTemplate(idName, id);
if (pathParams != null)
webClient = webClient.resolveTemplates(pathParams);
GenericType<T> genericType = new GenericType<T>(getClassP()) {
};
Builder builder = acceptMediaType(webClient.request());
if (builderProperties != null){
addBuilderProperties(builder, builderProperties);
}
return builder.put(Entity.entity(object, acceptMediaType()), genericType);
}
示例5: updateStatusReturn
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
@Override
public StatusResult updateStatusReturn(WebTarget webClient, final T object,
final String idName, final Long id,
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 (id != null && idName != null)
webClient = webClient.resolveTemplate(idName, id);
if (pathParams != null)
webClient = webClient.resolveTemplates(pathParams);
Builder builder = acceptMediaType(webClient.request());
if (builderProperties != null){
addBuilderProperties(builder, builderProperties);
}
Response resp = builder.put(Entity.entity(object, acceptMediaType()));
return getStatusResult(resp);
}
示例6: update
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
void update(MCRWork work) throws IOException, SAXException {
WebTarget target = orcid.getWebTarget().path("work").path(work.getPutCode());
Builder builder = buildInvocation(target);
Document workXML = buildWorkXMLFrom(work.getObjectID());
workXML.getRootElement().setAttribute("put-code", work.getPutCode());
Entity<InputStream> input = buildRequestEntity(workXML);
LOGGER.info("put (update) {} to {}", work.getObjectID(), target.getUri());
Response response = builder.put(input);
expect(response, Response.Status.OK);
}
示例7: makeRemoteCall
import javax.ws.rs.client.Invocation.Builder; //导入方法依赖的package包/类
protected Response makeRemoteCall(String method, UriBuilder uri, Object arg)
throws EcsManagementClientException {
if (!isLoggedIn())
login();
Client jerseyClient = buildJerseyClient();
Builder request = jerseyClient.target(uri)
.register(LoggingFeature.class).request()
.header("X-SDS-AUTH-TOKEN", authToken)
.header("Accept", "application/xml");
Response response;
if (GET.equals(method)) {
response = request.get();
} else if (POST.equals(method)) {
response = request.post(Entity.xml(arg));
} else if (PUT.equals(method)) {
response = request.put(Entity.xml(arg));
} else if (DELETE.equals(method)) {
response = request.delete();
} else {
throw new EcsManagementClientException(
"Invalid request method: " + method);
}
if (response.getStatus() == 401 && authRetries < AUTH_RETRIES_MAX) {
// attempt to re-authorize and retry up to _authMaxRetries_ times.
authRetries += 1;
this.authToken = null;
response = makeRemoteCall(method, uri, arg);
}
return response;
}