Package org.restlet.resource

Examples of org.restlet.resource.Representation


            String hello = "Hello World "+name+"!!";
            //
            // get Variant
            Variant variant = (Variant) item.getRestletVariant();

            Representation result = null;
            if (variant.getMediaType().equals(MediaType.TEXT_PLAIN))
                result = new StringRepresentation(hello);
            else
                result = new StringRepresentation("Variant no soportada");
View Full Code Here


        //if (variant.getMediaType().equals(MediaType.APPLICATION_JSON)) {
        //    result = new JsonRepresentation(this.user.toJSON());
        //} else {
        //    result = new StringRepresentation(this.user.toString());
        //}
        Representation result = null;
        if (variant.getMediaType().equals(MediaType.TEXT_PLAIN))
            result = new StringRepresentation(hello);
        else
            result = new StringRepresentation("Variant no soportada");
View Full Code Here

            response.setStatus(Status.CLIENT_ERROR_METHOD_NOT_ALLOWED);
        }
    }
   
    private void doGet(Request request, Response response) {
        Representation result = new StringRepresentation(
                "<html><body>\n"
                +"<a id=\"logo\" href=\"http://geowebcache.org\">"
                +"<img src=\"http://geowebcache.org/trac/chrome/site/geowebcache_logo.png\" alt=\"\" height=\"100\" width=\"353\" border=\"0\"/></a>\n"
                +"<h3>Resources available from here:</h3>"
                +"<ul>"
View Full Code Here

    /**
     * Returns a StringRepresentation with the status of the running threads
     * in the thread pool.
     */
    public void doGet(Request req, Response resp) throws RestletException {
        Representation rep = null;

        try {
            XStream xs = new XStream(new JsonHierarchicalStreamDriver());
            JSONObject obj = null;
            long[][] list = seeder.getStatusList();
View Full Code Here

    // public void testBogus() throws Exception {
    // assertTrue(true);
    // }

    public void testGetXml() throws Exception {
        Representation rep = tlr.doGetInternal("topp:states", "xml");

        String str = rep.getText();

        assertTrue(str.indexOf("<name>topp:states</name>") > 0);
        // TODO This needs to get back in
        // assertTrue(str.indexOf("<double>49.371735</double>") > 0);
        // assertTrue(str.indexOf("<wmsStyles>population</wmsStyles>") > 0);
View Full Code Here

        assertTrue(str.indexOf("</wmsLayer>") > 0);
        assertTrue(str.indexOf("states2") == -1);
    }

    public void testGetJson() throws Exception {
        Representation rep = tlr.doGetInternal("topp:states2", "json");

        String str = rep.getText();

        assertTrue(str.indexOf(",\"name\":\"topp:states2\",") > 0);
        // TODO this needs to go back in
        // assertTrue(str.indexOf("959189.3312465074]},") > 0);
        assertTrue(str.indexOf("[\"image/png\",\"image/jpeg\"]") > 0);
View Full Code Here

        assertTrue(str.indexOf("[\"image/png\",\"image/jpeg\"]") > 0);
        assertTrue(str.indexOf("}}") > 0);
    }

    public void testGetInvalid() throws Exception {
        Representation rep = null;
        try {
            rep = tlr.doGetInternal("topp:states", "jpeg");
        } catch (RestletException re) {
            // Format should be invalid
            assertTrue(re.getRepresentation().getText().indexOf("format") > 0);
View Full Code Here

    public void postDistributedServer(String action, String servers) throws MalformedURLException {
        checkNotNull(servers);
        Form form = new Form();
        form.add("action", action);
        form.add("serversString", servers);
        Representation representation = form.getWebRepresentation();
        URL url = localServerEndPoint.toURL();
        String requestURL = url.toString();
        Request request = new Request(Method.POST, requestURL, representation);
        Response response = client.handle(request);
        if (!response.getStatus().isSuccess()) {
View Full Code Here

    public boolean allowPost() {
        return true;
    }

    public Representation represent(Variant variant) {
        Representation rep = null;
        try {
            Map<String, Object> dataModel = new HashMap<String, Object>();
            dataModel.put(DEFAULT_PORT_STRING, Integer.toString(LOCAL_PORT_NUMBER));
            dataModel.put(ACTION, ACTION);
            final String[] servers = application.getServers();
View Full Code Here

        final String servers = form.getFirstValue(SERVERS_STRING);
        final String action = form.getFirstValue("action");
        processServerList(servers, action);
        Map<String, Object> dataModel = new HashMap<String, Object>();
        dataModel.put(SERVER_LIST, application.getServers());
        Representation rep = factory.createRepresentation(MediaType.TEXT_HTML, dataModel);
        getResponse().setEntity(rep);
        getResponse().setStatus(SUCCESS_OK);
    }
View Full Code Here

TOP

Related Classes of org.restlet.resource.Representation

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.