Package org.restlet.data

Examples of org.restlet.data.Reference


    throws ResourceException
  {
    try {
      String connectionID = getRepository().getConnection().getID();

      Reference connectionRef = getRequest().getResourceRef().clone();
      connectionRef.addSegment(connectionID);
      getResponse().setLocationRef(connectionRef);

      getResponse().setStatus(Status.SUCCESS_CREATED);
      return null;
    }
View Full Code Here


      throw new ResourceException(SERVER_ERROR_INTERNAL, "missing query attribute");
    }

    String queryID = getConnection().storeQuery(query);

    Reference queryRef = getRequest().getResourceRef().clone();
    queryRef.addSegment(queryID);
    getResponse().setLocationRef(queryRef);

    getResponse().setStatus(Status.SUCCESS_CREATED);
    return null;
  }
View Full Code Here

  }

  private boolean validateServiceTicket(String serviceTicket, Request request, Response response)
    throws ResourceException
  {
    Reference validationURL = new Reference(casServerURL + "proxyValidate");
    validationURL.addQueryParameter("service", getServiceURL(request));
    validationURL.addQueryParameter("ticket", serviceTicket);
    validationURL.addQueryParameter("pgtUrl", getServiceURL(request));

    ClientResource serviceValidate = new ClientResource(validationURL);
    try {
      Representation validationResult = serviceValidate.get();
      ServiceResponse serviceResponse = ServiceResponseParser.parse(validationResult.getStream());
View Full Code Here

    return false;
  }

  private void redirectToCAS(Request request, Response response) {
    Reference loginURL = new Reference(casServerURL + "login");
    loginURL.addQueryParameter("service", getServiceURL(request));
    response.redirectTemporary(loginURL);
  }
View Full Code Here

  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

  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

    return sw.toString();
  }

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

    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);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
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

      IOException
  {
    String httpUrlBase =
        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName
            + "/StateModelDefs/MasterSlave";
    Reference resourceRef = new Reference(httpUrlBase);
    Request request = new Request(Method.GET, resourceRef);
    Client client = new Client(Protocol.HTTP);
    Response response = client.handle(request);
    Representation result = response.getEntity();
    StringWriter sw = new StringWriter();
    result.write(sw);
    ObjectMapper mapper = new ObjectMapper();
    ZNRecord zn = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);

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

    paraMap.put(JsonParameters.MANAGEMENT_COMMAND,
                ClusterSetup.addStateModelDef);

    ZNRecord r = new ZNRecord("Test");
    r.merge(zn);
    StateModelDefinition newStateModel = new StateModelDefinition(r);

    httpUrlBase =
        "http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/StateModelDefs";
    resourceRef = new Reference(httpUrlBase);
    request = new Request(Method.POST, resourceRef);
    request.setEntity(JsonParameters.JSON_PARAMETERS + "="
                          + ClusterRepresentationUtil.ObjectToJson(paraMap) + "&"
                          + JsonParameters.NEW_STATE_MODEL_DEF + "="
                          + ClusterRepresentationUtil.ZNRecordToJson(r),
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.