Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added updateDBLayer #182

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,36 @@ public boolean publishDBLayer(final String workspace, final String storename,

return published && configured;
}

public boolean updateDBLayer(final String workspace, final String storename,final GSFeatureTypeEncoder fte){
/*
* This is the equivalent call with cUrl:
*
* {@code curl -u admin:geoserver -XPUT -H 'Content-type: text/xml' \ -d
* "<featureType><name>easia_gaul_1_aggr</name><nativeCRS>EPSG:4326</nativeCRS><enabled>true</enabled></featureType>" \
* http://localhost:8080/geoserver/rest/workspaces/it.geosolutions/ datastores/pg_kids/featuretypes/easia_gaul_1_aggr }
*
*/

String ftypeXml = fte.toString();
String layername = fte.getName();
StringBuilder putUrl = new StringBuilder(restURL)
.append("/rest/workspaces/").append(workspace)
.append("/datastores/").append(storename)
.append("/featuretypes").append("/"+layername);

if (layername == null || layername.isEmpty()) {
if (LOGGER.isErrorEnabled())
LOGGER.error("GSFeatureTypeEncoder has no valid name associated, try using GSFeatureTypeEncoder.setName(String)");
return false;
}

String configuredResult = HTTPUtils.putXml(putUrl.toString(), ftypeXml, this.gsuser,this.gspass);
boolean published = configuredResult != null;

return published;
}


// ==========================================================================
// === SHAPEFILES
Expand Down