use of eu.esdihumboldt.hale.io.geoserver.rest.DataStoreManager in project hale by halestudio.
the class AppSchemaMappingUploader method publishAppSchemaDataStore.
private void publishAppSchemaDataStore(ProgressIndicator progress, IOReporter reporter) throws IOException {
Workspace ws = generator.getMainWorkspace();
// build datastore resource
DataStore dataStore = generator.getAppSchemaDataStore();
DataStoreManager dsMgr = new DataStoreManager(geoserverURL);
dsMgr.setCredentials(username, password);
dsMgr.setResource(dataStore);
dsMgr.setWorkspace(ws.name());
// remove datastore, if necessary
if (dsMgr.exists()) {
Map<String, String> deleteParams = new HashMap<String, String>();
deleteParams.put("recurse", "true");
dsMgr.delete(deleteParams);
}
// build mapping file resource
ContentType contentType = getMimeType();
byte[] content = writeContent(dataStore.name(), contentType, progress, reporter);
DataStoreFile mappingFile = ResourceBuilder.dataStoreFile(new ByteArrayInputStream(content), contentType).setAttribute(DataStoreFile.EXTENSION, "appschema").setAttribute(DataStoreFile.DATASTORE, dataStore.name()).setAttribute(DataStoreFile.WORKSPACE, ws.name()).build();
DataStoreFileManager dsFileMgr = new DataStoreFileManager(geoserverURL);
dsFileMgr.setCredentials(username, password);
dsFileMgr.setResource(mappingFile);
Map<String, String> updateParams = new HashMap<String, String>();
updateParams.put("configure", "all");
dsFileMgr.update(updateParams);
}
Aggregations