Search in sources :

Example 1 with DataStoreFileManager

use of eu.esdihumboldt.hale.io.geoserver.rest.DataStoreFileManager 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);
}
Also used : ContentType(org.apache.http.entity.ContentType) DataStoreFile(eu.esdihumboldt.hale.io.geoserver.DataStoreFile) HashMap(java.util.HashMap) ByteArrayInputStream(java.io.ByteArrayInputStream) DataStore(eu.esdihumboldt.hale.io.geoserver.DataStore) DataStoreFileManager(eu.esdihumboldt.hale.io.geoserver.rest.DataStoreFileManager) DataStoreManager(eu.esdihumboldt.hale.io.geoserver.rest.DataStoreManager) Workspace(eu.esdihumboldt.hale.io.geoserver.Workspace)

Aggregations

DataStore (eu.esdihumboldt.hale.io.geoserver.DataStore)1 DataStoreFile (eu.esdihumboldt.hale.io.geoserver.DataStoreFile)1 Workspace (eu.esdihumboldt.hale.io.geoserver.Workspace)1 DataStoreFileManager (eu.esdihumboldt.hale.io.geoserver.rest.DataStoreFileManager)1 DataStoreManager (eu.esdihumboldt.hale.io.geoserver.rest.DataStoreManager)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 HashMap (java.util.HashMap)1 ContentType (org.apache.http.entity.ContentType)1