Examples of DataStoreInfo


Examples of org.geoserver.catalog.DataStoreInfo

        //create a builder to help build catalog objects
        CatalogBuilder builder = new CatalogBuilder(catalog);
        builder.setWorkspace( catalog.getWorkspaceByName( workspace ) );
       
        //check if the datastore already exists, if not auto configure one
        DataStoreInfo info = catalog.getDataStoreByName( datastore );
       
        boolean add = false;
        if ( info == null ) {
            LOGGER.info("Auto-configuring datastore: " + datastore);
           
            info = builder.buildDataStore( datastore );
            add = true;
        }
        else {
            LOGGER.info("Using existing datastore: " + datastore);
        }
       
        builder.setStore(info);
       
        //update the connection parameters to point to the new file
        Map connectionParameters = info.getConnectionParameters();
        for ( Param p : factory.getParametersInfo() ) {
            //the nasty url / file hack
            if ( File.class == p.type || URL.class == p.type ) {
                File f = uploadedFile;
               
                if ( "directory".equals( p.key ) ) {
                    //set the value to be the directory
                    f = directory;
                }
               
                //convert to the required type
                //TODO: use geotools converter
                Object converted = null;
                if ( URI.class.equals( p.type  ) ) {
                    converted = f.toURI();
                }
                else if ( URL.class.equals( p.type ) ) {
                    try {
                        converted = f.toURL();
                    }
                    catch (MalformedURLException e) {
                    }
                }
                //Converters.convert( f.getAbsolutePath(), p.type );
               
                if ( converted != null ) {
                    connectionParameters.put( p.key, converted );   
                }
                else {
                    connectionParameters.put( p.key, f );
                }
               
                continue;
            }
           
            if ( p.required ) {
                try {
                    p.lookUp( connectionParameters );
                }
                catch( Exception e ) {
                    //set the sample value
                    connectionParameters.put( p.key, p.sample );
                }   
            }
        }
       
        // 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
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

            throw new RestletException( "", Status.CLIENT_ERROR_NOT_FOUND );
        }

        LOGGER.fine( "GET feature type" + datastore + "," + featureType );
        DataStoreInfo ds = catalog.getDataStoreByName(workspace, datastore);
        return catalog.getFeatureTypeByDataStore( ds, featureType );
    }
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

        CatalogBuilder cb = new CatalogBuilder(catalog);
        cb.initFeatureType( featureType );
       
        if ( featureType.getStore() == null ) {
            //get from requests
            DataStoreInfo ds = catalog.getDataStoreByName( workspace, dataStore );
            featureType.setStore( ds );
        }
       
        NamespaceInfo ns = featureType.getNamespace();
        if ( ns != null && !ns.getPrefix().equals( workspace ) ) {
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

       
        String workspace = getAttribute("workspace");
        String datastore = getAttribute("datastore");
        String featuretype = getAttribute("featuretype");
       
        DataStoreInfo ds = catalog.getDataStoreByName(workspace, datastore);
        FeatureTypeInfo original = catalog.getFeatureTypeByDataStore( ds,  featuretype );
        new CatalogBuilder(catalog).updateFeatureType(original,ft);
        catalog.save( original );
       
        LOGGER.info( "PUT feature type" + datastore + "," + featuretype );
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

    public void handleObjectDelete() throws Exception {
        String workspace = getAttribute("workspace");
        String datastore = getAttribute("datastore");
        String featuretype = getAttribute("featuretype");
       
        DataStoreInfo ds = catalog.getDataStoreByName(workspace, datastore);
        FeatureTypeInfo ft = catalog.getFeatureTypeByDataStore( ds,  featuretype );
        catalog.remove( ft );
       
        LOGGER.info( "DELETE feature type" + datastore + "," + featuretype );
    }
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

                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

Examples of org.geoserver.catalog.DataStoreInfo

    @Override
    protected Object handleObjectGet() {
        String workspace = (String) getRequest().getAttributes().get( "workspace" );
        String datastore = (String) getRequest().getAttributes().get( "datastore" );
       
        DataStoreInfo info = catalog.getDataStoreByName( workspace, datastore );
        if ( info == null ) {
            throw new RestletException( "No such datastore: " + datastore, Status.CLIENT_ERROR_NOT_FOUND );
        }
       
        //list of available feature types
        List<String> available = new ArrayList<String>();
        try {
            DataStore ds = (DataStore) info.getDataStore(null);
           
            String[] featureTypeNames = ds.getTypeNames();
            for ( String featureTypeName : featureTypeNames ) {
                FeatureTypeInfo ftinfo = catalog.getFeatureTypeByDataStore(info, featureTypeName);
                if (ftinfo == null ) {
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

   
    @Override
    protected String handleObjectPost(Object object) throws Exception {
        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 ) );
        }
        ds.setEnabled(true);

        catalog.add( (DataStoreInfo) object );
       
        LOGGER.info( "POST data store " + ds.getName() );
        return ds.getName();
    }
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

    @Override
    protected void handleObjectPut(Object object) throws Exception {
        String workspace = getAttribute("workspace");
        String datastore = getAttribute("datastore");
       
        DataStoreInfo ds = (DataStoreInfo) object;
        DataStoreInfo original = catalog.getDataStoreByName(workspace, datastore);
       
        //ensure this is not a name or workspace change
        if ( ds.getName() != null && !ds.getName().equals( original.getName() ) ) {
            throw new RestletException( "Can't change name of data store.", Status.CLIENT_ERROR_FORBIDDEN );
        }
        if ( ds.getWorkspace() != null && !ds.getWorkspace().equals( original.getWorkspace() ) ) {
            throw new RestletException( "Can't change workspace of data store.", Status.CLIENT_ERROR_FORBIDDEN );
        }
       
        new CatalogBuilder( catalog ).updateDataStore( original, ds );
       
View Full Code Here

Examples of org.geoserver.catalog.DataStoreInfo

    @Override
    protected void handleObjectDelete() throws Exception {
        String workspace = getAttribute("workspace");
        String datastore = getAttribute("datastore");
       
        DataStoreInfo ds = catalog.getDataStoreByName(workspace, datastore);
        if ( !catalog.getFeatureTypesByDataStore(ds).isEmpty() ) {
            throw new RestletException( "datastore not empty", Status.CLIENT_ERROR_FORBIDDEN);
        }
        catalog.remove( ds );
        
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.