Here is my code to upload a new layer from a shapefile (zipped):

boolean exists = reader.existsDatastore(workspaceName, storeName);
  if ( !exists ) {
        File shapeFile = new File( "path/to/zipFile.zip" );
        boolean published = publisher.publishShp(workspaceName, 
              storeName, "TheLayerName", shapeFile, "EPSG:4326", "");

All is fine, but I need to set the "Description" of the new Store and maybe the "Create spatial index if missing/outdated" value too.

After run this code, I go to GeoServer and select "Stores". On "Edit Vector Data Source" screen I can see the "Description" field is empty.

After googling a lot I discover the GSCoverageEncoder layerEncoder = new GSCoverageEncoder(); method, but I've tried many ways and have no success ( with configureCoverage ).

    GeoServerRESTReader reader;
    GeoServerRESTStoreManager storeManager;

    reader = new GeoServerRESTReader(RESTURL, RESTUSER, RESTPW);
    storeManager = new GeoServerRESTStoreManager( new URL(RESTURL), RESTUSER, RESTPW); 

    RESTDataStore rds = reader.getDatastore(workSpaceName, storeName);

    GSDirectoryOfShapefilesDatastoreEncoder update = new GSDirectoryOfShapefilesDatastoreEncoder(rds);
    update.setDescription("New Description goes here"); 

    storeManager.update(workSpaceName, update);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.