Package org.geoserver.rest

Examples of org.geoserver.rest.PageInfo


    protected void configurePersister(XStreamPersister persister, DataFormat format) {
        persister.setCallback( new XStreamPersister.Callback() {
            @Override
            protected void postEncodeWorkspace(WorkspaceInfo ws,
                    HierarchicalStreamWriter writer, MarshallingContext context) {
                PageInfo pg = getPageInfo();
               
                //add a link to the stores
                writer.startNode( "dataStores");
                encodeCollectionLink("datastores", writer);
                writer.endNode();
View Full Code Here


            writer.setValue( href( link, format ) );
        }
    }
   
    String href( String link, DataFormat format ) {
        PageInfo pg = getPageInfo();
       
        //try to figure out extension
        String ext = null;
        if ( format != null ) {
            ext = MediaTypes.getExtensionForMediaType( format.getMediaType() );
        }
       
        if ( ext == null ) {
            ext = pg.getExtension();
        }
       
        if(ext != null && ext.length() > 0)
            link = link+ "." + ext;
       
        // encode as relative or absolute depending on the link type
        if ( link.startsWith( "/") ) {
            // absolute, encode from "root"
            return pg.rootURI(link);
        } else {
            //encode as relative
            return pg.pageURI(link);
        }
    }
View Full Code Here

            public TemplateModel wrap(Object obj) throws TemplateModelException {
                TemplateModel model = wrapper.wrap(obj);
                if ( model instanceof SimpleHash ) {
                    SimpleHash hash = (SimpleHash) model;
                    if ( hash.get( "page" ) == null ) {
                        PageInfo pageInfo = (PageInfo) request.getAttributes().get( PageInfo.KEY );
                        if ( pageInfo != null ) {
                            hash.put( "page", pageInfo );   
                        }
                    }
                }
View Full Code Here

            public TemplateModel wrap(Object obj) throws TemplateModelException {
                TemplateModel model = wrapper.wrap(obj);
                if ( model instanceof SimpleHash ) {
                    SimpleHash hash = (SimpleHash) model;
                    if ( hash.get( "page" ) == null ) {
                        PageInfo pageInfo = (PageInfo) request.getAttributes().get( PageInfo.KEY );
                        if ( pageInfo != null ) {
                            hash.put( "page", pageInfo );   
                        }
                    }
                }
View Full Code Here

    }
   
    @Test
    public void testGetAllHTML() throws Exception {
        Request req = new Request();
        PageInfo page = new PageInfo();
        page.setBasePath("foo");
        page.setPagePath("bar");
        page.setBaseURL("baz");
        req.getAttributes().put(PageInfo.KEY, page);
        Response res = new Response(req);
       
        RequestResource.HTMLFormat format = new RequestResource.HTMLFormat(req, res, resource);
       
View Full Code Here

    protected void encodeLink(String link, HierarchicalStreamWriter writer) {
        encodeLink(link, writer, getFormatGet());
    }

    protected String href(String link, DataFormat format) {
        PageInfo pg = getPageInfo();

        // encode as relative or absolute depending on the link type
        if (link.startsWith("/")) {
            // absolute, encode from "root"
            return pg.rootURI(link);
        } else {
            // encode as relative
            return pg.pageURI(link);
        }
    }
View Full Code Here

        getResponse().setEntity(new StringRepresentation(obj.toString(2), MediaType.APPLICATION_JSON));
        getResponse().setStatus(Status.SUCCESS_OK);
    }

    JSONObject toJSON(ScriptSession session) {
        PageInfo pageInfo = (PageInfo) getRequest().getAttributes().get(PageInfo.KEY);

        JSONObject obj = new JSONObject();
        obj.put("id", session.getId());
        obj.put("engine", session.getEngineName());
        obj.put("self", pageInfo.baseURI(
            String.format("sessions/%s/%d", session.getExtension(), session.getId())));

        return obj;
    }
View Full Code Here

        ScriptSession session = scriptMgr.createNewSession(ext);
        if (session == null) {
            throw new RestletException("Unable to create session", Status.SERVER_ERROR_INTERNAL);
        }

        PageInfo page = (PageInfo) getRequest().getAttributes().get(PageInfo.KEY);

        getResponse().redirectSeeOther(page.pageURI(String.valueOf(session.getId())));
        getResponse().setEntity(new StringRepresentation(String.valueOf(session.getId())));
        getResponse().setStatus(Status.SUCCESS_CREATED);

    }
View Full Code Here

            public TemplateModel wrap(Object obj) throws TemplateModelException {
                TemplateModel model = wrapper.wrap(obj);
                if ( model instanceof SimpleHash ) {
                    SimpleHash hash = (SimpleHash) model;
                    if ( hash.get( "page" ) == null ) {
                        PageInfo pageInfo = (PageInfo) request.getAttributes().get( PageInfo.KEY );
                        if ( pageInfo != null ) {
                            hash.put( "page", pageInfo );   
                        }
                    }
                }
View Full Code Here

    }
   
    @Test
    public void testGetAllHTML() throws Exception {
        Request req = new Request();
        PageInfo page = new PageInfo();
        page.setBasePath("foo");
        page.setPagePath("bar");
        page.setBaseURL("baz");
        req.getAttributes().put(PageInfo.KEY, page);
        Response res = new Response(req);
       
        RequestResource.HTMLFormat format =
            new RequestResource.HTMLFormat(req, res, resource, monitor);
View Full Code Here

TOP

Related Classes of org.geoserver.rest.PageInfo

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.