Package org.restlet.data

Examples of org.restlet.data.Reference


    Map<String, String> params = new HashMap<String, String>();

    params.put(JsonParameters.MANAGEMENT_COMMAND, command);
    params.put(JsonParameters.CONFIGS, configs);

    Request request = new Request(Method.POST, new Reference(url));
    request.setEntity(
        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(params),
        MediaType.APPLICATION_ALL);

    Response response = client.handle(request);
View Full Code Here


    Map<String, String> paramMap = new HashMap<String, String>();

    paramMap.put(JsonParameters.MANAGEMENT_COMMAND, ClusterSetup.enableCluster);
    paramMap.put(JsonParameters.ENABLED, "" + false);

    Reference resourceRef = new Reference(httpUrlBase);

    Request request = new Request(Method.POST, resourceRef);

    request.setEntity(
        JsonParameters.JSON_PARAMETERS + "=" + ClusterRepresentationUtil.ObjectToJson(paramMap),
View Full Code Here

    @Override
    public Void call() throws Exception {
      LOG.debug("Actual sending update with " + _updateMap.size() + " updates to " + _webServiceUrl);
      long time = System.currentTimeMillis();
      Reference resourceRef = new Reference(_webServiceUrl);
      Request request = new Request(Method.PUT, resourceRef);

      ObjectMapper mapper = new ObjectMapper();
      StringWriter sw = new StringWriter();
      try {
View Full Code Here

    return mapper.readValue(sr, clazz);
  }

  static String assertSuccessPostOperation(String url, Map<String, String> jsonParameters,
      boolean hasException) throws IOException {
    Reference resourceRef = new Reference(url);

    Request request = new Request(Method.POST, resourceRef);
    request.setEntity(
        JsonParameters.JSON_PARAMETERS + "="
            + ClusterRepresentationUtil.ObjectToJson(jsonParameters), MediaType.APPLICATION_ALL);
View Full Code Here

    return sw.toString();
  }

  static String assertSuccessPostOperation(String url, Map<String, String> jsonParameters,
      Map<String, String> extraForm, boolean hasException) throws IOException {
    Reference resourceRef = new Reference(url);

    Request request = new Request(Method.POST, resourceRef);
    String entity =
        JsonParameters.JSON_PARAMETERS + "="
            + ClusterRepresentationUtil.ObjectToJson(jsonParameters);
View Full Code Here

    Assert.assertTrue(hasException == sw.toString().toLowerCase().contains("exception"));
    return sw.toString();
  }

  void deleteUrl(String url, boolean hasException) throws IOException {
    Reference resourceRef = new Reference(url);
    Request request = new Request(Method.DELETE, resourceRef);
    Response response = _gClient.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
    result.write(sw);
View Full Code Here

    result.write(sw);
    Assert.assertTrue(hasException == sw.toString().toLowerCase().contains("exception"));
  }

  String getUrl(String url) throws IOException {
    Reference resourceRef = new Reference(url);
    Request request = new Request(Method.GET, resourceRef);
    Response response = _gClient.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
    result.write(sw);
View Full Code Here

    IdealState untaggedResource = new IdealState("untaggedResource");
    untaggedResource.setStateModelDefRef("OnlineOffline");
    admin.addResource(clusterName, untaggedResource.getId(), untaggedResource);

    // Now make a REST call for all resources
    Reference resourceRef = new Reference(URL_BASE);
    Request request = new Request(Method.GET, resourceRef);
    Response response = _gClient.handle(request);
    ZNRecord responseRecord =
        ClusterRepresentationUtil.JsonToObject(ZNRecord.class, response.getEntityAsText());
View Full Code Here

    admin.addInstance(clusterName, instance3);
    InstanceConfig instance4 = new InstanceConfig("localhost_4");
    admin.addInstance(clusterName, instance4);

    // Now make a REST call for all resources
    Reference resourceRef = new Reference(URL_BASE);
    Request request = new Request(Method.GET, resourceRef);
    Response response = _gClient.handle(request);
    ListInstancesWrapper responseWrapper =
        ClusterRepresentationUtil.JsonToObject(ListInstancesWrapper.class,
            response.getEntityAsText());
View Full Code Here

     * @param request
     *            The Servlet request.
     * @return The base reference of new Restlet requests.
     */
    public Reference getBaseRef(HttpServletRequest request) {
        Reference result = null;
        final String basePath = request.getContextPath()
                + request.getServletPath();
        final String baseUri = request.getRequestURL().toString();
        // Path starts at first slash after scheme://
        final int pathStart = baseUri.indexOf("/",
                request.getScheme().length() + 3);
        if (basePath.length() == 0) {
            // basePath is empty in case the webapp is mounted on root context
            if (pathStart != -1) {
                result = new Reference(baseUri.substring(0, pathStart));
            } else {
                result = new Reference(baseUri);
            }
        } else {
            if (pathStart != -1) {
                final int baseIndex = baseUri.indexOf(basePath, pathStart);
                if (baseIndex != -1) {
                    result = new Reference(baseUri.substring(0, baseIndex
                            + basePath.length()));
                }
            }
        }

View Full Code Here

TOP

Related Classes of org.restlet.data.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.