本文整理汇总了Java中com.sun.jersey.client.apache.ApacheHttpClient.resource方法的典型用法代码示例。如果您正苦于以下问题:Java ApacheHttpClient.resource方法的具体用法?Java ApacheHttpClient.resource怎么用?Java ApacheHttpClient.resource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jersey.client.apache.ApacheHttpClient
的用法示例。
在下文中一共展示了ApacheHttpClient.resource方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getStringFromUrl
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
/**
* get a String from a given URL
*
* @param urlString
* @return
*/
public static String getStringFromUrl(String urlString) {
ApacheHttpClient lclient = ApacheHttpClient.create();
WebResource webResource = lclient.resource(urlString);
ClientResponse response = webResource.get(ClientResponse.class);
if (response.getStatus() != 200) {
throw new RuntimeException("HTTP error code : " + response.getStatus());
}
String result = response.getEntity(String.class);
return result;
}
示例2: getOutages
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsOutage> getOutages(ApacheHttpClient httpClient, String baseUrl, String parameters) {
WebResource webResource = httpClient.resource(baseUrl + "rest/outages" + parameters);
List<OnmsOutage> outages = null;
try {
outages = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsOutage>>() {
});
} catch (Exception ex) {
logger.debug("Rest-Call for Outages went wrong", ex);
}
return outages;
}
示例3: getOutagesForNodes
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static Map<OnmsNode, List<OnmsOutage>> getOutagesForNodes(ApacheHttpClient httpClient, String baseUrl, List<OnmsNode> nodes, String parameters) {
Map<OnmsNode, List<OnmsOutage>> nodesToOutages = new HashMap<OnmsNode, List<OnmsOutage>>();
for (OnmsNode node : nodes) {
WebResource webResource = httpClient.resource(baseUrl + "rest/outages/forNode/" + node.getId() + parameters);
List<OnmsOutage> outages = null;
try {
outages = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsOutage>>() {
});
} catch (Exception ex) {
logger.debug("Rest-Call for Outages for Node '{}' went wrong", node, ex);
}
nodesToOutages.put(node, outages);
}
return nodesToOutages;
}
示例4: getNodes
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsNode> getNodes(ApacheHttpClient httpClient, String baseUrl, String parameters) {
WebResource webResource = httpClient.resource(baseUrl + "rest/nodes" + parameters);
List<OnmsNode> nodes = null;
try {
nodes = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsNode>>() {
});
} catch (Exception ex) {
logger.debug("Rest-Call for Nodes went wrong", ex);
}
return nodes;
}
示例5: getIpInterfacesByNode
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static OnmsIpInterfaceList getIpInterfacesByNode(ApacheHttpClient httpClient, String baseUrl, Integer nodeId, String parameters) {
WebResource webResource = httpClient.resource(baseUrl + "rest/nodes/" + nodeId + "/ipinterfaces" + parameters);
OnmsIpInterfaceList ipInterfaces = new OnmsIpInterfaceList();
try {
ipInterfaces = webResource.header("Accept", "application/xml").get(OnmsIpInterfaceList.class);
} catch (Exception ex) {
logger.debug("Rest-Call for IpInterfaces by Nodes went wrong", ex);
}
return ipInterfaces;
}
示例6: getEvents
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsEvent> getEvents(RestConnectionParameter restConnectionParameter, String parameters) {
ApacheHttpClient apacheHttpClient = RestHelper.createApacheHttpClient(restConnectionParameter);
String baseUrl = restConnectionParameter.getBaseUrl().toString();
WebResource webResource = apacheHttpClient.resource(baseUrl + "rest/events" + parameters);
List<OnmsEvent> events = null;
try {
events = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsEvent>>() {});
} catch (Exception ex) {
logger.debug("Rest-Call for Events went wrong", ex);
}
return events;
}
示例7: getEventsByUEI
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsEvent> getEventsByUEI(RestConnectionParameter restConnectionParameter, String uei, String parameters) {
ApacheHttpClient apacheHttpClient = RestHelper.createApacheHttpClient(restConnectionParameter);
String baseUrl = restConnectionParameter.getBaseUrl().toString();
WebResource webResource = apacheHttpClient.resource(baseUrl + "rest/events?eventUei=" + uei + parameters);
List<OnmsEvent> events = null;
try {
events = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsEvent>>() {});
} catch (Exception ex) {
logger.debug("Rest-Call for Events went wrong", ex);
}
return events;
}
示例8: getEventsByNodeLabelAndUEI
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsEvent> getEventsByNodeLabelAndUEI(RestConnectionParameter restConnectionParameter, String nodeLable, String uei, String parameters) {
ApacheHttpClient apacheHttpClient = RestHelper.createApacheHttpClient(restConnectionParameter);
String baseUrl = restConnectionParameter.getBaseUrl().toString();
WebResource webResource = apacheHttpClient.resource(baseUrl + "rest/events?eventUei=" + uei + parameters);
List<OnmsEvent> events = null;
try {
events = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsEvent>>() {});
} catch (Exception ex) {
logger.debug("Rest-Call for Events went wrong", ex);
}
return events;
}
示例9: getEventsByServerity
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static List<OnmsEvent> getEventsByServerity(RestConnectionParameter restConnectionParameter, String serverity, String parameters) {
ApacheHttpClient apacheHttpClient = RestHelper.createApacheHttpClient(restConnectionParameter);
String baseUrl = restConnectionParameter.getBaseUrl().toString();
WebResource webResource = apacheHttpClient.resource(baseUrl + "rest/events/?eventSeverity=" + getServeretyIdByLable(serverity) + parameters);
List<OnmsEvent> events = null;
try {
events = webResource.header("Accept", "application/xml").get(new GenericType<List<OnmsEvent>>() {});
} catch (Exception ex) {
logger.debug("Rest-Call Events by Serverity " + serverity + " went wrong", ex);
}
return events;
}
示例10: countEventsByServerity
import com.sun.jersey.client.apache.ApacheHttpClient; //导入方法依赖的package包/类
public static Integer countEventsByServerity(RestConnectionParameter restConnectionParameter, String serverity, String parameters) {
ApacheHttpClient apacheHttpClient = RestHelper.createApacheHttpClient(restConnectionParameter);
String baseUrl = restConnectionParameter.getBaseUrl().toString();
WebResource webResource = apacheHttpClient.resource(baseUrl + "rest/events/?eventSeverity=" + getServeretyIdByLable(serverity) + parameters);
OnmsEventCollection events = null;
try {
events = webResource.header("Accept", "application/xml").get(OnmsEventCollection.class);
} catch (Exception ex) {
logger.debug("Rest-Call Events by Serverity " + serverity + " went wrong", ex);
}
return events.getTotalCount();
}