From d864d43d15037abd45b7e1086bfe9218ee0b6b09 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 31 Jan 2022 17:06:32 +0100 Subject: [PATCH 01/58] #22757 moved to SHUB 2.0.0-SNAPSHOT --- CHANGELOG.md | 6 + pom.xml | 12 +- .../test/ServiceEndpointReader.java | 116 ++++++++++++++++++ 3 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 src/test/java/org/gcube/datatransfer/test/ServiceEndpointReader.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f2129d..161eb38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2-7.0-SNAPSHOT] - 2022-01-31 + +**New** + +- [#22757] moved to storagehub-client-library 2.0.0[-SNAPSHOT] + ## [v2-6-1] - 2022-01-17 **New features** diff --git a/pom.xml b/pom.xml index 2595b76..cd6a154 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.data.transfer uri-resolver - 2.6.1 + 2.7.0-SNAPSHOT war The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. @@ -123,7 +123,7 @@ org.gcube.common storagehub-client-library - [1.0.0, 2.0.0-SNAPSHOT) + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) @@ -200,6 +200,12 @@ + + org.geotoolkit + geotk-xml-base + 3.20-geoapi-3.0 + + commons-lang commons-lang @@ -298,4 +304,4 @@ - \ No newline at end of file + diff --git a/src/test/java/org/gcube/datatransfer/test/ServiceEndpointReader.java b/src/test/java/org/gcube/datatransfer/test/ServiceEndpointReader.java new file mode 100644 index 0000000..8f5c0ce --- /dev/null +++ b/src/test/java/org/gcube/datatransfer/test/ServiceEndpointReader.java @@ -0,0 +1,116 @@ +package org.gcube.datatransfer.test; + +import static org.gcube.resources.discovery.icclient.ICFactory.clientFor; +import static org.gcube.resources.discovery.icclient.ICFactory.queryFor; + +import java.util.Collection; +import java.util.List; + +import org.apache.log4j.Logger; +import org.gcube.common.encryption.StringEncrypter; +import org.gcube.common.resources.gcore.ServiceEndpoint; +import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.datatransfer.resolver.services.exceptions.NotFoundException; +import org.gcube.resources.discovery.client.api.DiscoveryClient; +import org.gcube.resources.discovery.client.queries.api.SimpleQuery; + +/** + * The Class ServiceEndpointReader. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Jan 27, 2022 + */ +public class ServiceEndpointReader { + + private static final String RESOURCE_NAME = "DEV Geoserver"; + private static final String CATEGORY_NAME = "Gis"; + private static final String SCOPE = "/gcube/devsec/devVRE"; + + public static Logger LOG = Logger.getLogger(ServiceEndpointReader.class); + + + public static void main(String[] args) { + try { + readServiceEndpoint(SCOPE); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + /** + * Read service endpoint. + * + * @param req the req + * @param scope the scope + * @throws Exception + */ + public static void readServiceEndpoint(String scope) throws Exception{ + + String callerScope = null; + try{ + callerScope = ScopeProvider.instance.get(); + ScopeProvider.instance.set(scope); + LOG.info("Searching SE "+RESOURCE_NAME +" configurations in the scope: "+ScopeProvider.instance.get()); + + SimpleQuery query = queryFor(ServiceEndpoint.class); + query.addCondition("$resource/Profile/Name/text() eq '"+ RESOURCE_NAME +"'"); + query.addCondition("$resource/Profile/Category/text() eq '"+ CATEGORY_NAME +"'"); + + DiscoveryClient client = clientFor(ServiceEndpoint.class); + List toReturn = client.submit(query); + + LOG.info("The query returned "+toReturn.size()+ " ServiceEndpoint/s"); + + if(toReturn.size()==0){ + String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RESOURCE_NAME,CATEGORY_NAME,ScopeProvider.instance.get()); + LOG.error(errorMessage); + throw new Exception(errorMessage); + + } + + String accessPointUsername = null; + String accessPointPwd = null; + + ServiceEndpoint se = toReturn.get(0); + Collection theAccessPoints = se.profile().accessPoints().asCollection(); + for (AccessPoint accessPoint : theAccessPoints) { + accessPointUsername = accessPoint.username(); + System.out.println("AccessPoint username: "+accessPointPwd); + accessPointPwd = accessPoint.password(); + if(accessPointUsername!=null && accessPointPwd!=null) { + LOG.info("returning the access point with name: "+accessPoint.name()); + if (accessPointPwd != null) { + accessPointPwd = StringEncrypter.getEncrypter().decrypt(accessPointPwd); + LOG.info("Decrypted pwd registered into Access Point '" + accessPoint.name() + "' is: " + + accessPointPwd.substring(0,accessPointPwd.length()/2)+"..."); + + System.out.println("AccessPoint pwd is: "+accessPointPwd); + } + } + } + + + }catch(Exception e){ + + if(e instanceof NotFoundException) + throw e; + + String errorMessage = "Error occurred on reading the "+RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get(); + LOG.error(errorMessage, e); + throw new Exception(errorMessage); + + }finally{ + if(callerScope!=null){ + LOG.info("Setting to the callerScope scope: "+callerScope); + ScopeProvider.instance.set(callerScope); + }else{ + LOG.info("Reset scope"); + ScopeProvider.instance.reset(); + } + } + + } + +} -- 2.17.1 From 1f7772c9151c902bce1d158852c764a492a2d732 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 2 Feb 2022 11:58:39 +0100 Subject: [PATCH 02/58] moved to SHUB1 --- pom.xml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index cd6a154..5ae5c92 100644 --- a/pom.xml +++ b/pom.xml @@ -123,7 +123,7 @@ org.gcube.common storagehub-client-library - [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) @@ -199,12 +199,7 @@ - - - org.geotoolkit - geotk-xml-base - 3.20-geoapi-3.0 - + commons-lang -- 2.17.1 From 35993464cde366d49fe378870a4b61176e9e382e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Wed, 2 Feb 2022 14:13:33 +0100 Subject: [PATCH 03/58] insert exclusion of shub.1.x in the storagehub-application-persistence --- pom.xml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 5ae5c92..0d41e0c 100644 --- a/pom.xml +++ b/pom.xml @@ -77,8 +77,15 @@ org.gcube.data-publishing storagehub-application-persistence [1.0.0, 2.0.0-SNAPSHOT) + + + org.gcube.common + storagehub-client-library + + + org.gcube.data.analysis dataminer-invocation-model @@ -123,7 +130,7 @@ org.gcube.common storagehub-client-library - [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) @@ -199,7 +206,7 @@ - + commons-lang -- 2.17.1 From d2d3fbbd6ee0ff137a0d259d34fbe94cda699e8a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 17 Mar 2022 16:43:34 +0100 Subject: [PATCH 04/58] Moved to weld-servlet-core v3.1.0.Final (see https://support.d4science.org/issues/20743#note-6) --- .settings/org.eclipse.wst.common.component | 29 ++++++++++++++-------- CHANGELOG.md | 4 +++ pom.xml | 4 +-- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index c74ee29..e84f7be 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,37 +1,46 @@ - + - - + + + + - + + - + + - + + - + + - + + - + + - + + diff --git a/CHANGELOG.md b/CHANGELOG.md index 161eb38..63b03e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#22757] moved to storagehub-client-library 2.0.0[-SNAPSHOT] +** Bug Fixing** + +- [#20743] Integration with javamelody + ## [v2-6-1] - 2022-01-17 **New features** diff --git a/pom.xml b/pom.xml index 0d41e0c..a970115 100644 --- a/pom.xml +++ b/pom.xml @@ -155,8 +155,8 @@ org.jboss.weld.servlet - weld-servlet - 2.2.10.Final + weld-servlet-core + 3.1.0.Final -- 2.17.1 From 5f5901845cb691e247cf3f37af659cd9b80d8d03 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 13:22:29 +0100 Subject: [PATCH 05/58] tryng to integrate enunciate https://github.com/stoicflame/enunciate/ --- CHANGELOG.md | 6 ++ enunciate.xml | 13 +++ pom.xml | 88 ++++++++++++++++++- .../resolver/services/UriResolverDocs.java | 56 ++++++++++++ src/main/webapp/WEB-INF/jsp/index.jsp | 13 ++- 5 files changed, 168 insertions(+), 8 deletions(-) create mode 100644 enunciate.xml create mode 100644 src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 63b03e5..7d9cf47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2-7.1-SNAPSHOT] - 2022-03-24 + +**New** + +- Integrate Enunicate https://github.com/stoicflame/enunciate/ + ## [v2-7.0-SNAPSHOT] - 2022-01-31 **New** diff --git a/enunciate.xml b/enunciate.xml new file mode 100644 index 0000000..add545d --- /dev/null +++ b/enunciate.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index a970115..8db149c 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.data.transfer uri-resolver - 2.7.0-SNAPSHOT + 2.7.1-SNAPSHOT war The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. @@ -23,7 +23,8 @@ 2.24.1 1.7 1.8 - + + 2.14.0 @@ -256,6 +257,38 @@ test + + + + + + + + + + + + + + + + + + + + + + + + + + + org.geotoolkit + geotk-xml-base + 3.20-geoapi-3.0 + + + @@ -276,8 +309,7 @@ - - + maven-compiler-plugin @@ -286,6 +318,52 @@ ${maven.compiler.target} + + + + com.webcohesion.enunciate + enunciate-maven-plugin + ${enunciate.version} + + ${project.build.directory}/docs + + + + assemble + + assemble + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-enunciate-docs + process-resources + + copy-resources + + + target + + + ${project.build.directory}/${project.artifactId}-${project.version}/docs + ${project.build.directory}/docs + true + + + + + + + + org.apache.maven.plugins maven-assembly-plugin @@ -304,6 +382,8 @@ + + diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java new file mode 100644 index 0000000..c67695f --- /dev/null +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -0,0 +1,56 @@ +/** + * + */ +package org.gcube.datatransfer.resolver.services; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; + +import javax.servlet.http.HttpServletRequest; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.MediaType; + +import org.gcube.datatransfer.resolver.services.error.ExceptionManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Oct 22, 2018 + */ +@Path("docs") +public class UriResolverDocs { + + private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class); + + @GET + @Produces({MediaType.TEXT_HTML}) + @Path("") + public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{ + + String indexFile = "/docs/index.html"; + + try{ + logger.info(UriResolverDocs.class.getSimpleName() +" called"); + String realPath = req.getServletContext().getRealPath(indexFile); + return new FileInputStream(new File(realPath)); + }catch (Exception e) { + + if(!(e instanceof WebApplicationException)){ + //UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Index.jsp not found. Please, contact the support!"; + throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); + } + //ALREADY MANAGED AS WebApplicationException + logger.error("Exception:", e); + throw (WebApplicationException) e; + } + } +} + diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index c65dc2e..44d30cd 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -18,11 +18,11 @@ body { height: 300px; margin-top: -150px; /*set to a negative number 1/2 of your height*/ margin-left: -300px; /*set to a negative number 1/2 of your width*/ -/* border: 1px solid #ccc; */ + /* border: 1px solid #ccc; */ /* background-color: #9b9b9b; */ position: fixed; text-align: center; -/* vertical-align: middle; */ + /* vertical-align: middle; */ } .myTitle { @@ -39,8 +39,13 @@ body {
The URI Resolver

See wiki page at gCube Wiki URI - Resolver + href="https://gcube.wiki.gcube-system.org/gcube/index.php/URI_Resolver" + target="_blank">gCube Wiki URI Resolver +

+

+ See API documentation at URI Resolver API

