Merged with private version adding:

Task #10070 resolve public/private items to public/private catalogue

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/data-transfer/uri-resolver@169879 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2018-07-20 12:38:09 +00:00
parent 475889d541
commit d60afce851
8 changed files with 622 additions and 93 deletions

View File

@ -94,7 +94,14 @@
</Changeset>
<Changeset component="org.gcube.data-transfer.uri-resolver.1-14-0"
date="2017-09-06">
<Change>[Task #9538] Geonetwork-Uri Resolver enhancement: provide new filters and improve current ones
<Change>[Task #9538] Geonetwork-Uri Resolver enhancement: provide new
filters and improve current ones
</Change>
</Changeset>
<Changeset component="org.gcube.data-transfer.uri-resolver.1-15-0"
date="2018-07-20">
<Change>[Task #10070] Catalogue Resolver enhancement: resolve
public/private items to public/private catalogue
</Change>
</Changeset>
</ReleaseNotes>

17
pom.xml
View File

@ -8,7 +8,7 @@
</parent>
<groupId>org.gcube.data.transfer</groupId>
<artifactId>uri-resolver</artifactId>
<version>1.14.0-SNAPSHOT</version>
<version>1.15.0-SNAPSHOT</version>
<packaging>war</packaging>
<description>The URI Resolver is an HTTP URI resolver implemented as an HTTP servlet which gives access trough HTTP to different protocols URIs. </description>
@ -22,7 +22,7 @@
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<!-- <additionalparam>-Xdoclint:none</additionalparam> -->
<!-- <additionalparam>-Xdoclint:none</additionalparam> -->
</properties>
<dependencies>
@ -98,6 +98,12 @@
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<!-- DOM -->
<dependency>
<groupId>org.w3c</groupId>
@ -106,6 +112,13 @@
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.data-catalogue</groupId>
<artifactId>ckan-util-library</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<!-- END GIS RESOLVER DEPENDENCIES -->
<dependency>

View File

@ -21,7 +21,8 @@ import org.gcube.datatransfer.resolver.ResourceCatalogueCodes;
import org.gcube.datatransfer.resolver.UriResolverRewriteFilter;
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
import org.gcube.datatransfer.resolver.catalogue.resource.ApplicationProfileReaderForCatalogueResolver;
import org.gcube.datatransfer.resolver.catalogue.resource.CkanPorltetApplicationProfile;
import org.gcube.datatransfer.resolver.catalogue.resource.CkanCatalogueConfigurationsReader;
import org.gcube.datatransfer.resolver.catalogue.resource.GatewayCKANCatalogueReference;
import org.gcube.datatransfer.resolver.catalogue.resource.UpdateApplicationProfileCatalogueResolver;
import org.gcube.datatransfer.resolver.scope.ScopeUtil;
import org.json.JSONArray;
@ -30,6 +31,8 @@ import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import eu.trentorise.opendata.jackan.model.CkanDataset;
/**
* The Class GisResolver.
@ -200,14 +203,35 @@ public class CatalogueResolver extends HttpServlet{
try{
logger.info("Setting scope "+scope+ " to search Ckan Portlet URL from IS");
ScopeProvider.instance.set(scope);
ckanPorltetUrl = CkanPorltetApplicationProfile.getPortletUrlFromInfrastrucure();
GatewayCKANCatalogueReference ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints();
//IS THE PRODUCT PLUBLIC OR PRIVATE?
//USING ACCESS TO PUBLIC PORTLET IF THE ITEM IS PUBLIC, OTHERWISE ACCESS TO PRIVATE PORTLET
ckanPorltetUrl = ckanCatalogueReference.getPrivatePortletURL();
String datasetName = cer.getValueOfParameter(CatalogueRequestParameter.ENTITY_NAME.getKey());
if(ckanCatalogueReference.getCkanURL()!=null){
try{
CkanDataset dataset = CkanCatalogueConfigurationsReader.getDataset(datasetName, ckanCatalogueReference.getCkanURL());
if(dataset!=null){
ckanPorltetUrl = ckanCatalogueReference.getPublicPortletURL();
logger.info("The dataset "+datasetName+" is a public item using public access to CKAN portlet: "+ckanPorltetUrl);
}
}catch(Exception e){
logger.warn("Error on checking if dataset: "+datasetName+" is private or not", e);
ckanPorltetUrl = ckanCatalogueReference.getPublicPortletURL();
}
}
if(ckanPorltetUrl == null || ckanPorltetUrl.isEmpty()){
sendError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR, "An error occurred during discovery Data Catalogue URL, try again later");
sendError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR, "An error occurred during discovery the resource: "+CkanCatalogueConfigurationsReader.APPLICATION_PROFILE_NAME+" in the scope: "+scope+", try again later");
return;
}
}catch(Exception e){
logger.error("An error occurred during discovery Data Catalogue URL: ",e);
sendError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR, "An error occurred during discovery Data Catalogue URL, try again later");
logger.error("Error during discovery the resource: "+CkanCatalogueConfigurationsReader.APPLICATION_PROFILE_NAME+" in the scope: "+scope, e);
sendError(resp, HttpStatus.SC_INTERNAL_SERVER_ERROR, "An error occurred during discovery the resource: "+CkanCatalogueConfigurationsReader.APPLICATION_PROFILE_NAME+" in the scope: "+scope+", try again later");
return;
}finally{
@ -227,6 +251,7 @@ public class CatalogueResolver extends HttpServlet{
buildPath+= PATH_SEPARATOR+cer.getValueOfParameter(CatalogueRequestParameter.ENTITY_CONTEXT.getKey()) + PATH_SEPARATOR;
buildPath+=cer.getValueOfParameter(CatalogueRequestParameter.ENTITY_NAME.getKey());
String finalUrl = ckanPorltetUrl+"?"+buildPath;
logger.info("Builded final URL: "+finalUrl);
resp.sendRedirect(resp.encodeRedirectURL(finalUrl));
@ -511,7 +536,7 @@ public class CatalogueResolver extends HttpServlet{
public static void main(String[] args) {
try{
String scope = "d4science.research";
String scope = "/d4science.research-infrastructures.eu";
ApplicationProfileReaderForCatalogueResolver appPrCatResolver = new ApplicationProfileReaderForCatalogueResolver(scope, true);
logger.info("Reosurce for Catalogue Resolver: "+appPrCatResolver);
}catch(Exception e){

View File

@ -0,0 +1,139 @@
/**
*
*/
package org.gcube.datatransfer.resolver.catalogue.endpoint;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The Class CatalogueServiceEndpointReader.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Apr 20, 2018
*/
public class CatalogueServiceEndpointReader {
// data catalogue info
private final static String RUNTIME_CATALOGUE_RESOURCE_NAME = "CKanDataCatalogue";
private final static String PLATFORM_CATALOGUE_NAME = "Tomcat";
private final static String CKAN_IS_ROOT_MASTER = "IS_ROOT_MASTER";
private static final Logger logger = LoggerFactory.getLogger(CatalogueServiceEndpointReader.class);
/** A map to cache couple SCOPE - THE CKAN PORTLET URL OPERATING IN THE SCOPE*/
private static Map<String, String> cacheCkanDataCatalogue = new HashMap<String, String>();
/**
* Instantiates a new catalogue service endpoint reader.
*/
public CatalogueServiceEndpointReader(){
}
/**
* Retrieve endpoints information from IS for DataCatalogue URL.
*
* @return list of endpoints for ckan data catalogue
* @throws Exception the exception
*/
public static List<ServiceEndpoint> getConfigurationFromISFORCatalogueUrl() throws Exception{
logger.info("Searching SE "+RUNTIME_CATALOGUE_RESOURCE_NAME+" configurations in the scope: "+ScopeProvider.instance.get());
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_CATALOGUE_RESOURCE_NAME +"'");
query.addCondition("$resource/Profile/Platform/Name/text() eq '"+ PLATFORM_CATALOGUE_NAME +"'");
query.addVariable("$prop", "$resource/Profile/AccessPoint/Properties/Property")
.addCondition("$prop/Name/text() eq '"+CKAN_IS_ROOT_MASTER+"'")
.addCondition("$prop/Value/text() eq 'true'");
logger.info("Performing query 1 with property '"+CKAN_IS_ROOT_MASTER+"': "+query);
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
List<ServiceEndpoint> toReturn = client.submit(query);
logger.info("The query 1 returned "+toReturn.size()+ " ServiceEndpoint/s");
if(toReturn.size()==0){
logger.info("NO "+RUNTIME_CATALOGUE_RESOURCE_NAME+" having "+CKAN_IS_ROOT_MASTER+" property");
query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_CATALOGUE_RESOURCE_NAME +"'");
query.addCondition("$resource/Profile/Platform/Name/text() eq '"+ PLATFORM_CATALOGUE_NAME +"'");
logger.info("Performing query 2: "+query);
client = clientFor(ServiceEndpoint.class);
toReturn = client.submit(query);
logger.info("The query 2 returned "+toReturn.size()+ " ServiceEndpoint/s");
}
return toReturn;
}
/**
* Gets the catalogue url.
*
* @return the catalogue url
*/
public static String getCatalogueUrl() {
String scope = ScopeProvider.instance.get();
logger.debug("Getting Catalogue URL for scope: "+scope +" read from ScopeProvider");
String catalogueURLForScope = cacheCkanDataCatalogue.get(scope);
if(catalogueURLForScope==null){
logger.debug("Catalogue URL not found in cache, loading from IS");
try{
logger.debug("Instancing again the scope provider with scope value: "+scope);
ScopeProvider.instance.set(scope);
DataCatalogueImpl utilCKAN = new DataCatalogueImpl(scope);
catalogueURLForScope = utilCKAN.getCatalogueUrl();
if(catalogueURLForScope==null)
throw new Exception("No cataluge url found in the scope: "+scope);
cacheCkanDataCatalogue.put(scope, catalogueURLForScope);
}catch(Exception e){
logger.error("Error on getting the catalogue url in the scope: "+scope, e);
}
}
logger.info("Returning Catalogue URL: "+catalogueURLForScope +" for the scope: "+scope);
return catalogueURLForScope;
}
// /**
// * The main method.
// *
// * @param args the arguments
// */
// public static void main(String[] args) {
//
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab";
// ScopeProvider.instance.set(scope);
// try {
// String catalogueURL = CatalogueServiceEndpointReader.getCatalogueUrl(scope);
// System.out.println(catalogueURL);
// }
// catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
}

View File

@ -0,0 +1,198 @@
/**
*
*/
package org.gcube.datatransfer.resolver.catalogue.resource;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
import java.util.List;
import java.util.Properties;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
import org.gcube.datatransfer.resolver.catalogue.endpoint.CatalogueServiceEndpointReader;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
import eu.trentorise.opendata.jackan.CkanClient;
import eu.trentorise.opendata.jackan.exceptions.CkanException;
import eu.trentorise.opendata.jackan.model.CkanDataset;
/**
* The Class CkanCatalogueConfigurationsReader.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Apr 20, 2018
*/
public class CkanCatalogueConfigurationsReader {
private static final Logger logger = LoggerFactory.getLogger(CkanCatalogueConfigurationsReader.class);
public final static String APPLICATION_PROFILE_NAME = "CkanPortlet";
private static final String DATACATALOGUECONFIGURATION_PROPERTIES = "datacatalogueconfiguration.properties";
/**
* Load catalogue end points.
*
* @return the gateway ckan catalogue reference
* @throws Exception the exception
*/
public static GatewayCKANCatalogueReference loadCatalogueEndPoints() throws Exception{
GatewayCKANCatalogueReference links = new GatewayCKANCatalogueReference();
links.setScope(ScopeProvider.instance.get());
String privatePortletURL = getPortletUrlForScopeFromIS();
links.setPrivatePortletURL(privatePortletURL);
//Building public URL from private portlet URL
try{
URI toURL = new URI(privatePortletURL);
String publicURL = privatePortletURL.startsWith("https://")?"https://"+toURL.getHost():"http://"+toURL.getHost();
String realiveURLToPublicCtlg = getRelativeURLToCatalogue();
links.setPublicPortletURL(publicURL+"/"+realiveURLToPublicCtlg);
}catch(Exception e){
logger.warn("Erron on generating public catalogue URL from private URL: "+privatePortletURL, e);
}
//Getting the CKAN Portet URL for current scope
try{
String ckanPortletURL = CatalogueServiceEndpointReader.getCatalogueUrl();
links.setCkanURL(ckanPortletURL);
}catch(Exception e){
logger.warn("Erron on getting CKAN Porlet URL for scope: "+ScopeProvider.instance.get(), e);
}
return links;
}
/**
* Retrieve a ckan dataset given its id. The CkanClient is used, without api key. The result is null also when the dataset is private.
* @param datasetIdorName
* @param catalogueURL
* @return
* @throws Exception
*/
public static CkanDataset getDataset(String datasetIdorName, String catalogueURL) throws Exception{
logger.info("Performing request GET CKAN dataset with id: " + datasetIdorName);
// checks
checkNotNull(datasetIdorName);
checkArgument(!datasetIdorName.isEmpty());
try{
CkanClient client = new CkanClient(catalogueURL);
return client.getDataset(datasetIdorName);
}catch(CkanException e){
logger.info("Getting dataset "+datasetIdorName+" thrown a CkanException, returning null");
return null;
}
}
/**
* Gets the portlet url for scope from is.
*
* @return the portlet url for scope from is
* @throws Exception the exception
*/
private static String getPortletUrlForScopeFromIS() throws Exception {
String scope = ScopeProvider.instance.get();
logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " +
APPLICATION_PROFILE_NAME + " scope: " + scope);
try {
Query q =
new QueryBox(
"for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Name/string() " +
" eq '" +
APPLICATION_PROFILE_NAME +
"'" +
"return $profile");
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException(
"Your applicationProfile is not registered in the infrastructure");
else {
String elem = appProfile.get(0);
DocumentBuilder docBuilder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
List<String> currValue = null;
currValue =
helper.evaluate("/Resource/Profile/Body/url/text()");
if (currValue != null && currValue.size() > 0) {
logger.debug("CKAN Portlet url found is " + currValue.get(0));
return currValue.get(0);
}
}
}
catch (Exception e) {
throw new Exception("Error while trying to fetch applicationProfile profile for name "+APPLICATION_PROFILE_NAME+"from the infrastructure, using scope: "+scope);
}
return null;
}
/**
* Gets the relative url to catalogue.
*
* @return the relative url to catalogue
*/
private static String getRelativeURLToCatalogue(){
Properties prop = new Properties();
String relativeURLToCatalogue = null;
try {
InputStream in = CkanCatalogueConfigurationsReader.class.getResourceAsStream(DATACATALOGUECONFIGURATION_PROPERTIES);
// load a properties file
prop.load(in);
// get the property value
relativeURLToCatalogue = prop.getProperty("PORTAL_RELATIVE_URL_TO_CATALOGUE");
if(relativeURLToCatalogue==null || relativeURLToCatalogue.isEmpty())
return "catalogue";
} catch (IOException e) {
logger.error("An error occurred on read property file: "+DATACATALOGUECONFIGURATION_PROPERTIES, e);
}
return relativeURLToCatalogue;
}
// /**
// * The main method.
// *
// * @param args the arguments
// */
// public static void main(String[] args) {
//
// ScopeProvider.instance.set("/gcube/devsec/devVRE");
// try {
// GatewayCKANCatalogueReference links = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints();
// System.out.println(links);
// }
// catch (Exception e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
}

