use of org.geosdi.geoplatform.connector.geoserver.model.layers.GeoserverLayerStyle in project geo-platform by geosdi.
the class GeoserverConnectorLayersTest method i_updateLayer.
@Ignore(value = "Layer poi_vito may be not present")
@Test
public void i_updateLayer() throws Exception {
GeoserverLayer geoserverLayer = this.geoserverConnectorStore.loadWorkspaceLayerRequest().withWorkspaceName("tiger").withLayerName("poi_vito").getResponse();
logger.info("##################LAYER {}\n", geoserverLayer);
GeoserverLayerStyle layerStyle = geoserverLayer.getLayerStyle() != null ? geoserverLayer.getLayerStyle() : new GeoserverLayerStyle();
List<IGPGeoserverStyle> styles = layerStyle.getStyles() != null ? geoserverLayer.getLayerStyle().getStyles() : Lists.newArrayList();
GPGeoserverStyle gpGeoserverStyle = new GPGeoserverStyle();
gpGeoserverStyle.setName("burg");
styles.add(gpGeoserverStyle);
layerStyle.setStyles(styles);
geoserverLayer.setLayerStyle(layerStyle);
logger.info("##################RESPONSE {}\n", this.geoserverConnectorStore.updateLayerRequest().withWorkspaceName("tiger").withLayerBody(geoserverLayer).withLayerName("poi_vito").getResponse());
logger.info("##################UPDATED_LAYER {}\n", this.geoserverConnectorStore.loadWorkspaceLayerRequest().withWorkspaceName("tiger").withLayerName("poi_vito").getResponse());
}
use of org.geosdi.geoplatform.connector.geoserver.model.layers.GeoserverLayerStyle in project geo-platform by geosdi.
the class GPPublisherBasicServiceImpl method updateLayerStyle.
@Override
public Boolean updateLayerStyle(String workspace, String layerName, String styleToPublish, String styleName, boolean isDefault, boolean override) throws ResourceNotFoundFault {
GeoserverLayer geoserverLayer = null;
if (!this.checkIfExsistLayerInWorkspace(layerName, workspace)) {
throw new ResourceNotFoundFault("The layer: " + layerName + " with workspace: " + workspace + " does not exists");
}
try {
geoserverLayer = this.geoserverConnectorStore.loadWorkspaceLayerRequest().withLayerName(layerName).withWorkspaceName(workspace).getResponse();
} catch (Exception e) {
final String error = "Error to load layer with workspace name: " + workspace + " and layer name:" + layerName + " " + e;
logger.error(error);
throw new IllegalArgumentException(error, e.getCause());
}
try {
if (override) {
this.geoserverConnectorStore.updateStyleSLDV100Request().withStringStyleBody(styleToPublish).withRaw(FALSE).withStyleName(styleName).getResponse();
} else {
this.geoserverConnectorStore.createStyleSLDV100Request().withRaw(TRUE).withStyleName(styleName).withStringStyleBody(styleToPublish).getResponse();
}
} catch (Exception e) {
throw new IllegalParameterFault("The Style with name " + styleName + " is not published.");
}
GeoserverLayerStyle layerStyle = geoserverLayer.getLayerStyle() != null ? geoserverLayer.getLayerStyle() : new GeoserverLayerStyle();
List<IGPGeoserverStyle> styles = layerStyle.getStyles() != null ? geoserverLayer.getLayerStyle().getStyles() : Lists.newArrayList();
GPGeoserverStyle gpGeoserverStyle = new GPGeoserverStyle();
gpGeoserverStyle.setName(styleName);
if (isDefault) {
geoserverLayer.setDefaultStyle(gpGeoserverStyle);
} else {
styles.add(gpGeoserverStyle);
}
layerStyle.setStyles(styles);
geoserverLayer.setLayerStyle(layerStyle);
try {
this.geoserverConnectorStore.updateLayerRequest().withWorkspaceName(workspace).withLayerBody(geoserverLayer).withLayerName(layerName).getResponse();
} catch (Exception e) {
final String error = "Error to update layer with workspace name: " + e;
logger.error(error);
return FALSE;
}
return TRUE;
}
Aggregations