Package org.geoserver.catalog

Examples of org.geoserver.catalog.WorkspaceInfo


            protected void onClick(AjaxRequestTarget target) {
                Catalog catalog = getCatalog();
                CascadeDeleteVisitor deleteVisitor = new CascadeDeleteVisitor(catalog);
                String project = summary.getProject();
                if(summary.isWorkspaceNew()) {
                    WorkspaceInfo ws = catalog.getWorkspaceByName(project);
                    if(ws != null)
                        ws.accept(deleteVisitor);
                } else if(summary.isStoreNew()) {
                    StoreInfo si = catalog.getStoreByName(project, project, StoreInfo.class);
                    if(si != null)
                        si.accept(deleteVisitor);
                } else {
View Full Code Here


    /**
     *
     */
    public WorkspaceInfo getWorkspaceByName(String name) {
        WorkspaceInfo ws = (WorkspaceInfo) first(buildQuery("from ", WorkspaceInfo.class,
                " where name = ", param(name)));
        return ws;
    }
View Full Code Here

        return getAttribute( "workspace") == null;
    }
   
    @Override
    protected String handleObjectPost(Object object) throws Exception {
        WorkspaceInfo workspace = (WorkspaceInfo) object;
        catalog.add( workspace );
       
        //create a namespace corresponding to the workspace if one does not
        // already exist
        NamespaceInfo namespace = catalog.getNamespaceByPrefix( workspace.getName() );
        if ( namespace == null ) {
            LOGGER.fine( "Automatically creating namespace for workspace " + workspace.getName() );

            namespace = catalog.getFactory().createNamespace();
            namespace.setPrefix( workspace.getName() );
            namespace.setURI( "http://" + workspace.getName() );
            catalog.add( namespace );
        }
       
        LOGGER.info( "POST workspace " + workspace.getName() );
        return workspace.getName();
    }
View Full Code Here

        return getAttribute( "workspace") != null;
    }
   
    @Override
    protected void handleObjectPut(Object object) throws Exception {
        WorkspaceInfo workspace = (WorkspaceInfo) object;
        String ws = (String) getRequest().getAttributes().get( "workspace" );
       
        if ( "default".equals( ws ) ) {
            catalog.setDefaultWorkspace( workspace );
        }
        else {
            WorkspaceInfo original = catalog.getWorkspaceByName( ws );
           
            //ensure this is not a name change
            if ( workspace.getName() != null && !workspace.getName().equals( original.getName() ) ) {
                throw new RestletException( "Can't change the name of a workspace.", Status.CLIENT_ERROR_FORBIDDEN );
            }
           
            new CatalogBuilder(catalog).updateWorkspace( original, workspace );
            catalog.save( original );
View Full Code Here

    }
   
    @Override
    protected void handleObjectDelete() throws Exception {
        String workspace = (String) getRequest().getAttributes().get( "workspace");
        WorkspaceInfo ws = catalog.getWorkspaceByName( workspace );
       
        if ( !catalog.getStoresByWorkspace(ws, StoreInfo.class).isEmpty() ) {
            throw new RestletException( "Workspace not empty", Status.CLIENT_ERROR_FORBIDDEN );
        }
       
        //check for "linked" workspace
        NamespaceInfo ns = catalog.getNamespaceByPrefix( ws.getName() );
        if ( ns != null ) {
            if ( !catalog.getFeatureTypesByNamespace( ns ).isEmpty() ) {
                throw new RestletException( "Namespace for workspace not empty.", Status.CLIENT_ERROR_FORBIDDEN );
            }
            catalog.remove( ns );
View Full Code Here

       
        //JD: we need to keep namespace and workspace in sync, so create a worksapce
        // if one does not already exists, we can remove this once we get to a point
        // where namespace is just an attribute on a layer, and not a containing element
        if ( catalog.getWorkspaceByName( namespace.getPrefix() ) == null ) {
            WorkspaceInfo ws = catalog.getFactory().createWorkspace();
            ws.setName( namespace.getPrefix() );
            catalog.add( ws );
        }
       
        LOGGER.info( "POST namespace " + namespace );
        return namespace.getPrefix();
View Full Code Here

        String workspace = getAttribute( "workspace" );

        DataStoreInfo ds = (DataStoreInfo) object;
        if ( ds.getWorkspace() != null ) {
             //ensure the specifried workspace matches the one dictated by the uri
             WorkspaceInfo ws = (WorkspaceInfo) ds.getWorkspace();
             if ( !workspace.equals( ws.getName() ) ) {
                 throw new RestletException( "Expected workspace " + workspace +
                     " but client specified " + ws.getName(), Status.CLIENT_ERROR_FORBIDDEN );
             }
        }
        else {
             ds.setWorkspace( catalog.getWorkspaceByName( workspace ) );
        }
View Full Code Here

    public void testDefaultWorkspace() {

        startPage();

        WorkspaceInfo defaultWs = getCatalog().getDefaultWorkspace();

        tester.assertModelValue("dataStoreForm:workspacePanel:border:paramValue", defaultWs);

        WorkspaceInfo anotherWs = getCatalog().getFactory().createWorkspace();
        anotherWs.setName("anotherWs");

        getCatalog().add(anotherWs);
        getCatalog().setDefaultWorkspace(anotherWs);
        anotherWs = getCatalog().getDefaultWorkspace();
View Full Code Here

                MockData.CITE_PREFIX).getURI());

        Serializable directory = store.getConnectionParameters().get("directory");
        tester.assertModelValue(directoryParamPath, directory);

        WorkspaceInfo expectedWorkspace = catalog.getWorkspaceByName(MockData.CDF_PREFIX);
        NamespaceInfo expectedNamespace = catalog.getNamespaceByPrefix(MockData.CDF_PREFIX);

        // select the fifth item in the drop down, which is the cdf workspace
        formTester.select("workspacePanel:border:paramValue", 4);
        Component wsDropDown = tester.getComponentFromLastRenderedPage(wsDropdownPath);
View Full Code Here

        // did the save finish normally?
        tester.assertRenderedPage(StorePage.class);

        CoverageStoreInfo store = catalog.getCoverageStore(coverageStore.getId());
        WorkspaceInfo workspace = store.getWorkspace();
        assertFalse(MockData.WCS_PREFIX.equals(workspace.getName()));

        // was the namespace for the datastore resources updated?
        List<CoverageInfo> resourcesByStore;
        resourcesByStore = catalog.getResourcesByStore(store, CoverageInfo.class);

        assertTrue(resourcesByStore.size() > 0);

        for (CoverageInfo cv : resourcesByStore) {
            assertEquals("Namespace for " + cv.getName() + " was not updated", workspace.getName(),
                    cv.getNamespace().getPrefix());
        }
    }
View Full Code Here

TOP

Related Classes of org.geoserver.catalog.WorkspaceInfo

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.