View File

@ -1,84 +1,84 @@
/**
*
*/
package org.gcube.datatransfer.resolver.catalogue.resource;
import static org.gcube.resources.discovery.icclient.ICFactory.client;
import java.io.StringReader;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.Query;
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.xml.sax.InputSource;
/**
* The Class CkanPorltetApplicationProfile.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* May 16, 2017
*/
public class CkanPorltetApplicationProfile {
private static final Logger logger = LoggerFactory.getLogger(CkanPorltetApplicationProfile.class);
private final static String APPLICATION_PROFILE_NAME = "CkanPortlet";
/**
* Gets the portlet url from infrastrucure.
*
* @return the portlet url from infrastrucure
* @throws Exception the exception
*/
public static String getPortletUrlFromInfrastrucure() throws Exception {
String scope = ScopeProvider.instance.get();
logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " +
APPLICATION_PROFILE_NAME + " scope: " + scope);
try {
Query q =
new QueryBox(
"for $profile in collection('/db/Profiles/GenericResource')//Resource " +
"where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Name/string() " +
" eq '" +
APPLICATION_PROFILE_NAME +
"'" +
"return $profile");
DiscoveryClient<String> client = client();
List<String> appProfile = client.submit(q);
if (appProfile == null || appProfile.size() == 0)
throw new ApplicationProfileNotFoundException(
"Your applicationProfile is not registered in the infrastructure");
else {
String elem = appProfile.get(0);
DocumentBuilder docBuilder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
XPathHelper helper = new XPathHelper(node);
List<String> currValue = null;
currValue =
helper.evaluate("/Resource/Profile/Body/url/text()");
if (currValue != null && currValue.size() > 0) {
logger.debug("CKAN Portlet url found is " + currValue.get(0));
return currValue.get(0);
}
}
}
catch (Exception e) {
throw new Exception("Error while trying to fetch applicationProfile profile for name "+APPLICATION_PROFILE_NAME+"from the infrastructure, using scope: "+scope);
}
return null;
}
}
///**
// *
// */
//
//package org.gcube.datatransfer.resolver.catalogue.resource;
//
//import static org.gcube.resources.discovery.icclient.ICFactory.client;
//
//import java.io.StringReader;
//import java.util.List;
//
//import javax.xml.parsers.DocumentBuilder;
//import javax.xml.parsers.DocumentBuilderFactory;
//
//import org.gcube.common.resources.gcore.utils.XPathHelper;
//import org.gcube.common.scope.api.ScopeProvider;
//import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
//import org.gcube.resources.discovery.client.api.DiscoveryClient;
//import org.gcube.resources.discovery.client.queries.api.Query;
//import org.gcube.resources.discovery.client.queries.impl.QueryBox;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.w3c.dom.Node;
//import org.xml.sax.InputSource;
//
//
///**
// * The Class CkanPorltetApplicationProfile.
// *
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
// * May 16, 2017
// */
//public class CkanPorltetApplicationProfile {
//
// private static final Logger logger = LoggerFactory.getLogger(CkanPorltetApplicationProfile.class);
// private final static String APPLICATION_PROFILE_NAME = "CkanPortlet";
//
// /**
// * Gets the portlet url from infrastrucure.
// *
// * @return the portlet url from infrastrucure
// * @throws Exception the exception
// */
// public static String getPortletUrlFromInfrastrucure() throws Exception {
//
// String scope = ScopeProvider.instance.get();
// logger.debug("Trying to fetch applicationProfile profile from the infrastructure for " +
// APPLICATION_PROFILE_NAME + " scope: " + scope);
// try {
// Query q =
// new QueryBox(
// "for $profile in collection('/db/Profiles/GenericResource')//Resource " +
// "where $profile/Profile/SecondaryType/string() eq 'ApplicationProfile' and $profile/Profile/Name/string() " +
// " eq '" +
// APPLICATION_PROFILE_NAME +
// "'" +
// "return $profile");
// DiscoveryClient<String> client = client();
// List<String> appProfile = client.submit(q);
// if (appProfile == null || appProfile.size() == 0)
// throw new ApplicationProfileNotFoundException(
// "Your applicationProfile is not registered in the infrastructure");
// else {
// String elem = appProfile.get(0);
// DocumentBuilder docBuilder =
// DocumentBuilderFactory.newInstance().newDocumentBuilder();
// Node node = docBuilder.parse(new InputSource(new StringReader(elem))).getDocumentElement();
// XPathHelper helper = new XPathHelper(node);
// List<String> currValue = null;
// currValue =
// helper.evaluate("/Resource/Profile/Body/url/text()");
// if (currValue != null && currValue.size() > 0) {
// logger.debug("CKAN Portlet url found is " + currValue.get(0));
// return currValue.get(0);
// }
// }
// }
// catch (Exception e) {
// throw new Exception("Error while trying to fetch applicationProfile profile for name "+APPLICATION_PROFILE_NAME+"from the infrastructure, using scope: "+scope);
// }
//
// return null;
// }
//}