-- 2.17.1 From 841909d09a87ad6b57652594b97c6d7385761a1d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 14:49:48 +0100 Subject: [PATCH 06/58] passed to cdi-api 2.0 --- pom.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8db149c..1f1209a 100644 --- a/pom.xml +++ b/pom.xml @@ -152,12 +152,13 @@ javax.enterprise cdi-api - 1.1 + 2.0 org.jboss.weld.servlet weld-servlet-core 3.1.0.Final + -- 2.17.1 From e53a5cc3eeb09dd3f4cc564dfcbfc7ffb624c4fa Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 14:56:36 +0100 Subject: [PATCH 07/58] passed jandex 2.2.2.Final --- pom.xml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 1f1209a..66f45e3 100644 --- a/pom.xml +++ b/pom.xml @@ -160,13 +160,14 @@ 3.1.0.Final - org.jboss jandex - 1.2.2.Final + 2.2.2.Final - + + + javax.servlet javax.servlet-api -- 2.17.1 From 94b3006b8a83d183b9f0df28a41e664dfd705697 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 15:37:54 +0100 Subject: [PATCH 08/58] changed UriResolverDocs --- pom.xml | 24 ------------------- .../resolver/services/UriResolverDocs.java | 20 +++++++++++----- src/main/webapp/WEB-INF/jsp/index.jsp | 2 +- 3 files changed, 15 insertions(+), 31 deletions(-) diff --git a/pom.xml b/pom.xml index 66f45e3..bcce5cc 100644 --- a/pom.xml +++ b/pom.xml @@ -259,30 +259,6 @@ test - - - - - - - - - - - - - - - - - - - - - - - - org.geotoolkit diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index c67695f..2e2d61c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -33,18 +33,26 @@ public class UriResolverDocs { @Produces({MediaType.TEXT_HTML}) @Path("") public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{ - - String indexFile = "/docs/index.html"; - + logger.info(UriResolverDocs.class.getSimpleName() +" called"); + + String requestURI = req.getRequestURI(); try{ - logger.info(UriResolverDocs.class.getSimpleName() +" called"); - String realPath = req.getServletContext().getRealPath(indexFile); + + + if(requestURI == null) + requestURI = "/index.html"; + + String pathInfo = req.getPathInfo(); + logger.info("pathInfo {}",pathInfo); + logger.info("request URI {}", requestURI); + + String realPath = req.getServletContext().getRealPath("/docs/"+requestURI); return new FileInputStream(new File(realPath)); }catch (Exception e) { if(!(e instanceof WebApplicationException)){ //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Index.jsp not found. Please, contact the support!"; + String error = requestURI+" not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } //ALREADY MANAGED AS WebApplicationException diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index 44d30cd..df8421c 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -44,7 +44,7 @@ body {

See API documentation at URI Resolver API

-- 2.17.1 From 645709a7017fb94a781b6edd8aedc35102bacc50 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 15:49:41 +0100 Subject: [PATCH 09/58] fixed path --- .../gcube/datatransfer/resolver/services/UriResolverDocs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 2e2d61c..1118ae2 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory; * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * Oct 22, 2018 */ -@Path("docs") +@Path("docs/*") public class UriResolverDocs { private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class); -- 2.17.1 From 50c822904e510dfb5180a41641c6ed57dbd6bd79 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 15:59:07 +0100 Subject: [PATCH 10/58] fixing UriResolverDocs --- .../resolver/services/UriResolverDocs.java | 67 +++++++++++-------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 1118ae2..dcca55b 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -21,44 +21,57 @@ import org.slf4j.LoggerFactory; /** * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Oct 22, 2018 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 22, 2018 */ -@Path("docs/*") +@Path("docs") public class UriResolverDocs { private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class); @GET - @Produces({MediaType.TEXT_HTML}) - @Path("") - public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{ - logger.info(UriResolverDocs.class.getSimpleName() +" called"); - - String requestURI = req.getRequestURI(); - try{ - - - if(requestURI == null) - requestURI = "/index.html"; - - String pathInfo = req.getPathInfo(); - logger.info("pathInfo {}",pathInfo); - logger.info("request URI {}", requestURI); - - String realPath = req.getServletContext().getRealPath("/docs/"+requestURI); - return new FileInputStream(new File(realPath)); - }catch (Exception e) { + @Produces({ MediaType.TEXT_HTML }) + @Path("/") + public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { + logger.info(UriResolverDocs.class.getSimpleName() + " called"); - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = requestURI+" not found. Please, contact the support!"; + String requestURI = req.getRequestURI(); + try { + + if (requestURI == null) + requestURI = "/index.html"; + + String pathInfo = req.getPathInfo(); + logger.info("pathInfo {}", pathInfo); + logger.info("request URI {}", requestURI); + + String realPath = req.getServletContext().getRealPath("/docs/" + requestURI); + return new FileInputStream(new File(realPath)); + } catch (Exception e) { + + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = requestURI + " not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } -} + @GET + @Produces({ MediaType.TEXT_HTML }) + @Path("*") + public InputStream toDoc1(@Context HttpServletRequest req) throws WebApplicationException { + logger.info(UriResolverDocs.class.getSimpleName() + " toDoc1 called"); + return index(req); + } + + @GET + @Produces({ MediaType.TEXT_HTML }) + @Path("/*") + public InputStream toDoc2(@Context HttpServletRequest req) throws WebApplicationException { + logger.info(UriResolverDocs.class.getSimpleName() + " toDoc2 called"); + return index(req); + } +} -- 2.17.1 From 76cf1eaee878cfa907c84a22605833eb2fd83295 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:04:23 +0100 Subject: [PATCH 11/58] fixing path --- .../gcube/datatransfer/resolver/services/UriResolverDocs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index dcca55b..2761dbf 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -61,7 +61,7 @@ public class UriResolverDocs { @GET @Produces({ MediaType.TEXT_HTML }) - @Path("*") + @Path("") public InputStream toDoc1(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " toDoc1 called"); return index(req); -- 2.17.1 From bcf5cdd56cce20d9c30ac1c75c38a8d75ed419b9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:09:44 +0100 Subject: [PATCH 12/58] changing path --- .../datatransfer/resolver/services/UriResolverDocs.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 2761dbf..0deddd5 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -67,11 +67,4 @@ public class UriResolverDocs { return index(req); } - @GET - @Produces({ MediaType.TEXT_HTML }) - @Path("/*") - public InputStream toDoc2(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(UriResolverDocs.class.getSimpleName() + " toDoc2 called"); - return index(req); - } } -- 2.17.1 From cfc9ad0c4976611f7491ffb5598dfadd41fb5bed Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:15:27 +0100 Subject: [PATCH 13/58] fixing path --- .../resolver/services/UriResolverDocs.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 0deddd5..d10fc61 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -30,7 +30,7 @@ public class UriResolverDocs { @GET @Produces({ MediaType.TEXT_HTML }) - @Path("/") + @Path("") public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " called"); @@ -58,13 +58,5 @@ public class UriResolverDocs { throw (WebApplicationException) e; } } - - @GET - @Produces({ MediaType.TEXT_HTML }) - @Path("") - public InputStream toDoc1(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(UriResolverDocs.class.getSimpleName() + " toDoc1 called"); - return index(req); - } } -- 2.17.1 From baa0a3fcdad291b31becae7c3ecc0700c4707856 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:20:26 +0100 Subject: [PATCH 14/58] any path added --- .../gcube/datatransfer/resolver/services/UriResolverDocs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index d10fc61..f14b575 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -30,7 +30,7 @@ public class UriResolverDocs { @GET @Produces({ MediaType.TEXT_HTML }) - @Path("") + @Path("/{any: .*}") public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " called"); -- 2.17.1 From 27ade09793e16f172bca6d2130653e660caffba2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:26:54 +0100 Subject: [PATCH 15/58] fixed pathInfo --- .../gcube/datatransfer/resolver/services/UriResolverDocs.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index f14b575..da6ed26 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -44,7 +44,7 @@ public class UriResolverDocs { logger.info("pathInfo {}", pathInfo); logger.info("request URI {}", requestURI); - String realPath = req.getServletContext().getRealPath("/docs/" + requestURI); + String realPath = req.getServletContext().getRealPath(pathInfo); return new FileInputStream(new File(realPath)); } catch (Exception e) { -- 2.17.1 From 2683d601b0e1148849f4d8c1367f015530d2ce19 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:29:53 +0100 Subject: [PATCH 16/58] fixing pathInfo --- .../resolver/services/UriResolverDocs.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index da6ed26..bb4efa4 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -34,15 +34,15 @@ public class UriResolverDocs { public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " called"); - String requestURI = req.getRequestURI(); + String pathInfo = req.getPathInfo(); + logger.info("pathInfo {}", pathInfo); try { - if (requestURI == null) - requestURI = "/index.html"; + if (pathInfo.equals("docs")) + pathInfo += "/index.html"; - String pathInfo = req.getPathInfo(); - logger.info("pathInfo {}", pathInfo); - logger.info("request URI {}", requestURI); + logger.info("redirecting to {}", pathInfo); + logger.info("request URI {}", req.getRequestURI()); String realPath = req.getServletContext().getRealPath(pathInfo); return new FileInputStream(new File(realPath)); @@ -50,7 +50,7 @@ public class UriResolverDocs { if (!(e instanceof WebApplicationException)) { // UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = requestURI + " not found. Please, contact the support!"; + String error = pathInfo + " not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } // ALREADY MANAGED AS WebApplicationException -- 2.17.1 From fd9a10be6cc967593abbf7817344a7fbfd5343f8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 16:38:16 +0100 Subject: [PATCH 17/58] fixing paths --- .../resolver/services/UriResolverDocs.java | 35 +++++++++++++++---- src/main/webapp/WEB-INF/jsp/index.jsp | 2 +- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index bb4efa4..f5aa5a6 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -31,18 +31,17 @@ public class UriResolverDocs { @GET @Produces({ MediaType.TEXT_HTML }) @Path("/{any: .*}") - public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(UriResolverDocs.class.getSimpleName() + " called"); + public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { + logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); String pathInfo = req.getPathInfo(); logger.info("pathInfo {}", pathInfo); try { - if (pathInfo.equals("docs")) - pathInfo += "/index.html"; + if (pathInfo.equals("/docs/")) + pathInfo += "index.html"; logger.info("redirecting to {}", pathInfo); - logger.info("request URI {}", req.getRequestURI()); String realPath = req.getServletContext().getRealPath(pathInfo); return new FileInputStream(new File(realPath)); @@ -58,5 +57,29 @@ public class UriResolverDocs { throw (WebApplicationException) e; } } - + + @GET + @Produces({ MediaType.TEXT_HTML }) + @Path("") + public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { + logger.info(UriResolverDocs.class.getSimpleName() + " index called"); + + String pathInfo = "/docs/index.html"; + try { + + String realPath = req.getServletContext().getRealPath(pathInfo); + return new FileInputStream(new File(realPath)); + } catch (Exception e) { + + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = pathInfo + " not found. Please, contact the support!"; + throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); + } + // ALREADY MANAGED AS WebApplicationException + logger.error("Exception:", e); + throw (WebApplicationException) e; + } + } + } diff --git a/src/main/webapp/WEB-INF/jsp/index.jsp b/src/main/webapp/WEB-INF/jsp/index.jsp index df8421c..44d30cd 100644 --- a/src/main/webapp/WEB-INF/jsp/index.jsp +++ b/src/main/webapp/WEB-INF/jsp/index.jsp @@ -44,7 +44,7 @@ body {

See API documentation at URI Resolver API

-- 2.17.1 From 2881f76ed06018e39e2ae247a4dea01abbf87044 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 17:33:54 +0100 Subject: [PATCH 18/58] fixing documentation --- pom.xml | 2 +- .../resolver/catalogue/CatalogueRequest.java | 19 +- .../resolver/parthenos/ParthenosRequest.java | 31 +- .../services/AnalyticsCreateResolver.java | 282 ++++++++++-------- .../services/AnalyticsGetResolver.java | 71 +++-- .../resolver/services/CatalogueResolver.java | 265 +++++++++------- .../resolver/services/GisResolver.java | 180 ++++++----- .../services/KnimeCreateResolver.java | 58 ++-- .../resolver/services/SMPIDResolver.java | 67 +++-- .../resolver/services/SMPResolver.java | 58 ++-- .../resolver/services/StorageIDResolver.java | 1 - .../resolver/services/UriResolverDocs.java | 19 +- .../resolver/services/UriResolverIndex.java | 34 ++- .../resolver/services/UriResolverInfo.java | 18 +- .../services/UriResolverResources.java | 10 +- .../resolver/services/WekeoResolver.java | 147 ++++----- 16 files changed, 708 insertions(+), 554 deletions(-) diff --git a/pom.xml b/pom.xml index bcce5cc..455565a 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ uri-resolver 2.7.1-SNAPSHOT war - The URI Resolver is an HTTP URI resolver implemented as an REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. + The URI Resolver is an HTTP URI resolver implemented as a REST service which gives access trough HTTP to different gcube Resolvers and gCube Applications. scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java index 05cb296..15cb1d6 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java @@ -1,13 +1,13 @@ package org.gcube.datatransfer.resolver.catalogue; - /** * The Class CatalogueRequest. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Nov 6, 2018 - * - * Binding Catalogue Request as a JSON + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 + * + * Binding Catalogue Request as a JSON */ public class CatalogueRequest { @@ -42,7 +42,14 @@ public class CatalogueRequest { return entity_name; } - /* (non-Javadoc) + /** + * To string. + * + * @return the string + */ + /* + * (non-Javadoc) + * * @see java.lang.Object#toString() */ @Override diff --git a/src/main/java/org/gcube/datatransfer/resolver/parthenos/ParthenosRequest.java b/src/main/java/org/gcube/datatransfer/resolver/parthenos/ParthenosRequest.java index 1e407e8..4fef115 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/parthenos/ParthenosRequest.java +++ b/src/main/java/org/gcube/datatransfer/resolver/parthenos/ParthenosRequest.java @@ -11,20 +11,41 @@ import lombok.NoArgsConstructor; import lombok.Setter; import lombok.ToString; - /** - * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Nov 26, 2018 + * Instantiates a new parthenos request. */ @NoArgsConstructor + +/** + * Instantiates a new parthenos request. + * + * @param entity_name the entity name + */ @AllArgsConstructor + +/** + * Gets the entity name. + * + * @return the entity name + */ @Getter + +/** + * Sets the entity name. + * + * @param entity_name the new entity name + */ @Setter + +/** + * To string. + * + * @return the java.lang. string + */ @ToString public class ParthenosRequest { - @JsonProperty(value="entity_name", required=true) + @JsonProperty(value = "entity_name", required = true) private String entity_name; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java index c20b674..94cdaa5 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java @@ -60,7 +60,7 @@ import org.xml.sax.SAXException; * The Class AnalyticsCreateResolver. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Dec 12, 2018 + * Dec 12, 2018 */ @Path("analytics") public class AnalyticsCreateResolver { @@ -77,11 +77,10 @@ public class AnalyticsCreateResolver { private static Logger logger = LoggerFactory.getLogger(AnalyticsCreateResolver.class); private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver"; - /** * Creates the analytics url. * - * @param req the req + * @param req the req * @param body the body * @return the response * @throws WebApplicationException the web application exception @@ -90,58 +89,65 @@ public class AnalyticsCreateResolver { @Path("/create") @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public Response createAnalyticsURL(@Context HttpServletRequest req, String body) throws WebApplicationException{ - logger.info(this.getClass().getSimpleName()+" POST starts..."); + public Response createAnalyticsURL(@Context HttpServletRequest req, String body) throws WebApplicationException { + logger.info(this.getClass().getSimpleName() + " POST starts..."); - try{ - logger.info("body is: "+body); + try { + logger.info("body is: " + body); DataMinerInvocation jsonRequest = null; try { - jsonRequest = DataMinerInvocationManager.getInstance().unmarshalingJSON(IOUtils.toInputStream(body), true); - } - catch (IOException | JAXBException | SAXException e1) { - logger.error("The body is not a valid DataMinerInvocation JSON request",e1); - throw ExceptionManager.badRequestException(req, "Bad 'dataminer-invocation' JSON request: \n"+e1.getCause().getMessage(), this.getClass(), helpURI); + jsonRequest = DataMinerInvocationManager.getInstance().unmarshalingJSON(IOUtils.toInputStream(body), + true); + } catch (IOException | JAXBException | SAXException e1) { + logger.error("The body is not a valid DataMinerInvocation JSON request", e1); + throw ExceptionManager.badRequestException(req, + "Bad 'dataminer-invocation' JSON request: \n" + e1.getCause().getMessage(), this.getClass(), + helpURI); } - logger.debug("The body contains the request: "+jsonRequest.toString()); + logger.debug("The body contains the request: " + jsonRequest.toString()); String contextToken = SecurityTokenProvider.instance.get(); String scope = ScopeProvider.instance.get(); - // logger.info("SecurityTokenProvider contextToken: "+contextToken); - logger.info("ScopeProvider has scope: "+scope); + // logger.info("SecurityTokenProvider contextToken: "+contextToken); + logger.info("ScopeProvider has scope: " + scope); String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN); - if(contextToken.compareTo(appToken)==0){ - logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"..."); - throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); + if (contextToken.compareTo(appToken) == 0) { + logger.error("Token not passed, SecurityTokenProvider contains the root app token: " + + appToken.substring(0, 10) + "..."); + throw ExceptionManager.unauthorizedException(req, + "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); } String operatorID = jsonRequest.getOperatorId(); - if(scope==null || scope.isEmpty()){ + if (scope == null || scope.isEmpty()) { logger.error("The parameter 'scope' not found or empty in the JSON object"); - throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, + "Mandatory body parameter 'scope' not found or empty in the JSON object", this.getClass(), + helpURI); } - - if(operatorID==null || operatorID.isEmpty()){ + if (operatorID == null || operatorID.isEmpty()) { logger.error("The parameter 'operatorId' not found or empty in the JSON object"); - throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, + "Mandatory body parameter 'operatorId' not found or empty in the JSON object", this.getClass(), + helpURI); } ScopeBean scopeBean = new ScopeBean(scope); String publicLinkToDMInvFile = ""; - if(scopeBean.is(Type.VRE)){ + if (scopeBean.is(Type.VRE)) { String vreName = scopeBean.name(); - String analyticsGetResolverURL = String.format("%s/%s", Util.getServerURL(req), "analytics/get"); - //Creating DM invocation file - if(jsonRequest.getActionType()==null) + String analyticsGetResolverURL = String.format("%s/%s", Util.getServerURL(req), "analytics/get"); + // Creating DM invocation file + if (jsonRequest.getActionType() == null) jsonRequest.setActionType(ActionType.RUN); File tempInvocationFile = null; @@ -150,17 +156,20 @@ public class AnalyticsCreateResolver { String xmlRequest = DataMinerInvocationManager.getInstance().marshalingXML(jsonRequest, true, true); String uniqueName = createDMInvocationFileName(jsonRequest.getOperatorId()); tempInvocationFile = createTempFile(uniqueName, ".xml", xmlRequest.getBytes()); - logger.info("Created StorageHubClient Instance, uploading file: "+tempInvocationFile.getName()); + logger.info("Created StorageHubClient Instance, uploading file: " + tempInvocationFile.getName()); AuthorizationEntry entry = authorizationService().get(contextToken); - //retrieve the info of the token owner + // retrieve the info of the token owner ClientInfo clientInfo = entry.getClientInfo(); - String owner = clientInfo.getId(); //IS THIS THE USERNAME? + String owner = clientInfo.getId(); // IS THIS THE USERNAME? String infra = ScopeUtil.getInfrastructureNameFromScope(ScopeProvider.instance.get()); String theAppToken = readApplicationTokenFromSE(req, infra); - logger.info("By using infra scope: "+infra +" and the Application Token: "+theAppToken.substring(0,theAppToken.length()/2)+"... of "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" to instance the "+StorageHubManagement.class.getSimpleName()); + logger.info("By using infra scope: " + infra + " and the Application Token: " + + theAppToken.substring(0, theAppToken.length() / 2) + "... of " + + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " to instance the " + + StorageHubManagement.class.getSimpleName()); ScopeProvider.instance.set(infra); ApplicationMode applicationMode = new ApplicationMode(theAppToken); applicationMode.start(); @@ -170,140 +179,159 @@ public class AnalyticsCreateResolver { Map theMap = new HashMap(); theMap.put("owner", owner); URL thePublicLink = null; - try{ + try { - logger.info("Saving dataminer-invocation file for the user: "+owner); - thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "application/xml", metadata); - logger.info("Saved dataminer-invocation file at: "+thePublicLink); - }catch(Exception e){ + logger.info("Saving dataminer-invocation file for the user: " + owner); + thePublicLink = storageHubManagement.persistFile(new FileInputStream(tempInvocationFile), + tempInvocationFile.getName(), "application/xml", metadata); + logger.info("Saved dataminer-invocation file at: " + thePublicLink); + } catch (Exception e) { logger.error("Error when storing your 'dataminer-invocation':", e); - throw ExceptionManager.internalErrorException(req, "Error when storing your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI); + throw ExceptionManager + .internalErrorException( + req, "Error when storing your 'dataminer-invocation' request with " + + jsonRequest + ". \nPlease contact the support", + this.getClass(), helpURI); } // FileContainer fileContainer = shc.getWSRoot().uploadFile(new FileInputStream(tempInvocationFile), tempInvocationFile.getName(), "DataMinerInvocation Request created by "+this.getClass().getSimpleName()); // logger.info("UPLOADED FILE at: "+fileContainer.getPublicLink()); // URL thePublicLink = fileContainer.getPublicLink(); - publicLinkToDMInvFile = thePublicLink!=null?thePublicLink.toString():null; - } - catch (Exception e) { + publicLinkToDMInvFile = thePublicLink != null ? thePublicLink.toString() : null; + } catch (Exception e) { - if(e instanceof InternalServerException){ - //error during storing the file via StorageHubManagent + if (e instanceof InternalServerException) { + // error during storing the file via StorageHubManagent throw e; } logger.error("Error on creating 'dataminer-invocation:", e); - throw ExceptionManager.badRequestException(req, "Error on creating your 'dataminer-invocation' request with "+jsonRequest+". \nPlease contact the support", this.getClass(), helpURI); - }finally{ - //No needed to reset the scope, it is provided by TokenSetter - try{ - //DELETING THE TEMP FILE - if(tempInvocationFile!=null && tempInvocationFile.exists()) - tempInvocationFile.delete(); - }catch(Exception e){ - //silent + throw ExceptionManager.badRequestException(req, + "Error on creating your 'dataminer-invocation' request with " + jsonRequest + + ". \nPlease contact the support", + this.getClass(), helpURI); + } finally { + // No needed to reset the scope, it is provided by TokenSetter + try { + // DELETING THE TEMP FILE + if (tempInvocationFile != null && tempInvocationFile.exists()) + tempInvocationFile.delete(); + } catch (Exception e) { + // silent } } - if(publicLinkToDMInvFile==null){ + if (publicLinkToDMInvFile == null) { logger.error("Error on creating the public link to file"); - throw ExceptionManager.badRequestException(req, "Error on getting link to your 'dataminer-invocation' request. Plese contact the support "+jsonRequest, this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, + "Error on getting link to your 'dataminer-invocation' request. Plese contact the support " + + jsonRequest, + this.getClass(), helpURI); } - String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName, DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile); - logger.info("Returning Analytics URL: "+dataMinerURL); + String dataMinerURL = String.format("%s/%s?%s=%s", analyticsGetResolverURL, vreName, + DATAMINER_INVOCATION_MODEL, publicLinkToDMInvFile); + logger.info("Returning Analytics URL: " + dataMinerURL); return Response.ok(dataMinerURL).header("Location", dataMinerURL).build(); - }else{ - logger.error("The input scope "+scope+" is not a VRE"); - throw ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI); + } else { + logger.error("The input scope " + scope + " is not a VRE"); + throw ExceptionManager.badRequestException(req, + "Working in the " + scope + " scope that is not a VRE. Use a token of VRE", this.getClass(), + helpURI); } - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on creating the Analytics for the request "+body+". Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on creating the Analytics for the request " + body + + ". Please, contact the support!"; + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** - * Reads the Application Token from Service Endpoint {@link AnalyticsCreateResolver#ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME} + * Reads the Application Token from Service Endpoint + * {@link AnalyticsCreateResolver#ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME} * - * @param req the req + * @param req the req * @param scope the scope * @return the string */ - private static String readApplicationTokenFromSE(HttpServletRequest req, String scope){ + private static String readApplicationTokenFromSE(HttpServletRequest req, String scope) { String callerScope = null; String gCubeAppToken = null; - try{ + try { callerScope = ScopeProvider.instance.get(); ScopeProvider.instance.set(scope); - logger.info("Searching SE "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" configurations in the scope: "+ScopeProvider.instance.get()); + logger.info("Searching SE " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " configurations in the scope: " + + ScopeProvider.instance.get()); SimpleQuery query = queryFor(ServiceEndpoint.class); - query.addCondition("$resource/Profile/Name/text() eq '"+ ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME +"'"); + query.addCondition("$resource/Profile/Name/text() eq '" + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + "'"); query.addCondition("$resource/Profile/Category/text() eq 'Service'"); DiscoveryClient client = clientFor(ServiceEndpoint.class); List toReturn = client.submit(query); - logger.info("The query returned "+toReturn.size()+ " ServiceEndpoint/s"); + logger.info("The query returned " + toReturn.size() + " ServiceEndpoint/s"); - if(toReturn.size()==0){ - String errorMessage = "No "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" registered in the scope: "+ScopeProvider.instance.get(); + if (toReturn.size() == 0) { + String errorMessage = "No " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " registered in the scope: " + + ScopeProvider.instance.get(); logger.error(errorMessage); - throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI); + throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, + helpURI); } - ServiceEndpoint se = toReturn.get(0); Collection theAccessPoints = se.profile().accessPoints().asCollection(); for (AccessPoint accessPoint : theAccessPoints) { Collection properties = accessPoint.properties().asCollection(); for (Property property : properties) { - if(property.name().equalsIgnoreCase(GCUBE_TOKEN)){ + if (property.name().equalsIgnoreCase(GCUBE_TOKEN)) { logger.info("gcube-token as property was found, returning it"); gCubeAppToken = property.value(); break; } } - if(gCubeAppToken!=null) + if (gCubeAppToken != null) break; } - if(gCubeAppToken!=null){ + if (gCubeAppToken != null) { String decryptedPassword = StringEncrypter.getEncrypter().decrypt(gCubeAppToken); - logger.info("Returning decrypted Application Token registered into "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME +" SE: "+decryptedPassword.substring(0,decryptedPassword.length()/2)+"...."); + logger.info("Returning decrypted Application Token registered into " + + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " SE: " + + decryptedPassword.substring(0, decryptedPassword.length() / 2) + "...."); return decryptedPassword; } - - String errorMessage = "No "+GCUBE_TOKEN+" as Property saved in the "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" SE registered in the scope: "+ScopeProvider.instance.get(); + String errorMessage = "No " + GCUBE_TOKEN + " as Property saved in the " + + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + " SE registered in the scope: " + + ScopeProvider.instance.get(); logger.error(errorMessage); throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI); - - }catch(Exception e){ - String errorMessage = "Error occurred on reading the "+ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME+" SE registered in the scope: "+ScopeProvider.instance.get(); + } catch (Exception e) { + String errorMessage = "Error occurred on reading the " + ANALYTICS_RESOLVER_SERVICE_ENDPOINT_NAME + + " SE registered in the scope: " + ScopeProvider.instance.get(); logger.error(errorMessage, e); throw ExceptionManager.internalErrorException(req, errorMessage, AnalyticsCreateResolver.class, helpURI); - }finally{ - if(callerScope!=null){ - logger.info("Setting to the callerScope scope: "+callerScope); + } finally { + if (callerScope != null) { + logger.info("Setting to the callerScope scope: " + callerScope); ScopeProvider.instance.set(callerScope); - }else{ + } else { logger.info("Reset scope"); ScopeProvider.instance.reset(); } @@ -311,48 +339,38 @@ public class AnalyticsCreateResolver { } + /** + * Creates the temp file. + * + * @param fileName the file name + * @param extension the extension + * @param data the data + * @return the file + * @throws IOException Signals that an I/O exception has occurred. + */ + private static File createTempFile(String fileName, String extension, byte[] data) throws IOException { + // Since Java 1.7 Files and Path API simplify operations on files + java.nio.file.Path path = Files.createTempFile(fileName, extension); + File file = path.toFile(); + // writing sample data + Files.write(path, data); + logger.info("Created the Temp File: " + file.getAbsolutePath()); + return file; + } - /** - * Creates the temp file. - * - * @param fileName the file name - * @param extension the extension - * @param data the data - * @return the file - * @throws IOException Signals that an I/O exception has occurred. - */ - private static File createTempFile(String fileName, String extension, byte[] data) throws IOException { - // Since Java 1.7 Files and Path API simplify operations on files - java.nio.file.Path path = Files.createTempFile(fileName, extension); - File file = path.toFile(); - // writing sample data - Files.write(path, data); - logger.info("Created the Temp File: "+file.getAbsolutePath()); - return file; - } - - - /** - * Creates the dm invocation file name. - * - * @param operatorId the operator id - * @return the string - */ - private static String createDMInvocationFileName(String operatorId){ - String fileName = "dim"; - int index = operatorId.lastIndexOf("."); - if(index>0 && index 0 && index < operatorId.length()) { + fileName += "-" + operatorId.substring(index + 1, operatorId.length()); + } + fileName += "-" + System.currentTimeMillis(); return fileName; - } - - -// public static void main(String[] args) { -// -// System.out.println(readApplicationTokenFromSE(null, "/gcube")); -// -// } - + } } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java index 26090ed..d945a19 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java @@ -23,20 +23,19 @@ import org.slf4j.LoggerFactory; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; - /** * The Class AnalyticsGetResolver. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Dec 13, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("analytics") public class AnalyticsGetResolver { private static Logger logger = LoggerFactory.getLogger(AnalyticsGetResolver.class); - private static final String ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL = - "org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl"; + private static final String ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL = "org.gcube.portlets.user.dataminermanager.server.DataMinerManagerServiceImpl"; private static final String APPLICATION_PROFILE = "ApplicationProfile"; @@ -44,60 +43,70 @@ public class AnalyticsGetResolver { private static final String ANALYTICS_EXECUTOR_PORTLET_NAME = "Analytics Executor"; - /** * Resolve analytics url. * - * @param req the req + * @param req the req * @param vreName the vre name * @return the response + * @throws WebApplicationException the web application exception */ @GET @Path("/get/{vreName}") - public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) throws WebApplicationException{ - logger.info(this.getClass().getSimpleName()+" GET starts..."); + public Response resolveAnalyticsURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) + throws WebApplicationException { + logger.info(this.getClass().getSimpleName() + " GET starts..."); try { - if(vreName==null || vreName.isEmpty()){ + if (vreName == null || vreName.isEmpty()) { logger.error("The path parameter 'vreName' not found or empty in the path"); - throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", + this.getClass(), helpURI); } ScopeBean fullScopeBean = null; - //CHECKING IF THE INPUT VRE NAME IS REGISTRED IN THE INFRASTRUCTURE... - try{ + // CHECKING IF THE INPUT VRE NAME IS REGISTRED IN THE INFRASTRUCTURE... + try { fullScopeBean = LoadingMapOfScopeCache.get(vreName); - }catch(ExecutionException | InvalidCacheLoadException e){ - logger.error("Error on getting the fullscope from cache for vreName "+vreName, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the VRE name "+vreName+". Is it registered as VRE in the D4Science Infrastructure System?", this.getClass(), helpURI); + } catch (ExecutionException | InvalidCacheLoadException e) { + logger.error("Error on getting the fullscope from cache for vreName " + vreName, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting full scope for the VRE name " + vreName + + ". Is it registered as VRE in the D4Science Infrastructure System?", + this.getClass(), helpURI); } ApplicationProfileReader reader = null; - try{ - reader = new ApplicationProfileReader(fullScopeBean.toString(), APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false); - }catch(Exception e){ - logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e); - throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+ANALYTICS_EXECUTOR_PORTLET_NAME+". Please contact the support", this.getClass(), helpURI); + try { + reader = new ApplicationProfileReader(fullScopeBean.toString(), APPLICATION_PROFILE, + ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, false); + } catch (Exception e) { + logger.error("Error on reading the " + APPLICATION_PROFILE + " with APPID: " + + ORG_GCUBE_PORTLETS_USER_DATAMINERMANAGER_SERVER_DATA_MINER_MANAGER_SERVICE_IMPL, e); + throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the " + + ANALYTICS_EXECUTOR_PORTLET_NAME + ". Please contact the support", this.getClass(), helpURI); } - //READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope + // READ THE DATAMINER URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE + // fullScope String analyticsExecutorEndPoint = reader.getApplicationProfile().getUrl(); - //CHECKING THE QUERY STRING - String queryString = req.getQueryString()!=null?req.getQueryString():""; + // CHECKING THE QUERY STRING + String queryString = req.getQueryString() != null ? req.getQueryString() : ""; String analitycsExecutorURL = String.format("%s?%s", analyticsExecutorEndPoint, queryString); - logger.info("Resolving the request with the "+ANALYTICS_EXECUTOR_PORTLET_NAME+" URL: "+analitycsExecutorURL); + logger.info("Resolving the request with the " + ANALYTICS_EXECUTOR_PORTLET_NAME + " URL: " + + analitycsExecutorURL); return Response.seeOther(new URI(analitycsExecutorURL)).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Error occurred on resolving the Analytics URL. Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index 5f461dd..d1f2362 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -47,33 +47,42 @@ import eu.trentorise.opendata.jackan.model.CkanDataset; * The Class CatalogueResolver. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Nov 16, 2018 + * Nov 16, 2018 */ @Path("{entityContext:ctlg(-(o|g|p|d))?}") public class CatalogueResolver { - private static Logger logger = LoggerFactory.getLogger(CatalogueResolver.class); private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver"; - private static enum SCOPE_STATUS {ACTIVE, DETACHED} + + /** + * The Enum SCOPE_STATUS. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 + */ + private static enum SCOPE_STATUS { + ACTIVE, DETACHED + } /** * Resolve catalogue. * - * @param req the req - * @param entityName the entity name - * @param vreName the vre name + * @param req the req + * @param entityName the entity name + * @param vreName the vre name * @param entityContext the entity context * @return the response + * @throws WebApplicationException the web application exception */ @GET @Path("/{vreName}/{entityName}") - public Response resolveCatalogue(@Context HttpServletRequest req, - @PathParam("entityName") String entityName, - @PathParam("vreName") String vreName, - @PathParam("entityContext") String entityContext) throws WebApplicationException{ + public Response resolveCatalogue(@Context HttpServletRequest req, @PathParam("entityName") String entityName, + @PathParam("vreName") String vreName, @PathParam("entityContext") String entityContext) + throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); try { InnerMethodName.instance.set("resolveCataloguePublicLink"); @@ -81,96 +90,110 @@ public class CatalogueResolver { String itemCatalogueURL; - if(itemCatalogueURLs.isPublicItem()){ - logger.info("The dataset "+itemCatalogueURLs.getItemName()+" was detected as public item (not private to VRE)"); - if(itemCatalogueURLs.getPublicVRECataloguePortletURL()!=null && !itemCatalogueURLs.getPublicVRECataloguePortletURL().isEmpty()) { + if (itemCatalogueURLs.isPublicItem()) { + logger.info("The dataset " + itemCatalogueURLs.getItemName() + + " was detected as public item (not private to VRE)"); + if (itemCatalogueURLs.getPublicVRECataloguePortletURL() != null + && !itemCatalogueURLs.getPublicVRECataloguePortletURL().isEmpty()) { itemCatalogueURL = itemCatalogueURLs.getPublicVRECataloguePortletURL(); - logger.info("I found the public VRE catalogue URL, so using public access to it: "+itemCatalogueURL); - }else { + logger.info( + "I found the public VRE catalogue URL, so using public access to it: " + itemCatalogueURL); + } else { itemCatalogueURL = itemCatalogueURLs.getPublicGatewayCataloguePortletURL(); - logger.info("No public VRE catalogue URL found, so using public access to gateway CKAN portlet: "+itemCatalogueURL); + logger.info("No public VRE catalogue URL found, so using public access to gateway CKAN portlet: " + + itemCatalogueURL); } - }else{ + } else { itemCatalogueURL = itemCatalogueURLs.getPrivateVRECataloguePortletURL(); - logger.info("The dataset "+itemCatalogueURLs.getItemName()+" is a private item (to VRE) so using protected access to CKAN portlet: "+itemCatalogueURL); + logger.info("The dataset " + itemCatalogueURLs.getItemName() + + " is a private item (to VRE) so using protected access to CKAN portlet: " + itemCatalogueURL); } return Response.seeOther(new URL(itemCatalogueURL).toURI()).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Error occurred on resolving the Catalgoue URL. Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - + /** * Post catalogue. * - * @param req the req + * @param req the req * @param jsonRequest the json request * @return the response + * @throws WebApplicationException the web application exception */ @POST @Path("") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) - public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) throws WebApplicationException{ - logger.info(this.getClass().getSimpleName()+" POST starts..."); + public Response postCatalogue(@Context HttpServletRequest req, CatalogueRequest jsonRequest) + throws WebApplicationException { + logger.info(this.getClass().getSimpleName() + " POST starts..."); - try{ + try { InnerMethodName.instance.set("postCataloguePublicLink"); - logger.info("The body contains the request: "+jsonRequest.toString()); + logger.info("The body contains the request: " + jsonRequest.toString()); - //CHECK IF INPUT SCOPE IS VALID + // CHECK IF INPUT SCOPE IS VALID String scope = jsonRequest.getGcube_scope(); - if(!scope.startsWith(ConstantsResolver.SCOPE_SEPARATOR)){ - logger.info("Scope not start with char '{}' adding it",ConstantsResolver.SCOPE_SEPARATOR); - scope+=ConstantsResolver.SCOPE_SEPARATOR+scope; + if (!scope.startsWith(ConstantsResolver.SCOPE_SEPARATOR)) { + logger.info("Scope not start with char '{}' adding it", ConstantsResolver.SCOPE_SEPARATOR); + scope += ConstantsResolver.SCOPE_SEPARATOR + scope; } String serverUrl = Util.getServerURL(req); - final String vreName = scope.substring(scope.lastIndexOf(ConstantsResolver.SCOPE_SEPARATOR)+1, scope.length()); + final String vreName = scope.substring(scope.lastIndexOf(ConstantsResolver.SCOPE_SEPARATOR) + 1, + scope.length()); ScopeBean fullScope = null; - //CHECK IF THE vreName has a valid scope, so it is a valid VRE + // CHECK IF THE vreName has a valid scope, so it is a valid VRE try { fullScope = LoadingMapOfScopeCache.get(vreName); - }catch(ExecutionException e){ - logger.error("Error on getting the fullscope from cache for vreName "+vreName, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the VRE name "+vreName+". Is it registered as VRE in the D4Science Infrastructure System?", this.getClass(), helpURI); + } catch (ExecutionException e) { + logger.error("Error on getting the fullscope from cache for vreName " + vreName, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting full scope for the VRE name " + vreName + + ". Is it registered as VRE in the D4Science Infrastructure System?", + this.getClass(), helpURI); } - if(fullScope==null) - throw ExceptionManager.notFoundException(req, "The scope '"+scope+"' does not matching any scope in the infrastructure. Is it valid?", this.getClass(), helpURI); + if (fullScope == null) + throw ExceptionManager.notFoundException(req, + "The scope '" + scope + "' does not matching any scope in the infrastructure. Is it valid?", + this.getClass(), helpURI); ResourceCatalogueCodes rc = ResourceCatalogueCodes.valueOfCodeValue(jsonRequest.getEntity_context()); - if(rc==null){ + if (rc == null) { logger.error("Entity context is null/malformed"); - throw ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Entity context is null/malformed", this.getClass(), + helpURI); } String linkURL = String.format("%s/%s/%s/%s", serverUrl, rc.getId(), vreName, jsonRequest.getEntity_name()); - logger.info("Returining Catalogue URL: "+linkURL); + logger.info("Returining Catalogue URL: " + linkURL); return Response.ok(linkURL).header("Location", linkURL).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Error occurred on resolving the Analytics URL. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationExceptiongetItemCatalogueURLs + // ALREADY MANAGED AS WebApplicationExceptiongetItemCatalogueURLs logger.error("Exception:", e); throw (WebApplicationException) e; } @@ -179,25 +202,28 @@ public class CatalogueResolver { /** * Gets the item catalogue UR ls. * - * @param req the req - * @param scopeName the scope name + * @param req the req + * @param scopeName the scope name * @param entityContext the entity context - * @param entityName the entity name + * @param entityName the entity name * @return the item catalogue UR ls * @throws Exception the exception */ - protected static ItemCatalogueURLs getItemCatalogueURLs(HttpServletRequest req, String scopeName, String entityContext, String entityName) throws Exception{ + protected static ItemCatalogueURLs getItemCatalogueURLs(HttpServletRequest req, String scopeName, + String entityContext, String entityName) throws Exception { try { String entityContextValue = ResourceCatalogueCodes.valueOfCodeId(entityContext).getValue(); ScopeBean scopeBean = null; SCOPE_STATUS scopeStatus = SCOPE_STATUS.ACTIVE; VRE vreDetached = null; - try{ + try { scopeBean = LoadingMapOfScopeCache.get(scopeName); - }catch(ExecutionException | InvalidCacheLoadException e){ - logger.error("Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE",scopeName); - + } catch (ExecutionException | InvalidCacheLoadException e) { + logger.error( + "Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE", + scopeName); + boolean isScopeDetached = false; try { vreDetached = LoadingMapOfDetachedVRE.get(scopeName); @@ -205,106 +231,115 @@ public class CatalogueResolver { scopeStatus = SCOPE_STATUS.DETACHED; logger.info("I loaded a valid VRE obj for scope name {}", scopeName); isScopeDetached = true; - }catch (Exception e1) { - logger.warn("I was not able to load a detached VRE for vreName {}. Going to error for wrong scope",scopeName); + } catch (Exception e1) { + logger.warn("I was not able to load a detached VRE for vreName {}. Going to error for wrong scope", + scopeName); } - - //If is not a cas of scope detached, going to error for wrong scope - if(!isScopeDetached) { - logger.error("Error on getting the fullscope from cache for scopeName "+scopeName, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the scope name '"+scopeName+"'. Is it registered as a valid Scope in the D4Science Infrastructure System?", CatalogueResolver.class, helpURI); + + // If is not a cas of scope detached, going to error for wrong scope + if (!isScopeDetached) { + logger.error("Error on getting the fullscope from cache for scopeName " + scopeName, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting full scope for the scope name '" + scopeName + + "'. Is it registered as a valid Scope in the D4Science Infrastructure System?", + CatalogueResolver.class, helpURI); } } - + String fullScope = scopeBean.toString(); - logger.info("Read fullScope: "+fullScope + " for SCOPE name: "+scopeName +" from cache created by: "+GetAllInfrastructureScopes.class.getSimpleName()); - - if(scopeBean.is(Type.VO)) { + logger.info("Read fullScope: " + fullScope + " for SCOPE name: " + scopeName + " from cache created by: " + + GetAllInfrastructureScopes.class.getSimpleName()); + + if (scopeBean.is(Type.VO)) { logger.info("It is a {} scope", Type.VO); - logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, Type.INFRASTRUCTURE); + logger.warn("The Catalogue can't work at {} level, I'm overriding the scope to {} level", Type.VO, + Type.INFRASTRUCTURE); String[] splitScope = fullScope.split(ConstantsResolver.SCOPE_SEPARATOR); - fullScope = ConstantsResolver.SCOPE_SEPARATOR+splitScope[1]; //THIS IS THE INFRASTRUCTURE SCOPE - logger.info("Overriden the input scope {} with {} as type: {}", scopeBean.toString(), Type.INFRASTRUCTURE, fullScope); + fullScope = ConstantsResolver.SCOPE_SEPARATOR + splitScope[1]; // THIS IS THE INFRASTRUCTURE SCOPE + logger.info("Overriden the input scope {} with {} as type: {}", scopeBean.toString(), + Type.INFRASTRUCTURE, fullScope); } ScopeProvider.instance.set(fullScope); GatewayCKANCatalogueReference ckanCatalogueReference = null; - logger.info("Managing scope status: {}",scopeStatus); - + logger.info("Managing scope status: {}", scopeStatus); + switch (scopeStatus) { case DETACHED: - + String privatePortletURL = vreDetached.getCatalogPortletURL(); - //The private portlet URL - Map mapAccessURLToCatalogue = new HashMap(3); - mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE,privatePortletURL); - - //Building the gateway catalogue public URL from private VRE Portlet URL + // The private portlet URL + Map mapAccessURLToCatalogue = new HashMap( + 3); + mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE, privatePortletURL); + + // Building the gateway catalogue public URL from private VRE Portlet URL URI toURL = new URI(privatePortletURL); - String publicURL = privatePortletURL.startsWith("https://")?"https://"+toURL.getHost():"http://"+toURL.getHost(); - //It returns the string "catalogue" + String publicURL = privatePortletURL.startsWith("https://") ? "https://" + toURL.getHost() + : "http://" + toURL.getHost(); + // It returns the string "catalogue" CatalogueStaticConfigurations staticConf = new CatalogueStaticConfigurations(); - //Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g catalogue-bb) - String relativeURLWithCatalogueName = staticConf.buildRelativeURLToPublicCatalogueGateway(vreDetached.getCatalogUrl()); + // Replacing for example "ckan-bb" with "[PREFIXES-TO-CATALOGUE-URL]-bb" (e.g + // catalogue-bb) + String relativeURLWithCatalogueName = staticConf + .buildRelativeURLToPublicCatalogueGateway(vreDetached.getCatalogUrl()); String toGatewayPortletURL = String.format("%s/%s", publicURL, relativeURLWithCatalogueName); - mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY,toGatewayPortletURL); - - ckanCatalogueReference = new GatewayCKANCatalogueReference(fullScope, vreDetached.getCatalogUrl(), mapAccessURLToCatalogue); + mapAccessURLToCatalogue.put(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY, toGatewayPortletURL); + + ckanCatalogueReference = new GatewayCKANCatalogueReference(fullScope, vreDetached.getCatalogUrl(), + mapAccessURLToCatalogue); break; case ACTIVE: default: - - ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); + + ckanCatalogueReference = CkanCatalogueConfigurationsReader.loadCatalogueEndPoints(); break; } - - logger.info("For scope "+fullScope+" loaded end points: "+ckanCatalogueReference); + logger.info("For scope " + fullScope + " loaded end points: " + ckanCatalogueReference); - //IS THE PRODUCT PLUBLIC OR PRIVATE? + // IS THE PRODUCT PLUBLIC OR PRIVATE? String datasetName = entityName; boolean isPublicItem = false; - if(ckanCatalogueReference.getCkanURL()!=null){ - try{ - CkanDataset dataset = CkanCatalogueConfigurationsReader.getDataset(datasetName, ckanCatalogueReference.getCkanURL()); - if(dataset!=null){ + if (ckanCatalogueReference.getCkanURL() != null) { + try { + CkanDataset dataset = CkanCatalogueConfigurationsReader.getDataset(datasetName, + ckanCatalogueReference.getCkanURL()); + if (dataset != null) { isPublicItem = true; - //ckanPorltetUrl = ckanCatalogueReference.getPublicPortletURL(); - logger.info("The dataset "+datasetName+" is a public item"); + // ckanPorltetUrl = ckanCatalogueReference.getPublicPortletURL(); + logger.info("The dataset " + datasetName + " is a public item"); } - }catch(Exception e){ - logger.warn("Error on checking if dataset: "+datasetName+" is private or not", e); + } catch (Exception e) { + logger.warn("Error on checking if dataset: " + datasetName + " is private or not", e); isPublicItem = true; } } String publicGatewayPorltetURL = String.format("%s?path=/%s/%s", ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_GATEWAY), - entityContextValue, - entityName); - + entityContextValue, entityName); + String privateVREPortletURL = String.format("%s?path=/%s/%s", ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PRIVATE_VRE), - entityContextValue, - entityName); - - //Checking if the public VRE portlet URL is available (so it was read from GR) + entityContextValue, entityName); + + // Checking if the public VRE portlet URL is available (so it was read from GR) String publicVREPortletURL = null; - String toCheckPublicVREPortletURL = ckanCatalogueReference.getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE); - if(toCheckPublicVREPortletURL!=null && !toCheckPublicVREPortletURL.isEmpty()) { - //here the catalogue is available/deployed as public at VRE level - publicVREPortletURL = String.format("%s?path=/%s/%s", - toCheckPublicVREPortletURL, - entityContextValue, + String toCheckPublicVREPortletURL = ckanCatalogueReference + .getCatalogueURL(ACCESS_LEVEL_TO_CATALOGUE_PORTLET.PUBLIC_VRE); + if (toCheckPublicVREPortletURL != null && !toCheckPublicVREPortletURL.isEmpty()) { + // here the catalogue is available/deployed as public at VRE level + publicVREPortletURL = String.format("%s?path=/%s/%s", toCheckPublicVREPortletURL, entityContextValue, entityName); } - return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, publicGatewayPorltetURL); - }catch (Exception e) { + return new ItemCatalogueURLs(entityName, isPublicItem, privateVREPortletURL, publicVREPortletURL, + publicGatewayPorltetURL); + } catch (Exception e) { logger.error("Error when resolving CatalogueURL:", e); throw e; } } - } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java index 79f0d6e..b79e667 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java @@ -32,13 +32,11 @@ import org.slf4j.LoggerFactory; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; - - /** * The Class GisResolver. * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Dec 14, 2018 + * Dec 14, 2018 */ @Path("gis") public class GisResolver { @@ -53,62 +51,60 @@ public class GisResolver { public static final String SCOPE = "scope"; public static final String GEO_EXPLORER_LAYER_UUID = "geo-exp"; - /** * Submit get. * - * @param req the req - * @param scope the scope - * @param gisUUID the gis uuid + * @param req the req + * @param scope the scope + * @param gisUUID the gis uuid * @param geoExplorerUUID the geo explorer uuid * @return the response * @throws WebApplicationException the web application exception */ @GET @Path("") - public Response submitGet(@Context HttpServletRequest req, @ - QueryParam(SCOPE) String scope, - @QueryParam(GIS_UUID) String gisUUID, - @QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID) throws WebApplicationException{ + public Response submitGet(@Context HttpServletRequest req, @QueryParam(SCOPE) String scope, + @QueryParam(GIS_UUID) String gisUUID, @QueryParam(GEO_EXPLORER_LAYER_UUID) String geoExplorerUUID) + throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); - try{ + try { boolean isGisLink = false; boolean isGeoExplorerLink = false; - if(scope==null || scope.isEmpty()){ + if (scope == null || scope.isEmpty()) { logger.error("Query Parameter 'scope' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", this.getClass(), help); + throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'scope'", + this.getClass(), help); } - if(gisUUID==null || gisUUID.isEmpty()){ + if (gisUUID == null || gisUUID.isEmpty()) { logger.error("Path Parameter 'gis-UUID' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", this.getClass(), help); - }else + throw ExceptionManager.badRequestException(req, "Missing mandatory query parameter 'gis-UUID'", + this.getClass(), help); + } else isGisLink = true; - logger.info(SCOPE +" is: " + scope); - logger.info(GIS_UUID +" is: " + gisUUID); + logger.info(SCOPE + " is: " + scope); + logger.info(GIS_UUID + " is: " + gisUUID); if (geoExplorerUUID == null || geoExplorerUUID.isEmpty()) { - logger.debug(GEO_EXPLORER_LAYER_UUID+ " not found"); - }else + logger.debug(GEO_EXPLORER_LAYER_UUID + " not found"); + } else isGeoExplorerLink = true; - logger.info(GEO_EXPLORER_LAYER_UUID +" is: " + geoExplorerUUID); + logger.info(GEO_EXPLORER_LAYER_UUID + " is: " + geoExplorerUUID); - if(!isGisLink && !isGeoExplorerLink){ - String err = GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string"; + if (!isGisLink && !isGeoExplorerLink) { + String err = GIS_UUID + " or " + GEO_EXPLORER_LAYER_UUID + " not found or empty in the query string"; logger.error(err); throw ExceptionManager.badRequestException(req, err, this.getClass(), help); } - - - if(isGisLink){ + if (isGisLink) { ScopeProvider.instance.set(scope); - //ServerParameters geonetworkParams = getCachedServerParameters(scope); + // ServerParameters geonetworkParams = getCachedServerParameters(scope); GisLayerItem gisLayerItem = getGisLayerForLayerUUID(req, scope, gisUUID); logger.info("wms url is: " + gisLayerItem.getFullWmsUrlRequest()); @@ -116,112 +112,132 @@ public class GisResolver { logger.info("encoded WMS url is: " + wmsRequest); String layerTitle = null; - if(gisLayerItem.getCitationTitle()!=null && !gisLayerItem.getCitationTitle().isEmpty()) - layerTitle = URLEncoder.encode(gisLayerItem.getCitationTitle(), UTF_8); + if (gisLayerItem.getCitationTitle() != null && !gisLayerItem.getCitationTitle().isEmpty()) + layerTitle = URLEncoder.encode(gisLayerItem.getCitationTitle(), UTF_8); logger.info("layer Title encoded is: " + layerTitle); String gisViewerPortletUrl = null; - try{ + try { gisViewerPortletUrl = LoadingGisViewerApplicationURLCache.get(scope); - }catch(ExecutionException | InvalidCacheLoadException e){ - logger.error("Error on getting the GisViewer Applicaton URL from cache for scope "+scope, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting the GisViewer Applicaton URL from cache for scope "+scope+".\nIs the Application Profile with APPID "+UriResolverSmartGearManagerInit.getGisViewerProfile().getAppId()+" registered for this scope: "+scope+"?", this.getClass(), help); + } catch (ExecutionException | InvalidCacheLoadException e) { + logger.error("Error on getting the GisViewer Applicaton URL from cache for scope " + scope, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting the GisViewer Applicaton URL from cache for scope " + scope + + ".\nIs the Application Profile with APPID " + + UriResolverSmartGearManagerInit.getGisViewerProfile().getAppId() + + " registered for this scope: " + scope + "?", + this.getClass(), help); } - //CHECKING IF THE GisViewer Portlet URL is valid - if(gisViewerPortletUrl==null || gisViewerPortletUrl.isEmpty()) - throw ExceptionManager.notFoundException(req, "GisViewer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help); + // CHECKING IF THE GisViewer Portlet URL is valid + if (gisViewerPortletUrl == null || gisViewerPortletUrl.isEmpty()) + throw ExceptionManager.notFoundException(req, + "GisViewer Portlet URL not found in the scope: " + scope + ". Please contact the support", + this.getClass(), help); logger.info("Gis Viewer Application url is: " + gisViewerPortletUrl); - gisViewerPortletUrl+="?rid="+new Random().nextLong() - +"&wmsrequest="+wmsRequest - +"&uuid="+URLEncoder.encode(gisUUID, UTF_8); + gisViewerPortletUrl += "?rid=" + new Random().nextLong() + "&wmsrequest=" + wmsRequest + "&uuid=" + + URLEncoder.encode(gisUUID, UTF_8); - if(layerTitle!=null) - gisViewerPortletUrl+="&layertitle="+layerTitle; + if (layerTitle != null) + gisViewerPortletUrl += "&layertitle=" + layerTitle; - logger.info("Redirecting to: "+gisViewerPortletUrl); + logger.info("Redirecting to: " + gisViewerPortletUrl); return Response.seeOther(new URI(gisViewerPortletUrl)).build(); } - if(isGeoExplorerLink){ + if (isGeoExplorerLink) { ScopeProvider.instance.set(scope); String geoExplorerPortletUrl = null; - try{ + try { geoExplorerPortletUrl = LoadingGeoExplorerApplicationURLCache.get(scope); - }catch(ExecutionException e){ - logger.error("Error on getting the GeoExplorer Applicaton URL from cache for scope "+scope, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting the GeoExplorer Applicaton URL from cache for scope "+scope+".\nIs the Application Profile with APPID "+UriResolverSmartGearManagerInit.getGeoExplorerProfile().getAppId()+" registered for this scope: "+scope+"?", this.getClass(), help); + } catch (ExecutionException e) { + logger.error("Error on getting the GeoExplorer Applicaton URL from cache for scope " + scope, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting the GeoExplorer Applicaton URL from cache for scope " + scope + + ".\nIs the Application Profile with APPID " + + UriResolverSmartGearManagerInit.getGeoExplorerProfile().getAppId() + + " registered for this scope: " + scope + "?", + this.getClass(), help); } - //CHECKING IF THE GeoExplorer Portlet URL is valid - if(geoExplorerPortletUrl==null || geoExplorerPortletUrl.isEmpty()) - throw ExceptionManager.notFoundException(req, "GeoExplorer Portlet URL not found in the scope: "+scope +". Please contact the support", this.getClass(), help); + // CHECKING IF THE GeoExplorer Portlet URL is valid + if (geoExplorerPortletUrl == null || geoExplorerPortletUrl.isEmpty()) + throw ExceptionManager.notFoundException(req, + "GeoExplorer Portlet URL not found in the scope: " + scope + ". Please contact the support", + this.getClass(), help); logger.info("GeoExplorer Application url is: " + geoExplorerPortletUrl); - geoExplorerPortletUrl+="?rid="+new Random().nextLong() - +"&luuid="+URLEncoder.encode(geoExplorerUUID, UTF_8); - //urlRedirect(req, resp, geoExplorerPortletUrl); + geoExplorerPortletUrl += "?rid=" + new Random().nextLong() + "&luuid=" + + URLEncoder.encode(geoExplorerUUID, UTF_8); + // urlRedirect(req, resp, geoExplorerPortletUrl); return Response.seeOther(new URI(geoExplorerPortletUrl)).build(); } - throw ExceptionManager.badRequestException(req, GIS_UUID+" or "+GEO_EXPLORER_LAYER_UUID+" not found or empty in the query string", this.getClass(), help); + throw ExceptionManager.badRequestException(req, + GIS_UUID + " or " + GEO_EXPLORER_LAYER_UUID + " not found or empty in the query string", + this.getClass(), help); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Sorry, an error occurred on resolving request with UUID "+gisUUID+" and scope "+scope+". Please, contact support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Sorry, an error occurred on resolving request with UUID " + gisUUID + " and scope " + + scope + ". Please, contact support!"; + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), help); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** * Gets the gis layer for layer uuid. * - * @param req the req - * @param scope the scope + * @param req the req + * @param scope the scope * @param gisUUID the gis uuid * @return the gis layer for layer uuid * @throws Exception the exception */ - public GisLayerItem getGisLayerForLayerUUID(HttpServletRequest req, String scope, String gisUUID) throws Exception{ + public GisLayerItem getGisLayerForLayerUUID(HttpServletRequest req, String scope, String gisUUID) throws Exception { try { GeonetworkInstance gi = null; try { gi = LoadingGeonetworkInstanceCache.get(scope); - - }catch(ExecutionException | InvalidCacheLoadException e){ - logger.error("Error on getting the Geonetwork Instance from cache for scope "+scope, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting the Geonetwork Instance from cache for scope "+scope+". Is it registered for this scope: "+scope+"?", this.getClass(), help); + + } catch (ExecutionException | InvalidCacheLoadException e) { + logger.error("Error on getting the Geonetwork Instance from cache for scope " + scope, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting the Geonetwork Instance from cache for scope " + scope + + ". Is it registered for this scope: " + scope + "?", + this.getClass(), help); } - if(gi==null) - throw new Exception("GeonetworkInstance not instanciable in the scope: "+scope); - + if (gi == null) + throw new Exception("GeonetworkInstance not instanciable in the scope: " + scope); + LoginLevel toLoginLevel = LoginLevel.SCOPE; - logger.info("Performing authentication on GN with "+LoginLevel.class.getSimpleName()+" "+toLoginLevel); + logger.info( + "Performing authentication on GN with " + LoginLevel.class.getSimpleName() + " " + toLoginLevel); gi.getGeonetworkPublisher().login(toLoginLevel); GisLayerItem gisLayerItem = MetadataConverter.getWMSOnLineResource(gi, gisUUID); return gisLayerItem; - //TODO CREATE A BEAN ADDING WMS REQUEST AND LAYER TITLE MetadataConverter. - }catch (GeonetworkInstanceException e){ - logger.error("An error occurred when instancing geonetowrk gis layer with UUID "+gisUUID, e); - throw new IllegalArgumentException("Sorry, An error occurred when instancing geonetwork with UUID: "+gisUUID); + // TODO CREATE A BEAN ADDING WMS REQUEST AND LAYER TITLE MetadataConverter. + } catch (GeonetworkInstanceException e) { + logger.error("An error occurred when instancing geonetowrk gis layer with UUID " + gisUUID, e); + throw new IllegalArgumentException( + "Sorry, An error occurred when instancing geonetwork with UUID: " + gisUUID); } catch (Exception e) { - logger.error("An error occurred when retrieving gis layer with UUID "+gisUUID, e); - throw new IllegalArgumentException("Sorry, An error occurred when retrieving gis layer with UUID "+gisUUID); + logger.error("An error occurred when retrieving gis layer with UUID " + gisUUID, e); + throw new IllegalArgumentException( + "Sorry, An error occurred when retrieving gis layer with UUID " + gisUUID); } } - } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java index ebd0816..9e16458 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java @@ -23,11 +23,12 @@ import org.gcube.datatransfer.resolver.util.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** + * The Class KnimeCreateResolver. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Dec 13, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("knime") public class KnimeCreateResolver { @@ -36,7 +37,6 @@ public class KnimeCreateResolver { private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver"; - /** * Creates the knime URL. * @@ -48,51 +48,55 @@ public class KnimeCreateResolver { @Path("/create") @Consumes(MediaType.TEXT_PLAIN) @Produces(MediaType.TEXT_PLAIN) - public Response createKnimeURL(@Context HttpServletRequest req) throws WebApplicationException{ + public Response createKnimeURL(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" POST starts..."); + logger.info(this.getClass().getSimpleName() + " POST starts..."); - try{ + try { String contextToken = SecurityTokenProvider.instance.get(); String scope = ScopeProvider.instance.get(); - // logger.info("SecurityTokenProvider contextToken: "+contextToken); - logger.info("ScopeProvider has scope: "+scope); + // logger.info("SecurityTokenProvider contextToken: "+contextToken); + logger.info("ScopeProvider has scope: " + scope); String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN); - if(contextToken.compareTo(appToken)==0){ - logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"..."); - throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); + if (contextToken.compareTo(appToken) == 0) { + logger.error("Token not passed, SecurityTokenProvider contains the root app token: " + + appToken.substring(0, 10) + "..."); + throw ExceptionManager.unauthorizedException(req, + "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); } ScopeBean scopeBean = new ScopeBean(scope); - if(scopeBean.is(Type.VRE)){ + if (scopeBean.is(Type.VRE)) { String vreName = scopeBean.name(); - String knimeGetResolverURL = String.format("%s/%s/%s", Util.getServerURL(req), "knime/get", vreName); - String queryString =req.getQueryString()==null?"":req.getQueryString(); + String knimeGetResolverURL = String.format("%s/%s/%s", Util.getServerURL(req), "knime/get", vreName); + String queryString = req.getQueryString() == null ? "" : req.getQueryString(); - if(req.getQueryString()!=null) - knimeGetResolverURL+="?"+queryString; + if (req.getQueryString() != null) + knimeGetResolverURL += "?" + queryString; - logger.info("Returning Knime Resolver URL: "+knimeGetResolverURL); + logger.info("Returning Knime Resolver URL: " + knimeGetResolverURL); return Response.ok(knimeGetResolverURL).header("Location", knimeGetResolverURL).build(); - }else{ - logger.error("The input scope "+scope+" is not a VRE"); - throw ExceptionManager.badRequestException(req, "Working in the "+scope+" scope that is not a VRE. Use a token of VRE", this.getClass(), helpURI); + } else { + logger.error("The input scope " + scope + " is not a VRE"); + throw ExceptionManager.badRequestException(req, + "Working in the " + scope + " scope that is not a VRE. Use a token of VRE", this.getClass(), + helpURI); } - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Sorry, an error occurred on creating Knime URL. Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java index 1c8c073..4745627 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java @@ -19,11 +19,12 @@ import org.gcube.datatransfer.resolver.util.ValidateContentDisposition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** + * The Class SMPIDResolver. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Oct 22, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("id") public class SMPIDResolver { @@ -37,54 +38,54 @@ public class SMPIDResolver { private static Logger logger = LoggerFactory.getLogger(SMPIDResolver.class); - /** * Gets the smpid. * - * @param req the req - * @param smpId the smp id - * @param fileName the file name - * @param contentType the content type - * @param validation the validation + * @param req the req + * @param smpId the smp id + * @param fileName the file name + * @param contentType the content type + * @param contentDisposition the content disposition + * @param validation the validation * @return the smpid * @throws WebApplicationException the web application exception */ @GET @Path("") - public Response getSMPID(@Context HttpServletRequest req, - @QueryParam(SMP_ID) @Nullable String smpId, - @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, - @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, - @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition, - @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) boolean validation) throws WebApplicationException{ - - logger.info(this.getClass().getSimpleName()+" GET starts..."); + public Response getSMPID(@Context HttpServletRequest req, @QueryParam(SMP_ID) @Nullable String smpId, + @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, + @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, + @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition, + @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) boolean validation) throws WebApplicationException { - try{ - //Checking mandatory parameter smpId - if(smpId==null || smpId.isEmpty()){ - logger.error(SMP_ID+" not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory parameter "+SMP_ID, SMPIDResolver.class, helpURI); + logger.info(this.getClass().getSimpleName() + " GET starts..."); + + try { + // Checking mandatory parameter smpId + if (smpId == null || smpId.isEmpty()) { + logger.error(SMP_ID + " not found"); + throw ExceptionManager.badRequestException(req, "Missing mandatory parameter " + SMP_ID, + SMPIDResolver.class, helpURI); } - - - //Checking the optional parameter "Content-Disposition" + + // Checking the optional parameter "Content-Disposition" CONTENT_DISPOSITION_VALUE dispositionValue = CONTENT_DISPOSITION_VALUE.attachment; - //Validating the Content-Disposition value + // Validating the Content-Disposition value dispositionValue = ValidateContentDisposition.validValue(req, this.getClass(), helpURI, contentDisposition); return StorageIDResolver.resolveStorageId(req, smpId, fileName, contentType, dispositionValue, validation); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on resolving the "+SMP_ID+": "+smpId+". Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on resolving the " + SMP_ID + ": " + smpId + + ". Please, contact the support!"; + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java index 8cb7c99..154aa57 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java @@ -19,12 +19,12 @@ import org.gcube.datatransfer.resolver.util.ValidateContentDisposition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class SMPResolver. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Dec 14, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("smp") public class SMPResolver { @@ -41,48 +41,48 @@ public class SMPResolver { /** * Gets the smpuri. * - * @param req the req - * @param smpURI the smp uri - * @param fileName the file name - * @param contentType the content type - * @param validation the validation + * @param req the req + * @param smpURI the smp uri + * @param fileName the file name + * @param contentType the content type + * @param contentDisposition the content disposition + * @param validation the validation * @return the smpuri * @throws WebApplicationException the web application exception */ @GET @Path("") - public Response getSMPURI(@Context HttpServletRequest req, - @QueryParam(SMP_URI) @Nullable - String smpURI, - @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, - @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, - @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition, - @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) boolean validation) throws WebApplicationException{ + public Response getSMPURI(@Context HttpServletRequest req, @QueryParam(SMP_URI) @Nullable String smpURI, + @QueryParam(ConstantsResolver.QUERY_PARAM_FILE_NAME) String fileName, + @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENT_TYPE) String contentType, + @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition, + @QueryParam(ConstantsResolver.QUERY_PARAM_VALIDATION) boolean validation) throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); - try{ - //Checking mandatory parameter smpURI - if(smpURI==null || smpURI.isEmpty()){ - logger.error(SMP_URI+" not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory parameter "+SMP_URI, SMPResolver.class, helpURI); + try { + // Checking mandatory parameter smpURI + if (smpURI == null || smpURI.isEmpty()) { + logger.error(SMP_URI + " not found"); + throw ExceptionManager.badRequestException(req, "Missing mandatory parameter " + SMP_URI, + SMPResolver.class, helpURI); } - - //Checking the optional parameter "Content-Disposition" + + // Checking the optional parameter "Content-Disposition" CONTENT_DISPOSITION_VALUE dispositionValue = CONTENT_DISPOSITION_VALUE.attachment; - //Validating the Content-Disposition value + // Validating the Content-Disposition value dispositionValue = ValidateContentDisposition.validValue(req, this.getClass(), helpURI, contentDisposition); return StorageIDResolver.resolveStorageId(req, smpURI, fileName, contentType, dispositionValue, validation); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on resolving the smpURI "+smpURI+". Please, contact the support!"; + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on resolving the smpURI " + smpURI + ". Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index bdb8832..47bc60f 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -27,7 +27,6 @@ import org.gcube.contentmanager.storageclient.wrapper.StorageClient; import org.gcube.datatransfer.resolver.ConstantsResolver; import org.gcube.datatransfer.resolver.ConstantsResolver.CONTENT_DISPOSITION_VALUE; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; -import org.gcube.datatransfer.resolver.storage.StorageClientInstance; import org.gcube.datatransfer.resolver.storage.StorageMetadataFile; import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput; import org.gcube.datatransfer.resolver.util.ValidateContentDisposition; diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index f5aa5a6..5a4819e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -20,14 +20,24 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * The Class UriResolverDocs. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 22, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("docs") public class UriResolverDocs { private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class); + /** + * To doc. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ @GET @Produces({ MediaType.TEXT_HTML }) @Path("/{any: .*}") @@ -58,6 +68,13 @@ public class UriResolverDocs { } } + /** + * Index. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ @GET @Produces({ MediaType.TEXT_HTML }) @Path("") diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverIndex.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverIndex.java index fd86ca3..286bf1a 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverIndex.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverIndex.java @@ -20,37 +20,45 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** + * The Class UriResolverIndex. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Oct 22, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("index") public class UriResolverIndex { private static Logger logger = LoggerFactory.getLogger(UriResolverIndex.class); + /** + * Index. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ @GET - @Produces({MediaType.TEXT_HTML}) + @Produces({ MediaType.TEXT_HTML }) @Path("") - public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{ + public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { String indexFile = "/WEB-INF/jsp/index.jsp"; - try{ - logger.info(UriResolverIndex.class.getSimpleName() +" called"); - String realPath = req.getServletContext().getRealPath(indexFile); - return new FileInputStream(new File(realPath)); - }catch (Exception e) { + try { + logger.info(UriResolverIndex.class.getSimpleName() + " called"); + String realPath = req.getServletContext().getRealPath(indexFile); + return new FileInputStream(new File(realPath)); + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Index.jsp not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } } - diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java index 4ec9625..3ebd196 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java @@ -14,18 +14,26 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; /** + * The Class UriResolverInfo. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Oct 22, 2018 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("info") public class UriResolverInfo { + /** + * Info. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ @GET - @Produces({MediaType.TEXT_HTML}) + @Produces({ MediaType.TEXT_HTML }) @Path("") - public InputStream info(@Context HttpServletRequest req) throws WebApplicationException{ + public InputStream info(@Context HttpServletRequest req) throws WebApplicationException { return new UriResolverIndex().index(req); } } - diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java index cab6298..6fcd4e4 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java @@ -20,12 +20,12 @@ import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.node.ObjectNode; - /** - * The Class ResourceListingResource. + * The Class UriResolverResources. * - * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Feb 14, 2019 + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Mar 24, 2022 */ @Path("resources") @Singleton @@ -37,7 +37,7 @@ public class UriResolverResources { * Show all. * * @param application the application - * @param request the request + * @param request the request * @return the response */ @GET diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java index 09c57b8..8bbadc1 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java @@ -35,26 +35,23 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class WekeoResolver. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Mar 30, 2021 + * Mar 24, 2022 */ @Path("wekeo") public class WekeoResolver { private static Logger logger = LoggerFactory.getLogger(WekeoResolver.class); - + private final static String RUNTIME_WKEO_RESOURCE_NAME = "WekeoDataBroker"; private final static String CATEGORY_WEKEO_TYPE = "OnlineService"; private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#Wekeo_Resolver"; - - /** * Gets the token. * @@ -65,23 +62,25 @@ public class WekeoResolver { @GET @Path("/gettoken") @Produces(MediaType.APPLICATION_JSON) - public Response getToken(@Context HttpServletRequest req) throws WebApplicationException{ - - logger.info(this.getClass().getSimpleName()+" getToken starts..."); - + public Response getToken(@Context HttpServletRequest req) throws WebApplicationException { + + logger.info(this.getClass().getSimpleName() + " getToken starts..."); + try { - + String contextToken = SecurityTokenProvider.instance.get(); String scope = ScopeProvider.instance.get(); - logger.info("ScopeProvider has scope: "+scope); + logger.info("ScopeProvider has scope: " + scope); String appToken = req.getServletContext().getInitParameter(RequestHandler.ROOT_APP_TOKEN); - if(contextToken.compareTo(appToken)==0){ - logger.error("Token not passed, SecurityTokenProvider contains the root app token: "+appToken.substring(0,10)+"..."); - throw ExceptionManager.unauthorizedException(req, "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); + if (contextToken.compareTo(appToken) == 0) { + logger.error("Token not passed, SecurityTokenProvider contains the root app token: " + + appToken.substring(0, 10) + "..."); + throw ExceptionManager.unauthorizedException(req, + "You are not authorized. You must pass a token of VRE", this.getClass(), helpURI); } - + StringBuilder wekeoResponse = new StringBuilder(); AccessPoint wekeoAccessPoint = WekeoResolver.readWekeoServiceEndpoint(req, scope); @@ -98,12 +97,12 @@ public class WekeoResolver { logger.debug(msg); } - logger.info("The pwd is: "+wekeoPwd); + logger.info("The pwd is: " + wekeoPwd); // decrypting the pwd if (wekeoPwd != null) { wekeoPwd = StringEncrypter.getEncrypter().decrypt(wekeoPwd); logger.info("Decrypted pwd registered into Access Point '" + wekeoAccessPoint.name() + "' is: " - + wekeoPwd.substring(0,wekeoPwd.length()/2)+"..."); + + wekeoPwd.substring(0, wekeoPwd.length() / 2) + "..."); } if (wekeoUsername != null && wekeoPwd != null & wekeoAddress != null) { @@ -117,18 +116,18 @@ public class WekeoResolver { String authStringEnc = new String(authEncBytes); logger.debug("Base64 encoded auth string: " + authStringEnc); - logger.info("Performing the request to: "+wekeoAddress); + logger.info("Performing the request to: " + wekeoAddress); URL url = new URL(wekeoAddress); connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.setDoOutput(true); connection.setRequestProperty("Authorization", "Basic " + authStringEnc); - + content = (InputStream) connection.getInputStream(); in = new InputStreamReader(content); - - logger.info("the response code is: "+connection.getResponseCode()); - + + logger.info("the response code is: " + connection.getResponseCode()); + int numCharsRead; char[] charArray = new char[1024]; StringBuffer sb = new StringBuffer(); @@ -137,7 +136,7 @@ public class WekeoResolver { sb.append(charArray, 0, numCharsRead); } wekeoResponse.append(sb.toString()); - //System.out.println(wekeoResponse); + // System.out.println(wekeoResponse); } catch (Exception e) { logger.error(e.getMessage(), e); @@ -145,12 +144,12 @@ public class WekeoResolver { throw new Exception(error); } finally { try { - if (content!= null && in != null) { + if (content != null && in != null) { in.close(); content.close(); } - }catch (Exception e) { - //silent + } catch (Exception e) { + // silent } } @@ -164,72 +163,83 @@ public class WekeoResolver { // to be sure if (wekeoResponse.length() == 0) { - String error = String - .format("Sorry an error occured on getting the access token from Wekeo. Please, retry the request"); + String error = String.format( + "Sorry an error occured on getting the access token from Wekeo. Please, retry the request"); throw new Exception(error); } - + String theResponse = wekeoResponse.toString(); - logger.info("returning: \n"+theResponse); - + logger.info("returning: \n" + theResponse); + return Response.ok(theResponse).build(); - }catch (Exception e) { - //ALREADY MANAGED AS WebApplicationException + } catch (Exception e) { + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - + + /** + * Index. + * + * @param req the req + * @return the input stream + * @throws WebApplicationException the web application exception + */ @GET - @Produces({MediaType.TEXT_HTML}) + @Produces({ MediaType.TEXT_HTML }) @Path("") - public InputStream index(@Context HttpServletRequest req) throws WebApplicationException{ + public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { String indexFile = "/WEB-INF/jsp/wekeo.jsp"; - try{ - logger.info(this.getClass().getSimpleName() +" index called"); - String realPath = req.getServletContext().getRealPath(indexFile); - return new FileInputStream(new File(realPath)); - }catch (Exception e) { + try { + logger.info(this.getClass().getSimpleName() + " index called"); + String realPath = req.getServletContext().getRealPath(indexFile); + return new FileInputStream(new File(realPath)); + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "wekeo.jsp not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - + /** - * Reads the wekeo endpoint information from IS. {The SE name is: @link WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME} + * Reads the wekeo endpoint information from IS. {The SE name is: @link + * WekeoResolver#RUNTIME_WKEO_RESOURCE_NAME} * - * @param req the req + * @param req the req * @param scope the scope * @return the string */ - public static AccessPoint readWekeoServiceEndpoint(HttpServletRequest req, String scope){ + public static AccessPoint readWekeoServiceEndpoint(HttpServletRequest req, String scope) { String callerScope = null; - try{ + try { callerScope = ScopeProvider.instance.get(); ScopeProvider.instance.set(scope); - logger.info("Searching SE "+RUNTIME_WKEO_RESOURCE_NAME+" configurations in the scope: "+ScopeProvider.instance.get()); + logger.info("Searching SE " + RUNTIME_WKEO_RESOURCE_NAME + " configurations in the scope: " + + ScopeProvider.instance.get()); SimpleQuery query = queryFor(ServiceEndpoint.class); - query.addCondition("$resource/Profile/Name/text() eq '"+ RUNTIME_WKEO_RESOURCE_NAME +"'"); - query.addCondition("$resource/Profile/Category/text() eq '"+ CATEGORY_WEKEO_TYPE +"'"); + query.addCondition("$resource/Profile/Name/text() eq '" + RUNTIME_WKEO_RESOURCE_NAME + "'"); + query.addCondition("$resource/Profile/Category/text() eq '" + CATEGORY_WEKEO_TYPE + "'"); DiscoveryClient client = clientFor(ServiceEndpoint.class); List toReturn = client.submit(query); - logger.info("The query returned "+toReturn.size()+ " ServiceEndpoint/s"); + logger.info("The query returned " + toReturn.size() + " ServiceEndpoint/s"); - if(toReturn.size()==0){ - String errorMessage = String.format("Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.",RUNTIME_WKEO_RESOURCE_NAME,CATEGORY_WEKEO_TYPE,ScopeProvider.instance.get()); + if (toReturn.size() == 0) { + String errorMessage = String.format( + "Missing the RR with Name '%s' and Category '%s' in the scope '%s'. Please contact the support.", + RUNTIME_WKEO_RESOURCE_NAME, CATEGORY_WEKEO_TYPE, ScopeProvider.instance.get()); logger.error(errorMessage); throw ExceptionManager.notFoundException(req, errorMessage, WekeoResolver.class, helpURI); @@ -237,34 +247,35 @@ public class WekeoResolver { String wekeoUsername = null; String wekeoPwd = null; - + ServiceEndpoint se = toReturn.get(0); Collection theAccessPoints = se.profile().accessPoints().asCollection(); for (AccessPoint accessPoint : theAccessPoints) { wekeoUsername = accessPoint.username(); wekeoPwd = accessPoint.password(); - if(wekeoUsername!=null && wekeoPwd!=null) { - logger.info("returning the access point with name: "+accessPoint.name()); + if (wekeoUsername != null && wekeoPwd != null) { + logger.info("returning the access point with name: " + accessPoint.name()); return accessPoint; } } - + return null; - }catch(Exception e){ - - if(e instanceof NotFoundException) + } catch (Exception e) { + + if (e instanceof NotFoundException) throw e; - - String errorMessage = "Error occurred on reading the "+RUNTIME_WKEO_RESOURCE_NAME+" SE registered in the scope: "+ScopeProvider.instance.get(); + + String errorMessage = "Error occurred on reading the " + RUNTIME_WKEO_RESOURCE_NAME + + " SE registered in the scope: " + ScopeProvider.instance.get(); logger.error(errorMessage, e); throw ExceptionManager.internalErrorException(req, errorMessage, WekeoResolver.class, helpURI); - }finally{ - if(callerScope!=null){ - logger.info("Setting to the callerScope scope: "+callerScope); + } finally { + if (callerScope != null) { + logger.info("Setting to the callerScope scope: " + callerScope); ScopeProvider.instance.set(callerScope); - }else{ + } else { logger.info("Reset scope"); ScopeProvider.instance.reset(); } -- 2.17.1 From f7aa94a7f015559fe547547bd39084d42f247dd7 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 17:55:50 +0100 Subject: [PATCH 19/58] trying to use enunciate 2.13.3 --- pom.xml | 2 +- .../gcube/datatransfer/resolver/catalogue/CatalogueRequest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 455565a..b03ab90 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ 1.7 1.8 - 2.14.0 + 2.13.3 diff --git a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java index 15cb1d6..1a025e5 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java +++ b/src/main/java/org/gcube/datatransfer/resolver/catalogue/CatalogueRequest.java @@ -7,7 +7,7 @@ package org.gcube.datatransfer.resolver.catalogue; * * Mar 24, 2022 * - * Binding Catalogue Request as a JSON + * Binding Catalogue Request as a JSON */ public class CatalogueRequest { -- 2.17.1 From 29ee91aed52b75a9037a2f5bd2efbe0d0ceaa62c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 24 Mar 2022 18:06:54 +0100 Subject: [PATCH 20/58] re-using enunciate 2.14.0 --- pom.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index b03ab90..b79179d 100644 --- a/pom.xml +++ b/pom.xml @@ -21,10 +21,9 @@ 2.24.1 - 1.7 + 1.8 1.8 - - 2.13.3 + 2.14.0 @@ -165,9 +164,9 @@ jandex 2.2.2.Final
- + - + javax.servlet javax.servlet-api -- 2.17.1 From c6a8de6a20856cfd900668a09a034fc3e038b282 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 25 Mar 2022 10:32:46 +0100 Subject: [PATCH 21/58] updated enunciate configs --- .classpath | 10 +++---- .settings/org.eclipse.jdt.core.prefs | 4 +-- .settings/org.eclipse.wst.common.component | 29 ++++++++++++------- ....eclipse.wst.common.project.facet.core.xml | 2 +- enunciate.xml | 14 ++++++++- pom.xml | 8 ++++- 6 files changed, 47 insertions(+), 20 deletions(-) diff --git a/.classpath b/.classpath index c3a4e8b..7368076 100644 --- a/.classpath +++ b/.classpath @@ -19,16 +19,16 @@ - - - - - + + + + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs index 43c8195..cac0df4 100644 --- a/.settings/org.eclipse.jdt.core.prefs +++ b/.settings/org.eclipse.jdt.core.prefs @@ -1,11 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled org.eclipse.jdt.core.compiler.problem.enumIdentifier=error org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore org.eclipse.jdt.core.compiler.release=disabled -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index e84f7be..99070a4 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -1,45 +1,54 @@ - + - - + + + + - + + - + + - + + - + + - + + - + + - + + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index e9d8776..87ff514 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,7 +2,7 @@ - + diff --git a/enunciate.xml b/enunciate.xml index add545d..2f87926 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -2,12 +2,24 @@ + + + + + + + - + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index b79179d..f570057 100644 --- a/pom.xml +++ b/pom.xml @@ -266,6 +266,12 @@ + + + + + + @@ -302,7 +308,7 @@ enunciate-maven-plugin ${enunciate.version} - ${project.build.directory}/docs + -- 2.17.1 From 425f06d7928ceddeb98588e52c5f7ecad3a6faa4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 25 Mar 2022 17:18:31 +0100 Subject: [PATCH 22/58] updated docs configs --- .classpath | 2 +- enunciate.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.classpath b/.classpath index 7368076..e7470b5 100644 --- a/.classpath +++ b/.classpath @@ -27,7 +27,7 @@ - + diff --git a/enunciate.xml b/enunciate.xml index 2f87926..36b9626 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -18,7 +18,7 @@ - + -- 2.17.1 From d13c54c3907dbb7bd74aeb808d992d6505268be3 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 11:37:15 +0200 Subject: [PATCH 23/58] added beans.xml to META-INF --- .classpath | 1 + src/main/resources/META-INF/beans.xml | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 src/main/resources/META-INF/beans.xml diff --git a/.classpath b/.classpath index e7470b5..6a52027 100644 --- a/.classpath +++ b/.classpath @@ -19,6 +19,7 @@ + diff --git a/src/main/resources/META-INF/beans.xml b/src/main/resources/META-INF/beans.xml new file mode 100644 index 0000000..77e45d1 --- /dev/null +++ b/src/main/resources/META-INF/beans.xml @@ -0,0 +1,6 @@ + + \ No newline at end of file -- 2.17.1 From 169ca49479fbc60578bfd10cafd9839e9a5ca9ac Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 11:40:53 +0200 Subject: [PATCH 24/58] added javax.interceptor-api --- pom.xml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index f570057..18e85d9 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,14 @@ compile
+ + + javax.interceptor + javax.interceptor-api + 1.2.2 + + + javax.enterprise @@ -266,11 +274,11 @@ - - - - - + + + + + @@ -308,7 +316,7 @@ enunciate-maven-plugin ${enunciate.version} - + -- 2.17.1 From 03196d957d1fe5861dfa1c99ca45923a62440303 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 11:52:02 +0200 Subject: [PATCH 25/58] added javamelody-core --- pom.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 18e85d9..e05d19a 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,13 @@ compile
+ + + net.bull.javamelody + javamelody-core + 1.82.0 + + javax.interceptor @@ -154,7 +161,6 @@ 1.2.2 - javax.enterprise -- 2.17.1 From 7a25614be03c18abbc89b4a680a554d246f9c20d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 13:24:58 +0200 Subject: [PATCH 26/58] updated toDoc method --- .../resolver/services/UriResolverDocs.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 5a4819e..042ceef 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -6,7 +6,9 @@ package org.gcube.datatransfer.resolver.services; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; +import java.net.URI; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -14,6 +16,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.slf4j.Logger; @@ -39,9 +43,9 @@ public class UriResolverDocs { * @throws WebApplicationException the web application exception */ @GET - @Produces({ MediaType.TEXT_HTML }) + //@Produces({ MediaType.TEXT_HTML }) @Path("/{any: .*}") - public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { + public Response toDoc(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); String pathInfo = req.getPathInfo(); @@ -51,10 +55,15 @@ public class UriResolverDocs { if (pathInfo.equals("/docs/")) pathInfo += "index.html"; - logger.info("redirecting to {}", pathInfo); - - String realPath = req.getServletContext().getRealPath(pathInfo); - return new FileInputStream(new File(realPath)); + ServletContext context = req.getServletContext(); + //String realPath = context.getRealPath(pathInfo); + UriBuilder builder = UriBuilder.fromPath(context.getContextPath()); + pathInfo=pathInfo.startsWith("/")?pathInfo:"/"+pathInfo; + builder.path(pathInfo); + + URI redirectTo = builder.build(); + logger.info("redirecting to {}", redirectTo); + return Response.seeOther(redirectTo).build(); } catch (Exception e) { if (!(e instanceof WebApplicationException)) { -- 2.17.1 From 5fb758e1d9215efb531567763bf0a810631cb774 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 13:31:58 +0200 Subject: [PATCH 27/58] changed toDoc redirect --- .../datatransfer/resolver/services/UriResolverDocs.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 042ceef..a274692 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -56,10 +56,9 @@ public class UriResolverDocs { pathInfo += "index.html"; ServletContext context = req.getServletContext(); - //String realPath = context.getRealPath(pathInfo); - UriBuilder builder = UriBuilder.fromPath(context.getContextPath()); - pathInfo=pathInfo.startsWith("/")?pathInfo:"/"+pathInfo; - builder.path(pathInfo); + String realPath = context.getRealPath(pathInfo); + UriBuilder builder = UriBuilder.fromPath(realPath); +// builder.path(pathInfo); URI redirectTo = builder.build(); logger.info("redirecting to {}", redirectTo); -- 2.17.1 From b0dcc5f0a8e3f7efa9e37f876b906beb224d2cef Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 15:02:54 +0200 Subject: [PATCH 28/58] redirect rebuild --- .../resolver/services/UriResolverDocs.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index a274692..9cf1e1c 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -48,16 +48,35 @@ public class UriResolverDocs { public Response toDoc(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); - String pathInfo = req.getPathInfo(); - logger.info("pathInfo {}", pathInfo); + StringBuilder newURL = null; try { + String scheme = req.getScheme(); // http + String serverName = req.getServerName(); // hostname.com + int serverPort = req.getServerPort(); + String pathInfo = req.getPathInfo(); + String queryString = req.getQueryString(); + + // Reconstruct original requesting URL + newURL = new StringBuilder(); + newURL.append(scheme).append("://").append(serverName); + +// if (serverPort != 80 && serverPort != 443) { +// url.append(":").append(serverPort); +// } + + logger.info("pathInfo {}", pathInfo); if (pathInfo.equals("/docs/")) pathInfo += "index.html"; - - ServletContext context = req.getServletContext(); - String realPath = context.getRealPath(pathInfo); - UriBuilder builder = UriBuilder.fromPath(realPath); + + if (pathInfo != null) { + newURL.append(pathInfo); + } + if (queryString != null) { + newURL.append("?").append(queryString); + } + + UriBuilder builder = UriBuilder.fromPath(newURL.toString()); // builder.path(pathInfo); URI redirectTo = builder.build(); @@ -67,7 +86,7 @@ public class UriResolverDocs { if (!(e instanceof WebApplicationException)) { // UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = pathInfo + " not found. Please, contact the support!"; + String error = newURL + " not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } // ALREADY MANAGED AS WebApplicationException -- 2.17.1 From 827e69486ca98bd31306d07fe339218b40d73159 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 15:18:17 +0200 Subject: [PATCH 29/58] restored previous solution --- .../resolver/services/UriResolverDocs.java | 50 +++++-------------- 1 file changed, 12 insertions(+), 38 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 9cf1e1c..67d1788 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -6,9 +6,7 @@ package org.gcube.datatransfer.resolver.services; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; -import java.net.URI; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; @@ -16,8 +14,6 @@ import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.slf4j.Logger; @@ -28,7 +24,7 @@ import org.slf4j.LoggerFactory; * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Mar 24, 2022 + * Mar 24, 2022 */ @Path("docs") public class UriResolverDocs { @@ -43,50 +39,28 @@ public class UriResolverDocs { * @throws WebApplicationException the web application exception */ @GET - //@Produces({ MediaType.TEXT_HTML }) + @Produces({ MediaType.TEXT_HTML }) @Path("/{any: .*}") - public Response toDoc(@Context HttpServletRequest req) throws WebApplicationException { + public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); - StringBuilder newURL = null; + String pathInfo = req.getPathInfo(); + logger.info("pathInfo {}", pathInfo); try { - String scheme = req.getScheme(); // http - String serverName = req.getServerName(); // hostname.com - int serverPort = req.getServerPort(); - String pathInfo = req.getPathInfo(); - String queryString = req.getQueryString(); - - // Reconstruct original requesting URL - newURL = new StringBuilder(); - newURL.append(scheme).append("://").append(serverName); - -// if (serverPort != 80 && serverPort != 443) { -// url.append(":").append(serverPort); -// } - - logger.info("pathInfo {}", pathInfo); if (pathInfo.equals("/docs/")) pathInfo += "index.html"; - - if (pathInfo != null) { - newURL.append(pathInfo); - } - if (queryString != null) { - newURL.append("?").append(queryString); - } - - UriBuilder builder = UriBuilder.fromPath(newURL.toString()); -// builder.path(pathInfo); - - URI redirectTo = builder.build(); - logger.info("redirecting to {}", redirectTo); - return Response.seeOther(redirectTo).build(); + + logger.info("redirecting to {}", pathInfo); + + String realPath = req.getServletContext().getRealPath(pathInfo); + return new FileInputStream(new File(realPath)); + } catch (Exception e) { if (!(e instanceof WebApplicationException)) { // UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = newURL + " not found. Please, contact the support!"; + String error = pathInfo + " not found. Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); } // ALREADY MANAGED AS WebApplicationException -- 2.17.1 From 3df4a29dd3bf2c2092e207724233127f5c1c5835 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 15:59:50 +0200 Subject: [PATCH 30/58] removed @Produces --- .../gcube/datatransfer/resolver/services/UriResolverDocs.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 67d1788..67944c1 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -39,7 +39,6 @@ public class UriResolverDocs { * @throws WebApplicationException the web application exception */ @GET - @Produces({ MediaType.TEXT_HTML }) @Path("/{any: .*}") public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); @@ -77,7 +76,7 @@ public class UriResolverDocs { * @throws WebApplicationException the web application exception */ @GET - @Produces({ MediaType.TEXT_HTML }) +// @Produces({ MediaType.TEXT_HTML }) @Path("") public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { logger.info(UriResolverDocs.class.getSimpleName() + " index called"); -- 2.17.1 From 0fd375f43c8164b227dc709b0a8b9d0c16f25e91 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 16:20:27 +0200 Subject: [PATCH 31/58] excluding BackCatalogueResolver and BackUriResolverCatalogueResolver from enunciate --- enunciate.xml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/enunciate.xml b/enunciate.xml index 36b9626..f048813 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -10,15 +10,20 @@ pattern="org.gcube.datatransfer.resolver.services.UriResolverIndex" /> + + - + - + -- 2.17.1 From 2a081f73a910cc00831a5d26564d452e60fe90f9 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 17:19:02 +0200 Subject: [PATCH 32/58] removed unused imports --- pom.xml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index e05d19a..89cfbca 100644 --- a/pom.xml +++ b/pom.xml @@ -98,13 +98,6 @@ [1.0.0,2.0.0-SNAPSHOT) - - - - - - - com.google.guava guava @@ -277,15 +270,9 @@ org.geotoolkit geotk-xml-base 3.20-geoapi-3.0 + provided - - - - - - - -- 2.17.1 From e4b38f74366b2a3bd9339bd3bcb3d1d412b38f9c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 18:04:57 +0200 Subject: [PATCH 33/58] commented java melody dependencies --- pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 89cfbca..bcb0154 100644 --- a/pom.xml +++ b/pom.xml @@ -141,18 +141,18 @@
- - net.bull.javamelody - javamelody-core - 1.82.0 - + + + + + - - javax.interceptor - javax.interceptor-api - 1.2.2 - + + + + + -- 2.17.1 From c33e879e543f9223e101c046cba7dd7994484df2 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Mon, 28 Mar 2022 18:16:30 +0200 Subject: [PATCH 34/58] added javamelody-core and javax.interceptor-api dependencies --- pom.xml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index bcb0154..89cfbca 100644 --- a/pom.xml +++ b/pom.xml @@ -141,18 +141,18 @@ - - - - - + + net.bull.javamelody + javamelody-core + 1.82.0 + - - - - - + + javax.interceptor + javax.interceptor-api + 1.2.2 + -- 2.17.1 From f0ad08703ea2c6ec17c1d7aec7af4dc3b4fe6c54 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 29 Mar 2022 11:03:29 +0200 Subject: [PATCH 35/58] updated readme --- CHANGELOG.md | 5 +++-- pom.xml | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d9cf47..2552d92 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,11 +4,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [v2-7.1-SNAPSHOT] - 2022-03-24 +## [v2-7.1-SNAPSHOT] - 2022-03-29 **New** -- Integrate Enunicate https://github.com/stoicflame/enunciate/ +- [#23049] Integrate Enunicate engine for Java Web service API (https://github.com/stoicflame/enunciate/) +- [#20743] Integrate JavaMelody ## [v2-7.0-SNAPSHOT] - 2022-01-31 diff --git a/pom.xml b/pom.xml index 89cfbca..e276720 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,6 @@ org.jboss.weld.servlet weld-servlet-core 3.1.0.Final - org.jboss -- 2.17.1 From c1a0913708b6b67acc3bf3fb855db6023750f3af Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 29 Mar 2022 11:03:48 +0200 Subject: [PATCH 36/58] updated README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 0f58964..b04d858 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ The URI Resolver is a RESTful service which gives access via HTTP(s) to differen You can find the URI Resolver documentation at [URI Resolver Wiki Page](https://wiki.gcube-system.org/gcube/URI_Resolver) +The API documentation accessible by [links](see at https://wiki.gcube-system.org/gcube/URI_Resolver#Instances) is provided by [Enunciate](https://github.com/stoicflame/enunciate/) + ## Change log See the [URI Resolver Releases](https://code-repo.d4science.org/gCubeSystem/uri-resolver/releases) -- 2.17.1 From dee5beeadf7773ff6288d7e7b922572eaf59ad7a Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Tue, 29 Mar 2022 11:10:31 +0200 Subject: [PATCH 37/58] fixed README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b04d858..fa871ef 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The URI Resolver is a RESTful service which gives access via HTTP(s) to differen You can find the URI Resolver documentation at [URI Resolver Wiki Page](https://wiki.gcube-system.org/gcube/URI_Resolver) -The API documentation accessible by [links](see at https://wiki.gcube-system.org/gcube/URI_Resolver#Instances) is provided by [Enunciate](https://github.com/stoicflame/enunciate/) +The API documentation accessible by [links](https://wiki.gcube-system.org/gcube/URI_Resolver#Instances) is provided by [Enunciate](https://github.com/stoicflame/enunciate/) ## Change log -- 2.17.1 From b8992a0124db957f8ffff19f0edb5da31489505b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 10:52:52 +0200 Subject: [PATCH 38/58] Updated documentation --- .classpath | 6 +- .../services/AnalyticsCreateResolver.java | 17 +- .../services/AnalyticsGetResolver.java | 11 +- .../resolver/services/CatalogueResolver.java | 16 +- .../resolver/services/GeonetworkResolver.java | 548 ++++++++++-------- .../resolver/services/GisResolver.java | 11 +- .../services/KnimeCreateResolver.java | 16 +- .../resolver/services/KnimeGetResolver.java | 66 ++- .../services/PartheosRegistryResolver.java | 134 +++-- .../resolver/services/SMPIDResolver.java | 10 +- .../resolver/services/SMPResolver.java | 8 +- .../resolver/services/StorageHubResolver.java | 96 +-- .../resolver/services/StorageIDResolver.java | 10 +- .../resolver/services/UriResolverDocs.java | 4 +- .../resolver/services/UriResolverInfo.java | 2 +- .../resolver/services/WekeoResolver.java | 9 +- 16 files changed, 568 insertions(+), 396 deletions(-) diff --git a/.classpath b/.classpath index 6a52027..06c0510 100644 --- a/.classpath +++ b/.classpath @@ -19,7 +19,11 @@ - + + + + + diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java index 94cdaa5..b8cd4ec 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java @@ -57,8 +57,14 @@ import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; /** - * The Class AnalyticsCreateResolver. - * + * The AnalyticsCreateResolver provides a method to get the Analytics URLs (that + * are simply URLs) by which is possible to invoke through the DataMiner + * Executor the run of an algorithm stored in a certain VRE. By the DataMiner + * Executor then the user is able to monitoring the algorithm execution. + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * Dec 12, 2018 */ @@ -79,7 +85,12 @@ public class AnalyticsCreateResolver { /** * Creates the analytics url. - * + * + * Request format: [URI_RESOLVER_SERVICE_ENDPOINT]/analytics/create + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#HTTP_POST:_Create_an_Analytics_URL + * * @param req the req * @param body the body * @return the response diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java index d945a19..108a7c6 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java @@ -24,7 +24,13 @@ import org.slf4j.LoggerFactory; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; /** - * The Class AnalyticsGetResolver. + * The AnalyticsGetResolver to resolve an Analytics URL + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/analytics/get/[VRE_NAME]?dim=[PUBLIC_URL_TO_DATAMIER_INVOCATION_FILE_GENERATED_BY_POST_REQUEST] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * @@ -46,6 +52,9 @@ public class AnalyticsGetResolver { /** * Resolve analytics url. * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#HTTP_GET:_Resolve_an_Analytics_URL + * * @param req the req * @param vreName the vre name * @return the response diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index d1f2362..491d8c1 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -44,8 +44,14 @@ import com.google.common.cache.CacheLoader.InvalidCacheLoadException; import eu.trentorise.opendata.jackan.model.CkanDataset; /** - * The Class CatalogueResolver. + * The CatalogueResolver is able to get/resolve a link to a "Catalogue Entity" + * stored in one of the gCube Data Catalogue's instances. A Catalogue Entity is + * either a "group" or an "organization" or a "product" of D4Science Data + * Catalogue. * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * Nov 16, 2018 */ @@ -67,7 +73,10 @@ public class CatalogueResolver { } /** - * Resolve catalogue. + * Resolve an entity of the Catalogue + * + * Request format: + * [URI_RESOLVER_SERVICE_ENDPOINT]/[ctlg|ctlg-d|ctlg-o|ctlg-g]/[VRE_NAME]/[entity_name] * * @param req the req * @param entityName the entity name @@ -126,7 +135,8 @@ public class CatalogueResolver { } /** - * Post catalogue. + * Create a Catalogue Link + * * * @param req the req * @param jsonRequest the json request diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java index 8303ef4..11fc477 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java @@ -48,10 +48,17 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; /** - * The Class GeonetworkResolver. + * The GeonetworkResolver is a "middle tier" (like a Proxy) to perform queries + * on D4Science Geonetwork services. + * + * Request format + * http[s]://[GEONETWORK_RESOLVER_BASE_URL]/[SCOPE]/[MODE]/[VISIBILITY]/[FILTER_KEY]/[FILTER_VALUE]/$$ + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Geonetwork_Resolver * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Oct 23, 2018 + * Oct 23, 2018 */ @Path("geonetwork") public class GeonetworkResolver { @@ -60,7 +67,8 @@ public class GeonetworkResolver { * */ public static final String REPLACED_A_PUBLIC_UUID_PLEASE_IGNORE = "Replaced a public UUID, please ignore"; - public static final String REPLACED_UUID_BY_FILTER_PLEASE_IGNORE = "Replaced UUID by "+GeonetworkResolver.class.getSimpleName()+" filters, please ignore"; + public static final String REPLACED_UUID_BY_FILTER_PLEASE_IGNORE = "Replaced UUID by " + + GeonetworkResolver.class.getSimpleName() + " filters, please ignore"; private static Logger logger = LoggerFactory.getLogger(GeonetworkResolver.class); @@ -78,180 +86,196 @@ public class GeonetworkResolver { public static final String QUERY_PARAM_RESET_CACHE_PARAM = "resetcache"; public static final String QUERY_PARAM_RESET_CACHED_SCOPE_PARAM = "resetcachedscope"; - public static final String SRV_EN_MEF_EXPORT = "/srv/en/mef.export"; //MEF Geonetwork service + public static final String SRV_EN_MEF_EXPORT = "/srv/en/mef.export"; // MEF Geonetwork service public static final String UUID = "uuid"; public static final String SCOPE_SEPARATOR = "|"; - //protected Map cacheGNInstances; + // protected Map cacheGNInstances; private String helpURI = "https://wiki.gcube-system.org/gcube/GCube_Resource_Catalogue#Geonetwork_Resolver"; /** - * Gets the geonetwork request criteria. - * Creates a request criteria from input parameter pathWithoutGN - * The parameter pathWithoutGN should be an ordered string (like REST request): - * SCOPE/MODE/VISIBILITY/OWNER/$$ - * SCOPE must be: ROOT|VO|VRE - * MODE must be: {@link MODE} - * VISIBILITY must be: {@link VISIBILITY} + * Gets the geonetwork request criteria. Creates a request criteria from input + * parameter pathWithoutGN The parameter pathWithoutGN should be an ordered + * string (like REST request): SCOPE/MODE/VISIBILITY/OWNER/$$ SCOPE must be: + * ROOT|VO|VRE MODE must be: {@link MODE} VISIBILITY must be: {@link VISIBILITY} * OWNER (is optional): filter by owner * - * @param req the req - * @param scope the scope - * @param mode the mode - * @param visibility the visibility - * @param filterKey the filter key + * @param req the req + * @param scope the scope + * @param mode the mode + * @param visibility the visibility + * @param filterKey the filter key * @param filterValue the filter value - * @param remainPath the remain path - * @param resetCache the reset cache - * @param resetScope the reset scope + * @param remainPath the remain path + * @param resetCache the reset cache + * @param resetScope the reset scope * @return the geonetwork request criteria * @throws WebApplicationException the web application exception */ @GET - @Path("/{"+PATH_PARAM_SCOPE+"}/{"+PATH_PARAM_MODE+"}/{"+PATH_PARAM_VISIBILITY+"}/{filterKey}/{filterValue}/$${"+PATH_PARAM_REMAINPATH+":(/[^?$]+)?}") - public Response submitGet(@Context HttpServletRequest req, - @PathParam(PATH_PARAM_SCOPE) @Nullable String scope, - @PathParam(PATH_PARAM_MODE) @Nullable String mode, - @PathParam(PATH_PARAM_VISIBILITY) @Nullable String visibility, - @PathParam("filterKey") @Nullable String filterKey, - @PathParam("filterValue") @Nullable String filterValue, - @PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath, - @QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache, - @QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) throws WebApplicationException{ + @Path("/{" + PATH_PARAM_SCOPE + "}/{" + PATH_PARAM_MODE + "}/{" + PATH_PARAM_VISIBILITY + + "}/{filterKey}/{filterValue}/$${" + PATH_PARAM_REMAINPATH + ":(/[^?$]+)?}") + public Response submitGet(@Context HttpServletRequest req, @PathParam(PATH_PARAM_SCOPE) @Nullable String scope, + @PathParam(PATH_PARAM_MODE) @Nullable String mode, + @PathParam(PATH_PARAM_VISIBILITY) @Nullable String visibility, + @PathParam("filterKey") @Nullable String filterKey, @PathParam("filterValue") @Nullable String filterValue, + @PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath, + @QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache, + @QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) + throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); String gnGetlURL = null; try { - logger.info("Params are [mode: "+mode+", scope: "+scope+", visibility: "+visibility+", filterKey: "+filterKey+", filterValue: "+filterValue+", remainPath: "+remainPath+"]"); + logger.info( + "Params are [mode: " + mode + ", scope: " + scope + ", visibility: " + visibility + ", filterKey: " + + filterKey + ", filterValue: " + filterValue + ", remainPath: " + remainPath + "]"); - if(scope==null || scope.isEmpty()){ + if (scope == null || scope.isEmpty()) { logger.error("Path Parameter 'scope' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", + this.getClass(), helpURI); } - if(mode==null || mode.isEmpty()){ + if (mode == null || mode.isEmpty()) { logger.error("Path Parameter 'scope' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", + this.getClass(), helpURI); } scope = ScopeUtil.normalizeScope(scope, "|"); mode = mode.toUpperCase(); - try{ + try { MODE.valueOf(mode); - }catch(Exception e){ + } catch (Exception e) { List toPrint = Arrays.asList(MODE.values()); - logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?"); - throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), helpURI); + logger.error( + "The 'mode' parameter is wrong, Have you pass a valid parameter MODE like " + toPrint + "?"); + throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of " + toPrint, + this.getClass(), helpURI); } - if(visibility==null){ + if (visibility == null) { logger.error("Path Parameter 'visibility' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", + this.getClass(), helpURI); } visibility = visibility.toUpperCase(); - try{ + try { VISIBILITY.valueOf(visibility); - }catch (Exception e) { + } catch (Exception e) { List toPrint = Arrays.asList(VISIBILITY.values()); - logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?"); - throw ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), helpURI); + logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like " + + toPrint + "?"); + throw ExceptionManager.wrongParameterException(req, + "The 'visibility' parameter must be value of " + toPrint, this.getClass(), helpURI); } - logger.info("Remaining path is: "+remainPath); - - + logger.info("Remaining path is: " + remainPath); + try { - - //I'M LOADING GN CONFIGURATIONS (ENDPOINT, USER, PWD AND SO ON..) FOR PASSED SCOPE FROM GN LIBRARY BY A GENERAL METHOD WITHOUT TO PERFORM AUTHENTICATION ON GN, - //AFTER THAT I'M USING THEM TO PERFORM AUTHENTICATION ON GN VIA HTTP_CLIENTS IF NEEDED + + // I'M LOADING GN CONFIGURATIONS (ENDPOINT, USER, PWD AND SO ON..) FOR PASSED + // SCOPE FROM GN LIBRARY BY A GENERAL METHOD WITHOUT TO PERFORM AUTHENTICATION + // ON GN, + // AFTER THAT I'M USING THEM TO PERFORM AUTHENTICATION ON GN VIA HTTP_CLIENTS IF + // NEEDED GeonetworkInstance gnInstance = getGeonetworkInstanceForScope(scope); - logger.info("set scope provider "+scope); + logger.info("set scope provider " + scope); ScopeProvider.instance.set(scope); Account account = gnInstance.getAccount(); Version version = gnInstance.getVersion(); String geonetworkUrl = gnInstance.getEndPoint(); - Configuration config = gnInstance.getConfig()!=null?gnInstance.getConfig():null; - - if(account==null || account.getUser()==null || account.getPassword()==null || config==null) { + Configuration config = gnInstance.getConfig() != null ? gnInstance.getConfig() : null; + + if (account == null || account.getUser() == null || account.getPassword() == null || config == null) { logger.info("Loading GN instance and configurations via Geonetwork Library..."); config = gnInstance.getGeonetworkPublisher().getConfiguration(); account = config.getScopeConfiguration().getAccounts().get(Type.CKAN); version = config.getGeoNetworkVersion(); geonetworkUrl = config.getGeoNetworkEndpoint(); } - - logger.info("SCOPE: {}, CKAN user used is: {}, GN EndPoint: {}",scope, account.getUser(), geonetworkUrl); - + + logger.info("SCOPE: {}, CKAN user used is: {}, GN EndPoint: {}", scope, account.getUser(), + geonetworkUrl); + HTTPCallsUtils httpUtils = new HTTPCallsUtils(); - - if(visibility.equals(VISIBILITY.PRV.name())){ - if(account.getUser()!=null){ + + if (visibility.equals(VISIBILITY.PRV.name())) { + if (account.getUser() != null) { switch (version) { case DUE: - boolean authorized = GNAuthentication.login(httpUtils, geonetworkUrl, account.getUser(), account.getPassword()); - logger.info("Authorized on GN2 "+geonetworkUrl +" ? "+authorized); + boolean authorized = GNAuthentication.login(httpUtils, geonetworkUrl, account.getUser(), + account.getPassword()); + logger.info("Authorized on GN2 " + geonetworkUrl + " ? " + authorized); break; - + default: httpUtils = new HTTPCallsUtils(account.getUser(), account.getPassword()); logger.info("Authorized on GN3 via HTTCallsUtils..."); break; } - - }else { - logger.warn("I'm not able to perform authentication, the user read from config with "+Type.CKAN+" is null"); + + } else { + logger.warn("I'm not able to perform authentication, the user read from config with " + + Type.CKAN + " is null"); } } - String baseURL = remainPath==null ||remainPath.isEmpty()?geonetworkUrl+"/"+CSW_SERVER:geonetworkUrl+"/"+CSW_SERVER+remainPath; - logger.info("The base URL is: "+baseURL); - String queryString = req.getQueryString()==null || req.getQueryString().isEmpty()?"":"?"+req.getQueryString(); - gnGetlURL = baseURL+queryString; - logger.info("Sending get request to URL: "+gnGetlURL); + String baseURL = remainPath == null || remainPath.isEmpty() ? geonetworkUrl + "/" + CSW_SERVER + : geonetworkUrl + "/" + CSW_SERVER + remainPath; + logger.info("The base URL is: " + baseURL); + String queryString = req.getQueryString() == null || req.getQueryString().isEmpty() ? "" + : "?" + req.getQueryString(); + gnGetlURL = baseURL + queryString; + logger.info("Sending get request to URL: " + gnGetlURL); HttpResponse proxedGNResponse = httpUtils.get(gnGetlURL); - switch(proxedGNResponse.getStatus()){ + switch (proxedGNResponse.getStatus()) { case HttpServletResponse.SC_OK: - //Building the response + // Building the response InputStream streamToWrite = IOUtils.toInputStream(proxedGNResponse.getResponse()); StreamingOutput so = new SingleFileStreamingOutput(streamToWrite); - logger.info("Response return Content-Type: "+httpUtils.getLastContentType()); + logger.info("Response return Content-Type: " + httpUtils.getLastContentType()); - ResponseBuilder responseBuilder = Response - .ok(so) - .header(ConstantsResolver.CONTENT_TYPE, httpUtils.getLastContentType()); + ResponseBuilder responseBuilder = Response.ok(so).header(ConstantsResolver.CONTENT_TYPE, + httpUtils.getLastContentType()); return responseBuilder.build(); case HttpServletResponse.SC_FORBIDDEN: - throw ExceptionManager.forbiddenException(req, "You are not authorized to perform the request "+gnGetlURL, this.getClass(), helpURI); + throw ExceptionManager.forbiddenException(req, + "You are not authorized to perform the request " + gnGetlURL, this.getClass(), helpURI); default: - throw ExceptionManager.internalErrorException(req, "Sorry, an error occurred performing the geonetwork request "+gnGetlURL+" with scope "+scope, this.getClass(), helpURI); + throw ExceptionManager.internalErrorException(req, + "Sorry, an error occurred performing the geonetwork request " + gnGetlURL + " with scope " + + scope, + this.getClass(), helpURI); } } catch (Exception e) { logger.error("Exception:", e); - String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!"; + String error = "Sorry, an error occurred on resolving geonetwork request with scope " + scope + + ". Please, contact support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } + } catch (Exception e) { - }catch (Exception e) { - - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error during perform GET operation to: "+gnGetlURL+". Please, contact the support!"; + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error during perform GET operation to: " + gnGetlURL + ". Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } @@ -261,157 +285,172 @@ public class GeonetworkResolver { /** * Submit post. * - * @param req the req - * @param scope the scope - * @param mode the mode - * @param visibility the visibility - * @param filterKey the filter key + * @param req the req + * @param scope the scope + * @param mode the mode + * @param visibility the visibility + * @param filterKey the filter key * @param filterValue the filter value - * @param remainPath the remain path - * @param resetCache the reset cache - * @param resetScope the reset scope + * @param remainPath the remain path + * @param resetCache the reset cache + * @param resetScope the reset scope * @return the response * @throws WebApplicationException the web application exception */ @POST - @Path("/{"+PATH_PARAM_SCOPE+"}/{"+PATH_PARAM_MODE+"}/{"+PATH_PARAM_VISIBILITY+"}/{filterKey}/{filterValue}/$${"+PATH_PARAM_REMAINPATH+":(/[^?$]+)?}") - public Response submitPost(@Context HttpServletRequest req, - @PathParam(PATH_PARAM_SCOPE) @Nullable String scope, - @PathParam(PATH_PARAM_MODE) @Nullable String mode, - @PathParam(PATH_PARAM_VISIBILITY) @Nullable String visibility, - @PathParam("filterKey") @Nullable String filterKey, - @PathParam("filterValue") @Nullable String filterValue, - @PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath, - @QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache, - @QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) throws WebApplicationException{ + @Path("/{" + PATH_PARAM_SCOPE + "}/{" + PATH_PARAM_MODE + "}/{" + PATH_PARAM_VISIBILITY + + "}/{filterKey}/{filterValue}/$${" + PATH_PARAM_REMAINPATH + ":(/[^?$]+)?}") + public Response submitPost(@Context HttpServletRequest req, @PathParam(PATH_PARAM_SCOPE) @Nullable String scope, + @PathParam(PATH_PARAM_MODE) @Nullable String mode, + @PathParam(PATH_PARAM_VISIBILITY) @Nullable String visibility, + @PathParam("filterKey") @Nullable String filterKey, @PathParam("filterValue") @Nullable String filterValue, + @PathParam(PATH_PARAM_REMAINPATH) @Nullable String remainPath, + @QueryParam(QUERY_PARAM_RESET_CACHE_PARAM) @Nullable String resetCache, + @QueryParam(QUERY_PARAM_RESET_CACHED_SCOPE_PARAM) @Nullable String resetScope) + throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" POST starts..."); + logger.info(this.getClass().getSimpleName() + " POST starts..."); String gnCSWlURL = null; - try{ - logger.info("Params are [mode: "+mode+", scope: "+scope+", visibility: "+visibility+", filterKey: "+filterKey+", filterValue: "+filterValue+", remainPath: "+remainPath+"]"); + try { + logger.info( + "Params are [mode: " + mode + ", scope: " + scope + ", visibility: " + visibility + ", filterKey: " + + filterKey + ", filterValue: " + filterValue + ", remainPath: " + remainPath + "]"); - if(scope==null || scope.isEmpty()){ + if (scope == null || scope.isEmpty()) { logger.error("Path Parameter 'scope' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'scope'", + this.getClass(), helpURI); } - if(mode==null || mode.isEmpty()){ + if (mode == null || mode.isEmpty()) { logger.error("Path Parameter 'scope' not found"); - ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), helpURI); + ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'mode'", this.getClass(), + helpURI); } scope = ScopeUtil.normalizeScope(scope, "|"); mode = mode.toUpperCase(); - try{ + try { MODE.valueOf(mode); - }catch(Exception e){ + } catch (Exception e) { List toPrint = Arrays.asList(MODE.values()); - logger.error("The 'mode' parameter is wrong, Have you pass a valid parameter MODE like "+toPrint+"?"); - throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of "+toPrint, this.getClass(), helpURI); + logger.error( + "The 'mode' parameter is wrong, Have you pass a valid parameter MODE like " + toPrint + "?"); + throw ExceptionManager.wrongParameterException(req, "The 'mode' parameter must be value of " + toPrint, + this.getClass(), helpURI); } - if(visibility==null){ + if (visibility == null) { logger.error("Path Parameter 'visibility' not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter 'visibility'", + this.getClass(), helpURI); } visibility = visibility.toUpperCase(); - try{ + try { VISIBILITY.valueOf(visibility); - }catch (Exception e) { + } catch (Exception e) { List toPrint = Arrays.asList(VISIBILITY.values()); - logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like "+toPrint+"?"); - throw ExceptionManager.wrongParameterException(req, "The 'visibility' parameter must be value of "+toPrint, this.getClass(), helpURI); + logger.error("The 'visibility' parameter is wrong, Have you pass a valid parameter VISIBILITY like " + + toPrint + "?"); + throw ExceptionManager.wrongParameterException(req, + "The 'visibility' parameter must be value of " + toPrint, this.getClass(), helpURI); } - //HOW TO PASS ANY FILTER? - //TODO INVESTIGATE ON HOW TO PASS MORE THAN ONE FILTER... - Map filters = new HashMap(); - if(filterKey!=null && filterValue!=null){ - //IGNORING THE EMPTY FILTER 'null|null' - if(filterKey.compareToIgnoreCase("null")!=0){ + // HOW TO PASS ANY FILTER? + // TODO INVESTIGATE ON HOW TO PASS MORE THAN ONE FILTER... + Map filters = new HashMap(); + if (filterKey != null && filterValue != null) { + // IGNORING THE EMPTY FILTER 'null|null' + if (filterKey.compareToIgnoreCase("null") != 0) { filters.put(filterKey, filterValue); - logger.debug("Added filter parmas to map filters: "+filters); + logger.debug("Added filter parmas to map filters: " + filters); } } - try { - //I'M LOADING GN CONFIGURATIONS (ENDPOINT, USER, PWD AND SO ON..) FOR PASSED SCOPE FROM GN LIBRARY BY A GENERAL METHOD WITHOUT TO PERFORM AUTHENTICATION ON GN, - //AFTER THAT I'M USING THEM TO PERFORM AUTHENTICATION ON GN VIA HTTP_CLIENTS IF NEEDED + // I'M LOADING GN CONFIGURATIONS (ENDPOINT, USER, PWD AND SO ON..) FOR PASSED + // SCOPE FROM GN LIBRARY BY A GENERAL METHOD WITHOUT TO PERFORM AUTHENTICATION + // ON GN, + // AFTER THAT I'M USING THEM TO PERFORM AUTHENTICATION ON GN VIA HTTP_CLIENTS IF + // NEEDED GeonetworkInstance gnInstance = getGeonetworkInstanceForScope(scope); - logger.info("set scope provider "+scope); + logger.info("set scope provider " + scope); ScopeProvider.instance.set(scope); Account account = gnInstance.getAccount(); Version version = gnInstance.getVersion(); String geonetworkUrl = gnInstance.getEndPoint(); - Configuration config = gnInstance.getConfig()!=null?gnInstance.getConfig():null; - - if(account==null || account.getUser()==null || account.getPassword()==null || config==null) { + Configuration config = gnInstance.getConfig() != null ? gnInstance.getConfig() : null; + + if (account == null || account.getUser() == null || account.getPassword() == null || config == null) { logger.info("Loading GN instance and configurations via Geonetwork Library..."); config = gnInstance.getGeonetworkPublisher().getConfiguration(); account = config.getScopeConfiguration().getAccounts().get(Type.CKAN); version = config.getGeoNetworkVersion(); geonetworkUrl = config.getGeoNetworkEndpoint(); } - logger.info("SCOPE: {}, CKAN user used is: {}, GN EndPoint: {}",scope, account.getUser(), geonetworkUrl); + logger.info("SCOPE: {}, CKAN user used is: {}, GN EndPoint: {}", scope, account.getUser(), + geonetworkUrl); - // logger.info("Parameters.."); - // for (Enumeration e = req.getParameterNames(); e.hasMoreElements();){ - // String p = e.nextElement(); - // logger.debug("param "+p + " value "+Arrays.toString(req.getParameterValues(p))); - // } + // logger.info("Parameters.."); + // for (Enumeration e = req.getParameterNames(); e.hasMoreElements();){ + // String p = e.nextElement(); + // logger.debug("param "+p + " value + // "+Arrays.toString(req.getParameterValues(p))); + // } - //DEBUG BODY - // String readBody = IOUtils.toString(req.getReader()); - // logger.debug("doPost read body request: "+readBody); + // DEBUG BODY + // String readBody = IOUtils.toString(req.getReader()); + // logger.debug("doPost read body request: "+readBody); ByteArrayOutputStream byteArray = new ByteArrayOutputStream(); - // SPECIFIC HANDLER FOR GEONETWORK REQUEST: /srv/en/mef.export - if(remainPath!=null && remainPath.compareTo(SRV_EN_MEF_EXPORT)==0){ + if (remainPath != null && remainPath.compareTo(SRV_EN_MEF_EXPORT) == 0) { logger.info("In case of mef.export, perfoming a custom handler"); gnCSWlURL = geonetworkUrl + SRV_EN_MEF_EXPORT; String[] uuidValues = req.getParameterValues(UUID); - if(uuidValues!=null){ + if (uuidValues != null) { String data = null; for (String uuid : uuidValues) { - data = UUID+"="+uuid; + data = UUID + "=" + uuid; } - if(data!=null){ - logger.debug("Writing "+data +" into byte array"); + if (data != null) { + logger.debug("Writing " + data + " into byte array"); byteArray.write(data.getBytes()); - }else + } else IOUtils.copy(req.getInputStream(), byteArray); - }else + } else IOUtils.copy(req.getInputStream(), byteArray); - }else{ - logger.debug("IS NOT A REQUEST TO "+SRV_EN_MEF_EXPORT); - gnCSWlURL = remainPath==null || remainPath.isEmpty()?geonetworkUrl+"/"+CSW_SERVER:geonetworkUrl+"/"+CSW_SERVER+remainPath; + } else { + logger.debug("IS NOT A REQUEST TO " + SRV_EN_MEF_EXPORT); + gnCSWlURL = remainPath == null || remainPath.isEmpty() ? geonetworkUrl + "/" + CSW_SERVER + : geonetworkUrl + "/" + CSW_SERVER + remainPath; IOUtils.copy(req.getInputStream(), byteArray); } HTTPCallsUtils httpUtils = new HTTPCallsUtils(); - //PRIVATE LAYERS - if(visibility.equals(VISIBILITY.PRV.name())){ - logger.info("Visibility: "+VISIBILITY.PRV+" getting private layers.."); - //VRE LAYERS - if(mode.equals(MODE.VRE.name())){ - logger.info("Getting "+MODE.VRE+" layers.."); - //HARVESTED LAYERS - }else{ + // PRIVATE LAYERS + if (visibility.equals(VISIBILITY.PRV.name())) { + logger.info("Visibility: " + VISIBILITY.PRV + " getting private layers.."); + // VRE LAYERS + if (mode.equals(MODE.VRE.name())) { + logger.info("Getting " + MODE.VRE + " layers.."); + // HARVESTED LAYERS + } else { filters.put("isHarvested", "y"); - logger.info("Getting "+MODE.HARVEST+" layers, I added 'isHarvested = y' to the filters ["+filters+"]"); + logger.info("Getting " + MODE.HARVEST + " layers, I added 'isHarvested = y' to the filters [" + + filters + "]"); } - if(account.getUser()!=null){ + if (account.getUser() != null) { switch (version) { case DUE: - boolean authorized = GNAuthentication.login(httpUtils, geonetworkUrl, account.getUser(), account.getPassword()); - logger.info("Authorized on GN2 "+geonetworkUrl +" ? "+authorized); + boolean authorized = GNAuthentication.login(httpUtils, geonetworkUrl, account.getUser(), + account.getPassword()); + logger.info("Authorized on GN2 " + geonetworkUrl + " ? " + authorized); break; default: @@ -419,81 +458,101 @@ public class GeonetworkResolver { logger.info("Authorized on GN3 via HTTCallsUtils..."); break; } - - }else { - logger.warn("I'm not able to perform authentication, the user read from config with "+Type.CKAN+" is null"); + + } else { + logger.warn("I'm not able to perform authentication, the user read from config with " + + Type.CKAN + " is null"); } - //PUBLIC LAYERS - }else{ - logger.info("Visibility: "+VISIBILITY.PUB+" getting public layers.."); - //VRE LAYERS - if(mode.equals(MODE.VRE.name())){ - logger.info("Getting "+MODE.VRE+" layers, the VRE account: "+account.getUser() +" will be used as owner user for filtering... Is it right?"); + // PUBLIC LAYERS + } else { + logger.info("Visibility: " + VISIBILITY.PUB + " getting public layers.."); + // VRE LAYERS + if (mode.equals(MODE.VRE.name())) { + logger.info("Getting " + MODE.VRE + " layers, the VRE account: " + account.getUser() + + " will be used as owner user for filtering... Is it right?"); filters.put("ownername", account.getUser()); - //HARVESTED LAYERS - }else{ - //filters.put("isHarvested", "y"); - logger.info("Getting "+MODE.HARVEST+" layers, I'm applying the filters ["+filters+"]"); + // HARVESTED LAYERS + } else { + // filters.put("isHarvested", "y"); + logger.info("Getting " + MODE.HARVEST + " layers, I'm applying the filters [" + filters + "]"); } } - logger.info("Sending CSW POST request to URL: "+gnCSWlURL); - logger.debug("Content-Type: "+req.getContentType()); + logger.info("Sending CSW POST request to URL: " + gnCSWlURL); + logger.debug("Content-Type: " + req.getContentType()); - //DEBUG - //logger.debug("POST - BODY : "+byteArray.toString()); - InputStream in = httpUtils.post(gnCSWlURL, new ByteArrayInputStream(byteArray.toByteArray()), req.getContentType(), req.getParameterMap()); + // DEBUG + // logger.debug("POST - BODY : "+byteArray.toString()); + InputStream in = httpUtils.post(gnCSWlURL, new ByteArrayInputStream(byteArray.toByteArray()), + req.getContentType(), req.getParameterMap()); - if(in==null){ - logger.warn("Input stream returned is null, sending "+HttpServletResponse.SC_NOT_FOUND); - throw ExceptionManager.notFoundException(req, "Input stream is null to the request "+gnCSWlURL+ " with body: "+byteArray.toString(), this.getClass(), helpURI); + if (in == null) { + logger.warn("Input stream returned is null, sending " + HttpServletResponse.SC_NOT_FOUND); + throw ExceptionManager.notFoundException(req, + "Input stream is null to the request " + gnCSWlURL + " with body: " + byteArray.toString(), + this.getClass(), helpURI); } - try{ + try { ReusableInputStream reus = new ReusableInputStream(in); - if(visibility.equals(VISIBILITY.PRV.name())){ - logger.info("Private VISIBILITY requested, retrieving public file identifiers to apply filtering.."); + if (visibility.equals(VISIBILITY.PRV.name())) { + logger.info( + "Private VISIBILITY requested, retrieving public file identifiers to apply filtering.."); FilterGetRecords filterGetRecords = new FilterGetRecords(byteArray.toString(), geonetworkUrl); - if(filterGetRecords.getFoundPublicIds()!=null && filterGetRecords.getFoundPublicIds().size()>0){ - logger.info("I'm removing list of public IDs with "+filterGetRecords.getFoundPublicIds().size() +" item/s. Is it right?"); - in = GetResponseRecordFilter.overrideResponseIdsByListIds(reus, filterGetRecords.getFoundPublicIds(), REPLACED_A_PUBLIC_UUID_PLEASE_IGNORE); + if (filterGetRecords.getFoundPublicIds() != null + && filterGetRecords.getFoundPublicIds().size() > 0) { + logger.info("I'm removing list of public IDs with " + + filterGetRecords.getFoundPublicIds().size() + " item/s. Is it right?"); + in = GetResponseRecordFilter.overrideResponseIdsByListIds(reus, + filterGetRecords.getFoundPublicIds(), REPLACED_A_PUBLIC_UUID_PLEASE_IGNORE); } } - if(filters.size()>0){ - logger.info("Applying filtering on geonet:info... filter/s used: "+filters); + if (filters.size() > 0) { + logger.info("Applying filtering on geonet:info... filter/s used: " + filters); Document doc = GetResponseRecordFilter.inputStreamToW3CDocument(reus); - List fileIdentifiers = GetResponseRecordFilter.getTextContentStringsForTagName(doc, "gmd:fileIdentifier"); + List fileIdentifiers = GetResponseRecordFilter.getTextContentStringsForTagName(doc, + "gmd:fileIdentifier"); List noMatchingFilter = new ArrayList(); for (String fileId : fileIdentifiers) { - //CKECKING THE FILTERS + // CKECKING THE FILTERS for (String fkey : filters.keySet()) { - String value = GetResponseRecordFilter.getMetadataValueByFileIdentifier(fileId, config.getGeoNetworkEndpoint(),config.getAdminAccount().getUser(), config.getAdminAccount().getPassword(), fkey); - //String own = GetResponseRecordFilter.getMetaOwnerNameByFileIdentifier(fileId, config.getGeoNetworkEndpoint(),config.getAdminAccount().getUser(), config.getAdminAccount().getPassword()); - String fValue = filters.get(fkey); - //Either the filter KEY doesn't matching any geonet:info (value==null) - //or the value of filterKey in geonet:info doesn't matching the passed filterValue (value.compareTo(fValue)!=0) - if(value==null || value.compareTo(fValue)!=0){ - logger.trace(fkey +" of File Identifier "+fileId+" not matching the filter: "+fkey+" with value: "+fValue+", adding it to list to remove file identifier and exit from loop.."); - noMatchingFilter.add(fileId); - //WHEN I ADD THE FILE IDENTIFIER TO FILTERED ID, I CAN EXIT FROM CKECKING FILTERS LOOP - break; - } + String value = GetResponseRecordFilter.getMetadataValueByFileIdentifier(fileId, + config.getGeoNetworkEndpoint(), config.getAdminAccount().getUser(), + config.getAdminAccount().getPassword(), fkey); + // String own = GetResponseRecordFilter.getMetaOwnerNameByFileIdentifier(fileId, + // config.getGeoNetworkEndpoint(),config.getAdminAccount().getUser(), + // config.getAdminAccount().getPassword()); + String fValue = filters.get(fkey); + // Either the filter KEY doesn't matching any geonet:info (value==null) + // or the value of filterKey in geonet:info doesn't matching the passed + // filterValue (value.compareTo(fValue)!=0) + if (value == null || value.compareTo(fValue) != 0) { + logger.trace(fkey + " of File Identifier " + fileId + " not matching the filter: " + + fkey + " with value: " + fValue + + ", adding it to list to remove file identifier and exit from loop.."); + noMatchingFilter.add(fileId); + // WHEN I ADD THE FILE IDENTIFIER TO FILTERED ID, I CAN EXIT FROM CKECKING + // FILTERS LOOP + break; + } } } - if(noMatchingFilter.size()>0){ - logger.info("Removing "+noMatchingFilter.size()+" layer/s that not macthing the filters: "+filters); - //Document doc2 = GetResponseRecordFilter.inputStreamToW3CDocument(reus); - in = GetResponseRecordFilter.overrideResponseIdsByListIds(reus, noMatchingFilter, REPLACED_UUID_BY_FILTER_PLEASE_IGNORE); - //in = GetResponseRecordFilter.w3CDocumentToInputStream(doc); + if (noMatchingFilter.size() > 0) { + logger.info("Removing " + noMatchingFilter.size() + + " layer/s that not macthing the filters: " + filters); + // Document doc2 = GetResponseRecordFilter.inputStreamToW3CDocument(reus); + in = GetResponseRecordFilter.overrideResponseIdsByListIds(reus, noMatchingFilter, + REPLACED_UUID_BY_FILTER_PLEASE_IGNORE); + // in = GetResponseRecordFilter.w3CDocumentToInputStream(doc); - }else{ - logger.info("No replace on UUIDs was applied from filters: "+filters); + } else { + logger.info("No replace on UUIDs was applied from filters: " + filters); in = reus; } @@ -501,46 +560,49 @@ public class GeonetworkResolver { ReusableInputStream reusIs = new ReusableInputStream(in); - //END DEBUG - logger.info("Response return Content-Type: "+httpUtils.getLastContentType()); - return Response - .ok(reusIs) - //.header(ConstantsResolver.CONTENT_DISPOSITION,"attachment; filename = \""+fileName+"\"") - .header(ConstantsResolver.CONTENT_TYPE, httpUtils.getLastContentType()).build(); + // END DEBUG + logger.info("Response return Content-Type: " + httpUtils.getLastContentType()); + return Response.ok(reusIs) + // .header(ConstantsResolver.CONTENT_DISPOSITION,"attachment; filename = + // \""+fileName+"\"") + .header(ConstantsResolver.CONTENT_TYPE, httpUtils.getLastContentType()).build(); - }catch(Exception e){ + } catch (Exception e) { logger.error("Error on copy the response to send to client: ", e); - throw ExceptionManager.internalErrorException(req, "Error on copy the response!", this.getClass(), helpURI); - }finally{ + throw ExceptionManager.internalErrorException(req, "Error on copy the response!", this.getClass(), + helpURI); + } finally { IOUtils.closeQuietly(in); } - } catch (IllegalArgumentException e){ + } catch (IllegalArgumentException e) { logger.error("IllegalArgumentException:", e); - throw ExceptionManager.badRequestException(req, "Illegal argument to carry out the request!", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Illegal argument to carry out the request!", + this.getClass(), helpURI); } catch (Exception e) { logger.error("Exception:", e); - String error = "Sorry, an error occurred on resolving geonetwork request with scope "+scope+". Please, contact support!"; + String error = "Sorry, an error occurred on resolving geonetwork request with scope " + scope + + ". Please, contact support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error during perform POST operation to: "+gnCSWlURL+". Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error during perform POST operation to: " + gnCSWlURL + + ". Please, contact the support!"; + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** * Gets the geonetwork instance for scope. @@ -549,15 +611,15 @@ public class GeonetworkResolver { * @return the geonetwork instance for scope * @throws Exception the exception */ - protected GeonetworkInstance getGeonetworkInstanceForScope(String scope) throws Exception{ + protected GeonetworkInstance getGeonetworkInstanceForScope(String scope) throws Exception { - logger.info("Trying to read the {} from cache for scope: {}",GeonetworkInstance.class.getSimpleName(), scope); + logger.info("Trying to read the {} from cache for scope: {}", GeonetworkInstance.class.getSimpleName(), scope); GeonetworkInstance geoInstance; try { geoInstance = LoadingGeonetworkInstanceCache.get(scope); - }catch (Exception e) { - logger.error("An error occurred on reading GeonetworkInstance for scope "+scope, e); - throw new Exception("Sorry, An error occurred on reading GeonetworkInstance for scope "+scope); + } catch (Exception e) { + logger.error("An error occurred on reading GeonetworkInstance for scope " + scope, e); + throw new Exception("Sorry, An error occurred on reading GeonetworkInstance for scope " + scope); } return geoInstance; diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java index b79e667..63fcc46 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java @@ -33,8 +33,17 @@ import org.slf4j.LoggerFactory; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; /** - * The Class GisResolver. + * The GisResolver is able to resolve GIS Links (as a redirect to Gis Viewer + * Application) in order to display and navigate on web-map the gis layers + * stored in D4Science Geonetwork + * (e.g. http://wiki.i-marine.eu/index.php/Blue_Hackathon_iMarine_Data_Challenges#iMarine_GeoNetwork) * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/gis?gis-UUID=[UUID]&scope=[SCOPE] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#GIS_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * Dec 14, 2018 */ diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java index 9e16458..dd7fcf3 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java @@ -24,8 +24,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class KnimeCreateResolver. - * + * The KnimeCreateResolver is able to create a KNIME URL. + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/knime/create?[QUERY_STRING_TO_INVOKE_A_KNIME_MODEL] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Mar 24, 2022 @@ -38,7 +44,11 @@ public class KnimeCreateResolver { private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver"; /** - * Creates the knime URL. + * Creates the KNIME URL. Generate a Knime URL (then resolved by the /get path) + * for a KNIME Model Simulation passed by query string. + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#HTTP_POST:_Create_a_KNIME_URL * * @param req the req * @return the response diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeGetResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeGetResolver.java index 0367d22..d3cc27e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeGetResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeGetResolver.java @@ -23,12 +23,14 @@ import org.slf4j.LoggerFactory; import com.google.common.cache.CacheLoader.InvalidCacheLoadException; - /** - * The Class KnimeGetResolver. + * The KnimeGetResolver provides a method to get the Knime URLs (that are simply + * URLs) by which is possible to invoke the KNIME Model Simulation Application. * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Dec 13, 2018 + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Dec 13, 2018 */ @Path("knime") public class KnimeGetResolver { @@ -37,8 +39,7 @@ public class KnimeGetResolver { private static String helpURI = "https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver"; - private static final String ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL = - "org.gcube.portlets.user.model-simulation-configuration.server.KnimeModelSimulationManagerServiceImpl"; + private static final String ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL = "org.gcube.portlets.user.model-simulation-configuration.server.KnimeModelSimulationManagerServiceImpl"; private static final String APPLICATION_PROFILE = "ApplicationProfile"; @@ -47,55 +48,62 @@ public class KnimeGetResolver { /** * Resolve knime url. * - * @param req the req + * @param req the req * @param vreName the vre name * @return the response */ @GET @Path("/get/{vreName}") public Response resolveKnimeURL(@Context HttpServletRequest req, @PathParam("vreName") String vreName) { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); try { - if(vreName==null || vreName.isEmpty()){ + if (vreName == null || vreName.isEmpty()) { logger.error("The path parameter 'vreName' not found or empty in the path"); - throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, "Mandatory path parameter 'vreName' not found or empty", + this.getClass(), helpURI); } ScopeBean scopeBean = null; - try{ + try { scopeBean = LoadingMapOfScopeCache.get(vreName); - }catch(ExecutionException | InvalidCacheLoadException e){ - logger.error("Error on getting the fullscope from cache for vreName "+vreName, e); - throw ExceptionManager.wrongParameterException(req, "Error on getting full scope for the VRE name "+vreName+". Is it registered as VRE in the D4Science Infrastructure System?", this.getClass(), helpURI); + } catch (ExecutionException | InvalidCacheLoadException e) { + logger.error("Error on getting the fullscope from cache for vreName " + vreName, e); + throw ExceptionManager.wrongParameterException(req, + "Error on getting full scope for the VRE name " + vreName + + ". Is it registered as VRE in the D4Science Infrastructure System?", + this.getClass(), helpURI); } ApplicationProfileReader reader = null; String fullScope = scopeBean.toString(); - try{ - reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false); - }catch(Exception e){ - logger.error("Error on reading the "+APPLICATION_PROFILE+" with APPID: "+ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e); - throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the "+KNIME_EXECUTOR_APPLICATION+". Please contact the support", this.getClass(), helpURI); + try { + reader = new ApplicationProfileReader(fullScope, APPLICATION_PROFILE, + ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, false); + } catch (Exception e) { + logger.error("Error on reading the " + APPLICATION_PROFILE + " with APPID: " + + ORG_GCUBE_PORTLETS_USER_KNIMEMODELSIMULATION_MANAGER_SERVICE_IMPL, e); + throw ExceptionManager.internalErrorException(req, "Error on reading the Application Profile for the " + + KNIME_EXECUTOR_APPLICATION + ". Please contact the support", this.getClass(), helpURI); } - //READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope + // READ THE KNIME URL PORTLET FROM APPLICATION PROFRILE IN THE SCOPE fullScope String knimeExecutorEndPoint = reader.getApplicationProfile().getUrl(); - //CHECKING THE QUERY STRING - String queryString = req.getQueryString()!=null?req.getQueryString():""; + // CHECKING THE QUERY STRING + String queryString = req.getQueryString() != null ? req.getQueryString() : ""; String knimeExecutorURL = String.format("%s?%s", knimeExecutorEndPoint, queryString); - logger.info("Resolving the Knime URL with: "+knimeExecutorURL); + logger.info("Resolving the Knime URL with: " + knimeExecutorURL); return Response.seeOther(new URI(knimeExecutorURL)).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException String error = "Sorry, an error occurred on resolving the Knime URL. Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/PartheosRegistryResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/PartheosRegistryResolver.java index 1062a2b..aa215d7 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/PartheosRegistryResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/PartheosRegistryResolver.java @@ -28,12 +28,13 @@ import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** - * The Class PartheosRegistryResolver. + * The PartheosRegistryResolver. + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Parthenos_URL_Resolver * - * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it - * Nov 16, 2018 + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Nov 16, 2018 */ @Path("parthenos_registry") public class PartheosRegistryResolver { @@ -43,65 +44,70 @@ public class PartheosRegistryResolver { /** * Resolve parthenos url. + * + * To resolve an "item" from a Parthenos URL stored in the Parthenos Catalogue + * at https://ckan-parthenos.d4science.org/ * - * @param req the req - * @param provider the provider - * @param path the path + * @param req the req + * @param provider the provider + * @param path the path * @param remainPath the remain path * @return the response */ @GET @Path("/{provider}/{path}{remainPath:(/[^?$]+)?}") - public Response resolveParthenosURL(@Context HttpServletRequest req, - @PathParam("provider") String provider, - @PathParam("path") String path, - @PathParam("remainPath") String remainPath) throws WebApplicationException { + public Response resolveParthenosURL(@Context HttpServletRequest req, @PathParam("provider") String provider, + @PathParam("path") String path, @PathParam("remainPath") String remainPath) throws WebApplicationException { - logger.info(this.getClass().getSimpleName()+" GET starts..."); + logger.info(this.getClass().getSimpleName() + " GET starts..."); String remainPathParthenosURL = null; try { - logger.debug("provider is: "+provider); - logger.debug("path is: "+path); - logger.debug("remainPath is: "+remainPath); + logger.debug("provider is: " + provider); + logger.debug("path is: " + path); + logger.debug("remainPath is: " + remainPath); - remainPathParthenosURL = String.format("%s/%s",provider,path); + remainPathParthenosURL = String.format("%s/%s", provider, path); - if(remainPath!=null && !remainPath.isEmpty()){ - remainPathParthenosURL+=remainPath.startsWith("/")?remainPath:"/"+remainPath; + if (remainPath != null && !remainPath.isEmpty()) { + remainPathParthenosURL += remainPath.startsWith("/") ? remainPath : "/" + remainPath; } - logger.info("Resolving parthenos URL: "+remainPathParthenosURL); - //APPLYING URL DECODING + logger.info("Resolving parthenos URL: " + remainPathParthenosURL); + // APPLYING URL DECODING remainPathParthenosURL = URLDecoder.decode(remainPathParthenosURL, "UTF-8"); - //APPLYING NAME TRANSFORMATION + // APPLYING NAME TRANSFORMATION String normalizedEntityName = toNameForCatalogue(remainPathParthenosURL); - logger.info("Trying to resolve with Catalogue EntityName: "+normalizedEntityName); - ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName); + logger.info("Trying to resolve with Catalogue EntityName: " + normalizedEntityName); + ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, + UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), + normalizedEntityName); return Response.seeOther(new URL(itemCatalogueURLs.getPrivateVRECataloguePortletURL()).toURI()).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on resolving the path "+remainPathParthenosURL+". Please, contact the support!"; - if(e.getCause()!=null) - error+="\n\nCaused: "+e.getCause().getMessage(); + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on resolving the path " + remainPathParthenosURL + + ". Please, contact the support!"; + if (e.getCause() != null) + error += "\n\nCaused: " + e.getCause().getMessage(); throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** - * Post catalogue. + * To get a normalized item name from a Parthenos URL. It applies a + * normalization function to get from an input Parthenos URL an item name that + * is catalogue compliant. * - * @param req the req + * @param req the req * @param jsonRequest the json request * @return the response * @throws Exception the exception @@ -110,59 +116,67 @@ public class PartheosRegistryResolver { @Path("") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.TEXT_PLAIN) - public Response postCatalogue(@Context HttpServletRequest req, ParthenosRequest jsonRequest) throws WebApplicationException{ - logger.info(this.getClass().getSimpleName()+" POST starts..."); + public Response postCatalogue(@Context HttpServletRequest req, ParthenosRequest jsonRequest) + throws WebApplicationException { + logger.info(this.getClass().getSimpleName() + " POST starts..."); - try{ + try { String entityName = jsonRequest.getEntity_name(); - if(entityName==null || entityName.isEmpty()){ + if (entityName == null || entityName.isEmpty()) { logger.error("Entity Name Parameter like 'entity_name' not found or empty"); - throw ExceptionManager.badRequestException(req, "Mandatory body parameter 'entity_name' not found or empty", this.getClass(), helpURI); + throw ExceptionManager.badRequestException(req, + "Mandatory body parameter 'entity_name' not found or empty", this.getClass(), helpURI); } - //REMOVING FIRST '/' IF EXISTS - entityName = entityName.startsWith("/")?entityName.substring(1,entityName.length()):entityName; + // REMOVING FIRST '/' IF EXISTS + entityName = entityName.startsWith("/") ? entityName.substring(1, entityName.length()) : entityName; - //APPLYING NAME TRANSFORMATION + // APPLYING NAME TRANSFORMATION String normalizedEntityName = toNameForCatalogue(entityName); - ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), normalizedEntityName); - logger.info("Returining Catalogue URL: "+itemCatalogueURLs.getPrivateVRECataloguePortletURL()); - return Response.ok(normalizedEntityName).header("Location", itemCatalogueURLs.getPrivateVRECataloguePortletURL()).build(); + ItemCatalogueURLs itemCatalogueURLs = CatalogueResolver.getItemCatalogueURLs(req, + UriResolverSmartGearManagerInit.getParthenosVREName(), ResourceCatalogueCodes.CTLGD.getId(), + normalizedEntityName); + logger.info("Returining Catalogue URL: " + itemCatalogueURLs.getPrivateVRECataloguePortletURL()); + return Response.ok(normalizedEntityName) + .header("Location", itemCatalogueURLs.getPrivateVRECataloguePortletURL()).build(); - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on transforming the "+jsonRequest+". Please, contact the support!"; + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on transforming the " + jsonRequest + ". Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** - * To name for catalogue. - * this method applyes a fuction to transform a parthenos URL to acceptable catalogue name (that is URL) + * To name for catalogue. this method applyes a fuction to transform a parthenos + * URL to acceptable catalogue name (that is URL) + * * @param remainPathParthenosURL the remain path parthenos url * @return the string * @throws UnsupportedEncodingException the unsupported encoding exception */ protected String toNameForCatalogue(final String remainPathParthenosURL) throws UnsupportedEncodingException { - //need to double decode for URLs like: http://parthenos.d4science.org/handle/Parthenos/REG/Dataset/Appellation/Isidore%2520Dataset - String name = StringUtils.replaceChars(URLDecoder.decode(remainPathParthenosURL,"UTF-8"),"/ .:", "_").toLowerCase().replaceAll("[^A-Za-z0-9]", "_"); - //TO LOWERCASE FOR CKAN SUPPORTING + // need to double decode for URLs like: + // http://parthenos.d4science.org/handle/Parthenos/REG/Dataset/Appellation/Isidore%2520Dataset + String name = StringUtils.replaceChars(URLDecoder.decode(remainPathParthenosURL, "UTF-8"), "/ .:", "_") + .toLowerCase().replaceAll("[^A-Za-z0-9]", "_"); + // TO LOWERCASE FOR CKAN SUPPORTING return name.toLowerCase(); } - //TO TEST - // public static void main(String[] args) throws UnsupportedEncodingException { + // TO TEST + // public static void main(String[] args) throws UnsupportedEncodingException { // - // String remainPathParthenosURL = "Culturalitalia/unknown/Dataset/oai%3Aculturaitalia.it%3Aoai%3Aculturaitalia.it%3Amuseiditalia-mus_11953"; - // System.out.println(URLDecoder.decode(remainPathParthenosURL, "UTF-8")); + // String remainPathParthenosURL = + // "Culturalitalia/unknown/Dataset/oai%3Aculturaitalia.it%3Aoai%3Aculturaitalia.it%3Amuseiditalia-mus_11953"; + // System.out.println(URLDecoder.decode(remainPathParthenosURL, "UTF-8")); // - // } + // } } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java index 4745627..bde54dc 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java @@ -20,8 +20,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class SMPIDResolver. - * + * The SMPIDResolver is able to give HTTP resolution to storage resource by ID. + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/id?smp-id=[STORAGE_SMP_ID]&fileName=[FILENAME]&contentType=[CONTENT_TYPE] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#SMP-ID_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Mar 24, 2022 diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java index 154aa57..716adee 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java @@ -20,8 +20,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class SMPResolver. + * The SMPResolver is able to give HTTP resolution to SMP protocol URIs + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/smp?smp-uri=smp://..... * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#SMP_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * * Mar 24, 2022 diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java index da5711c..2e7eee1 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java @@ -25,10 +25,17 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class StorageHubResolver. - * + * The StorageHubResolver provides the methods either to download a gCube + * Workspace file or to get its metadata. + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/shub/[STORAGE_HUB_FILE_ID] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#STORAGE-HUB_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) - * Dec 14, 2018 + * Dec 14, 2018 */ @Path("shub") public class StorageHubResolver { @@ -46,7 +53,6 @@ public class StorageHubResolver { @PathParam(STORAGE_HUB_ID) String id; - /** * Gets the metadata. * @@ -56,45 +62,47 @@ public class StorageHubResolver { @HEAD @Path("/{id}") public Response getMetadata(@Context HttpServletRequest req) { - logger.info(this.getClass().getSimpleName()+" HEAD getMetadata called"); + logger.info(this.getClass().getSimpleName() + " HEAD getMetadata called"); - try{ - //TODO Do we need to check the token? + try { + // TODO Do we need to check the token? - //Checking mandatory parameter id - if(id==null || id.isEmpty()){ - logger.error("Path Parameter "+STORAGE_HUB_ID+" not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter "+STORAGE_HUB_ID, this.getClass(), help); + // Checking mandatory parameter id + if (id == null || id.isEmpty()) { + logger.error("Path Parameter " + STORAGE_HUB_ID + " not found"); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter " + STORAGE_HUB_ID, + this.getClass(), help); } - try{ + try { ItemManagerClient client = AbstractPlugin.item().build(); StreamDescriptor descriptor = client.resolvePublicLink(id); ResponseBuilder response = Response.ok(); - response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, CONTENT_DISPOSITION_VALUE.attachment); + response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, + CONTENT_DISPOSITION_VALUE.attachment); return response.build(); - }catch(Exception e){ - logger.error("Error on getting metadata for file with "+id, e); - String errorMsg = "Error on getting metadata for file with hub id '"+id+"'. "+e.getMessage(); + } catch (Exception e) { + logger.error("Error on getting metadata for file with " + id, e); + String errorMsg = "Error on getting metadata for file with hub id '" + id + "'. " + e.getMessage(); throw ExceptionManager.internalErrorException(req, errorMsg, this.getClass(), help); } - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on resolving the StorageHub URL with id: "+id+". Please, contact the support!"; + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on resolving the StorageHub URL with id: " + id + + ". Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), help); } - //ALREADY MANAGED as WebApplicationException + // ALREADY MANAGED as WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } } - /** * Download. * @@ -103,46 +111,50 @@ public class StorageHubResolver { */ @GET @Path("/{id}") - public Response download(@Context HttpServletRequest req, @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition) { - logger.info(this.getClass().getSimpleName()+" GET download called"); + public Response download(@Context HttpServletRequest req, + @QueryParam(ConstantsResolver.QUERY_PARAM_CONTENTDISPOSITION) String contentDisposition) { + logger.info(this.getClass().getSimpleName() + " GET download called"); - try{ + try { InnerMethodName.instance.set("resolveStorageHubPublicLink"); - //Checking mandatory parameter "id" - if(id==null || id.isEmpty()){ - logger.error("Path Parameter "+STORAGE_HUB_ID+" not found"); - throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter "+STORAGE_HUB_ID, StorageHubResolver.class, help); + // Checking mandatory parameter "id" + if (id == null || id.isEmpty()) { + logger.error("Path Parameter " + STORAGE_HUB_ID + " not found"); + throw ExceptionManager.badRequestException(req, "Missing mandatory path parameter " + STORAGE_HUB_ID, + StorageHubResolver.class, help); } - - //Checking the optional parameter "Content-Disposition" + + // Checking the optional parameter "Content-Disposition" CONTENT_DISPOSITION_VALUE dispositionValue = CONTENT_DISPOSITION_VALUE.attachment; - //Validating the Content-Disposition value + // Validating the Content-Disposition value dispositionValue = ValidateContentDisposition.validValue(req, this.getClass(), help, contentDisposition); - try{ + try { ItemManagerClient client = AbstractPlugin.item().build(); StreamDescriptor descriptor = client.resolvePublicLink(id); ResponseBuilder response = Response.ok(descriptor.getStream()); - response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, dispositionValue); + response = new StorageHubMetadataResponseBuilder(req, response).fillMetadata(descriptor, id, + dispositionValue); return response.build(); - }catch(Exception e){ - logger.error("Error on getting file with "+id, e); - String errorMsg = "Error on getting file with hub id '"+id+"'. "+e.getMessage(); + } catch (Exception e) { + logger.error("Error on getting file with " + id, e); + String errorMsg = "Error on getting file with hub id '" + id + "'. " + e.getMessage(); throw ExceptionManager.internalErrorException(req, errorMsg, StorageHubResolver.class, help); } - }catch (Exception e) { + } catch (Exception e) { - if(!(e instanceof WebApplicationException)){ - //UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = "Error occurred on resolving the StorageHub URL with id: "+id+". Please, contact the support!"; + if (!(e instanceof WebApplicationException)) { + // UNEXPECTED EXCEPTION managing it as WebApplicationException + String error = "Error occurred on resolving the StorageHub URL with id: " + id + + ". Please, contact the support!"; throw ExceptionManager.internalErrorException(req, error, this.getClass(), help); } - //ALREADY MANAGED AS WebApplicationException + // ALREADY MANAGED AS WebApplicationException logger.error("Exception:", e); throw (WebApplicationException) e; } diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index 47bc60f..51a7baa 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -36,8 +36,14 @@ import org.slf4j.LoggerFactory; /** - * The Class StorageIDResolver. - * + * The StorageIDResolver is able to give HTTP resolution to storage resource by ID + * + * Request Format + * [URI_RESOLVER_SERVICE_ENDPOINT]/[STORAGE_ID] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#STORAGE-ID_Resolver + * * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * Dec 14, 2018 */ diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index 67944c1..e6053dd 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -10,17 +10,15 @@ import java.io.InputStream; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; import javax.ws.rs.Path; -import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; import org.gcube.datatransfer.resolver.services.error.ExceptionManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class UriResolverDocs. + * The UriResolverDocs provides the URI Resolver API Documentation * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java index 3ebd196..d63639a 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverInfo.java @@ -14,7 +14,7 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; /** - * The Class UriResolverInfo. + * The UriResolverInfo get index. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java index 8bbadc1..757eb9b 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java @@ -36,7 +36,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The Class WekeoResolver. + * The WekeoResolver provides a method to wrap the basic authentication from + * D4Science account to WekeoBroker service. + * + * Request format + * [URI_RESOLVER_SERVICE_ENDPOINT]/wekeo/gettoken?gcube-token=[YOUR_GCUBE_TOKEN] + * + * See more at + * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Wekeo_Resolver * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * -- 2.17.1 From a154b5b849deb2c988708be6569880809bdc9650 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 10:57:38 +0200 Subject: [PATCH 39/58] updated the documentation --- .../gcube/datatransfer/resolver/services/CatalogueResolver.java | 2 +- .../datatransfer/resolver/services/GeonetworkResolver.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index 491d8c1..e59ab94 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -45,7 +45,7 @@ import eu.trentorise.opendata.jackan.model.CkanDataset; /** * The CatalogueResolver is able to get/resolve a link to a "Catalogue Entity" - * stored in one of the gCube Data Catalogue's instances. A Catalogue Entity is + * stored in one of the D4Science Catalogue's instances. A Catalogue Entity is * either a "group" or an "organization" or a "product" of D4Science Data * Catalogue. * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java index 11fc477..b41cdb3 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java @@ -52,7 +52,7 @@ import org.w3c.dom.Document; * on D4Science Geonetwork services. * * Request format - * http[s]://[GEONETWORK_RESOLVER_BASE_URL]/[SCOPE]/[MODE]/[VISIBILITY]/[FILTER_KEY]/[FILTER_VALUE]/$$ + * [GEONETWORK_RESOLVER_BASE_URL]/[SCOPE]/[MODE]/[VISIBILITY]/[FILTER_KEY]/[FILTER_VALUE]/$$ * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Geonetwork_Resolver -- 2.17.1 From 729e9d9f0b505545061f5eea1089c5517ff9768b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 11:01:17 +0200 Subject: [PATCH 40/58] updated documentation --- .../resolver/services/GeonetworkResolver.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java index b41cdb3..6992c81 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java @@ -98,9 +98,12 @@ public class GeonetworkResolver { /** * Gets the geonetwork request criteria. Creates a request criteria from input - * parameter pathWithoutGN The parameter pathWithoutGN should be an ordered - * string (like REST request): SCOPE/MODE/VISIBILITY/OWNER/$$ SCOPE must be: - * ROOT|VO|VRE MODE must be: {@link MODE} VISIBILITY must be: {@link VISIBILITY} + * parameter pathWithoutGN. The parameter pathWithoutGN should be an ordered + * string (like REST request): SCOPE/MODE/VISIBILITY/OWNER/$$ + * + * SCOPE must be: ROOT|VO|VRE + * MODE must be: {@link MODE} + * VISIBILITY must be: {@link VISIBILITY} * OWNER (is optional): filter by owner * * @param req the req @@ -283,7 +286,7 @@ public class GeonetworkResolver { } /** - * Submit post. + * The post request * * @param req the req * @param scope the scope -- 2.17.1 From 64e00bb53b54a29fdddd704949c71a3379f6d41c Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 11:03:40 +0200 Subject: [PATCH 41/58] updated doc --- .../datatransfer/resolver/services/UriResolverResources.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java index 6fcd4e4..8513ae2 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverResources.java @@ -21,7 +21,7 @@ import org.slf4j.LoggerFactory; import com.fasterxml.jackson.databind.node.ObjectNode; /** - * The Class UriResolverResources. + * The UriResolverResources. Show the resources as a JSON * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * -- 2.17.1 From db870b5d757c25f143749414cb9bc81fb92aadd8 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 17:04:43 +0200 Subject: [PATCH 42/58] fixed typo --- CHANGELOG.md | 2 +- pom.xml | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2552d92..959df85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm **New** -- [#23049] Integrate Enunicate engine for Java Web service API (https://github.com/stoicflame/enunciate/) +- [#23049] Integrate Enunciate engine for Java Web service API (https://github.com/stoicflame/enunciate/) - [#20743] Integrate JavaMelody ## [v2-7.0-SNAPSHOT] - 2022-01-31 diff --git a/pom.xml b/pom.xml index e276720..adb6fdd 100644 --- a/pom.xml +++ b/pom.xml @@ -292,7 +292,6 @@ - maven-compiler-plugin -- 2.17.1 From dba18685f6615adbd4488c10d77a7ad54ff24347 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Mar 2022 18:30:19 +0200 Subject: [PATCH 43/58] revisited the API doc --- pom.xml | 35 ------------------- .../services/AnalyticsGetResolver.java | 3 -- .../resolver/services/CatalogueResolver.java | 3 -- .../resolver/services/GisResolver.java | 3 -- .../services/KnimeCreateResolver.java | 3 -- .../resolver/services/SMPIDResolver.java | 3 -- .../resolver/services/SMPResolver.java | 3 -- .../resolver/services/StorageHubResolver.java | 3 -- .../resolver/services/UriResolverDocs.java | 34 +----------------- 9 files changed, 1 insertion(+), 89 deletions(-) diff --git a/pom.xml b/pom.xml index adb6fdd..61f49c9 100644 --- a/pom.xml +++ b/pom.xml @@ -202,20 +202,6 @@ compile - - - - - - - - - - - - - - commons-lang commons-lang @@ -345,27 +331,6 @@ - - - org.apache.maven.plugins - maven-assembly-plugin - - - descriptor.xml - - - - - servicearchive - install - - single - - - - - - diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java index 108a7c6..3eff1da 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsGetResolver.java @@ -26,9 +26,6 @@ import com.google.common.cache.CacheLoader.InvalidCacheLoadException; /** * The AnalyticsGetResolver to resolve an Analytics URL * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/analytics/get/[VRE_NAME]?dim=[PUBLIC_URL_TO_DATAMIER_INVOCATION_FILE_GENERATED_BY_POST_REQUEST] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java index e59ab94..6f781a5 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/CatalogueResolver.java @@ -74,9 +74,6 @@ public class CatalogueResolver { /** * Resolve an entity of the Catalogue - * - * Request format: - * [URI_RESOLVER_SERVICE_ENDPOINT]/[ctlg|ctlg-d|ctlg-o|ctlg-g]/[VRE_NAME]/[entity_name] * * @param req the req * @param entityName the entity name diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java index 63fcc46..cc24d7e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java @@ -37,9 +37,6 @@ import com.google.common.cache.CacheLoader.InvalidCacheLoadException; * Application) in order to display and navigate on web-map the gis layers * stored in D4Science Geonetwork * (e.g. http://wiki.i-marine.eu/index.php/Blue_Hackathon_iMarine_Data_Challenges#iMarine_GeoNetwork) - * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/gis?gis-UUID=[UUID]&scope=[SCOPE] * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#GIS_Resolver diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java index dd7fcf3..d1de43d 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/KnimeCreateResolver.java @@ -26,9 +26,6 @@ import org.slf4j.LoggerFactory; /** * The KnimeCreateResolver is able to create a KNIME URL. * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/knime/create?[QUERY_STRING_TO_INVOKE_A_KNIME_MODEL] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#KNIME_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java index bde54dc..338d478 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPIDResolver.java @@ -22,9 +22,6 @@ import org.slf4j.LoggerFactory; /** * The SMPIDResolver is able to give HTTP resolution to storage resource by ID. * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/id?smp-id=[STORAGE_SMP_ID]&fileName=[FILENAME]&contentType=[CONTENT_TYPE] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#SMP-ID_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java index 716adee..7ca8b7e 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/SMPResolver.java @@ -22,9 +22,6 @@ import org.slf4j.LoggerFactory; /** * The SMPResolver is able to give HTTP resolution to SMP protocol URIs * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/smp?smp-uri=smp://..... - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#SMP_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java index 2e7eee1..937bf75 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageHubResolver.java @@ -28,9 +28,6 @@ import org.slf4j.LoggerFactory; * The StorageHubResolver provides the methods either to download a gCube * Workspace file or to get its metadata. * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/shub/[STORAGE_HUB_FILE_ID] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#STORAGE-HUB_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java index e6053dd..f610233 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java @@ -45,7 +45,7 @@ public class UriResolverDocs { logger.info("pathInfo {}", pathInfo); try { - if (pathInfo.equals("/docs/")) + if (pathInfo.endsWith("/docs/")) pathInfo += "index.html"; logger.info("redirecting to {}", pathInfo); @@ -65,36 +65,4 @@ public class UriResolverDocs { throw (WebApplicationException) e; } } - - /** - * Index. - * - * @param req the req - * @return the input stream - * @throws WebApplicationException the web application exception - */ - @GET -// @Produces({ MediaType.TEXT_HTML }) - @Path("") - public InputStream index(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(UriResolverDocs.class.getSimpleName() + " index called"); - - String pathInfo = "/docs/index.html"; - try { - - String realPath = req.getServletContext().getRealPath(pathInfo); - return new FileInputStream(new File(realPath)); - } catch (Exception e) { - - if (!(e instanceof WebApplicationException)) { - // UNEXPECTED EXCEPTION managing it as WebApplicationException - String error = pathInfo + " not found. Please, contact the support!"; - throw ExceptionManager.internalErrorException(req, error, this.getClass(), null); - } - // ALREADY MANAGED AS WebApplicationException - logger.error("Exception:", e); - throw (WebApplicationException) e; - } - } - } -- 2.17.1 From e430a4acbeb8b9299294ecd7ac9eaa027ae3d6d4 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 10:25:30 +0200 Subject: [PATCH 44/58] improved documentation --- enunciate.xml | 7 +++---- .../resolver/services/AnalyticsCreateResolver.java | 7 +++---- .../{UriResolverDocs.java => DocsGenerator.java} | 13 +++++++------ .../resolver/services/GeonetworkResolver.java | 7 ++----- .../datatransfer/resolver/services/GisResolver.java | 3 +-- .../resolver/services/StorageIDResolver.java | 3 --- .../resolver/services/WekeoResolver.java | 3 --- 7 files changed, 16 insertions(+), 27 deletions(-) rename src/main/java/org/gcube/datatransfer/resolver/services/{UriResolverDocs.java => DocsGenerator.java} (83%) diff --git a/enunciate.xml b/enunciate.xml index f048813..716a60c 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -5,7 +5,7 @@ + pattern="org.gcube.datatransfer.resolver.services.DocsGenerator" /> - + - + \ No newline at end of file diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java index b8cd4ec..ad76f38 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/AnalyticsCreateResolver.java @@ -57,10 +57,9 @@ import org.slf4j.LoggerFactory; import org.xml.sax.SAXException; /** - * The AnalyticsCreateResolver provides a method to get the Analytics URLs (that - * are simply URLs) by which is possible to invoke through the DataMiner - * Executor the run of an algorithm stored in a certain VRE. By the DataMiner - * Executor then the user is able to monitoring the algorithm execution. + * The AnalyticsCreateResolver provides a method to get the Analytics URLs by + * which is possible to invoke through the DataMiner Executor the run of an + * algorithm stored in a certain VRE. * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Analytics_Resolver diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java b/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java similarity index 83% rename from src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java rename to src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java index f610233..71661da 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/UriResolverDocs.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java @@ -18,16 +18,16 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The UriResolverDocs provides the URI Resolver API Documentation + * The Class DocsGenerator. * * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it * - * Mar 24, 2022 + * Apr 1, 2022 */ @Path("docs") -public class UriResolverDocs { +public class DocsGenerator { - private static Logger logger = LoggerFactory.getLogger(UriResolverDocs.class); + private static Logger logger = LoggerFactory.getLogger(DocsGenerator.class); /** * To doc. @@ -39,14 +39,15 @@ public class UriResolverDocs { @GET @Path("/{any: .*}") public InputStream toDoc(@Context HttpServletRequest req) throws WebApplicationException { - logger.info(UriResolverDocs.class.getSimpleName() + " toDoc called"); + logger.info(DocsGenerator.class.getSimpleName() + " toDoc called"); String pathInfo = req.getPathInfo(); logger.info("pathInfo {}", pathInfo); try { - if (pathInfo.endsWith("/docs/")) + if (pathInfo.endsWith("/docs/")) { pathInfo += "index.html"; + } logger.info("redirecting to {}", pathInfo); diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java index 6992c81..6b75e52 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GeonetworkResolver.java @@ -48,11 +48,8 @@ import org.slf4j.LoggerFactory; import org.w3c.dom.Document; /** - * The GeonetworkResolver is a "middle tier" (like a Proxy) to perform queries - * on D4Science Geonetwork services. - * - * Request format - * [GEONETWORK_RESOLVER_BASE_URL]/[SCOPE]/[MODE]/[VISIBILITY]/[FILTER_KEY]/[FILTER_VALUE]/$$ + * The GeonetworkResolver is a "middle tier" to perform queries + * to D4Science's Geonetwork services. * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Geonetwork_Resolver diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java index cc24d7e..2d5d789 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/GisResolver.java @@ -35,8 +35,7 @@ import com.google.common.cache.CacheLoader.InvalidCacheLoadException; /** * The GisResolver is able to resolve GIS Links (as a redirect to Gis Viewer * Application) in order to display and navigate on web-map the gis layers - * stored in D4Science Geonetwork - * (e.g. http://wiki.i-marine.eu/index.php/Blue_Hackathon_iMarine_Data_Challenges#iMarine_GeoNetwork) + * stored in D4Science's Geonetwork * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#GIS_Resolver diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java index 51a7baa..edc1fae 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/StorageIDResolver.java @@ -38,9 +38,6 @@ import org.slf4j.LoggerFactory; /** * The StorageIDResolver is able to give HTTP resolution to storage resource by ID * - * Request Format - * [URI_RESOLVER_SERVICE_ENDPOINT]/[STORAGE_ID] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#STORAGE-ID_Resolver * diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java index 757eb9b..af0c459 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/WekeoResolver.java @@ -39,9 +39,6 @@ import org.slf4j.LoggerFactory; * The WekeoResolver provides a method to wrap the basic authentication from * D4Science account to WekeoBroker service. * - * Request format - * [URI_RESOLVER_SERVICE_ENDPOINT]/wekeo/gettoken?gcube-token=[YOUR_GCUBE_TOKEN] - * * See more at * https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Wekeo_Resolver * -- 2.17.1 From 35f6cd7a06ad8444a25c82ae900a0a515fa4d6cd Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 10:50:28 +0200 Subject: [PATCH 45/58] improved documentation --- enunciate.xml | 2 ++ .../gcube/datatransfer/resolver/services/DocsGenerator.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/enunciate.xml b/enunciate.xml index 716a60c..3fe560f 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -23,6 +23,8 @@ + diff --git a/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java b/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java index 71661da..d782da0 100644 --- a/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java +++ b/src/main/java/org/gcube/datatransfer/resolver/services/DocsGenerator.java @@ -42,14 +42,14 @@ public class DocsGenerator { logger.info(DocsGenerator.class.getSimpleName() + " toDoc called"); String pathInfo = req.getPathInfo(); - logger.info("pathInfo {}", pathInfo); + logger.debug("pathInfo {}", pathInfo); try { if (pathInfo.endsWith("/docs/")) { pathInfo += "index.html"; } - logger.info("redirecting to {}", pathInfo); + logger.info("going to {}", pathInfo); String realPath = req.getServletContext().getRealPath(pathInfo); return new FileInputStream(new File(realPath)); -- 2.17.1 From 59fec814413a5c1fe7e4fed6173eaa062a5f8f6d Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 13:01:02 +0200 Subject: [PATCH 46/58] Added D4Science template customisation --- enunciate.xml | 5 + .../resources/META-INF/d4science_docs.fmt | 1179 +++++++++++++++++ .../META-INF/d4science_enunciate_custom.css | 25 + 3 files changed, 1209 insertions(+) create mode 100644 src/main/resources/META-INF/d4science_docs.fmt create mode 100644 src/main/resources/META-INF/d4science_enunciate_custom.css diff --git a/enunciate.xml b/enunciate.xml index 3fe560f..6abbcac 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -26,6 +26,11 @@ + + + \ No newline at end of file diff --git a/src/main/resources/META-INF/d4science_docs.fmt b/src/main/resources/META-INF/d4science_docs.fmt new file mode 100644 index 0000000..4d3b10f --- /dev/null +++ b/src/main/resources/META-INF/d4science_docs.fmt @@ -0,0 +1,1179 @@ +[#ftl] +[#-- + + Copyright © 2006-2016 Web Cohesion (info@webcohesion.com) + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +--] +[#-- @ftlvariable name="resourceApis" type="java.util.List" --] +[#-- @ftlvariable name="serviceApis" type="java.util.List" --] +[#-- @ftlvariable name="data" type="java.util.List" --] +[#-- @ftlvariable name="downloads" type="java.util.List" --] +[#-- @ftlvariable name="title" type="java.lang.String" --] +[#-- @ftlvariable name="indexPageName" type="java.lang.String" --] +[#-- @ftlvariable name="disableMountpoint" type="java.lang.Boolean" --] +[#-- @ftlvariable name="disableResourceLinks" type="java.lang.Boolean" --] +[#-- @ftlvariable name="apiRelativePath" type="java.lang.String" --] +[#-- @ftlvariable name="cssFile" type="java.lang.String" --] +[#-- @ftlvariable name="additionalCssFiles" type="java.util.List" --] +[#-- @ftlvariable name="copyright" type="java.lang.String" --] +[#-- @ftlvariable name="apiDoc" type="java.lang.String" --] +[#-- @ftlvariable name="swaggerUI" type="com.webcohesion.enunciate.api.InterfaceDescriptionFile" --] +[#-- @ftlvariable name="favicon" type="java.lang.String" --] +[#-- @ftlvariable name="includeApplicationPath" type="java.lang.Boolean" --] +[#-- @ftlvariable name="includeDataTypesHomeIndex" type="java.lang.Boolean" --] +[#--set up the subnavigation menus--] +[#assign nav_sections = { } /] +[#if resourceApis?size > 0] + [#assign nav_sections = nav_sections + { "Resources" : "resources.html" }/] +[/#if] +[#if serviceApis?size > 0] + [#assign nav_sections = nav_sections + { "Services" : "services.html" }/] +[/#if] +[#if data?size > 0] + [#list data as syntax] + [#assign nav_sections = { syntax.label : syntax.slug + ".html" } /] + [/#list] +[/#if] +[#if downloads?size > 0] + [#assign nav_sections = nav_sections + { "Files and Libraries" : "downloads.html"} /] +[/#if] +[#--Basic boilerplate macro.--] +[#macro boilerplate title=title breadcrumbs=[{"title" : "Home", "href" : indexPageName}] pagenav=[] codeblocks=true] + + + + + + + + + ${title} + + + + + + + + [#if cssFile??] + + + [/#if] + [#list additionalCssFiles as additionalCssFile] + + [/#list] + [#if favicon??] + + + [/#if] + + + + + + +
+ D4Science + D4Science + + Don't have a D4Science account? + + Create one +
+ + + +
+
+ + +
+ + + [#nested/] + +
+
+

[#if copyright??]Copyright © ${copyright}. [/#if]Generated by Enunciate.

+
+
+ +
+
+
+ + + + + + + + + + + + + + +[/#macro] +[#--Macro that wraps its text in a deprecated tag if the element is deprecated.--] +[#macro deprecation element] + [#assign deprecated=(element?? && element.deprecated??)/] + [#if deprecated][/#if][#nested/][#if deprecated][/#if] +[/#macro] +[@file name=indexPageName] + [#assign pagenav=[]/] + [#if resourceApis?size > 0] + [#assign pagenav=pagenav + [{ "href" : "#resources", "title" : "Resources" }]/] + [/#if] + [#if serviceApis?size > 0] + [#assign pagenav=pagenav + [{ "href" : "#services", "title" : "Services" }]/] + [/#if] + [#list data as syntax] + [#assign pagenav=pagenav + [{ "href" : "#" + syntax.slug, "title" : syntax.label }]/] + [/#list] + [@boilerplate pagenav=pagenav] + [#if apiDoc??] + + [/#if] + [#if resourceApis?size > 0] + +

Resources

+ [#list resourceApis as resourceApi] + [#if downloads?size > 0] + +

+ The resources use a data model that is supported by a set of client-side libraries that are made available on the + files and libraries page. +

+ [/#if] + [#if resourceApi.wadlFile??] + +

+ There is a WADL document available that describes the resources API. +

+ [/#if] + [#if swaggerUI??] + +

+ You may also enjoy the interactive interface provided for this API by Swagger. +

+

+ Try it out! +

+ [/#if] + + + + + [#if resourceApi.includeResourceGroupName!false] + + [/#if] + + + + + + + [#list resourceApi.resourceGroups as resourceGroup] + [@processResourceGroup resourceGroup=resourceGroup/] + + [#if resourceApi.includeResourceGroupName!false] + + [/#if] + + + + + [/#list] + +
namepathmethodsdescription
[@deprecation element=resourceGroup]${resourceGroup.label}[/@deprecation]
    [#list resourceGroup.paths as path]
  • [@deprecation element=resourceGroup][#if ((includeApplicationPath!false) && (resourceGroup.relativeContextPath?has_content))]/${resourceGroup.relativeContextPath}[/#if]${path.path}[/@deprecation]
  • [/#list]
    [#list resourceGroup.paths as path]
  • [@deprecation element=resourceGroup][#list path.methods as method]${method} [/#list][/@deprecation]
  • [/#list]
[@deprecation element=resourceGroup]${resourceGroup.description!" "}[/@deprecation]
+ [/#list] + [/#if] + [#if serviceApis?size > 0] + +

Services

+ [#list serviceApis as serviceApi] + [#list serviceApi.serviceGroups as serviceGroup] + + + + + + + + + + + [#list serviceGroup.services as service] + [@processService service=service/] + + + + + [/#list] + +
Namespace ${serviceGroup.namespace!"(Default)"}[#if serviceGroup.wsdlFile??] (wsdl)[/#if]
namedescription
[@deprecation element=service]${service.label}[/@deprecation][@deprecation element=service]${service.description!" "}[/@deprecation]
+ [/#list] + [/#list] + [#if downloads?size > 0] + +

The services API is also accessible by a set of client-side libraries that can be downloaded from the files and libraries page.

+ [/#if] + [/#if] + [#if data?size > 0 && includeDataTypesHomeIndex] + +

Data Types

+ [#list data as syntax] + [@processDataSyntax syntax=syntax/] + +

${syntax.label}

+ [#list syntax.namespaces as ns] + [#if ns.types?size > 0] + + + [#if ns.uri??] + [#if ns.uri?length > 0] + + [#else] + + [/#if] + [/#if] + + + + + + + + [#list ns.types as type] + + + + + [/#list] + +
Namespace ${ns.uri}[#if ns.schemaFile??] (schema)[/#if]Default Namespace [#if ns.schemaFile??] (schema)[/#if]
typedescription
[@deprecation element=type]${type.label}[/@deprecation][@deprecation element=type]${type.description}[/@deprecation]
+ [/#if] + [/#list] + [/#list] + [#elseif data?size > 0] + [#list data as syntax] + [@processDataSyntax syntax=syntax/] + [/#list] + [/#if] + [/@boilerplate] +[/@file] +[@file name="data.html"] + [#assign pagenav=[]/] + [#list data as syntax] + [#assign pagenav=pagenav + [{ "href" : "#" + syntax.slug, "title" : syntax.label }]/] + [/#list] + [@boilerplate title=title + ": Data Types" breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : "Data Types" , "href" : "data.html"}] pagenav=pagenav] +

Data Types

+ [#list data as syntax] + +

${syntax.label}

+ [#list syntax.namespaces as ns] + [#if ns.types?size > 0] + + + [#if ns.uri??] + [#if ns.uri?length > 0] + + [#else] + + [/#if] + [/#if] + + + + + + + + [#list ns.types as type] + + + + + [/#list] + +
Namespace ${ns.uri}[#if ns.schemaFile??] (schema)[/#if]Default Namespace [#if ns.schemaFile??] (schema)[/#if]
typedescription
[@deprecation element=type]${type.label}[/@deprecation][@deprecation element=type]${type.description}[/@deprecation]
+ [/#if] + [/#list] + [/#list] + [/@boilerplate] +[/@file] +[#if downloads?size > 0] + [@file name="downloads.html"] + [#assign pagenav=[]/] + [#list downloads as download] + [#assign pagenav=pagenav + [{ "href" : "#" + download.slug, "title" : download.name }]/] + [/#list] + [@boilerplate title=title + ": Files and Libraries" breadcrumbs=[{"title" : "Home", "href" : indexPageName}, { "title" : "Files and Libraries" , "href" : "downloads.html"}] codeblocks=true pagenav=pagenav] +

Files and Libraries

+ + [#list downloads as download] +

${download.name}

+ [#if download.created??] +

Created ${download.created?date?string.long}

+ [/#if] + [#if download.artifactId??] +
+ [#if download.groupId??] +
groupId
+
${download.groupId}
+ [/#if] + [#if download.artifactId??] +
artifactId
+
${download.artifactId}
+ [/#if] + [#if download.version??] +
version
+
${download.version}
+
+ [/#if] + [/#if] + [#if download.description??] +

${download.description}

+ [/#if] + + + + + + + + + + + [#list download.files as file] + + + + + + [/#list] + +
Files
namesizedescription
${file.name}${file.size}${file.description!download.description!" "}
+ [/#list] + [/@boilerplate] + [/@file] +[/#if] +[#if resourceApis?size > 0] + [@file name="resources.html"] + [@boilerplate title=title + ": Resources" breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : "Resources" , "href" : "resources.html"}]] +

Resources

+ + [#list resourceApis as resourceApi] + [#if downloads?size > 0] +

+ The resources use a data model that is supported by a set of client-side libraries that are made available on the + files and libraries page. +

+ [/#if] + [#if resourceApi.wadlFile??] +

+ There is a WADL document available that describes the resources API. +

+ [/#if] + [#if swaggerUI??] +

+ You may also enjoy the interactive interface provided for this API by Swagger. +

+

+ Try it out! +

+ [/#if] + + + + [#if resourceApi.includeResourceGroupName!false] + + [/#if] + + + + + + + [#list resourceApi.resourceGroups as resourceGroup] + + [#if resourceApi.includeResourceGroupName!false] + + [/#if] + + + + + [/#list] + +
namepathmethodsdescription
[@deprecation element=resourceGroup]${resourceGroup.label}[/@deprecation]
    [#list resourceGroup.paths as path]
  • [@deprecation element=resourceGroup][#if ((includeApplicationPath!false) && (resourceGroup.relativeContextPath?has_content))]/${resourceGroup.relativeContextPath}[/#if]${path.path}[/@deprecation]
  • [/#list]
    [#list resourceGroup.paths as path]
  • [@deprecation element=resourceGroup][#list path.methods as method]${method} [/#list][/@deprecation]
  • [/#list]
[@deprecation element=resourceGroup]${resourceGroup.description!" "}[/@deprecation]
+ [/#list] + [/@boilerplate] + [/@file] +[/#if] +[#if serviceApis?size > 0] + [@file name="services.html"] + [@boilerplate title=title + ": Services" breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : "Services" , "href" : "services.html"}]] +

Services

+ [#list serviceApis as serviceApi] + [#list serviceApi.serviceGroups as serviceGroup] + + + + + + + + + + + [#list serviceGroup.services as service] + + + + + [/#list] + +
Namespace ${serviceGroup.namespace}[#if serviceGroup.wsdlFile??] (wsdl)[/#if]
namedescription
[@deprecation element=service]${service.label}[/@deprecation][@deprecation element=service]${service.description!" "}[/@deprecation]
+ [/#list] + [/#list] + [#if downloads?size > 0] + +

The services API is also accessible by a set of client-side libraries that can be downloaded from the files and libraries page.

+ [/#if] + [/@boilerplate] + [/@file] +[/#if] +[#macro processResourceGroup resourceGroup] + [#assign pagenav=[]/] + [#list resourceGroup.resources as resource] + [#list resource.methods as method] + [#assign path=resource.path/] + [#if ((includeApplicationPath!false) && (resourceGroup.relativeContextPath?has_content))] + [#assign path="/" + resourceGroup.relativeContextPath + resource.path/] + [/#if] + [#assign pagenav=pagenav + [{ "href" : "#" + method.slug, "title" : method.label + " " + path }]/] + [/#list] + [/#list] + [#-- @ftlvariable name="resourceGroup" type="com.webcohesion.enunciate.api.resources.ResourceGroup" --] + [@file name=resourceGroup.slug + ".html"] + [@boilerplate title=title + ": " + resourceGroup.label breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : "Resources" , "href" : "resources.html"}, {"title" : resourceGroup.label , "href" : resourceGroup.slug + ".html"}] pagenav=pagenav] +

${resourceGroup.label} Resource

+ [#if resourceGroup.description??] + +

${resourceGroup.description}

+ [/#if] + [#list resourceGroup.resources as resource] + [#if resource.since?? || resource.version?? || resource.seeAlso??] + +
+ [#if resource.since??] +
Available Since
+
${resource.since}
+ [/#if] + [#if resource.version??] +
Version
+
${resource.version}
+ [/#if] + [#if resource.seeAlso??] + [#list resource.seeAlso as seeAlso] +
See Also
+
${seeAlso}
+ [/#list] + [/#if] +
+ [/#if] + [#list resource.methods as method] + +
+

${method.label} [#if ((includeApplicationPath!false) && (resourceGroup.relativeContextPath?has_content))]/${resourceGroup.relativeContextPath}[/#if]${resource.path}[#if !disableResourceLinks!false] [/#if]

+ [#if resourceGroup.deprecated?? || method.deprecated??] + +
This method has been deprecated. [#if method.deprecated??] ${method.deprecated!""}[#else] ${resource.deprecated!""}[/#if]
+ [/#if] + [#if method.description??] + +

${method.description}

+ [/#if] + [#-- would be nice to enable a "Try it out" link to Swagger. See https://github.com/swagger-api/swagger-spec/issues/239 + [#if swaggerUI??] + +

Try it out!

+ [/#if] + --] + [#assign securityRoles=method.securityRoles![]/] + [#if (method.since?? || method.version?? || method.seeAlso?? || securityRoles?size > 0)] + +
+ [#if method.since??] +
Available Since
+
${method.since}
+ [/#if] + [#if method.version??] +
Version
+
${method.version}
+ [/#if] + [#if securityRoles?size > 0] +
Security Roles Allowed
+
[#list securityRoles as role]${role}[#if role_has_next], [/#if][/#list]
+ [/#if] + [#if method.seeAlso??] + [#list method.seeAlso as seeAlso] +
See Also
+
${seeAlso}
+ [/#list] + [/#if] +
+ [/#if] + [#if method.parameters?size > 0] + + + + + + + + + [#assign includeDefault=method.includeDefaultParameterValues/] + [#if includeDefault] + + [/#if] + [#assign includeConstraints=method.hasParameterConstraints/] + [#if includeConstraints] + + [/#if] + [#assign includeMultiplicity=method.hasParameterMultiplicity/] + [#if includeMultiplicity] + + [/#if] + + + + [#list method.parameters as parameter] + + + + + [#if includeDefault] + + [/#if] + [#if includeConstraints] + + [/#if] + [#if includeMultiplicity] + + [/#if] + + [/#list] + +
Request Parameters
nametypedescriptiondefaultconstraintsmultivalued
${parameter.name}${parameter.typeLabel}${parameter.description!" "}${parameter.defaultValue!" "}${parameter.constraints!" "}${parameter.multivalued?string("yes", "no")}
+ [/#if] + [#if method.requestEntity??] + + + + + + + + [#if method.requestEntity.description??] + + [/#if] + + + + [#list method.requestEntity.mediaTypes as io] + + + + [#if io_index = 0 && method.requestEntity.description??] + 1] rowspan="${method.requestEntity.mediaTypes?size}" class="multi-row-description"[/#if]>${method.requestEntity.description} + [/#if] + + [/#list] + +
Request Body
media typedata typedescription
${io.mediaType}[@referenceDataType referenceType=io.dataType!{"label" : "(custom)"}/][#if io.syntax??] (${io.syntax})[/#if]
+ [/#if] + [#if method.responseCodes?size > 0] + + + + + + + + [#assign hasExpectedTypes=false/] + [#list method.responseCodes as responseCode] + [#if responseCode.mediaTypes?size > 0] + [#assign hasExpectedTypes=true/] + [/#if] + [/#list] + [#if hasExpectedTypes] + + [/#if] + + + + [#list method.responseCodes as responseCode] + + + + [#if hasExpectedTypes] + + [/#if] + + [/#list] + +
Response Codes
codeconditiontype
${responseCode.code}${responseCode.condition!""}
    [#list responseCode.mediaTypes as io]
  • [@referenceDataType referenceType=io.dataType!{"label" : "(custom)"}/][#if io.syntax??] (${io.syntax})[/#if]
  • [/#list]
+ [/#if] + [#if method.responseEntity??] + + + + + + + + [#if method.responseEntity.description??] + + [/#if] + + + + [#list method.responseEntity.mediaTypes as io] + + + + [#if io_index = 0 && method.responseEntity.description??] + 1] rowspan="${method.responseEntity.mediaTypes?size}" class="multi-row-description"[/#if]>${method.responseEntity.description} + [/#if] + + [/#list] + +
Response Body
media typedata typedescription
${io.mediaType}[@referenceDataType referenceType=io.dataType!{"label" : "(custom)"}/][#if io.syntax??] (${io.syntax})[/#if]
+ [/#if] + [#if method.warnings?size > 0] + + + + + + + + + + + [#list method.warnings as responseCode] + + + + + [/#list] + +
Response Warnings
codecondition
${responseCode.code}${responseCode.condition!""}
+ [/#if] + [#if method.responseHeaders?size > 0] + + + + + + + + + + + [#list method.responseHeaders as header] + + + + + [/#list] + +
Response Headers
namedescription
${header.name}${header.description!" "}
+ + [/#if] + [#if method.example??] +

Example

+ +
+
+
+
Request
+
+${method.example.requestHeaders?xhtml}
+            [#if method.example.requestLang??]
+                
+${method.example.requestBody?xhtml}
+                
+            [/#if]
+              
+
+
+
Response
+
+${method.example.responseHeaders?xhtml}
+            [#if method.example.responseLang??]
+                
+${method.example.responseBody?xhtml}
+                
+            [/#if]
+              
+
+
+
+ [/#if] +
+ [/#list] + [/#list] + [/@boilerplate] + [/@file] +[/#macro] +[#macro processService service] + [#assign pagenav=[]/] + [#list service.operations as operation] + [#assign pagenav=pagenav + [{ "href" : "#" + operation.slug, "title" : operation.name }]/] + [/#list] + [#-- @ftlvariable name="service" type="com.webcohesion.enunciate.api.services.Service" --] + [@file name=service.slug + ".html"] + [@boilerplate title=title + ": " + service.label breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : service.label , "href" : service.slug + ".html"}] pagenav=pagenav] +

${service.label} Service

+ [#if service.deprecated??] + +
This service has been deprecated. ${service.deprecated}
+ [/#if] + [#if service.description??] + +

${service.description}

+ [/#if] + +
+ [#if service.namespace?? && service.namespace?length > 0] +
Namespace
+
${service.namespace}
+ [/#if] + [#if service.group.wsdlFile??] +
WSDL
+
${service.group.wsdlFile.href}
+ [/#if] + [#if service.path??] +
Path
+
${service.path}
+ [/#if] + [#if service.since??] +
Available Since
+
${service.since}
+ [/#if] + [#if service.version??] +
Version
+
${service.version}
+ [/#if] + [#if service.seeAlso??] + [#list service.seeAlso as seeAlso] +
See Also
+
${seeAlso}
+ [/#list] + [/#if] +
+ [#list service.operations as operation] + +

${operation.name} Operation

+ [#if operation.deprecated??] + +
This method has been deprecated. ${operation.deprecated}
+ [/#if] + [#if operation.description??] + +

${operation.description}

+ [/#if] + [#if (operation.since?? || operation.version?? || operation.seeAlso??)] + +
+ [#if operation.since??] +
Available Since
+
${operation.since}
+ [/#if] + [#if operation.version??] +
Version
+
${operation.version}
+ [/#if] + [#if operation.seeAlso??] + [#list operation.seeAlso as seeAlso] +
See Also
+
${seeAlso}
+ [/#list] + [/#if] +
+ [/#if] + [#if operation.inputParameters?size > 0] + + + + + + + + + + + + [#list operation.inputParameters as parameter] + + + + + + [/#list] + +
Input Parameters
nametypedescription
${parameter.name}[@referenceDataType referenceType=parameter.dataType/]${parameter.description!" "}
+ [/#if] + [#if operation.httpRequestHeaders?size > 0] + + + + + + + + + + + + [#list operation.httpRequestHeaders as parameter] + + + + + + [/#list] + +
HTTP Request Headers
nametypedescription
${parameter.name}[@referenceDataType referenceType=parameter.dataType/]${parameter.description!" "}
+ [/#if] + [#if operation.outputParameters?size > 0] + + + + + + + + + + + + [#list operation.outputParameters as parameter] + + + + + + [/#list] + +
Output Parameters
nametypedescription
${parameter.name}[@referenceDataType referenceType=parameter.dataType/]${parameter.description!" "}
+ [/#if] + [#if operation.returnType??] + + + + + + + + + + + + + + + +
Return Value
typedescription
[@referenceDataType referenceType=operation.returnType/]${operation.returnDescription!" "}
+ [/#if] + [#if operation.faults?size > 0] + + + + + + + + + + + + [#list operation.faults as fault] + + + + + + [/#list] + +
Faults
nametypeconditions
${fault.name}[@referenceDataType referenceType=fault.dataType/]${fault.conditions!" "}
+ [/#if] + [/#list] + [/@boilerplate] + [/@file] +[/#macro] +[#macro processDataSyntax syntax] + [#-- @ftlvariable name="syntax" type="com.webcohesion.enunciate.api.datatype.Syntax" --] + [@file name=syntax.slug + ".html"] + [@boilerplate title=title + ": " + syntax.label breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : syntax.label , "href" : syntax.slug + ".html"} ]] +

${syntax.label}

+ [#list syntax.namespaces as ns] + [#if ns.types?size > 0] + + + [#if ns.uri??] + [#if ns.uri?length > 0] + + [#else] + + [/#if] + [/#if] + + + + + + + + [#list ns.types as type] + [@processDataType type=type/] + + + + + [/#list] + +
Namespace ${ns.uri}[#if ns.schemaFile??] (schema)[/#if]Default Namespace [#if ns.schemaFile??] (schema)[/#if]
typedescription
[@deprecation element=type]${type.label}[/@deprecation][@deprecation element=type]${type.description}[/@deprecation]
+ [/#if] + [/#list] + [/@boilerplate] + [/@file] +[/#macro] +[#macro processDataType type] + [#-- @ftlvariable name="type" type="com.webcohesion.enunciate.api.datatype.DataType" --] + [#assign pagenav=[]/] + [#if type.values??] + [#list type.values as value] + [#assign pagenav=pagenav + [{ "href" : "#" + value.value, "title" : value.value }]/] + [/#list] + [/#if] + [@file name=type.slug + ".html"] + [@boilerplate title=title + ": " + type.label breadcrumbs=[{"title" : "Home", "href" : indexPageName}, {"title" : type.syntax.label , "href" : type.syntax.slug + ".html"}, {"title" : type.label , "href" : type.slug + ".html"} ] pagenav=pagenav codeblocks=true] +

${type.label} Data Type

+ [#if type.deprecated??] + +
This data type has been deprecated. ${type.deprecated}
+ [/#if] + [#if type.description??] + +

${type.description}

+ [/#if] + +
+ [#if type.namespace.uri??] +
Namespace
+ [#if type.namespace.uri?length > 0] +
${type.namespace.uri}
+ [#else] +
(Default)
+ [/#if] + [/#if] + [#if type.namespace.schemaFile??] +
Schema
+
${type.namespace.schemaFile.href}
+ [/#if] + [#if type.since??] +
Available Since
+
${type.since}
+ [/#if] + [#if type.version??] +
Version
+
${type.version}
+ [/#if] + [#if type.abstract] +
Abstract Type
+
+ [/#if] + [#if type.subtypes??] +
Subtypes
+
[#list type.subtypes as subtype][#if subtype.slug??]${subtype.label}[#else]${subtype.label}[/#if][#if subtype_has_next], [/#if][/#list]
+ [/#if] + [#if type.interfaces??] +
Implemented Interfaces
+
[#list type.interfaces as iface]${iface.label}[#if iface_has_next], [/#if][/#list]
+ [/#if] + [#if type.seeAlso??] + [#list type.seeAlso as seeAlso] +
See Also
+
${seeAlso}
+ [/#list] + [/#if] +
+ [#if type.values??] + + + + + + + + + + + [#list type.values as value] + + + + + [/#list] + +
Values
valuedescription
${value.value}[#if value.since??]since ${value.since} [/#if]${value.description!" "}
+ [/#if] + [#if type.properties??] + + + + + + + + [#list type.propertyMetadata?keys as meta] + + [/#list] + + + + + [#list type.properties as property] + + + + [#list type.propertyMetadata?keys as meta] + + [/#list] + + + [/#list] + + [#if type.supertypes??] + [#list type.supertypes as supertype] + [#if supertype.value?? && supertype.value.properties?? && supertype.value.properties?size > 0] + + + + + [#list supertype.value.properties as superProperty] + + + + [#list type.propertyMetadata?keys as meta] + + [/#list] + + + [/#list] + + [/#if] + [/#list] + [/#if] +
Properties
namedata type${type.propertyMetadata[meta]}description
[@deprecation element=property]${property.name}[/@deprecation][@deprecation element=property][@referenceDataType referenceType=property.dataType/][/@deprecation][@deprecation element=property][@printPropertyMetadata property=property meta=meta/][/@deprecation][@deprecation element=property][#if property.since??]since ${property.since} [/#if]${property.description!" "}[/@deprecation]
Properties inherited from ${supertype.label}
${superProperty.name}[@referenceDataType referenceType=superProperty.dataType/][@printPropertyMetadata property=superProperty meta=meta/][#if superProperty.since??]since ${superProperty.since} [/#if]${superProperty.description!" "}
+ [/#if] + [#if type.example??] + +

Example

+ [#if type.abstract && type.subtypes?? ] + +
This data type is abstract. The example below may be incomplete. More accurate examples can be found in subtypes pages.
+ [/#if] + +
${type.example.body?xhtml}
+ [/#if] + [/@boilerplate] + [/@file] +[/#macro] +[#macro referenceDataType referenceType] +[#-- @ftlvariable name="type" type="com.webcohesion.enunciate.api.datatype.DataTypeReference" --] +[#if referenceType.containers??][#list referenceType.containers as container]${container?string} of [/#list][/#if][#if referenceType.slug??][/#if]${referenceType.label!"(custom)"}[#if referenceType.slug??][/#if] +[/#macro] +[#macro printPropertyMetadata property meta] + [#assign metaValue=property[meta]!({ "structure" : true })/] + [#if metaValue?is_hash && metaValue.structure!false] +[#if metaValue.href??][/#if][#if metaValue.title??][/#if]${metaValue.value!" "}[#if metaValue.title??][/#if][#if metaValue.href??][/#if] + [#else] +${metaValue} + [/#if] +[/#macro] \ No newline at end of file diff --git a/src/main/resources/META-INF/d4science_enunciate_custom.css b/src/main/resources/META-INF/d4science_enunciate_custom.css new file mode 100644 index 0000000..9dae183 --- /dev/null +++ b/src/main/resources/META-INF/d4science_enunciate_custom.css @@ -0,0 +1,25 @@ +.d4science_intro { + top: 0; + z-index: 2000; + position: fixed; + display: block ruby; + padding: 10px; + background: white; + width: 100%; +} + +.navbar-fixed-top { + top: 100px !important; +} + +.sidebar { + top: 160px !important; +} + +.navbar { + margin-bottom: 40px !important; +} + +.main { + top: 90px; +} \ No newline at end of file -- 2.17.1 From eba3ee5635ff3197c0ade659a719b76b92ff0e61 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 13:28:30 +0200 Subject: [PATCH 47/58] updated css --- enunciate.xml | 2 +- .../META-INF/{ => enunciate/css}/d4science_enunciate_custom.css | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/resources/META-INF/{ => enunciate/css}/d4science_enunciate_custom.css (100%) diff --git a/enunciate.xml b/enunciate.xml index 6abbcac..4fa1610 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -29,7 +29,7 @@ + file="${project.basedir}/src/main/resources/META-INF/enunciate/css/d4science_enunciate_custom.css" /> diff --git a/src/main/resources/META-INF/d4science_enunciate_custom.css b/src/main/resources/META-INF/enunciate/css/d4science_enunciate_custom.css similarity index 100% rename from src/main/resources/META-INF/d4science_enunciate_custom.css rename to src/main/resources/META-INF/enunciate/css/d4science_enunciate_custom.css -- 2.17.1 From 041cb24c3bbf2d0b2886dc147d06e4fbcadf0404 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 14:32:29 +0200 Subject: [PATCH 48/58] updated enunciate css location --- enunciate.xml | 4 ++-- .../resources/META-INF/{ => enunciate}/d4science_docs.fmt | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename src/main/resources/META-INF/{ => enunciate}/d4science_docs.fmt (100%) diff --git a/enunciate.xml b/enunciate.xml index 4fa1610..ac0ddb9 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -27,9 +27,9 @@ /gcat, /uri-resolver /> --> + freemarkerTemplate="${project.basedir}/src/main/resources/META-INF/enunciate/d4science_docs.fmt"> + file="../WEB-INF/classes/META-INF/enunciate/css/d4science_enunciate_custom.css" /> diff --git a/src/main/resources/META-INF/d4science_docs.fmt b/src/main/resources/META-INF/enunciate/d4science_docs.fmt similarity index 100% rename from src/main/resources/META-INF/d4science_docs.fmt rename to src/main/resources/META-INF/enunciate/d4science_docs.fmt -- 2.17.1 From 0b6db6bb580b3bcf60b6c2b860598de05dfe083e Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 14:48:22 +0200 Subject: [PATCH 49/58] tried to fix location of d4science_enunciate_custom.css --- enunciate.xml | 2 +- .../enunciate/css/d4science_enunciate_custom.css | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/{resources/META-INF => webapp}/enunciate/css/d4science_enunciate_custom.css (100%) diff --git a/enunciate.xml b/enunciate.xml index ac0ddb9..1ea8160 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -29,7 +29,7 @@ + file="../enunciate/css/d4science_enunciate_custom.css" /> diff --git a/src/main/resources/META-INF/enunciate/css/d4science_enunciate_custom.css b/src/main/webapp/enunciate/css/d4science_enunciate_custom.css similarity index 100% rename from src/main/resources/META-INF/enunciate/css/d4science_enunciate_custom.css rename to src/main/webapp/enunciate/css/d4science_enunciate_custom.css -- 2.17.1 From 9d28699bc811fc2a01dd35bb88b2966f9f0a189b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 14:54:16 +0200 Subject: [PATCH 50/58] trying to fix css position --- enunciate.xml | 6 ++++-- .../{enunciate => docs}/css/d4science_enunciate_custom.css | 0 2 files changed, 4 insertions(+), 2 deletions(-) rename src/main/webapp/{enunciate => docs}/css/d4science_enunciate_custom.css (100%) diff --git a/enunciate.xml b/enunciate.xml index 1ea8160..435b83a 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -28,8 +28,10 @@ - + + + diff --git a/src/main/webapp/enunciate/css/d4science_enunciate_custom.css b/src/main/webapp/docs/css/d4science_enunciate_custom.css similarity index 100% rename from src/main/webapp/enunciate/css/d4science_enunciate_custom.css rename to src/main/webapp/docs/css/d4science_enunciate_custom.css -- 2.17.1 From f857c3a784854991ad73c68aef227cabde7964e3 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 15:24:46 +0200 Subject: [PATCH 51/58] updated CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 959df85..586d5a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - [#23049] Integrate Enunciate engine for Java Web service API (https://github.com/stoicflame/enunciate/) - [#20743] Integrate JavaMelody +- [#23105] Added D4Science brand in the APIs Documentation pages ## [v2-7.0-SNAPSHOT] - 2022-01-31 -- 2.17.1 From 86b9fdd95adb89f0bd772840deb5c74c31b83c38 Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Fri, 1 Apr 2022 17:28:19 +0200 Subject: [PATCH 52/58] updated the D4Science Template --- enunciate.xml | 11 ++++------- .../resources/META-INF/enunciate/d4science_docs.fmt | 6 +++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/enunciate.xml b/enunciate.xml index 435b83a..fec0ed6 100644 --- a/enunciate.xml +++ b/enunciate.xml @@ -23,15 +23,12 @@ - - + + - - - + diff --git a/src/main/resources/META-INF/enunciate/d4science_docs.fmt b/src/main/resources/META-INF/enunciate/d4science_docs.fmt index 4d3b10f..a5ee6ab 100644 --- a/src/main/resources/META-INF/enunciate/d4science_docs.fmt +++ b/src/main/resources/META-INF/enunciate/d4science_docs.fmt @@ -90,10 +90,14 @@
D4Science D4Science - + Don't have a D4Science account? Create one + + Could not find what you are looking for? + + Contact us.