当前位置: 首页>>代码示例>>Java>>正文


Java ApacheHttpClient.resource方法代码示例

本文整理汇总了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;
}
 
开发者ID:WolfgangFahl,项目名称:Mediawiki-Japi,代码行数:18,代码来源:Mediawiki.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:12,代码来源:RestOutageProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:16,代码来源:RestOutageProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:12,代码来源:RestNodeProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:11,代码来源:RestNodeProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:14,代码来源:RestEventProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:14,代码来源:RestEventProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:14,代码来源:RestEventProvider.java

示例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;
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:14,代码来源:RestEventProvider.java

示例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();
}
 
开发者ID:opennms-forge,项目名称:opennms-rest-client-api,代码行数:14,代码来源:RestEventProvider.java


注:本文中的com.sun.jersey.client.apache.ApacheHttpClient.resource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。