Package org.geoserver.catalog

Examples of org.geoserver.catalog.NamespaceInfo


                }   
            }
        }
       
        // set the namespace uri
        NamespaceInfo namespace = catalog.getNamespaceByPrefix( info.getWorkspace().getName() );
        connectionParameters.put( "namespace", namespace.getURI() );
       
        // ensure the parameters are valid
        if ( !factory.canProcess( connectionParameters ) ) {
            //TODO: log the parameters at the debug level
            throw new RestletException( "Unable to configure datastore, bad parameters.", Status.SERVER_ERROR_INTERNAL );
        }
       
        //add or update the datastore info
        if ( add ) {
            catalog.add( info );
        }
        else {
            catalog.save( info );
        }
       
        //check configure parameter, if set to none to not try to configure
        // data feature types
        String configure = form.getFirstValue( "configure" );
        if ( "none".equalsIgnoreCase( configure ) ) {
            getResponse().setStatus( Status.SUCCESS_CREATED );
            return;
        }
       
        //load the datastore
        try {
            DataStore ds = (DataStore) info.getDataStore(null);
           
            String[] featureTypeNames = ds.getTypeNames();
            for ( int i = 0; i < featureTypeNames.length; i++ ) {
               
                //unless configure specified "all", only configure the first feature type
                if ( !"all".equalsIgnoreCase( configure ) && i > 0 ) {
                    break;
                }
               
                FeatureSource fs = ds.getFeatureSource(featureTypeNames[i]);
                FeatureTypeInfo ftinfo = null;
                if ( add ) {
                    //auto configure the feature type as well
                    ftinfo = builder.buildFeatureType(fs);
                    builder.lookupSRS(ftinfo, true);
                    builder.setupBounds(ftinfo);
                }
                else {
                    ftinfo = catalog.getFeatureTypeByName( namespace.getPrefix(), featureTypeNames[i] );
                }
               
                //update the bounds
                ReferencedEnvelope bounds = fs.getBounds();
                ftinfo.setNativeBoundingBox( bounds );
View Full Code Here


        String coverage = getAttribute( "coverage" );

        if ( coveragestore == null ) {
            LOGGER.fine( "GET coverage " + workspace + "," + coverage );
            //grab the corresponding namespace for this workspace
            NamespaceInfo ns = catalog.getNamespaceByPrefix( workspace );
            if ( ns != null ) {
                return catalog.getCoverageByName(ns,coverage);
            }

            throw new RestletException( "", Status.CLIENT_ERROR_NOT_FOUND );
View Full Code Here

            //get from requests
            CoverageStoreInfo ds = catalog.getCoverageStoreByName( workspace, coveragestore );
            coverage.setStore( ds );
        }
       
        NamespaceInfo ns = coverage.getNamespace();
        if ( ns != null && !ns.getPrefix().equals( workspace ) ) {
            //TODO: change this once the two can be different and we untie namespace
            // from workspace
            LOGGER.warning( "Namespace: " + ns.getPrefix() + " does not match workspace: " + workspace + ", overriding." );
            ns = null;
        }
       
        if ( ns == null){
            //infer from workspace
View Full Code Here

        persister.setCallback( new XStreamPersister.Callback() {
            @Override
            protected void postEncodeReference(Object obj, String ref,
                    HierarchicalStreamWriter writer, MarshallingContext context) {
                if ( obj instanceof NamespaceInfo ) {
                    NamespaceInfo ns = (NamespaceInfo) obj;
                    encodeLink( "/namespaces/" + ns.getPrefix(), writer);
                }
                if ( obj instanceof CoverageStoreInfo ) {
                    CoverageStoreInfo cs = (CoverageStoreInfo) obj;
                    encodeLink( "/workspaces/" + cs.getWorkspace().getName() + "/coveragestores/" +
                            cs.getName(), writer );
View Full Code Here

                    catalog.getFeatureTypeByDataStore(catalog.getDataStoreByName(ws, ds), ft) == null) {
                throw new RestletException( "No such feature type: "+ws+","+ds+","+ft, Status.CLIENT_ERROR_NOT_FOUND );
            }
            else {
                //look up by workspace/namespace
                NamespaceInfo ns = catalog.getNamespaceByPrefix( ws );
                if ( ns == null || catalog.getFeatureTypeByName( ns, ft ) == null ) {
                    throw new RestletException( "No such feature type: "+ws+","+ft, Status.CLIENT_ERROR_NOT_FOUND );
                }
            }
        }
View Full Code Here

        if ( datastore == null ) {
            LOGGER.fine( "GET feature type" + workspace + "," + featureType );
           
            //grab the corresponding namespace for this workspace
            NamespaceInfo ns = catalog.getNamespaceByPrefix( workspace );
            if ( ns != null ) {
                return catalog.getFeatureTypeByName(ns,featureType);
            }

            throw new RestletException( "", Status.CLIENT_ERROR_NOT_FOUND );
View Full Code Here

            //get from requests
            DataStoreInfo ds = catalog.getDataStoreByName( workspace, dataStore );
            featureType.setStore( ds );
        }
       
        NamespaceInfo ns = featureType.getNamespace();
        if ( ns != null && !ns.getPrefix().equals( workspace ) ) {
            //TODO: change this once the two can be different and we untie namespace
            // from workspace
            LOGGER.warning( "Namespace: " + ns.getPrefix() + " does not match workspace: " + workspace + ", overriding." );
            ns = null;
        }
       
        if ( ns == null){
            //infer from workspace
View Full Code Here

        persister.setCallback( new XStreamPersister.Callback() {
            @Override
            protected void postEncodeReference(Object obj, String ref,
                    HierarchicalStreamWriter writer, MarshallingContext context) {
                if ( obj instanceof NamespaceInfo ) {
                    NamespaceInfo ns = (NamespaceInfo) obj;
                    encodeLink( "/namespaces/" + ns.getPrefix(), writer);
                }
                if ( obj instanceof DataStoreInfo ) {
                    DataStoreInfo ds = (DataStoreInfo) obj;
                    encodeLink( "/workspaces/" + ds.getWorkspace().getName() + "/datastores/" +
                        ds.getName(), writer );
View Full Code Here

        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

        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

TOP

Related Classes of org.geoserver.catalog.NamespaceInfo

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.