Example #1
0
        /**
         * This method does not upload a shapefile via zip. It rather creates a reference to a Shapefile that has already
         * exists in the GS data directory. <br/>
         *
         * TODO: This is buggy and always puts the coveragestore in the default workspace. Therefore we set the default
         * workspace defore every command, and reset it afterwards. This will change the default workspace for a moment!
         *
         * @param relpath
         *            A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
         */
        public Boolean createCoverageGeoTiff(String wsName, String csName, String csNamespace, String relpath, Configure autoConfig)
        {
            String oldDefault = getDefaultWs();

            try {
                setDefaultWs(wsName);

                if (relpath == null)
                {
                    throw new Exception("parameter relpath may not be null");
                }

                if (autoConfig == Configure.empty)
                {
                    autoConfig = Configure.first;
                }

                String urlParamter = "<url>" + relpath + "</url>";

                // String namespaceParamter = "<entry key=\"namespace\">" + dsName
                // + "</entry>";
                String typeParamter = "<type>GeoTIFF</type>";
                String xml          = "<coverageStore><name>" + csName + "</name><enabled>true</enabled>" + typeParamter
                                      + urlParamter + "</coverageStore>";

                int returnCode = sendRESTint(METHOD_POST, "/workspaces/" + wsName + "/coveragestores?configure="
                                             + autoConfig.ToString(), xml);
                return(201 == returnCode);
            } catch (IOException e) {
                setDefaultWs(oldDefault);
                throw e;
            } finally {
                reload();
            }
        }
Example #2
0
        /**
         * − <dataStore> <name>xxx</name> <description>xxx</description> <type>Shapefile</type> <enabled>true</enabled> −
         * <workspace> <name>ws</name> <atom:link rel="alternate"
         * href="http://localhost:8085/geoserver/rest/workspaces/ws.xml" type="application/xml"/> </workspace> −
         * <connectionParameters> <entry key="memory mapped buffer">true</entry> <entry
         * key="create spatial index">true</entry> <entry key="charset">ISO-8859-1</entry> <entry
         * key="url">file:data/ad2/soils.shp</entry> <entry key="namespace">http://ws</entry> </connectionParameters> −
         * <featureTypes> <atom:link rel="alternate" href=
         * "http://localhost:8085/geoserver/rest/workspaces/ws/datastores/xxx/featuretypes.xml" type="application/xml"/>
         * </featureTypes> </dataStore>
         */
        /**
         * This method does not upload a shapefile via zip. It rather creates a reference to a Shapefile that has already
         * exists in the GS data directory.
         *
         * @param charset
         *            defaults to UTF-8 if not set. Charset, that any text content is stored in.
         *
         * @param relpath
         *            A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
         */
        public Boolean createDatastoreShapefile(String workspace, String dsName, String dsNamespace, String relpath,
            String charset, Boolean memoryMappedBuffer, Boolean createSpatialIndex, Configure autoConfig)
        {
            if (autoConfig == Configure.first)
                autoConfig = Configure.empty;

            if (relpath == null)
                throw new Exception("parameter relpath may not be null");

            String createSpatialIndexParam = RestUtil.entryKey("create spatial index", createSpatialIndex);
            String memoryMappedBufferParamter = RestUtil.entryKey("memory mapped buffer", memoryMappedBuffer);
            String charsetParamter = "<entry key=\"charset\">" + (charset == null ? "UTF-8" : charset) + "</entry>";
            String urlParamter = "<entry key=\"url\">" + relpath + "</entry>";
            String namespaceParamter = "<entry key=\"namespace\">" + dsName + "</entry>";
            String typeParamter = "<type>Shapefile</type>";
            String xml = "<dataStore><name>" + dsName + "</name><enabled>true</enabled>" + typeParamter
                            + "<connectionParameters>" + createSpatialIndexParam + memoryMappedBufferParamter + charsetParamter
                            + urlParamter + namespaceParamter + typeParamter + "</connectionParameters></dataStore>";
            String configureParam = autoConfig == Configure.empty ? "" : "?configure=" + autoConfig.ToString();

            int returnCode = sendRESTint(METHOD_POST, "/workspaces/" + workspace + "/datastores.xml" + configureParam, xml);
            return 201 == returnCode;
        }
