Package org.restlet

Examples of org.restlet.Client


    populateServiceTypes();
  }
  public void populateHostNames() {
    try {
      Request request = new Request(Method.GET,"http://info.teragrid.org/web-apps/XML/ctss-resources-v1/");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Resource");
      for(int i=0;i<nodeList.getLength();i++){
        this.hostNameItems.add(new SelectItem(nodeList.item(i).getAttributes().getNamedItem("UniqueID").getNodeValue()));
View Full Code Here


   */
  public void populateGridFtpEndPoints(String hostName) {
    if(!hostName.isEmpty()){
    try{
      Request request = new Request(Method.GET,"http://info.teragrid.org/web-apps/xml/kit-services-v1/type/gridftp/");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Service");
      for(int i=0;i<nodeList.getLength();i++){
        Node node = nodeList.item(i);
View Full Code Here

   * Need to remove the hard-coded checks on the service types as only 3 types has to be displayed now.
   */
  public void populateServiceTypes() {
    try {
      Request request = new Request(Method.GET,"http://info.teragrid.org/restdemo/xml/tg/services");
      Client client = new Client(Protocol.HTTP);
      Response response = client.handle(request);
      DomRepresentation representation = response.getEntityAsDom();
      Document document = representation.getDocument();
      NodeList nodeList = document.getElementsByTagName("Service");
      for(int i=0;i<nodeList.getLength();i++){
        String type = nodeList.item(i).getAttributes().getNamedItem("Type").getNodeValue();
View Full Code Here

      List<String> types = (List<String>) event.getNewValue();
      Iterator<String> iterator = types.iterator();
      while(iterator.hasNext()){
        try{
          Request request = new Request(Method.GET,"http://info.teragrid.org/restdemo/xml/tg/services/"+iterator.next());
          Client client = new Client(Protocol.HTTP);
          Response response = client.handle(request);
          DomRepresentation representation = response.getEntityAsDom();
          Document document = representation.getDocument();
          NodeList nodeList = document.getElementsByTagName("Service");
          String currentHostName = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("hostInfo:hostName");
          for(int i=0;i<nodeList.getLength();i++){
View Full Code Here

    // start admin
    _adminThread = new AdminThread(_zkaddr, ADMIN_PORT);
    _adminThread.start();

    // create a client
    _gClient = new Client(Protocol.HTTP);

    // wait for the web service to start
    try {
      Thread.sleep(100);
    } catch (InterruptedException e) {
View Full Code Here

     * @param categoriesUri
     *            The feed URI.
     * @throws IOException
     */
    public Categories(String categoriesUri) throws IOException {
        this(new Client(new Reference(categoriesUri).getSchemeProtocol()),
                categoriesUri);

    }
View Full Code Here

                for (int i = 0; i < childNodes.getLength(); i++) {
                    childNode = childNodes.item(i);
                    if ("client".equals(childNode.getNodeName())) {
                        Node item = childNode.getAttributes().getNamedItem(
                                "protocol");
                        Client client = null;

                        if (item == null) {
                            item = childNode.getAttributes().getNamedItem(
                                    "protocols");

                            if (item != null) {
                                final String[] protocols = item.getNodeValue()
                                        .split(" ");
                                final List<Protocol> protocolsList = new ArrayList<Protocol>();

                                for (final String protocol : protocols) {
                                    protocolsList.add(getProtocol(protocol));
                                }

                                client = new Client(new Context(),
                                        protocolsList);
                            }
                        } else {
                            client = new Client(new Context(),
                                    getProtocol(item.getNodeValue()));
                        }

                        if (client != null) {
                            getComponent().getClients().add(client);

                            // Look for Restlet's attributes
                            parseRestlet(client, childNode);

                            // Look for parameters
                            for (int j = 0; j < childNode.getChildNodes()
                                    .getLength(); j++) {
                                final Node childNode2 = childNode
                                        .getChildNodes().item(j);

                                if (isParameter(childNode2)) {
                                    Parameter p = parseParameter(childNode2);
                                    if (p != null) {
                                        client.getContext().getParameters()
                                                .add(p);
                                    }
                                }
                            }
                        }
View Full Code Here

        c = new Component();
        c.getServers().add(Protocol.HTTP, 8111);
        c.getDefaultHost().attach(new TestApplication());
        c.start();

        client = new Client(Protocol.HTTP);
    }
View Full Code Here

     *
     * @throws IOException
     * @throws ResourceException
     */
    public void test() throws IOException, ResourceException {
        client = new Client(Protocol.HTTP);
        Request request = new Request(Method.GET, "http://localhost:8111/test");
        Response response = client.handle(request);
        assertEquals(Status.SUCCESS_OK, response.getStatus());
        assertEquals("asText", response.getEntity().getText());
        response.getEntity().release();
View Full Code Here

     * Test POST, PUT and GET using the Client class
     *
     * @throws Exception
     */
    public void testIntegration() throws Exception {
        Client client = new Client(new Context(), Arrays.asList(Protocol.HTTP));
        Request request = new Request(Method.POST, uri);
        request.setEntity(new JaxbRepresentation<Sample>(new Sample(IN_STRING)));

        Response response = client.handle(request);

        JaxbRepresentation<Sample> resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        Sample sample = resultRepresentation.getObject();
        assertEquals(HELLO_OUT_STRING, sample.getVal());

        request = new Request(Method.PUT, uri);
        request.setEntity(new JaxbRepresentation<Sample>(new Sample(IN_STRING)));

        response = client.handle(request);
        resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        sample = resultRepresentation.getObject();
        assertEquals(HELLO_OUT_STRING, sample.getVal());

        request = new Request(Method.GET, uri);
        response = client.handle(request);
        resultRepresentation = new JaxbRepresentation<Sample>(
                response.getEntity(), Sample.class);
        sample = resultRepresentation.getObject();
        assertEquals(IN_STRING, sample.getVal());

        client.stop();
    }
View Full Code Here

TOP

Related Classes of org.restlet.Client

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.