Package org.geoserver.catalog

Examples of org.geoserver.catalog.DataStoreInfo


            postAsServletResponse( "/rest/workspaces/sf/datastores", xml, "text/xml" );
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/workspaces/sf/datastores/newDataStore" ) );

        DataStoreInfo newDataStore = catalog.getDataStoreByName( "newDataStore" );
        assertNotNull( newDataStore );
       
        DataStore ds = (DataStore) newDataStore.getDataStore(null);
        assertNotNull(ds);
    }
View Full Code Here


       
        assertEquals( 201, response.getStatusCode() );
        assertNotNull( response.getHeader( "Location") );
        assertTrue( response.getHeader("Location").endsWith( "/workspaces/sf/datastores/newDataStore" ) );
       
        DataStoreInfo newDataStore = catalog.getDataStoreByName( "newDataStore" );
        assertNotNull( newDataStore );
       
        DataStore ds = (DataStore) newDataStore.getDataStore(null);
        assertNotNull(ds);
    }
View Full Code Here

       
        MockHttpServletResponse response =
            putAsServletResponse( "/rest/workspaces/sf/datastores/sf", xml, "text/xml");
        assertEquals( 200, response.getStatusCode() );
       
        DataStoreInfo ds = catalog.getDataStoreByName( "sf", "sf" );
        assertEquals( 2, ds.getConnectionParameters().size() );
        assertTrue( ds.getConnectionParameters().containsKey( "one" ) );
        assertTrue( ds.getConnectionParameters().containsKey( "two" ) );
    }
View Full Code Here

        logger.warn("fire on commit? " + catalog.isFireEventsOnCommit());

        Listener listener = new Listener();
        catalog.addListener(listener);

        DataStoreInfo store = catalog.getFactory().createDataStore();
        store.setName("foo" + System.currentTimeMillis()); // we need a unique name
        store.setDescription("testAddStore() "); // just for data debugging

        WorkspaceInfoImpl ws = catalog.getFactory().createWorkspace();
        ws.setName("testAddStore" + System.currentTimeMillis()); // we need a unique name
        catalog.add(ws);

        store.setWorkspace(ws);
        catalog.add(store);

        assertFalse("Listener added, shouldn't", listener.added);

        endTransaction();
View Full Code Here

    }

    public void _testModifyStore() {
        logger.error("------------------> running testModifyStore");

        DataStoreInfo store = catalog.getFactory().createDataStore();
        store.setName("bar");

        WorkspaceInfoImpl ws = catalog.getFactory().createWorkspace();
        ws.setName("testModifyStore" + System.currentTimeMillis()); // we need a unique name
        catalog.add(ws);

        store.setWorkspace(ws);
        catalog.add(store);

        endTransaction();
        startNewTransaction();

        Listener listener = new Listener();
        catalog.addListener(listener);
        store = (DataStoreInfo) catalog.getDataStore(store.getId());
        store.setName("bar2");
        catalog.save(store);

        assertFalse("Listener modified, it should not.", listener.modified);
        endTransaction();
        assertTrue("Listener not modified.", listener.modified);
View Full Code Here

                    String storeType = new DirectoryDataStoreFactory().getDisplayName();
                    Map<String, Serializable> params = new HashMap<String, Serializable>();
                    params.put(DirectoryDataStoreFactory.URLP.key, new File(directory).toURI().toURL().toString());
                    params.put(DirectoryDataStoreFactory.NAMESPACE.key, new URI(ns).toString());
                   
                    DataStoreInfo si;
                    StoreInfo preExisting = getCatalog().getStoreByName(ws, project, StoreInfo.class);
                    boolean storeNew = false;
                    if(preExisting != null) {
                        if(!(preExisting instanceof DataStoreInfo)) {
                            error(new ParamResourceModel("storeExistsNotVector", this, project));
                            return;
                        }
                        si = (DataStoreInfo) preExisting;
                        if(!si.getType().equals(storeType) || !si.getConnectionParameters().equals(params)) {
                            error(new ParamResourceModel("storeExistsNotSame", this, project));
                            return;
                        }
                        // make sure it's enabled, we just verified the directory exists
                        si.setEnabled(true);
                    } else {
                        storeNew = true;
                        CatalogBuilder builder = new CatalogBuilder(getCatalog());
                        builder.setWorkspace(ws);
                        si = builder.buildDataStore(project);
                        si.getConnectionParameters().putAll(params);
                        si.setEnabled(true);
                        si.setType(storeType);
                       
                        getCatalog().add(si);
                    }
                   
                    // build and run the importer
View Full Code Here

    protected List handleListGet() throws Exception {
        String ws = getAttribute( "workspace" );
        String ds = getAttribute("datastore");
       
        if ( ds != null ) {
            DataStoreInfo dataStore = catalog.getDataStoreByName( ds );
            return catalog.getFeatureTypesByDataStore(dataStore);   
        }
       
        NamespaceInfo ns = catalog.getNamespaceByPrefix( ws );
        return catalog.getFeatureTypesByNamespace( ns );
View Full Code Here

        //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

            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

        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

TOP

Related Classes of org.geoserver.catalog.DataStoreInfo

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.