fixed wms request

This commit is contained in:
francesco 2020-10-27 16:41:30 +01:00
parent f9bab75d98
commit 41d90e8147
6 changed files with 53 additions and 49 deletions

12
pom.xml
View File

@ -129,6 +129,18 @@
<version>2.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>

View File

@ -48,7 +48,7 @@ public class GeoportalDataViewer implements EntryPoint {
private String paramLayerTitle;
/** The layer manager. */
private LayerManager layerManager;
private LayerManager layerManager = new LayerManager();
/**
* This is the entry point method.
@ -64,7 +64,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override
public void execute() {
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId());
layerManager = new LayerManager(olMap);
layerManager.setOlMap(olMap);
mainPanel.setMap(olMap);
}
@ -93,7 +93,7 @@ public class GeoportalDataViewer implements EntryPoint {
int indexStart = paramWmsRequest.indexOf("?");
String url;
if(indexStart>=0){
url = paramWmsRequest.substring(0, indexStart); //get only base uri
url = paramWmsRequest.substring(0, indexStart); //get only base uri
url = url.trim(); //string trim
}else{
Window.alert("Bad wms request '?' not found!");
@ -102,9 +102,16 @@ public class GeoportalDataViewer implements EntryPoint {
String layerName = URLUtil.getValueOfParameter("layers", paramWmsRequest);
String displayName = paramLayerTitle==null || paramLayerTitle.isEmpty()?layerName:paramLayerTitle;
layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true);
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true);
}
});
} catch (Exception e) {
GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest);
GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest, e);
e.printStackTrace();
}
}

View File

@ -5,31 +5,24 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForW
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface GeoportalDataViewerServiceAsync
{
public interface GeoportalDataViewerServiceAsync {
/**
* Utility class to get the RPC Async interface from client-side code
*/
public static final class Util {
private static GeoportalDataViewerServiceAsync instance;
public static final GeoportalDataViewerServiceAsync getInstance() {
if (instance == null) {
instance = (GeoportalDataViewerServiceAsync) GWT.create(GeoportalDataViewerService.class);
}
return instance;
}
/**
* Utility class to get the RPC Async interface from client-side code
*/
public static final class Util
{
private static GeoportalDataViewerServiceAsync instance;
public static final GeoportalDataViewerServiceAsync getInstance()
{
if ( instance == null )
{
instance = (GeoportalDataViewerServiceAsync) GWT.create( GeoportalDataViewerService.class );
}
return instance;
}
private Util()
{
// Utility class should not be instantiated
}
}
private Util() {
// Utility class should not be instantiated
}
}
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
}

View File

@ -15,6 +15,7 @@ import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
// TODO: Auto-generated Javadoc
/**
* The Class LayerManager.
*
@ -32,11 +33,8 @@ public class LayerManager {
/**
* Instantiates a new layer manager.
*
* @param olMap the ol map
*/
public LayerManager(OpenLayerOSM olMap) {
this.olMap = olMap;
public LayerManager() {
}
@ -179,6 +177,16 @@ public class LayerManager {
// layersPanel.addLayerItems(layerItems, onTop);
// layersPanel.updateLayersOrder();
}
/**
* Sets the ol map.
*
* @param olMap the new ol map
*/
public void setOlMap(OpenLayerOSM olMap) {
this.olMap = olMap;
}

View File

@ -15,7 +15,6 @@ public class URLUtil {
// logger.trace("start index of "+wmsParam+ " is: "+index);
String value = "";
if(index > -1){
int start = index + paramName.length()+1; //add +1 for char '='
String sub = url.substring(start, url.length());
int indexOfSeparator = sub.indexOf("&");

View File

@ -27,23 +27,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class);
/**
* Escape an html string. Escaping data received from the client helps to
* prevent cross-site script vulnerabilities.
*
* @param html the html string to escape
* @return the escaped string
*/
private String escapeHtml(String html) {
if (html == null) {
return null;
}
return html.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(
">", "&gt;");
}
@Override
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception{
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
return loadGeoInfoForWmsRequest(wmsRequest, layerName);
}