Example #3
0
        /**
         * This method does not upload a shapefile via zip. It rather creates a reference to a Shapefile that has already
         * exists in the GS data directory. <br/>
         *
         * TODO: This is buggy and always puts the coveragestore in the default workspace. Therefore we set the default
         * workspace defore every command, and reset it afterwards. This will change the default workspace for a moment!
         *
         * @param relpath
         *            A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
         */
        public Boolean createCoverageGeoTiff(String wsName, String csName, String csNamespace, String relpath, Configure autoConfig)
        {
            String oldDefault = getDefaultWs();

            try {
                setDefaultWs(wsName);

                if (relpath == null)
                        throw new Exception("parameter relpath may not be null");

                if (autoConfig == Configure.empty)
                        autoConfig = Configure.first;

                String urlParamter = "<url>" + relpath + "</url>";

                // String namespaceParamter = "<entry key=\"namespace\">" + dsName
                // + "</entry>";
                String typeParamter = "<type>GeoTIFF</type>";
                String xml = "<coverageStore><name>" + csName + "</name><enabled>true</enabled>" + typeParamter
                                + urlParamter + "</coverageStore>";

                int returnCode = sendRESTint(METHOD_POST, "/workspaces/" + wsName + "/coveragestores?configure="
                                + autoConfig.ToString(), xml);
                return 201 == returnCode;
            } catch (IOException e) {
                setDefaultWs(oldDefault);
                throw e;
            } finally {
                reload();
            }
        }
Example #4
0
        /**
         * − <dataStore> <name>xxx</name> <description>xxx</description> <type>Shapefile</type> <enabled>true</enabled> −
         * <workspace> <name>ws</name> <atom:link rel="alternate"
         * href="http://localhost:8085/geoserver/rest/workspaces/ws.xml" type="application/xml"/> </workspace> −
         * <connectionParameters> <entry key="memory mapped buffer">true</entry> <entry
         * key="create spatial index">true</entry> <entry key="charset">ISO-8859-1</entry> <entry
         * key="url">file:data/ad2/soils.shp</entry> <entry key="namespace">http://ws</entry> </connectionParameters> −
         * <featureTypes> <atom:link rel="alternate" href=
         * "http://localhost:8085/geoserver/rest/workspaces/ws/datastores/xxx/featuretypes.xml" type="application/xml"/>
         * </featureTypes> </dataStore>
         */
        /**
         * This method does not upload a shapefile via zip. It rather creates a reference to a Shapefile that has already
         * exists in the GS data directory.
         *
         * @param charset
         *            defaults to UTF-8 if not set. Charset, that any text content is stored in.
         *
         * @param relpath
         *            A path to the file, relative to gsdata dir, e.g. "file:data/water.shp"
         */
        public Boolean createDatastoreShapefile(String workspace, String dsName, String dsNamespace, String relpath,
                                                String charset, Boolean memoryMappedBuffer, Boolean createSpatialIndex, Configure autoConfig)
        {
            if (autoConfig == Configure.first)
            {
                autoConfig = Configure.empty;
            }

            if (relpath == null)
            {
                throw new Exception("parameter relpath may not be null");
            }

            String createSpatialIndexParam    = RestUtil.entryKey("create spatial index", createSpatialIndex);
            String memoryMappedBufferParamter = RestUtil.entryKey("memory mapped buffer", memoryMappedBuffer);
            String charsetParamter            = "<entry key=\"charset\">" + (charset == null ? "UTF-8" : charset) + "</entry>";
            String urlParamter       = "<entry key=\"url\">" + relpath + "</entry>";
            String namespaceParamter = "<entry key=\"namespace\">" + dsName + "</entry>";
            String typeParamter      = "<type>Shapefile</type>";
            String xml = "<dataStore><name>" + dsName + "</name><enabled>true</enabled>" + typeParamter
                         + "<connectionParameters>" + createSpatialIndexParam + memoryMappedBufferParamter + charsetParamter
                         + urlParamter + namespaceParamter + typeParamter + "</connectionParameters></dataStore>";
            String configureParam = autoConfig == Configure.empty ? "" : "?configure=" + autoConfig.ToString();

            int returnCode = sendRESTint(METHOD_POST, "/workspaces/" + workspace + "/datastores.xml" + configureParam, xml);

            return(201 == returnCode);
        }