本文整理汇总了Java中org.apache.wink.client.Resource类的典型用法代码示例。如果您正苦于以下问题:Java Resource类的具体用法?Java Resource怎么用?Java Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Resource类属于org.apache.wink.client包,在下文中一共展示了Resource类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeRequest
import org.apache.wink.client.Resource; //导入依赖的package包/类
/**
* Perform a http GET with the specified url and extra parameters.
*
* @param request
* Url
* @param extra
* Url parameters
* @return The response from the request
*/
public static String makeRequest(final String request, final String extra)
{
final String methodName = "makeRequest(String request, String extra)";
ITRACER.debugEntry(methodName);
String fullRequest = "/v2/" + request;
String timestamp = (new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"))
.format(new Date());
String full = "http://api.domaintools.com" + fullRequest
+ "?format=xml" + "&api_username=" + APIUSERNAME + "&api_key="
+ APIKEY + "×tamp=" + timestamp + extra;
if (ITRACER.isDebugEnabled())
{
Object[] values = {request, extra, full};
ITRACER.debug("request is : {0}, extra is : {1}, full uri is : {2}", values);
}
Resource resource = CLIENT.resource(full);
String result = resource.contentType(MediaType.TEXT_XML)
.accept(MediaType.TEXT_XML).get(String.class);
ITRACER.debugExit(methodName);
return result;
}
开发者ID:IBM-i2,项目名称:Data-Acquisition-Accelerators,代码行数:31,代码来源:DomainToolsLoader.java
示例2: genericRestRequestPut
import org.apache.wink.client.Resource; //导入依赖的package包/类
/**
* Generic rest client for basic rest PUT calls over REST based on Apache Wink
*
* @param resourceUrl Resource endpoint Url
* @param contentType ContentType of request
* @param acceptMediaType ContentType for response
* @param postBody Body
* @param queryParamMap Map of Query parameters
* @param headerMap Map of headers
* @param cookie jSessionID in form of JSESSIONID=<ID>
* @return Returns the response from the REST client
*/
public ClientResponse genericRestRequestPut(String resourceUrl, String contentType, String acceptMediaType,
Object postBody, Map<String, String> queryParamMap, Map<String, String> headerMap, String cookie) {
Resource resource = client.resource(resourceUrl);
if (!(queryParamMap.size() <= 0)) {
for (Map.Entry<String, String> queryParamEntry : queryParamMap.entrySet()) {
resource.queryParam(queryParamEntry.getKey(), queryParamEntry.getValue());
}
}
if (!(headerMap.size() <= 0)) {
for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) {
resource.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (cookie != null) {
resource.cookie(cookie);
}
response = resource.contentType(contentType).
accept(acceptMediaType).put(postBody);
return response;
}
开发者ID:wso2,项目名称:product-es,代码行数:35,代码来源:GenericRestClient.java
示例3: geneticRestRequestDelete
import org.apache.wink.client.Resource; //导入依赖的package包/类
public ClientResponse geneticRestRequestDelete(String resourceUrl, String contentType,
String acceptMediaType,
Map<String, String> queryParamMap,
Map<String, String> headerMap,
String cookie) {
Resource resource = client.resource(resourceUrl);
if (!(queryParamMap.size() <= 0)) {
for (Map.Entry<String, String> queryParamEntry : queryParamMap.entrySet()) {
resource.queryParam(queryParamEntry.getKey(), queryParamEntry.getValue());
}
}
if (!(headerMap.size() <= 0)) {
for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) {
resource.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (cookie != null) {
resource.cookie(cookie);
}
response = resource.contentType(contentType).
accept(acceptMediaType).delete();
return response;
}
开发者ID:wso2,项目名称:product-es,代码行数:25,代码来源:GenericRestClient.java
示例4: geneticRestRequestGet
import org.apache.wink.client.Resource; //导入依赖的package包/类
public ClientResponse geneticRestRequestGet(String resourceUrl,
Map<String, String> queryParamMap,
Map<String, String> headerMap,
String cookie) {
Resource resource = client.resource(resourceUrl);
MultivaluedMap<String, String> queryParamInMap = new MultivaluedHashMap<>();
if (!(queryParamMap.size() <= 0)) {
for (Map.Entry<String, String> queryParamEntry : queryParamMap.entrySet()) {
queryParamInMap.add(queryParamEntry.getKey(), queryParamEntry.getValue());
}
resource.queryParams(queryParamInMap);
}
if (!(headerMap.size() <= 0)) {
for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) {
resource.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (cookie != null) {
resource.cookie(cookie);
}
response = resource.get();
return response;
}
开发者ID:wso2,项目名称:product-es,代码行数:24,代码来源:GenericRestClient.java
示例5: createResource
import org.apache.wink.client.Resource; //导入依赖的package包/类
private Resource createResource(){
Resource resource = client.resource(retrieveEPR()+url).header("Authorization", "Basic "+usernametoken);
if(contentType != null){
resource.contentType(contentType);
}
if(accept != null){
resource.accept(accept);
}
return resource;
}
开发者ID:angarg12,项目名称:cloudcompaas-common,代码行数:13,代码来源:RESTComm.java
示例6: delete
import org.apache.wink.client.Resource; //导入依赖的package包/类
public void delete() throws Exception {
System.out.println("delete "+url+" "+usernametoken);
//Thread.dumpStack();
Resource resource = createResource();
ClientResponse clientResponse = resource.delete();
if(clientResponse.getStatusCode() != HttpStatus.OK.getCode()){
throw new Exception(clientResponse.getMessage());
}
}
开发者ID:angarg12,项目名称:cloudcompaas-common,代码行数:12,代码来源:RESTComm.java
示例7: put
import org.apache.wink.client.Resource; //导入依赖的package包/类
public void put(Object payload) throws Exception {
System.out.println("put "+url);
//Thread.dumpStack();
Resource resource = createResource();
ClientResponse clientResponse = resource.put(payload);
if(clientResponse.getStatusCode() != HttpStatus.OK.getCode()){
throw new Exception(clientResponse.getMessage());
}
}
开发者ID:angarg12,项目名称:cloudcompaas-common,代码行数:12,代码来源:RESTComm.java
示例8: post
import org.apache.wink.client.Resource; //导入依赖的package包/类
public XMLWrapper post(Object payload) throws Exception {
System.out.println("post "+url);
//Thread.dumpStack();
Resource resource = createResource();
ClientResponse clientResponse = resource.post(payload);
if(clientResponse.getStatusCode() != HttpStatus.OK.getCode()){
throw new Exception(clientResponse.getMessage());
}
return new XMLWrapper(clientResponse.getEntity(String.class));
}
开发者ID:angarg12,项目名称:cloudcompaas-common,代码行数:14,代码来源:RESTComm.java
示例9: get
import org.apache.wink.client.Resource; //导入依赖的package包/类
public XMLWrapper get() throws Exception {
System.out.println("get "+url);
//Thread.dumpStack();
Resource resource = createResource();
ClientResponse clientResponse = resource.get();
if(clientResponse.getStatusCode() != HttpStatus.OK.getCode()){
throw new Exception(clientResponse.getMessage());
}
return new XMLWrapper(clientResponse.getEntity(String.class));
}
开发者ID:angarg12,项目名称:cloudcompaas-common,代码行数:14,代码来源:RESTComm.java
示例10: geneticRestRequestPost
import org.apache.wink.client.Resource; //导入依赖的package包/类
/**
* Generic rest client for basic rest POST calls over REST based on Apache Wink
*
* @param resourceUrl Resource endpoint Url
* @param contentType ContentType of request
* @param acceptMediaType ContentType for response
* @param postBody Body
* @param queryParamMap Map of Query parameters
* @param headerMap Map of headers
* @param cookie jSessionID in form of JSESSIONID=<ID>
* @return
*/
public ClientResponse geneticRestRequestPost(String resourceUrl, String contentType,
String acceptMediaType, Object postBody,
Map<String, String> queryParamMap,
Map<String, String> headerMap,
String cookie) {
Resource resource = client.resource(resourceUrl);
if (!(queryParamMap.size() <= 0)) {
for (Map.Entry<String, String> queryParamEntry : queryParamMap.entrySet()) {
resource.queryParam(queryParamEntry.getKey(), queryParamEntry.getValue());
}
}
if (!(headerMap.size() <= 0)) {
for (Map.Entry<String, String> headerEntry : headerMap.entrySet()) {
resource.header(headerEntry.getKey(), headerEntry.getValue());
}
}
if (cookie != null) {
resource.cookie(cookie);
}
response = resource.contentType(contentType).
accept(acceptMediaType).post(postBody);
return response;
}
开发者ID:wso2,项目名称:product-es,代码行数:39,代码来源:GenericRestClient.java
示例11: connect
import org.apache.wink.client.Resource; //导入依赖的package包/类
/**
* link http
*
* @param server
* @param port
* @param url
* @param method
* @param data
* @return
*/
public RetRpc connect(String server, int port, String url, String method,
String data) {
RetRpc ret = new RetRpc();
String address;
if (!url.startsWith("http")) {
address = "http://" + server + ":" + port + url;
} else {
address = url;
}
// create the rest client instance
RestClient client = new RestClient();
// create the resource instance to interact with
Resource resource = client.resource(address);
// issue the request
ClientResponse response = null;
try {
if (ACTION_POST.equals(method)) {
response = resource.accept("text/plain").post(data);
} else if (ACTION_PUT.equals(method)) {
response = resource.accept("text/plain").put(data);
} else if (ACTION_DELETE.equals(method)) {
response = resource.accept("text/plain").delete();
} else {
response = resource.accept("text/plain").get();
}
} catch (Exception ex) {
ex.printStackTrace();
ret.setStatusCode(500);
ret.setMsg(ex.getMessage());
ret.setStatus("connected failed .");
return ret;
}
int code = response.getStatusCode();
String msg = response.getMessage();
ret.setStatusCode(code);
ret.setStatus(response.getStatusType().getReasonPhrase());
ret.setMsg(msg);
// deserialize response
ret.setContent(response.getEntity(String.class));
return ret;
}
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:64,代码来源:OpsRestCaller.java
示例12: connect
import org.apache.wink.client.Resource; //导入依赖的package包/类
/**
* link http
*
* @param server
* @param port
* @param url
* @param method
* @param data
* @return
*/
public RetRpc connect(String server, int port, String url, String method,
String data, String protocal, String userName, String password) {
RetRpc ret = new RetRpc();
String address;
address = protocal + "://" + server + ":" + port + url;
ClientConfig config = new ClientConfig();
config.connectTimeout(600000);
if (null != userName && userName.length() > 0 && null != password
&& password.length() > 0) {
OpsAuthSecurityHandler opsAuthHandler = new OpsAuthSecurityHandler();
opsAuthHandler.setUserName(userName);
opsAuthHandler.setPassword(password);
config.handlers(opsAuthHandler);
}
// create the rest client instance
OpsRestClient client = new OpsRestClient(config);
// create the resource instance to interact with
Resource resource = client.resource(address);
// issue the request
ClientResponse response = null;
try {
if (ACTION_POST.equals(method)) {
response = resource.post(data);
} else if (ACTION_PUT.equals(method)) {
response = resource.put(data);
} else if (ACTION_DELETE.equals(method)) {
response = resource.delete();
} else {
response = resource.get();
}
} catch (Exception ex) {
ex.printStackTrace();
ret.setStatusCode(500);
ret.setMsg(ex.getMessage());
ret.setStatus("connected failed .");
return ret;
}
int code = response.getStatusCode();
String msg = response.getMessage();
ret.setStatusCode(code);
ret.setMsg(msg);
// deserialize response
ret.setContent(response.getEntity(String.class));
return ret;
}
开发者ID:HuaweiSNC,项目名称:OpsDev,代码行数:69,代码来源:OpsRestCaller.java
注:本文中的org.apache.wink.client.Resource类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论