fixed wms request
This commit is contained in:
parent
f9bab75d98
commit
41d90e8147
12
pom.xml
12
pom.xml
|
@ -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>
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
||||||
int indexStart = paramWmsRequest.indexOf("?");
|
int indexStart = paramWmsRequest.indexOf("?");
|
||||||
String url;
|
String url;
|
||||||
if(indexStart>=0){
|
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
|
url = url.trim(); //string trim
|
||||||
}else{
|
}else{
|
||||||
Window.alert("Bad wms request '?' not found!");
|
Window.alert("Bad wms request '?' not found!");
|
||||||
|
@ -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;
|
||||||
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) {
|
} 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,31 +5,24 @@ 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
|
||||||
|
*/
|
||||||
|
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 to get the RPC Async interface from client-side code
|
// Utility class should not be instantiated
|
||||||
*/
|
}
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
|
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,6 +177,16 @@ public class LayerManager {
|
||||||
// layersPanel.addLayerItems(layerItems, onTop);
|
// layersPanel.addLayerItems(layerItems, onTop);
|
||||||
// layersPanel.updateLayersOrder();
|
// layersPanel.updateLayersOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ol map.
|
||||||
|
*
|
||||||
|
* @param olMap the new ol map
|
||||||
|
*/
|
||||||
|
public void setOlMap(OpenLayerOSM olMap) {
|
||||||
|
this.olMap = olMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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("&");
|
||||||
|
|
|
@ -27,23 +27,8 @@ 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("&", "&").replaceAll("<", "<").replaceAll(
|
|
||||||
">", ">");
|
|
||||||
}
|
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue