/** * 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) throws IOException { if (autoConfig == Configure.first) autoConfig = null; if (relpath == null) throw new IllegalArgumentException("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 == null ? "" : "?configure=" + autoConfig.toString(); int returnCode = sendRESTint( METHOD_POST, "/workspaces/" + workspace + "/datastores.xml" + configureParam, xml); return 201 == returnCode; }
/** * 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) throws IOException { String oldDefault = getDefaultWs(); try { setDefaultWs(wsName); if (relpath == null) throw new IllegalArgumentException("parameter relpath may not be null"); if (autoConfig == null) 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(); } }