本文整理了Java中javax.ws.rs.client.Entity.xml()
方法的一些代码示例,展示了Entity.xml()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Entity.xml()
方法的具体详情如下:
包路径:javax.ws.rs.client.Entity
类名称:Entity
方法名:xml
[英]Create an javax.ws.rs.core.MediaType#APPLICATION_XML entity.
[中]创建一个javax。ws。rs.core。MediaType#应用程序"XML实体。
代码示例来源:origin: oracle/opengrok
/**
* Write the current configuration to a socket
*
* @param host the host address to receive the configuration
* @throws IOException if an error occurs
*/
public void writeConfiguration(String host) throws IOException {
String configXML;
try {
configLock.readLock().lock();
configXML = configuration.getXMLRepresentationAsString();
} finally {
configLock.readLock().unlock();
}
Response r = ClientBuilder.newClient()
.target(host)
.path("api")
.path("v1")
.path("configuration")
.queryParam("reindex", true)
.request()
.put(Entity.xml(configXML));
if (r.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
throw new IOException(r.toString());
}
}
代码示例来源:origin: Pay-Group/best-pay-sdk
@Post
public ResponseValue postXml(Path path, QueryParam queryParam, String xmlParam, HeaderParam headerParam) {
Objects.requireNonNull(xmlParam, "Xml is null.");
WebTarget target = this.target;
if (path != null) {
target = path.appendToTarget(this.target);
}
if (queryParam != null) {
target = queryParam.appendToTarget(target);
}
Builder request = target.request();
if (headerParam != null) {
request = headerParam.appendToRequest(request);
}
try {
this.logger.debug("Prepare to post to {} with query {}, body {} and header {}.", path, queryParam, xmlParam, headerParam);
Response r = request.post(Entity.xml(xmlParam), Response.class);
return toResponseValue(r);
} catch (ProcessingException | WebApplicationException e) {
this.logger.error("Fail to post.", e);
return ResponseValue.internalServerError();
}
}
代码示例来源:origin: Pay-Group/best-pay-sdk
@Put
public ResponseValue putXml(Path path, QueryParam queryParam, String xmlParam, HeaderParam headerParam) {
Objects.requireNonNull(xmlParam, "Xml is null.");
WebTarget target = this.target;
if (path != null) {
target = path.appendToTarget(this.target);
}
if (queryParam != null) {
target = queryParam.appendToTarget(target);
}
Builder request = target.request();
if (headerParam != null) {
request = headerParam.appendToRequest(request);
}
try {
this.logger.debug("Prepare to put to {} with query {}, body {} and header {}.", path, queryParam, xmlParam, headerParam);
Response r = request.put(Entity.xml(xmlParam), Response.class);
return toResponseValue(r);
} catch (ProcessingException | WebApplicationException e) {
this.logger.error("Fail to put.", e);
return ResponseValue.internalServerError();
}
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult createDatabase(String database, boolean ignoreIfExists) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("databases")
.queryParam("sessionid", this.connection.getSessionHandle())
.queryParam("ignoreIfExisting", ignoreIfExists)
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(database)));
}
代码示例来源:origin: apache/lens
public APIResult addPartitionToFactTable(String fact, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("facts").path(fact)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){})));
}
代码示例来源:origin: apache/lens
public APIResult addStorageToFactTable(String factname, XStorageTableElement storage) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("facts").path(factname).path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XStorageTableElement>>(
objFact.createXStorageTableElement(storage)){})));
}
代码示例来源:origin: zanata/zanata-platform
public Response put(ProjectIteration projectVersion) {
Response response = webResource().request()
.put(Entity.xml(projectVersion));
if (response.getStatusInfo().getFamily() != Response.Status.Family.SUCCESSFUL) {
throw new RuntimeException(response.getStatusInfo().toString());
}
response.close();
return response;
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult updatePartitionsOfDimensionTable(String dimTblName, String storage,
XPartitionList partitions) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("dimtables").path(dimTblName)
.path("storages").path(storage).path("partitions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.put(Entity.xml(new GenericEntity<JAXBElement<XPartitionList>>(objFact.createXPartitionList(partitions)){})));
}
代码示例来源:origin: apache/lens
public APIResult updatePartitionOfFactTable(String fact, String storage,
XPartition partition) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("facts").path(fact)
.path("storages").path(storage).path("partition")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.put(Entity.xml(new GenericEntity<JAXBElement<XPartition>>(objFact.createXPartition(partition)){})));
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult createDimension(XDimension dimension) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("dimensions")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XDimension>>(objFact.createXDimension(dimension)){})));
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult createCube(XCube cube) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("cubes")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){})));
}
代码示例来源:origin: apache/lens
public APIResult setDatabase(String database) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("databases").path("current")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
.put(Entity.xml(database)));
}
代码示例来源:origin: apache/lens
public APIResult createNewStorage(XStorage storage) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("storages")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XStorage>>(objFact.createXStorage(storage)){})));
}
代码示例来源:origin: apache/lens
public APIResult createFactTable(XFact f) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("facts")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XFact>>(objFact.createXFact(f)){})));
}
代码示例来源:origin: apache/lens
public APIResult createCube(XCube cube) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("cubes")
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.post(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){})));
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult updateFactTable(String factName, XFact table) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("facts").path(factName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
.put(Entity.xml(new GenericEntity<JAXBElement<XFact>>(objFact.createXFact(table)){})));
}
代码示例来源:origin: org.apache.lens/lens-client
public APIResult updateCube(String cubeName, XCube cube) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("cubes").path(cubeName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML)
.put(Entity.xml(new GenericEntity<JAXBElement<XCube>>(objFact.createXCube(cube)){})));
}
代码示例来源:origin: apache/lens
public APIResult updateSegmentation(String segName, XSegmentation seg) {
WebTarget target = getMetastoreWebTarget();
return translate(target.path("segmentations").path(segName)
.queryParam("sessionid", this.connection.getSessionHandle())
.request(MediaType.APPLICATION_XML_TYPE)
.put(Entity.xml(new GenericEntity<JAXBElement<XSegmentation>>(objFact.
createXSegmentation(seg)){})));
}
代码示例来源:origin: apache/cxf
@Test
public void testPostBookAsync() throws Exception {
String address = "http://localhost:" + PORT + "/bookstore/bookheaders/simple/async";
WebClient wc = createWebClientPost(address);
Future<Book> future = wc.async().post(Entity.xml(new Book("Book", 126L)), Book.class);
assertEquals(124L, future.get().getId());
validatePostResponse(wc, true, false);
}
代码示例来源:origin: apache/cxf
@Test
public void testRetrieveBookCustomMethodAsync() throws Exception {
String address = "http://localhost:" + PORT + "/bookstore/retrieve";
WebClient wc = WebClient.create(address);
wc.accept("application/xml");
Future<Book> book = wc.async().method("RETRIEVE", Entity.xml(new Book("Retrieve", 123L)),
Book.class);
assertEquals("Retrieve", book.get().getName());
wc.close();
}
内容来源于网络,如有侵权,请联系作者删除!