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> <version>2.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </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> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -48,7 +48,7 @@ public class GeoportalDataViewer implements EntryPoint {
private String paramLayerTitle; private String paramLayerTitle;
/** The layer manager. */ /** The layer manager. */
private LayerManager layerManager; private LayerManager layerManager = new LayerManager();
/** /**
* This is the entry point method. * This is the entry point method.
@ -64,7 +64,7 @@ public class GeoportalDataViewer implements EntryPoint {
@Override @Override
public void execute() { public void execute() {
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId()); olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId());
layerManager = new LayerManager(olMap); layerManager.setOlMap(olMap);
mainPanel.setMap(olMap); mainPanel.setMap(olMap);
} }
@ -102,9 +102,16 @@ public class GeoportalDataViewer implements EntryPoint {
String layerName = URLUtil.getValueOfParameter("layers", paramWmsRequest); String layerName = URLUtil.getValueOfParameter("layers", paramWmsRequest);
String displayName = paramLayerTitle==null || paramLayerTitle.isEmpty()?layerName:paramLayerTitle; String displayName = paramLayerTitle==null || paramLayerTitle.isEmpty()?layerName:paramLayerTitle;
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true); layerManager.addLayerByWmsRequest(displayName, layerName, paramWmsRequest, false, false, paramUUID, true);
}
});
} catch (Exception e) { } catch (Exception e) {
GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest); GWT.log("An error occurred on adding wmsrequest :" + paramWmsRequest, e);
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -5,28 +5,21 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForW
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; 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 * Utility class to get the RPC Async interface from client-side code
*/ */
public static final class Util public static final class Util {
{
private static GeoportalDataViewerServiceAsync instance; private static GeoportalDataViewerServiceAsync instance;
public static final GeoportalDataViewerServiceAsync getInstance() public static final GeoportalDataViewerServiceAsync getInstance() {
{ if (instance == null) {
if ( instance == null )
{
instance = (GeoportalDataViewerServiceAsync) GWT.create(GeoportalDataViewerService.class); instance = (GeoportalDataViewerServiceAsync) GWT.create(GeoportalDataViewerService.class);
} }
return instance; return instance;
} }
private Util() private Util() {
{
// Utility class should not be instantiated // Utility class should not be instantiated
} }
} }

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.Window;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
// TODO: Auto-generated Javadoc
/** /**
* The Class LayerManager. * The Class LayerManager.
* *
@ -32,11 +33,8 @@ public class LayerManager {
/** /**
* Instantiates a new layer manager. * Instantiates a new layer manager.
*
* @param olMap the ol map
*/ */
public LayerManager(OpenLayerOSM olMap) { public LayerManager() {
this.olMap = olMap;
} }
@ -181,5 +179,15 @@ public class LayerManager {
} }
/**
* 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); // logger.trace("start index of "+wmsParam+ " is: "+index);
String value = ""; String value = "";
if(index > -1){ if(index > -1){
int start = index + paramName.length()+1; //add +1 for char '=' int start = index + paramName.length()+1; //add +1 for char '='
String sub = url.substring(start, url.length()); String sub = url.substring(start, url.length());
int indexOfSeparator = sub.indexOf("&"); int indexOfSeparator = sub.indexOf("&");

View File

@ -27,21 +27,6 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** The Constant LOG. */ /** The Constant LOG. */
private static final Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerServiceImpl.class); 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 @Override
public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception { public GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception {
return loadGeoInfoForWmsRequest(wmsRequest, layerName); return loadGeoInfoForWmsRequest(wmsRequest, layerName);