updated the "GeoNa-Viewer-Profile" definition

This commit is contained in:
Francesco Mangiacrapa 2020-11-13 13:06:39 +01:00
parent 5b959299bd
commit 38f6a2da03
2 changed files with 67 additions and 18 deletions

View File

@ -40,7 +40,7 @@ import org.xml.sax.InputSource;
*/ */
public class GeoNaDataViewerProfileReader { public class GeoNaDataViewerProfileReader {
private static final String RESOURCE_PROFILE_BODY_PORTLET_URL = "/Resource/Profile/Body/PortletURL"; private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
/** /**
* *
*/ */
@ -98,12 +98,19 @@ public class GeoNaDataViewerProfileReader {
XPathHelper helper = new XPathHelper(doc.getDocumentElement()); XPathHelper helper = new XPathHelper(doc.getDocumentElement());
List<String> currValue = null; List<String> currValue = null;
String portletURL = null; String xPathExp = RESOURCE_PROFILE_BODY+"/RestrictedPortletURL/text()";
currValue = helper.evaluate(RESOURCE_PROFILE_BODY_PORTLET_URL+"/text()"); currValue = helper.evaluate(xPathExp);
if (currValue != null && currValue.size() > 0) { if (currValue != null && currValue.size() > 0) {
portletURL = currValue.get(0); profile.setRestrictedPortletURL(currValue.get(0));
}else }else
throw new Exception("I'm not able to read the path: "+RESOURCE_PROFILE_BODY_PORTLET_URL); throw new Exception("I'm not able to read the path: "+xPathExp);
xPathExp = RESOURCE_PROFILE_BODY+"/OpenPortletURL/text()";
currValue = helper.evaluate(xPathExp);
if (currValue != null && currValue.size() > 0) {
profile.setOpenPortletURL(currValue.get(0));
}else
throw new Exception("I'm not able to read the path: "+xPathExp);
XPath xPath = XPathFactory.newInstance().newXPath(); XPath xPath = XPathFactory.newInstance().newXPath();
@ -117,7 +124,7 @@ public class GeoNaDataViewerProfileReader {
if (layerNode.getNodeType() == Node.ELEMENT_NODE) { if (layerNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) layerNode; Element eElement = (Element) layerNode;
String layerType = eElement.getElementsByTagName("Type").item(0).getTextContent(); String layerType = eElement.getElementsByTagName("Type").item(0).getTextContent();
String wmsLink = eElement.getElementsByTagName("WMS_LINK").item(0).getTextContent(); String wmsLink = eElement.getElementsByTagName("WMSLink").item(0).getTextContent();
String decodedURL = URLDecoder.decode(wmsLink, "UTF-8"); String decodedURL = URLDecoder.decode(wmsLink, "UTF-8");
LayerItem layer = new LayerItem(); LayerItem layer = new LayerItem();
layer.setWmsLink(decodedURL); layer.setWmsLink(decodedURL);
@ -125,7 +132,6 @@ public class GeoNaDataViewerProfileReader {
} }
} }
profile.setPortletURL(portletURL);
profile.setMapLayers(mapLayers); profile.setMapLayers(mapLayers);
logger.info("returning: "+profile); logger.info("returning: "+profile);
return profile; return profile;
@ -178,4 +184,19 @@ public class GeoNaDataViewerProfileReader {
return "GeoNaViewerProfileReader [secondaryType=" + secondaryType + ", scope=" + scope + ", appID=" + appID return "GeoNaViewerProfileReader [secondaryType=" + secondaryType + ", scope=" + scope + ", appID=" + appID
+ "]"; + "]";
} }
/*
public static void main(String[] args) throws Exception {
ScopeProvider.instance.set("/gcube/devNext/NextNext");
GeoNaDataViewerProfileReader gdvp = new GeoNaDataViewerProfileReader("geoportal-data-viewer-app");
GeoNaDataViewerProfile profile = gdvp.readProfileFromInfrastrucure();
System.out.println(profile.getRestrictedPortletURL());
System.out.println(profile.getOpenPortletURL());
if(profile.getMapLayers()!=null) {
for (String type : profile.getMapLayers().keySet()) {
System.out.println("key: "+type+", value: "+profile.getMapLayers().get(type));
}
}
}*/
} }

View File

@ -13,7 +13,7 @@ import com.google.gwt.user.client.rpc.IsSerializable;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Nov 12, 2020 * Nov 13, 2020
*/ */
public class GeoNaDataViewerProfile implements IsSerializable, Serializable{ public class GeoNaDataViewerProfile implements IsSerializable, Serializable{
@ -21,7 +21,8 @@ public class GeoNaDataViewerProfile implements IsSerializable, Serializable{
* *
*/ */
private static final long serialVersionUID = 8583236018312392009L; private static final long serialVersionUID = 8583236018312392009L;
private String portletURL; private String restrictedPortletURL;
private String openPortletURL;
//the key is the layer type //the key is the layer type
private Map<String, LayerItem> mapLayers; private Map<String, LayerItem> mapLayers;
@ -33,21 +34,39 @@ public class GeoNaDataViewerProfile implements IsSerializable, Serializable{
} }
/** /**
* Gets the portlet URL. * Gets the restricted portlet URL.
* *
* @return the portlet URL * @return the restricted portlet URL
*/ */
public String getPortletURL() { public String getRestrictedPortletURL() {
return portletURL; return restrictedPortletURL;
} }
/** /**
* Sets the portlet URL. * Sets the restricted portlet URL.
* *
* @param portletURL the new portlet URL * @param restrictedPortletURL the new restricted portlet URL
*/ */
public void setPortletURL(String portletURL) { public void setRestrictedPortletURL(String restrictedPortletURL) {
this.portletURL = portletURL; this.restrictedPortletURL = restrictedPortletURL;
}
/**
* Gets the open portlet URL.
*
* @return the open portlet URL
*/
public String getOpenPortletURL() {
return openPortletURL;
}
/**
* Sets the open portlet URL.
*
* @param openPortletURL the new open portlet URL
*/
public void setOpenPortletURL(String openPortletURL) {
this.openPortletURL = openPortletURL;
} }
/** /**
@ -75,7 +94,16 @@ public class GeoNaDataViewerProfile implements IsSerializable, Serializable{
*/ */
@Override @Override
public String toString() { public String toString() {
return "GeoNaDataViewerProfile [portletURL=" + portletURL + ", mapLayers=" + mapLayers + "]"; StringBuilder builder = new StringBuilder();
builder.append("GeoNaDataViewerProfile [restrictedPortletURL=");
builder.append(restrictedPortletURL);
builder.append(", openPortletURL=");
builder.append(openPortletURL);
builder.append(", mapLayers=");
builder.append(mapLayers);
builder.append("]");
return builder.toString();
} }
} }