View File

@ -0,0 +1,140 @@
/**
*
*/
package org.gcube.datatransfer.resolver.catalogue.resource;
import java.io.Serializable;
/**
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Nov 23, 2017
*/
public class GatewayCKANCatalogueReference implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String privatePortletURL;
private String publicPortletURL;
private String scope;
private String ckanURL;
/**
*
*/
public GatewayCKANCatalogueReference() {
}
/**
* @param privatePortletURL
* @param publicPortletURL
* @param ckanURL
* @param scope
*/
public GatewayCKANCatalogueReference(String scope,
String privatePortletURL, String publicPortletURL, String ckanURL) {
this.scope = scope;
this.privatePortletURL = privatePortletURL;
this.publicPortletURL = publicPortletURL;
this.ckanURL = ckanURL;
}
/**
* @return the ckanURL
*/
public String getCkanURL() {
return ckanURL;
}
/**
* @param ckanURL the ckanURL to set
*/
public void setCkanURL(String ckanURL) {
this.ckanURL = ckanURL;
}
/**
* @return the privatePortletURL
*/
public String getPrivatePortletURL() {
return privatePortletURL;
}
/**
* @return the publicPortletURL
*/
public String getPublicPortletURL() {
return publicPortletURL;
}
/**
* @return the scope
*/
public String getScope() {
return scope;
}
/**
* @param privatePortletURL the privatePortletURL to set
*/
public void setPrivatePortletURL(String privatePortletURL) {
this.privatePortletURL = privatePortletURL;
}
/**
* @param publicPortletURL the publicPortletURL to set
*/
public void setPublicPortletURL(String publicPortletURL) {
this.publicPortletURL = publicPortletURL;
}
/**
* @param scope the scope to set
*/
public void setScope(String scope) {
this.scope = scope;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GatewayCatalogueReference [privatePortletURL=");
builder.append(privatePortletURL);
builder.append(", publicPortletURL=");
builder.append(publicPortletURL);
builder.append(", scope=");
builder.append(scope);
builder.append(", ckanURL=");
builder.append(ckanURL);
builder.append("]");
return builder.toString();
}
}

View File

@ -0,0 +1,7 @@
# Property files
#
# author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
# created 11/2017
#
PORTAL_RELATIVE_URL_TO_CATALOGUE = catalogue