export_to_pdf #8
|
@ -18,7 +18,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-module deploy-name="uri-resolver-2.9.0">
|
|
||||||
|
<wb-module deploy-name="uri-resolver-2.10.0-SNAPSHOT">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +60,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +81,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,6 +102,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,6 +123,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="context-root" value="uri-resolver"/>
|
<property name="context-root" value="uri-resolver"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -138,6 +144,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||||
|
|
||||||
|
|
||||||
|
@ -158,6 +165,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</wb-module>
|
</wb-module>
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,4 +186,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</project-modules>
|
</project-modules>
|
||||||
|
|
|
@ -12,6 +12,8 @@ public class GeoportalCommonConstants {
|
||||||
public static final String GET_GEONA_ITEM_TYPE = "git";
|
public static final String GET_GEONA_ITEM_TYPE = "git";
|
||||||
public static final String GET_GEONA_ITEM_ID = "gid";
|
public static final String GET_GEONA_ITEM_ID = "gid";
|
||||||
|
|
||||||
public static final String GEOPORTAL_DATA_VIEWER_APP = "geoportal-data-viewer-app";
|
public static final String GEOPORTAL_DATA_VIEWER_APP_ID = "geoportal-data-viewer-app";
|
||||||
|
|
||||||
|
public static final String GEOPORTAL_DATA_ENTRY_APP_ID = "geoportal-data-entry-app";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,25 +3,25 @@ package org.gcube.datatransfer.resolver.geoportal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class GeoportalDataViewerConfigProfile.
|
* The Class GeoportalConfigApplicationProfile.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Dec 21, 2021
|
* Apr 3, 2024
|
||||||
*/
|
*/
|
||||||
public class GeoportalDataViewerConfigProfile implements Serializable {
|
public class GeoportalConfigApplicationProfile implements Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 2968334957258327191L;
|
private static final long serialVersionUID = 8340275391003882511L;
|
||||||
private String restrictedPortletURL;
|
private String restrictedPortletURL;
|
||||||
private String openPortletURL;
|
private String openPortletURL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new geo na data viewer profile.
|
* Instantiates a new geo na data viewer profile.
|
||||||
*/
|
*/
|
||||||
public GeoportalDataViewerConfigProfile() {
|
public GeoportalConfigApplicationProfile() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,10 +61,15 @@ public class GeoportalDataViewerConfigProfile implements Serializable {
|
||||||
this.openPortletURL = openPortletURL;
|
this.openPortletURL = openPortletURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("GeoportalDataViewerConfigProfile [restrictedPortletURL=");
|
builder.append("GeoportalConfigApplicationProfile [restrictedPortletURL=");
|
||||||
builder.append(restrictedPortletURL);
|
builder.append(restrictedPortletURL);
|
||||||
builder.append(", openPortletURL=");
|
builder.append(", openPortletURL=");
|
||||||
builder.append(openPortletURL);
|
builder.append(openPortletURL);
|
|
@ -20,36 +20,35 @@ import org.w3c.dom.Document;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class GeoportalDataViewerConfigProfileReader.
|
* The Class GeoportalConfigApplicationProfileReader.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Mar 23, 2023
|
* Apr 3, 2024
|
||||||
*/
|
*/
|
||||||
public class GeoportalDataViewerConfigProfileReader {
|
public class GeoportalConfigApplicationProfileReader {
|
||||||
|
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(GeoportalConfigApplicationProfileReader.class);
|
||||||
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
||||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||||
public static final String GENERIC_RESOURCE_NAME = "Geoportal-DataViewer-Configs";
|
|
||||||
|
|
||||||
private static Logger LOG = LoggerFactory.getLogger(GeoportalDataViewerConfigProfileReader.class);
|
|
||||||
private String secondaryType;
|
private String secondaryType;
|
||||||
private String scope;
|
private String scope;
|
||||||
private String appID;
|
private String appID;
|
||||||
private GeoportalDataViewerConfigProfile geoportalDataViewerConfigProfile;
|
private GeoportalConfigApplicationProfile geoportalConfigAppProfile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new geoportal data viewer config profile reader.
|
* Instantiates a new geoportal config application profile reader.
|
||||||
*
|
*
|
||||||
* @param appID the app ID
|
* @param appID the app ID
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public GeoportalDataViewerConfigProfileReader(String appID) throws Exception {
|
public GeoportalConfigApplicationProfileReader(String appID) throws Exception {
|
||||||
|
|
||||||
this.appID = appID;
|
this.appID = appID;
|
||||||
this.secondaryType = SECONDARY_TYPE;
|
this.secondaryType = SECONDARY_TYPE;
|
||||||
this.scope = ScopeProvider.instance.get();
|
this.scope = ScopeProvider.instance.get();
|
||||||
this.geoportalDataViewerConfigProfile = readProfileFromInfrastructure();
|
this.geoportalConfigAppProfile = readProfileFromInfrastructure();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +57,7 @@ public class GeoportalDataViewerConfigProfileReader {
|
||||||
* @return the map
|
* @return the map
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
private GeoportalDataViewerConfigProfile readProfileFromInfrastructure() throws Exception {
|
private GeoportalConfigApplicationProfile readProfileFromInfrastructure() throws Exception {
|
||||||
|
|
||||||
String queryString = getGcubeGenericQueryString(secondaryType, appID);
|
String queryString = getGcubeGenericQueryString(secondaryType, appID);
|
||||||
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
||||||
|
@ -68,7 +67,7 @@ public class GeoportalDataViewerConfigProfileReader {
|
||||||
if (scope == null)
|
if (scope == null)
|
||||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||||
|
|
||||||
GeoportalDataViewerConfigProfile profile = new GeoportalDataViewerConfigProfile();
|
GeoportalConfigApplicationProfile profile = new GeoportalConfigApplicationProfile();
|
||||||
|
|
||||||
LOG.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: " + secondaryType
|
LOG.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: " + secondaryType
|
||||||
+ ", AppId: " + appID);
|
+ ", AppId: " + appID);
|
||||||
|
@ -107,8 +106,8 @@ public class GeoportalDataViewerConfigProfileReader {
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error while trying to read the " + SECONDARY_TYPE + " with SecondaryType "
|
LOG.error("Error while trying to read the SecondaryType " + SECONDARY_TYPE + " with appID " + appID
|
||||||
+ GENERIC_RESOURCE_NAME + " from scope " + scope, e);
|
+ " from scope " + scope, e);
|
||||||
return null;
|
return null;
|
||||||
} finally {
|
} finally {
|
||||||
|
|
||||||
|
@ -116,8 +115,13 @@ public class GeoportalDataViewerConfigProfileReader {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeoportalDataViewerConfigProfile getGeoportalDataViewerConfigProfile() {
|
/**
|
||||||
return geoportalDataViewerConfigProfile;
|
* Gets the geoportal config app profile.
|
||||||
|
*
|
||||||
|
* @return the geoportal config app profile
|
||||||
|
*/
|
||||||
|
public GeoportalConfigApplicationProfile getGeoportalConfigAppProfile() {
|
||||||
|
return geoportalConfigAppProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -152,17 +156,22 @@ public class GeoportalDataViewerConfigProfileReader {
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("GeoportalDataViewerConfigProfileReader [secondaryType=");
|
builder.append("GeoportalConfigApplicationProfileReader [secondaryType=");
|
||||||
builder.append(secondaryType);
|
builder.append(secondaryType);
|
||||||
builder.append(", scope=");
|
builder.append(", scope=");
|
||||||
builder.append(scope);
|
builder.append(scope);
|
||||||
builder.append(", appID=");
|
builder.append(", appID=");
|
||||||
builder.append(appID);
|
builder.append(appID);
|
||||||
builder.append(", geoportalDataViewerConfigProfile=");
|
builder.append(", geoportalConfigAppProfile=");
|
||||||
builder.append(geoportalDataViewerConfigProfile);
|
builder.append(geoportalConfigAppProfile);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
|
@ -24,8 +24,8 @@ import org.gcube.common.scope.impl.ScopeBean;
|
||||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||||
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
|
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
|
||||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants;
|
import org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants;
|
||||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalDataViewerConfigProfile;
|
import org.gcube.datatransfer.resolver.geoportal.GeoportalConfigApplicationProfile;
|
||||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalDataViewerConfigProfileReader;
|
import org.gcube.datatransfer.resolver.geoportal.GeoportalConfigApplicationProfileReader;
|
||||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalRequest;
|
import org.gcube.datatransfer.resolver.geoportal.GeoportalRequest;
|
||||||
import org.gcube.datatransfer.resolver.geoportal.TargetAppGeoportalCodes;
|
import org.gcube.datatransfer.resolver.geoportal.TargetAppGeoportalCodes;
|
||||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||||
|
@ -45,7 +45,7 @@ import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
*
|
*
|
||||||
* Mar 23, 2023
|
* Apr 03, 2024
|
||||||
*/
|
*/
|
||||||
@Path("/geo")
|
@Path("/geo")
|
||||||
public class GeoportalResolver {
|
public class GeoportalResolver {
|
||||||
|
@ -141,8 +141,7 @@ public class GeoportalResolver {
|
||||||
public Response resolveDataViewerLink(@Context HttpServletRequest req,
|
public Response resolveDataViewerLink(@Context HttpServletRequest req,
|
||||||
@QueryParam(GeoportalRequest.P_GCUBE_SCOPE) String gcubeScope,
|
@QueryParam(GeoportalRequest.P_GCUBE_SCOPE) String gcubeScope,
|
||||||
@QueryParam(GeoportalRequest.P_ITEM_ID) String itemId,
|
@QueryParam(GeoportalRequest.P_ITEM_ID) String itemId,
|
||||||
@QueryParam(GeoportalRequest.P_ITEM_TYPE) String itemType,
|
@QueryParam(GeoportalRequest.P_ITEM_TYPE) String itemType, @QueryParam(QP_RESOLVE_AS) String resolveAs)
|
||||||
@QueryParam(QP_RESOLVE_AS) String resolveAs)
|
|
||||||
throws WebApplicationException {
|
throws WebApplicationException {
|
||||||
|
|
||||||
LOG.info(this.getClass().getSimpleName() + " resolveDataViewerLink - GET starts...");
|
LOG.info(this.getClass().getSimpleName() + " resolveDataViewerLink - GET starts...");
|
||||||
|
@ -321,21 +320,35 @@ public class GeoportalResolver {
|
||||||
LOG.info("Found RESOLVE_AS_PARAMETER: " + resolveAs);
|
LOG.info("Found RESOLVE_AS_PARAMETER: " + resolveAs);
|
||||||
|
|
||||||
String originalScope = ScopeProvider.instance.get();
|
String originalScope = ScopeProvider.instance.get();
|
||||||
GeoportalDataViewerConfigProfileReader reader;
|
GeoportalConfigApplicationProfileReader reader;
|
||||||
|
String itemLink = null;
|
||||||
|
String appID = null;
|
||||||
|
|
||||||
|
// Resolving towards Data-Viewer or Data-Entry Application
|
||||||
|
switch (resoruceGeoportalCodes) {
|
||||||
|
case GEO_DE: {
|
||||||
|
appID = org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants.GEOPORTAL_DATA_ENTRY_APP_ID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GEO_DV:
|
||||||
|
default: {
|
||||||
|
appID = org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP_ID;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String theScope = fullScopeBean.toString();
|
String theScope = fullScopeBean.toString();
|
||||||
LOG.info("Full scope is: " + theScope);
|
LOG.info("Full scope is: " + theScope);
|
||||||
ScopeProvider.instance.set(theScope);
|
ScopeProvider.instance.set(theScope);
|
||||||
reader = new GeoportalDataViewerConfigProfileReader(
|
reader = new GeoportalConfigApplicationProfileReader(appID);
|
||||||
org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LOG.error("Error on reading the " + GeoportalDataViewerConfigProfileReader.SECONDARY_TYPE
|
String error = "Error on reading the generic resource with SecondaryType: "
|
||||||
+ " with generic resource name: "
|
+ GeoportalConfigApplicationProfileReader.SECONDARY_TYPE + " and APP ID: " + appID
|
||||||
+ GeoportalDataViewerConfigProfileReader.GENERIC_RESOURCE_NAME, e);
|
+ " in the scope: " + appID;
|
||||||
throw ExceptionManager.internalErrorException(req,
|
LOG.error(error, e);
|
||||||
"Error on reading the " + GeoportalDataViewerConfigProfileReader.SECONDARY_TYPE + " for name "
|
|
||||||
+ GeoportalDataViewerConfigProfileReader.GENERIC_RESOURCE_NAME
|
throw ExceptionManager.internalErrorException(req, error + ". Please contact the support",
|
||||||
+ ". Please contact the support",
|
|
||||||
this.getClass(), helpURI);
|
this.getClass(), helpURI);
|
||||||
} finally {
|
} finally {
|
||||||
if (originalScope != null && !originalScope.isEmpty()) {
|
if (originalScope != null && !originalScope.isEmpty()) {
|
||||||
|
@ -347,22 +360,17 @@ public class GeoportalResolver {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolving towards Data-Viewer or Data-Entry Application
|
GeoportalConfigApplicationProfile geonaDataProfile = reader.getGeoportalConfigAppProfile();
|
||||||
String itemLink = null;
|
|
||||||
|
|
||||||
switch (resoruceGeoportalCodes) {
|
|
||||||
case GEO_DV: {
|
|
||||||
|
|
||||||
GeoportalDataViewerConfigProfile geonaDataProfile = reader.getGeoportalDataViewerConfigProfile();
|
|
||||||
|
|
||||||
switch (resolveTO) {
|
switch (resolveTO) {
|
||||||
case PUBLIC:
|
case PUBLIC: {
|
||||||
// Open Link
|
// Open Link
|
||||||
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getOpenPortletURL(),
|
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getOpenPortletURL(),
|
||||||
GeoportalCommonConstants.GET_GEONA_ITEM_ID, projectID,
|
GeoportalCommonConstants.GET_GEONA_ITEM_ID, projectID,
|
||||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
||||||
break;
|
break;
|
||||||
case PRIVATE:
|
}
|
||||||
|
case PRIVATE: {
|
||||||
|
|
||||||
// Restricted Link
|
// Restricted Link
|
||||||
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getRestrictedPortletURL(),
|
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getRestrictedPortletURL(),
|
||||||
|
@ -370,28 +378,15 @@ public class GeoportalResolver {
|
||||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case GEO_DE: {
|
|
||||||
|
|
||||||
LOG.error("The Resolver towards '" + resoruceGeoportalCodes + "' not implemented yet");
|
|
||||||
throw ExceptionManager.internalErrorException(req,
|
|
||||||
"The Resolver towards '" + resoruceGeoportalCodes + "' not implemented yet", this.getClass(),
|
|
||||||
helpURI);
|
|
||||||
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Returning link: " + itemLink);
|
LOG.info("Returning link: " + itemLink);
|
||||||
return Response.seeOther(new URL(itemLink).toURI()).build();
|
return Response.seeOther(new URL(itemLink).toURI()).build();
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
||||||
if (!(e instanceof WebApplicationException)) {
|
if (!(e instanceof WebApplicationException)) {
|
||||||
|
|
Loading…
Reference in New Issue