Compare commits
6 Commits
master
...
feature_23
Author | SHA1 | Date |
---|---|---|
Francesco Mangiacrapa | 89d3c847b4 | |
Francesco Mangiacrapa | 71a1b52478 | |
Francesco Mangiacrapa | 20d9a782bf | |
Francesco Mangiacrapa | 25f54f122c | |
Francesco Mangiacrapa | ca07d7ae0e | |
Francesco Mangiacrapa | cda5599d27 |
10
.classpath
10
.classpath
|
@ -24,16 +24,16 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
||||
|
|
5
.project
5
.project
|
@ -30,11 +30,6 @@
|
|||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.springframework.ide.eclipse.boot.validation.springbootbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
|
|
|
@ -10,99 +10,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.10.0">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-module deploy-name="uri-resolver-2.8.1-SNAPSHOT">
|
||||
|
||||
|
||||
|
||||
|
@ -126,52 +34,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
|
||||
|
||||
|
||||
|
@ -184,52 +46,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
|
||||
|
||||
|
||||
|
@ -242,105 +58,7 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
|
||||
<dependent-module archiveName="geoportal-client-1.2.2.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-client/geoportal-client">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module archiveName="geoportal-common-1.1.1.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/geoportal-common/geoportal-common">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -364,52 +82,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<property name="java-output-path" value="/uri-resolver/target/classes"/>
|
||||
|
||||
|
||||
|
@ -422,52 +94,6 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</wb-module>
|
||||
|
||||
|
||||
|
@ -480,50 +106,4 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</project-modules>
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
boot.validation.initialized=true
|
||||
eclipse.preferences.version=1
|
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -4,21 +4,7 @@
|
|||
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.10.0]
|
||||
|
||||
- GeoPortal-Resolver enhancement: implemented share link towards Geoportal Data-Entry facility [#27135]
|
||||
- Added Geoportal Exporter as PDF [#27274]
|
||||
- Migrated to `catalogue-util-library` [#27423]
|
||||
- Included new SHUB client library [#27944]
|
||||
- Moved to `gcube-smartgears-bom 2.5.1{-SNAPSHOT}` [#28026]
|
||||
- Bug fixing StorageID resolver [#28276]
|
||||
- Added HealthCheckResponse via `microprofile-health-api` (see https://microprofile.io/specifications/microprofile-health/)
|
||||
|
||||
## [v2.9.0]
|
||||
|
||||
- GeoPortal-Resolver implemented [#24792]
|
||||
|
||||
## [v2.8.1] - 2022-06-13
|
||||
## [v2.8.1-SNAPSHOT] - 2022-06-13
|
||||
|
||||
**New**
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
# gCube URI Resolver
|
||||
|
||||
The URI Resolver is a RESTful service which gives access via HTTP(s) to different gCube Resolver services and gCube Applications.
|
||||
|
||||
The URI Resolver production service is available at [D4Science URI Resolver](https://data.d4science.org/)
|
||||
The URI Resolver is a RESTful service which gives access via HTTP(s) to different gCube Resolver services and gCube Applications
|
||||
|
||||
## Built With
|
||||
|
||||
|
@ -13,7 +11,7 @@ The URI Resolver production service is available at [D4Science URI Resolver](htt
|
|||
|
||||
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 this [link](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
|
||||
|
||||
|
|
133
pom.xml
133
pom.xml
|
@ -5,11 +5,11 @@
|
|||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.2.0</version>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
<groupId>org.gcube.data.transfer</groupId>
|
||||
<artifactId>uri-resolver</artifactId>
|
||||
<version>2.10.0</version>
|
||||
<version>2.8.1-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<description>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.</description>
|
||||
|
||||
|
@ -19,44 +19,8 @@
|
|||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
|
||||
<profiles>
|
||||
<!-- PROD profile -->
|
||||
<profile>
|
||||
<id>uri-resolver-release-profile</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>Release</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<!-- <gcube-bom>2.4.0</gcube-bom> -->
|
||||
<gcube-smartgears-bom-version>2.5.1</gcube-smartgears-bom-version>
|
||||
<authorization-utils-range>[2.0.0, 3.0.0-SNAPSHOT)</authorization-utils-range>
|
||||
</properties>
|
||||
</profile>
|
||||
<!-- DEV profile -->
|
||||
<profile>
|
||||
<id>uri-resolver-snapshot-profile</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>!Release</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<!-- <gcube-bom>2.4.1-SNAPSHOT</gcube-bom> -->
|
||||
<gcube-smartgears-bom-version>2.5.1-SNAPSHOT</gcube-smartgears-bom-version>
|
||||
<authorization-utils-range>[2.0.0, 3.0.0-SNAPSHOT)</authorization-utils-range>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<properties>
|
||||
<jersey.version>2.25.1</jersey.version>
|
||||
<!-- Using 2.8.4 because storagehub-model.1.1.1 uses indirectly this version
|
||||
via jsersey-media-json -->
|
||||
<jackson.version>2.8.4</jackson.version>
|
||||
<jersey.version>2.24.1</jersey.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<enunciate.version>2.14.0</enunciate.version>
|
||||
|
@ -67,14 +31,13 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>${gcube-smartgears-bom-version}</version>
|
||||
<version>2.1.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
|
@ -82,13 +45,6 @@
|
|||
<artifactId>common-smartgears</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.microprofile.health</groupId>
|
||||
<artifactId>microprofile-health-api</artifactId>
|
||||
<version>4.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-smartgears-app</artifactId>
|
||||
|
@ -102,13 +58,13 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
<version>[3.0.0, 4.0.0-SNAPSHOT)</version>
|
||||
<version>[3.0.0-SNAPSHOT, 4.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
<version>[3.0.0,4.0.0-SNAPSHOT)</version>
|
||||
<version>[3.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
|
@ -120,7 +76,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data-publishing</groupId>
|
||||
<artifactId>storagehub-application-persistence</artifactId>
|
||||
<version>[1.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -133,7 +89,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.data.analysis</groupId>
|
||||
<artifactId>dataminer-invocation-model</artifactId>
|
||||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -142,12 +98,6 @@
|
|||
<version>[1.0.0,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-utils</artifactId>
|
||||
<version>${authorization-utils-range}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
@ -173,6 +123,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>storagehub-client-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -181,6 +132,7 @@
|
|||
<version>${jersey.version}</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-server</artifactId>
|
||||
|
@ -188,25 +140,6 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- java melody -->
|
||||
<dependency>
|
||||
<groupId>net.bull.javamelody</groupId>
|
||||
|
@ -254,20 +187,10 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- FOR BUILDING towards JDK_11 -->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<!-- <version>2.3.0</version> -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- FOR BUILDING towards JDK_11 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<!-- <version>1.18.4</version> -->
|
||||
<scope>provided</scope>
|
||||
<version>1.14.8</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
@ -279,15 +202,6 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- THIS ONE IS NOT A DIRECT DEPENDENCY OF URI-RESOLVER IT IS REQUIRED
|
||||
TO BUILD -->
|
||||
<dependency>
|
||||
<groupId>org.opengis</groupId>
|
||||
<artifactId>geoapi</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
|
@ -303,33 +217,14 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.datacatalogue</groupId>
|
||||
<artifactId>catalogue-util-library</artifactId>
|
||||
<version>[1.0.0, 2.0.0-SNAPSHOT)</version>
|
||||
<groupId>org.gcube.data-catalogue</groupId>
|
||||
<artifactId>ckan-util-library</artifactId>
|
||||
<version>[2.0.0, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- END GIS RESOLVER DEPENDENCIES -->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.application</groupId>
|
||||
<artifactId>geoportal-data-mapper</artifactId>
|
||||
<version>[1.1.0, 2.0.0-SNAPSHOT)</version>
|
||||
<!-- Excluding these beacuse geoportal uses [2-3] ranges conflicting with
|
||||
[3-4] used by URI-Resolver -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-wrapper</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.gcube.contentmanagement</groupId>
|
||||
<artifactId>storage-manager-core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
|
|
|
@ -14,12 +14,10 @@ import org.glassfish.jersey.server.ResourceConfig;
|
|||
@ManagedBy(UriResolverSmartGearManagerInit.class)
|
||||
public class UriResolver extends ResourceConfig {
|
||||
|
||||
public UriResolver() {
|
||||
// Register all resources present under the package.
|
||||
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName(), BackCatalogueResolver.class.getPackage().getName());
|
||||
packages(DataMinerInvocation.class.getPackage().getName());
|
||||
//
|
||||
// register(JspMvcFeature.class);
|
||||
// property(JspMvcFeature.TEMPLATE_BASE_PATH, "/WEB-INF/img");
|
||||
}
|
||||
public UriResolver() {
|
||||
// Register all resources present under the package.
|
||||
packages(CatalogueResolver.class.getPackage().getName(), RequestHandler.class.getPackage().getName(), BackCatalogueResolver.class.getPackage().getName());
|
||||
packages(DataMinerInvocation.class.getPackage().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,15 +11,14 @@ import java.util.Set;
|
|||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.glassfish.jersey.server.model.Resource;
|
||||
import org.glassfish.jersey.server.model.ResourceMethod;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -193,9 +192,8 @@ public class UriResolverServices {
|
|||
if(listResourcePath.isEmpty()){
|
||||
log.info("Reference to the List of Resources/Services is empty, creating it...");
|
||||
readResources(applicationClasses);
|
||||
List<String> listHardCodedResources = Arrays.asList(ConstantsResolver.resourcesHardCoded);
|
||||
log.info("Hard-Coding the resource/s: "+listHardCodedResources);
|
||||
listResourcePath.addAll(listHardCodedResources);
|
||||
log.info("Hard-Coding the resource/s: "+ConstantsResolver.resourcesHardCoded);
|
||||
listResourcePath.addAll(Arrays.asList(ConstantsResolver.resourcesHardCoded));
|
||||
}
|
||||
|
||||
return listResourcePath;
|
||||
|
|
|
@ -3,34 +3,35 @@
|
|||
*/
|
||||
package org.gcube.datatransfer.resolver.catalogue;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* The Enum ResourceCatalogueCodes.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Jan 31, 2017
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Jan 31, 2017
|
||||
*
|
||||
* see wiki page:
|
||||
* https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver
|
||||
* see wiki page: https://wiki.gcube-system.org/gcube/URI_Resolver#CATALOGUE_Resolver
|
||||
*/
|
||||
public enum ResourceCatalogueCodes {
|
||||
|
||||
CTLG("ctlg", "dataset", "Catalogue Product/Dataset"),
|
||||
// CTLGP("ctlg-p","product", "Catalogue Product"),
|
||||
CTLGD("ctlg-d", "dataset", "Catalogue Dataset"), CTLGO("ctlg-o", "organization", "Catalogue Organization"),
|
||||
CTLGG("ctlg-g", "group", "Catalogue Group");
|
||||
CTLG("ctlg","dataset", "Catalogue Product/Dataset"),
|
||||
//CTLGP("ctlg-p","product", "Catalogue Product"),
|
||||
CTLGD("ctlg-d","dataset", "Catalogue Dataset"),
|
||||
CTLGO("ctlg-o","organization", "Catalogue Organization"),
|
||||
CTLGG("ctlg-g","group", "Catalogue Group");
|
||||
|
||||
private String id; // the code id
|
||||
private String value; // the code value
|
||||
private String id; //the code id
|
||||
private String value; //the code value
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Instantiates a new resource catalogue codes.
|
||||
*
|
||||
* @param id the id
|
||||
* @param value the value
|
||||
* @param id the id
|
||||
* @param value the value
|
||||
* @param description the description
|
||||
*/
|
||||
private ResourceCatalogueCodes(String id, String value, String description) {
|
||||
|
@ -49,6 +50,7 @@ public enum ResourceCatalogueCodes {
|
|||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the value.
|
||||
*
|
||||
|
@ -59,6 +61,7 @@ public enum ResourceCatalogueCodes {
|
|||
return value;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
|
@ -69,55 +72,55 @@ public enum ResourceCatalogueCodes {
|
|||
return description;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Codes.
|
||||
*
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> codes() {
|
||||
public static List<String> codes(){
|
||||
|
||||
return Arrays.asList(ResourceCatalogueCodes.values()).stream().map(ResourceCatalogueCodes::getId)
|
||||
.collect(Collectors.toList());
|
||||
List<String> codes = new ArrayList<String>(ResourceCatalogueCodes.values().length);
|
||||
for (ResourceCatalogueCodes value : ResourceCatalogueCodes.values()) {
|
||||
codes.add(value.getId());
|
||||
}
|
||||
|
||||
return codes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Value of code id.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the resource catalogue codes
|
||||
*/
|
||||
public static ResourceCatalogueCodes valueOfCodeId(String id) {
|
||||
if (id == null || id.isEmpty())
|
||||
public static ResourceCatalogueCodes valueOfCodeId(String id){
|
||||
if(id==null || id.isEmpty())
|
||||
return null;
|
||||
|
||||
List<ResourceCatalogueCodes> codes = Arrays.asList(ResourceCatalogueCodes.values()).stream()
|
||||
.filter(r -> r.getId().compareTo(id) == 0)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (codes == null || codes.isEmpty())
|
||||
return null;
|
||||
|
||||
return codes.get(0);
|
||||
|
||||
for (ResourceCatalogueCodes value : ResourceCatalogueCodes.values()) {
|
||||
if(value.id.compareTo(id)==0)
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Value of code value.
|
||||
*
|
||||
* @param codeValue the code value
|
||||
* @return the resource catalogue codes
|
||||
*/
|
||||
public static ResourceCatalogueCodes valueOfCodeValue(String codeValue) {
|
||||
if (codeValue == null || codeValue.isEmpty())
|
||||
public static ResourceCatalogueCodes valueOfCodeValue(String codeValue){
|
||||
if(codeValue==null || codeValue.isEmpty())
|
||||
return null;
|
||||
|
||||
List<ResourceCatalogueCodes> codes = Arrays.asList(ResourceCatalogueCodes.values()).stream()
|
||||
.filter(r -> r.getValue().compareTo(codeValue) == 0)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (codes == null || codes.isEmpty())
|
||||
return null;
|
||||
|
||||
return codes.get(0);
|
||||
for (ResourceCatalogueCodes rcc : ResourceCatalogueCodes.values()) {
|
||||
if(rcc.value.compareTo(codeValue)==0)
|
||||
return rcc;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import java.util.Map;
|
|||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -18,11 +18,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datacatalogue.utillibrary.jackan.CkanClient;
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.exceptions.CkanException;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueImpl;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
|
||||
import org.gcube.datatransfer.resolver.catalogue.endpoint.CatalogueServiceEndpointReader;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
|
@ -33,6 +30,10 @@ import org.slf4j.LoggerFactory;
|
|||
import org.w3c.dom.Node;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import eu.trentorise.opendata.jackan.CkanClient;
|
||||
import eu.trentorise.opendata.jackan.exceptions.CkanException;
|
||||
import eu.trentorise.opendata.jackan.model.CkanDataset;
|
||||
|
||||
|
||||
/**
|
||||
* The Class CkanCatalogueConfigurationsReader.
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.io.Serializable;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal;
|
||||
|
||||
/**
|
||||
* The Class GeoportalCommonConstants.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Dec 1, 2020
|
||||
*/
|
||||
public class GeoportalCommonConstants {
|
||||
|
||||
public static final String GET_GEONA_ITEM_TYPE = "git";
|
||||
public static final String GET_GEONA_ITEM_ID = "gid";
|
||||
|
||||
public static final String GEOPORTAL_DATA_VIEWER_APP_ID = "geoportal-data-viewer-app";
|
||||
|
||||
public static final String GEOPORTAL_DATA_ENTRY_APP_ID = "geoportal-data-entry-app";
|
||||
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The Class GeoportalConfigApplicationProfile.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 3, 2024
|
||||
*/
|
||||
public class GeoportalConfigApplicationProfile implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 8340275391003882511L;
|
||||
private String restrictedPortletURL;
|
||||
private String openPortletURL;
|
||||
|
||||
/**
|
||||
* Instantiates a new geo na data viewer profile.
|
||||
*/
|
||||
public GeoportalConfigApplicationProfile() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the restricted portlet URL.
|
||||
*
|
||||
* @return the restricted portlet URL
|
||||
*/
|
||||
public String getRestrictedPortletURL() {
|
||||
return restrictedPortletURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the restricted portlet URL.
|
||||
*
|
||||
* @param restrictedPortletURL the new restricted portlet URL
|
||||
*/
|
||||
public void setRestrictedPortletURL(String restrictedPortletURL) {
|
||||
this.restrictedPortletURL = restrictedPortletURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the open portlet URL.
|
||||
*
|
||||
* @return the open portlet URL
|
||||
*/
|
||||
public String getOpenPortletURL() {
|
||||
return openPortletURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the open portlet URL.
|
||||
*
|
||||
* @param openPortletURL the new open portlet URL
|
||||
*/
|
||||
public void setOpenPortletURL(String openPortletURL) {
|
||||
this.openPortletURL = openPortletURL;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoportalConfigApplicationProfile [restrictedPortletURL=");
|
||||
builder.append(restrictedPortletURL);
|
||||
builder.append(", openPortletURL=");
|
||||
builder.append(openPortletURL);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,179 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.client;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.gcube.common.resources.gcore.utils.XPathHelper;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileNotFoundException;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.Query;
|
||||
import org.gcube.resources.discovery.client.queries.impl.QueryBox;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
/**
|
||||
* The Class GeoportalConfigApplicationProfileReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 3, 2024
|
||||
*/
|
||||
public class GeoportalConfigApplicationProfileReader {
|
||||
|
||||
private static Logger LOG = LoggerFactory.getLogger(GeoportalConfigApplicationProfileReader.class);
|
||||
private static final String RESOURCE_PROFILE_BODY = "/Resource/Profile/Body";
|
||||
public static final String SECONDARY_TYPE = "ApplicationProfile";
|
||||
|
||||
private String secondaryType;
|
||||
private String scope;
|
||||
private String appID;
|
||||
private GeoportalConfigApplicationProfile geoportalConfigAppProfile;
|
||||
|
||||
/**
|
||||
* Instantiates a new geoportal config application profile reader.
|
||||
*
|
||||
* @param appID the app ID
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoportalConfigApplicationProfileReader(String appID) throws Exception {
|
||||
|
||||
this.appID = appID;
|
||||
this.secondaryType = SECONDARY_TYPE;
|
||||
this.scope = ScopeProvider.instance.get();
|
||||
this.geoportalConfigAppProfile = readProfileFromInfrastructure();
|
||||
}
|
||||
|
||||
/**
|
||||
* Read profile from infrastrucure.
|
||||
*
|
||||
* @return the map
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private GeoportalConfigApplicationProfile readProfileFromInfrastructure() throws Exception {
|
||||
|
||||
String queryString = getGcubeGenericQueryString(secondaryType, appID);
|
||||
LOG.info("Scope " + scope + ", trying to perform query: " + queryString);
|
||||
|
||||
try {
|
||||
|
||||
if (scope == null)
|
||||
throw new Exception("Scope is null, set scope into ScopeProvider");
|
||||
|
||||
GeoportalConfigApplicationProfile profile = new GeoportalConfigApplicationProfile();
|
||||
|
||||
LOG.info("Trying to fetch ApplicationProfile in the scope: " + scope + ", SecondaryType: " + secondaryType
|
||||
+ ", AppId: " + appID);
|
||||
Query q = new QueryBox(queryString);
|
||||
DiscoveryClient<String> client = client();
|
||||
List<String> appProfile = client.submit(q);
|
||||
// String item_fields = "";
|
||||
|
||||
if (appProfile == null || appProfile.size() == 0)
|
||||
throw new ApplicationProfileNotFoundException("ApplicationProfile with SecondaryType: " + secondaryType
|
||||
+ ", AppId: " + appID + " is not registered in the scope: " + scope);
|
||||
else {
|
||||
String elem = appProfile.get(0);
|
||||
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||
Document doc = docBuilder.parse(new InputSource(new StringReader(elem)));
|
||||
|
||||
XPathHelper helper = new XPathHelper(doc.getDocumentElement());
|
||||
|
||||
List<String> currValue = null;
|
||||
String xPathExp = RESOURCE_PROFILE_BODY + "/RestrictedPortletURL/text()";
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
profile.setRestrictedPortletURL(currValue.get(0));
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
xPathExp = RESOURCE_PROFILE_BODY + "/OpenPortletURL/text()";
|
||||
currValue = helper.evaluate(xPathExp);
|
||||
if (currValue != null && currValue.size() > 0) {
|
||||
profile.setOpenPortletURL(currValue.get(0));
|
||||
} else
|
||||
throw new Exception("I'm not able to read the path: " + xPathExp);
|
||||
|
||||
LOG.info("returning: " + profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error while trying to read the SecondaryType " + SECONDARY_TYPE + " with appID " + appID
|
||||
+ " from scope " + scope, e);
|
||||
return null;
|
||||
} finally {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the geoportal config app profile.
|
||||
*
|
||||
* @return the geoportal config app profile
|
||||
*/
|
||||
public GeoportalConfigApplicationProfile getGeoportalConfigAppProfile() {
|
||||
return geoportalConfigAppProfile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the gcube generic query string.
|
||||
*
|
||||
* @param secondaryType the secondary type
|
||||
* @param appId the app id
|
||||
* @return the gcube generic query string
|
||||
*/
|
||||
public static String getGcubeGenericQueryString(String secondaryType, String appId) {
|
||||
|
||||
return "for $profile in collection('/db/Profiles/GenericResource')//Resource "
|
||||
+ "where $profile/Profile/SecondaryType/string() eq '" + secondaryType
|
||||
+ "' and $profile/Profile/Body/AppId/string() " + " eq '" + appId + "'" + "return $profile";
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the secondary type.
|
||||
*
|
||||
* @return the secondary type
|
||||
*/
|
||||
public String getSecondaryType() {
|
||||
return secondaryType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the scope.
|
||||
*
|
||||
* @return the scope
|
||||
*/
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GeoportalConfigApplicationProfileReader [secondaryType=");
|
||||
builder.append(secondaryType);
|
||||
builder.append(", scope=");
|
||||
builder.append(scope);
|
||||
builder.append(", appID=");
|
||||
builder.append(appID);
|
||||
builder.append(", geoportalConfigAppProfile=");
|
||||
builder.append(geoportalConfigAppProfile);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* The Class GeoportalRequest.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 23, 2023
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class GeoportalRequest {
|
||||
|
||||
public static final String P_GCUBE_SCOPE = "gcube_scope";
|
||||
public static final String P_ITEM_TYPE = "item_type";
|
||||
public static final String P_ITEM_ID = "item_id";
|
||||
public static final String P_RESOLVES_AS = "res";
|
||||
public static final String P_QUERY_STRING = "query_string";
|
||||
|
||||
@JsonProperty(P_GCUBE_SCOPE)
|
||||
private String gcubeScope;
|
||||
/**
|
||||
* It is the UCD ID {usecase_id}
|
||||
*/
|
||||
@JsonProperty(P_ITEM_TYPE)
|
||||
private String itemType;
|
||||
/**
|
||||
* It is the Project ID {project_id}
|
||||
*/
|
||||
@JsonProperty(P_ITEM_ID)
|
||||
private String itemID;
|
||||
|
||||
@JsonProperty(P_QUERY_STRING)
|
||||
private String queryString;
|
||||
|
||||
@JsonProperty(P_RESOLVES_AS)
|
||||
private String res;
|
||||
|
||||
}
|
|
@ -1,121 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.geoportal;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.gcube.datatransfer.resolver.services.GeoportalResolver;
|
||||
|
||||
/**
|
||||
* The Enum TargetAppGeoportalCodes.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 24, 2023
|
||||
*/
|
||||
public enum TargetAppGeoportalCodes {
|
||||
|
||||
GEO_DV(GeoportalResolver.GEO_DV, "data-viewer", "Geoportal Viewer"),
|
||||
GEO_DE(GeoportalResolver.GEO_DE, "data-entry", "Geoportal Entry");
|
||||
|
||||
private String id; // the code id
|
||||
private String name; // the code value
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Instantiates a new resource catalogue codes.
|
||||
*
|
||||
* @param id the id
|
||||
* @param name the target app
|
||||
* @param description the description
|
||||
*/
|
||||
private TargetAppGeoportalCodes(String id, String name, String description) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public String getId() {
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the target app.
|
||||
*
|
||||
* @return the target app
|
||||
*/
|
||||
public String getTarget_app() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the description.
|
||||
*
|
||||
* @return the description
|
||||
*/
|
||||
public String getDescription() {
|
||||
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Codes.
|
||||
*
|
||||
* @return the list
|
||||
*/
|
||||
public static List<String> codes() {
|
||||
|
||||
return Arrays.asList(TargetAppGeoportalCodes.values()).stream().map(TargetAppGeoportalCodes::getId)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of id.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the target app geoportal codes
|
||||
*/
|
||||
public static TargetAppGeoportalCodes valueOfId(String id) {
|
||||
if (id == null || id.isEmpty())
|
||||
return null;
|
||||
|
||||
List<TargetAppGeoportalCodes> codes = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
|
||||
.filter(value -> value.getId().compareTo(id) == 0).collect(Collectors.toList());
|
||||
|
||||
if (codes == null || codes.isEmpty())
|
||||
return null;
|
||||
|
||||
return codes.get(0);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of name.
|
||||
*
|
||||
* @param name the name
|
||||
* @return the target app geoportal codes
|
||||
*/
|
||||
public static TargetAppGeoportalCodes valueOfName(String name) {
|
||||
if (name == null || name.isEmpty())
|
||||
return null;
|
||||
|
||||
List<TargetAppGeoportalCodes> codes = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
|
||||
.filter(value -> value.getTarget_app().compareTo(name) == 0).collect(Collectors.toList());
|
||||
|
||||
if (codes == null || codes.isEmpty())
|
||||
return null;
|
||||
|
||||
return codes.get(0);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal.exporter;
|
||||
|
||||
import org.gcube.application.geoportaldatamapper.shared.FileReference;
|
||||
|
||||
public class FetchPDF {
|
||||
|
||||
private final int MAX_RETRY = 60;
|
||||
private FileReference fileRef;
|
||||
private String code;
|
||||
|
||||
private int attempt = 0;
|
||||
|
||||
public FetchPDF() {
|
||||
|
||||
}
|
||||
|
||||
public FetchPDF(FileReference fileRef, String code, int attempt) {
|
||||
super();
|
||||
this.fileRef = fileRef;
|
||||
this.code = code;
|
||||
this.attempt = attempt;
|
||||
}
|
||||
|
||||
public int getMAX_RETRY() {
|
||||
return MAX_RETRY;
|
||||
}
|
||||
|
||||
public FileReference getFileRef() {
|
||||
return fileRef;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public int getAttempt() {
|
||||
return attempt;
|
||||
}
|
||||
|
||||
public void setFileRef(FileReference fileRef) {
|
||||
this.fileRef = fileRef;
|
||||
}
|
||||
|
||||
public synchronized int incrementAttempt() {
|
||||
attempt++;
|
||||
return attempt;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("FetchPDF [MAX_RETRY=");
|
||||
builder.append(MAX_RETRY);
|
||||
builder.append(", fileRef=");
|
||||
builder.append(fileRef);
|
||||
builder.append(", code=");
|
||||
builder.append(code);
|
||||
builder.append(", attempt=");
|
||||
builder.append(attempt);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal.exporter;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class GeoportalJsonResponse {
|
||||
|
||||
//State can be "OK" or "ERROR"
|
||||
String state;
|
||||
String url;
|
||||
String message;
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.geoportal.exporter;
|
||||
|
||||
public class Geoportal_HTML_Page {
|
||||
|
||||
/**
|
||||
* Sets the HTML message.
|
||||
*
|
||||
* @param action the action
|
||||
* @param message the message
|
||||
* @param waiting the waiting
|
||||
* @return the string
|
||||
*/
|
||||
public static String entityHTMLMessage(String action, String message, boolean waiting, String viewPdfURL) {
|
||||
|
||||
//NB the images are located at https://data.d4science.net/qLix
|
||||
String newHTML = "<html>\n"
|
||||
+ "\n"
|
||||
+ " <head>\n"
|
||||
+ " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n"
|
||||
+ " <style>\n"
|
||||
+ " html,\n"
|
||||
+ " body {\n"
|
||||
+ " margin: 10px;\n"
|
||||
+ " width: 100%;\n"
|
||||
+ " height: 100%;\n"
|
||||
+ " display: table\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #content {\n"
|
||||
+ " position: absolute;\n"
|
||||
+ " left: 50%;\n"
|
||||
+ " top: 50%;\n"
|
||||
+ " -webkit-transform: translate(-50%, -50%);\n"
|
||||
+ " transform: translate(-50%, -50%);\n"
|
||||
+ " text-align: center;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #title-geo {\n"
|
||||
+ " font-weight: bold;\n"
|
||||
+ " color: black;\n"
|
||||
+ " font-size: 26px;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #message {\n"
|
||||
+ " color: gray;\n"
|
||||
+ " font-size: 24px;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " </style>\n"
|
||||
+ " <script type=\"text/javascript\">\n"
|
||||
+ " async function fetchPDF_URL() {\n"
|
||||
+ " try {\n"
|
||||
+ "\n"
|
||||
+ " const response = await fetch('"+viewPdfURL+"');\n"
|
||||
+ " console.log(\"polling response\");\n"
|
||||
+ " return response.json();\n"
|
||||
+ " } catch (error) {\n"
|
||||
+ " console.error(\"polling error: \" + error);\n"
|
||||
+ " showError(\"Error when exporting PDF :-(\");\n"
|
||||
+ " }\n"
|
||||
+ " }\n"
|
||||
+ " async function playPDFPoll() {\n"
|
||||
+ " const response_object = await fetchPDF_URL();\n"
|
||||
+ " try {\n"
|
||||
+ " console.log(\"json response \" + response_object);\n"
|
||||
+ " if (response_object.state === \"OK\") {\n"
|
||||
+ " if (!(response_object.url === null) && !(response_object.url === undefined)) {\n"
|
||||
+ " window.location.replace(response_object.url);\n"
|
||||
+ " } else {\n"
|
||||
+ " setTimeout(() => {\n"
|
||||
+ " playPDFPoll();\n"
|
||||
+ " }, 1000);\n"
|
||||
+ " }\n"
|
||||
+ " } else {\n"
|
||||
+ " showError(response_object.message);\n"
|
||||
+ " }\n"
|
||||
+ " } catch (error) {\n"
|
||||
+ " console.log(\"no json response \" + response_object);\n"
|
||||
+ " //console.log(\"error \" + error);\n"
|
||||
+ " showError(\"Error when exporting PDF :-(\");\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " function showError(error_msg) {\n"
|
||||
+ " let inner_div = document.getElementById(\"inner-content\");\n"
|
||||
+ " inner_div.innerHTML = error_msg;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " </script>\n"
|
||||
+ " <title>D4Science Geoportal - Action</title>\n"
|
||||
+ " </head>\n"
|
||||
+ "\n"
|
||||
+ " <body onload=\"playPDFPoll()\">";
|
||||
|
||||
newHTML += "<img alt=\"D4Science Logo\" src=\"https://services.d4science.org/image/layout_set_logo?img_id=32727\"><br />";
|
||||
|
||||
newHTML += "<div id=\"content\">";
|
||||
newHTML += "<p id=\"title-geo\">Geoportal</p><br />";
|
||||
newHTML += "<div id=\"inner-content\">";
|
||||
newHTML += "<p style=\"font-size: 18px;\">" + action + "</p>";
|
||||
|
||||
if (waiting) {
|
||||
newHTML += "<img alt=\"D4Science Geoportal Loading Icon\" src=\"https://data.d4science.org/shub/E_a2Y1N2ZIaUhCVlE5R0JXNjJhVXVsTlNyNVJta2ZKZVFMaG52N2gxZm05VWJOb2RFTVBpa0pyV1hsUlg2WXJSTw==\"><br />";
|
||||
}
|
||||
|
||||
newHTML += "<br/><p id=\"message\">" + message + "</p>";
|
||||
newHTML += "</div></div></body></html>";
|
||||
|
||||
return newHTML;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the HTML message.
|
||||
*
|
||||
* @param action the action
|
||||
* @param message the message
|
||||
* @param waiting the waiting
|
||||
* @return the string
|
||||
*/
|
||||
public static String getErrorPage(String action, String message) {
|
||||
|
||||
String newHTML = "<html>\n"
|
||||
+ "\n"
|
||||
+ " <head>\n"
|
||||
+ " <meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\">\n"
|
||||
+ " <style>\n"
|
||||
+ " html,\n"
|
||||
+ " body {\n"
|
||||
+ " margin: 10px;\n"
|
||||
+ " width: 100%;\n"
|
||||
+ " height: 100%;\n"
|
||||
+ " display: table\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #content {\n"
|
||||
+ " position: absolute;\n"
|
||||
+ " left: 50%;\n"
|
||||
+ " top: 50%;\n"
|
||||
+ " -webkit-transform: translate(-50%, -50%);\n"
|
||||
+ " transform: translate(-50%, -50%);\n"
|
||||
+ " text-align: center;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #title-geo {\n"
|
||||
+ " font-weight: bold;\n"
|
||||
+ " color: black;\n"
|
||||
+ " font-size: 26px;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " #message {\n"
|
||||
+ " color: gray;\n"
|
||||
+ " font-size: 24px;\n"
|
||||
+ " }\n"
|
||||
+ "\n"
|
||||
+ " </style>\n"
|
||||
+ "</head>";
|
||||
|
||||
newHTML += "<img alt=\"D4Science Logo\" src=\"https://services.d4science.org/image/layout_set_logo?img_id=32727\"><br />";
|
||||
|
||||
newHTML += "<div id=\"content\">";
|
||||
newHTML += "<p id=\"title-geo\">Geoportal Exporter</p><br />";
|
||||
newHTML += "<p style=\"font-size: 18px;\">" + action + "</p>";
|
||||
newHTML += "<br/><p id=\"message\">" + message + "</p>";
|
||||
newHTML += "</div></body></html>";
|
||||
|
||||
return newHTML;
|
||||
}
|
||||
|
||||
}
|
|
@ -19,25 +19,20 @@ import javax.ws.rs.core.MultivaluedMap;
|
|||
import javax.ws.rs.core.UriBuilder;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||
import org.gcube.datatransfer.resolver.UriResolverServices;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* The Class RequestHandler.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Mar 15, 2019
|
||||
* Mar 15, 2019
|
||||
*/
|
||||
@Provider
|
||||
@PreMatching
|
||||
|
@ -49,8 +44,7 @@ public class RequestHandler implements ContainerRequestFilter, ContainerResponse
|
|||
|
||||
private static final Logger log = LoggerFactory.getLogger(RequestHandler.class);
|
||||
|
||||
@Context
|
||||
ServletContext context;
|
||||
@Context ServletContext context;
|
||||
|
||||
@Context
|
||||
HttpServletRequest webRequest;
|
||||
|
@ -61,195 +55,127 @@ public class RequestHandler implements ContainerRequestFilter, ContainerResponse
|
|||
@Context
|
||||
ResourceContext resourceContext;
|
||||
|
||||
/**
|
||||
* Filter.
|
||||
*
|
||||
* @param reqContext the req context
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* javax.ws.rs.container.ContainerRequestFilter#filter(javax.ws.rs.container.
|
||||
* ContainerRequestContext)
|
||||
*/
|
||||
@Override
|
||||
public void filter(ContainerRequestContext reqContext) throws IOException {
|
||||
log.debug(RequestHandler.class.getSimpleName() + " Request called");
|
||||
setSecretManager(reqContext);
|
||||
/* (non-Javadoc)
|
||||
* @see javax.ws.rs.container.ContainerRequestFilter#filter(javax.ws.rs.container.ContainerRequestContext)
|
||||
*/
|
||||
@Override
|
||||
public void filter(ContainerRequestContext reqContext) throws IOException {
|
||||
log.info(RequestHandler.class.getSimpleName() +" Request called");
|
||||
|
||||
if (SecurityTokenProvider.instance.get() == null)
|
||||
SecurityTokenProvider.instance.set(context.getInitParameter(ROOT_APP_TOKEN));
|
||||
if(SecurityTokenProvider.instance.get()==null)
|
||||
SecurityTokenProvider.instance.set(context.getInitParameter(ROOT_APP_TOKEN));
|
||||
|
||||
if (ScopeProvider.instance.get() == null)
|
||||
ScopeProvider.instance.set(context.getInitParameter(ROOT_SCOPE));
|
||||
if(ScopeProvider.instance.get()==null)
|
||||
ScopeProvider.instance.set(context.getInitParameter(ROOT_SCOPE));
|
||||
|
||||
log.debug("Token and Scope Provider set called");
|
||||
log.info("Token and Scope Provider set called");
|
||||
|
||||
List<String> listOfPath = UriResolverServices.getInstance().getListOfResourcePath(application.getClasses());
|
||||
log.debug("The resources are: {}", listOfPath);
|
||||
log.debug("The resources are: {}", listOfPath);
|
||||
|
||||
String path = reqContext.getUriInfo().getPath();
|
||||
log.debug("The path is: {}", path);
|
||||
String path = reqContext.getUriInfo().getPath();
|
||||
log.debug("The path is: {}", path);
|
||||
|
||||
// HOW TO READ THE QUERY STRING
|
||||
/*
|
||||
* MultivaluedMap<String, String> queryParameters =
|
||||
* reqContext.getUriInfo().getQueryParameters(); String queryString = ""; try {
|
||||
* queryString = Util.toQueryString(queryParameters); }catch (Exception e) {
|
||||
* //silent
|
||||
* log.warn("Error on reading the query string, trying to continue..."); }
|
||||
* log.debug("The query string is: {}", queryString);
|
||||
*/
|
||||
|
||||
if (path == null || path.isEmpty()) {
|
||||
log.debug("The path is null or empty, redirecting to /index");
|
||||
URI newRequestURI = reqContext.getUriInfo().getBaseUriBuilder().path("/index").build();
|
||||
reqContext.setRequestUri(newRequestURI);
|
||||
return;
|
||||
//HOW TO READ THE QUERY STRING
|
||||
/*MultivaluedMap<String, String> queryParameters = reqContext.getUriInfo().getQueryParameters();
|
||||
String queryString = "";
|
||||
try {
|
||||
queryString = Util.toQueryString(queryParameters);
|
||||
}catch (Exception e) {
|
||||
//silent
|
||||
log.warn("Error on reading the query string, trying to continue...");
|
||||
}
|
||||
log.debug("The query string is: {}", queryString);
|
||||
*/
|
||||
|
||||
String[] splittePath = null;
|
||||
boolean resourceToRedirectFound = false;
|
||||
String candidateResource = "";
|
||||
try {
|
||||
splittePath = path.split("/");
|
||||
if (splittePath != null && splittePath.length > 0) {
|
||||
String requestedResourceName = splittePath[0];
|
||||
log.debug("The resource requested is: {}", requestedResourceName);
|
||||
if(path==null || path.isEmpty()) {
|
||||
log.debug("The path is null or empty, redirecting to /index");
|
||||
URI newRequestURI = reqContext.getUriInfo().getBaseUriBuilder().path("/index").build();
|
||||
reqContext.setRequestUri(newRequestURI);
|
||||
return;
|
||||
}
|
||||
|
||||
if (requestedResourceName != null && !requestedResourceName.isEmpty()) {
|
||||
for (String resource : listOfPath) {
|
||||
log.trace("Is resource '{}' starting with '{}' ?", resource, requestedResourceName);
|
||||
if (resource.startsWith(requestedResourceName)) {
|
||||
String[] splittePath = null;
|
||||
boolean resourceToRedirectFound = false;
|
||||
String candidateResource = "";
|
||||
try {
|
||||
splittePath = path.split("/");
|
||||
if(splittePath!=null && splittePath.length>0) {
|
||||
String requestedResourceName = splittePath[0];
|
||||
log.debug("The resource requested is: {}",requestedResourceName);
|
||||
|
||||
if(requestedResourceName!=null && !requestedResourceName.isEmpty()) {
|
||||
for (String resource : listOfPath) {
|
||||
log.trace("Is resource '{}' starting with '{}' ?",resource,requestedResourceName);
|
||||
if(resource.startsWith(requestedResourceName)) {
|
||||
log.trace("Yes it starts!");
|
||||
candidateResource = requestedResourceName;
|
||||
log.info("The candidate resource to manage the request is: {}", candidateResource);
|
||||
log.info("The candidate resource to manage the request is: {}",candidateResource);
|
||||
resourceToRedirectFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Try to manage as Catalogue Request ctlg, ctlg-p, etc.
|
||||
if (!resourceToRedirectFound) {
|
||||
log.info("Trying to manage as hard-coded case among cases: {}",
|
||||
Arrays.asList(ConstantsResolver.resourcesHardCoded).toString());
|
||||
String[] hardCode = ConstantsResolver.resourcesHardCoded;
|
||||
//Try to manage as Catalogue Request ctlg, ctlg-p, etc.
|
||||
if(!resourceToRedirectFound) {
|
||||
log.info("Trying to manage as hard-coded case among cases: {}", Arrays.asList(ConstantsResolver.resourcesHardCoded).toString());
|
||||
String[] hardCode = ConstantsResolver.resourcesHardCoded;
|
||||
|
||||
for (String resource : hardCode) {
|
||||
log.trace("Is requested resource '{}' starting with hard-coded resource '{}'?",
|
||||
requestedResourceName, resource);
|
||||
if (requestedResourceName.startsWith(resource)) {
|
||||
for (String resource : hardCode) {
|
||||
log.trace("Is requested resource '{}' starting with hard-coded resource '{}'?",requestedResourceName,resource);
|
||||
if(requestedResourceName.startsWith(resource)) {
|
||||
log.trace("Yes it starts!");
|
||||
candidateResource = resource;
|
||||
log.info("The candidate resource to manage the request is the hard-coded resource: {}",
|
||||
candidateResource);
|
||||
log.info("The candidate resource to manage the request is the hard-coded resource: {}",candidateResource);
|
||||
resourceToRedirectFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
log.warn(
|
||||
"It was not possible to get the resource name from the splitted path {}. No action performed",
|
||||
path);
|
||||
} else {
|
||||
log.warn("It was not possible to split the path {}. No action performed", path);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}else
|
||||
log.warn("It was not possible to get the resource name from the splitted path {}. No action performed", path);
|
||||
}else {
|
||||
log.warn("It was not possible to split the path {}. No action performed", path);
|
||||
}
|
||||
}catch (Exception e) {
|
||||
log.error("Error trying to retrieve the service able to manage the request. No action performed", e);
|
||||
}
|
||||
|
||||
if (resourceToRedirectFound) {
|
||||
log.debug("The input request '{}' can be managed by the service '{}'. No redirect performed", path,
|
||||
candidateResource);
|
||||
} else {
|
||||
log.info("No resource/service found to manage the input request '{}'", path);
|
||||
String newPath = String.format("/%s/%s", ConstantsResolver.defaultServiceToRedirect, path);
|
||||
// log.debug("The path to redirect is '{}'", newPath);
|
||||
// URI newRequestURI =
|
||||
// reqContext.getUriInfo().getBaseUriBuilder().path(newPath).build();
|
||||
UriBuilder uriBuilder = reqContext.getUriInfo().getBaseUriBuilder();
|
||||
// ADDING THE INPUT QUERY STRING
|
||||
MultivaluedMap<String, String> queryParameters = reqContext.getUriInfo().getQueryParameters();
|
||||
for (String param : queryParameters.keySet()) {
|
||||
List<String> values = queryParameters.get(param);
|
||||
if (values != null && !values.isEmpty())
|
||||
uriBuilder.queryParam(param, values.toArray());
|
||||
}
|
||||
if(resourceToRedirectFound) {
|
||||
log.debug("The input request '{}' can be managed by the service '{}'. No redirect performed", path, candidateResource);
|
||||
}else {
|
||||
log.info("No resource/service found to manage the input request '{}'", path);
|
||||
String newPath = String.format("/%s/%s", ConstantsResolver.defaultServiceToRedirect,path);
|
||||
//log.debug("The path to redirect is '{}'", newPath);
|
||||
//URI newRequestURI = reqContext.getUriInfo().getBaseUriBuilder().path(newPath).build();
|
||||
UriBuilder uriBuilder = reqContext.getUriInfo().getBaseUriBuilder();
|
||||
//ADDING THE INPUT QUERY STRING
|
||||
MultivaluedMap<String, String> queryParameters = reqContext.getUriInfo().getQueryParameters();
|
||||
for (String param : queryParameters.keySet()) {
|
||||
List<String> values = queryParameters.get(param);
|
||||
if(values!=null && !values.isEmpty())
|
||||
uriBuilder.queryParam(param,values.toArray());
|
||||
}
|
||||
|
||||
URI newRequestURI = uriBuilder.path(newPath).build();
|
||||
log.info("Redirect to URI path '{}'", newRequestURI.toString());
|
||||
reqContext.setRequestUri(newRequestURI);
|
||||
}
|
||||
}
|
||||
URI newRequestURI = uriBuilder.path(newPath).build();
|
||||
log.info("Redirect to URI path '{}'", newRequestURI.toString());
|
||||
reqContext.setRequestUri(newRequestURI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter.
|
||||
*
|
||||
* @param requestContext the request context
|
||||
* @param responseContext the response context
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.
|
||||
* ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext)
|
||||
/* (non-Javadoc)
|
||||
* @see javax.ws.rs.container.ContainerResponseFilter#filter(javax.ws.rs.container.ContainerRequestContext, javax.ws.rs.container.ContainerResponseContext)
|
||||
*/
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
|
||||
throws IOException {
|
||||
log.debug(RequestHandler.class.getSimpleName() + " Response called");
|
||||
log.info(RequestHandler.class.getSimpleName() +" Response called");
|
||||
SecurityTokenProvider.instance.reset();
|
||||
ScopeProvider.instance.reset();
|
||||
log.debug("Token and Scope Provider reset called");
|
||||
resetScretManager(requestContext, responseContext);
|
||||
log.info("Token and Scope Provider reset called");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset scret manager.
|
||||
*
|
||||
* @param requestContext the request context
|
||||
* @param responseContext the response context
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void resetScretManager(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
|
||||
throws IOException {
|
||||
log.debug("SecreteManager instance remove");
|
||||
SecretManagerProvider.instance.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the secret manager.
|
||||
*
|
||||
* @param requestContext the new secret manager
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void setSecretManager(ContainerRequestContext requestContext) throws IOException {
|
||||
log.debug("setSecretManager called");
|
||||
|
||||
SecretManagerProvider.instance.remove();
|
||||
SecretManager secretManager = new SecretManager();
|
||||
|
||||
String token = AccessTokenProvider.instance.get();
|
||||
if (token != null) {
|
||||
Secret secret = new JWTSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
token = SecurityTokenProvider.instance.get();
|
||||
if (token != null) {
|
||||
Secret secret = new GCubeSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,8 +22,7 @@ import org.apache.commons.codec.binary.Base64;
|
|||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.datacatalogue.utillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
import org.gcube.datacatalogue.utillibrary.shared.jackan.model.CkanDataset;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogueRunningCluster.ACCESS_LEVEL_TO_CATALOGUE_PORTLET;
|
||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingMapOfDetachedVRE;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
|
||||
|
@ -43,6 +42,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
|
||||
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 D4Science Catalogue's instances. A Catalogue Entity is
|
||||
|
@ -92,6 +93,7 @@ public class CatalogueResolver {
|
|||
|
||||
try {
|
||||
InnerMethodName.instance.set("resolveCataloguePublicLink");
|
||||
|
||||
ItemCatalogueURLs itemCatalogueURLs = getItemCatalogueURLs(req, vreName, entityContext, entityName);
|
||||
|
||||
String itemCatalogueURL;
|
||||
|
@ -131,8 +133,7 @@ public class CatalogueResolver {
|
|||
|
||||
if (!(e instanceof WebApplicationException)) {
|
||||
// UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on resolving the " + CatalogueResolver.class.getSimpleName()
|
||||
+ " URL. Please, contact the support!";
|
||||
String error = "Error occurred on resolving the Catalgoue URL. Please, contact the support!";
|
||||
if (e.getCause() != null)
|
||||
error += "\n\nCaused: " + e.getCause().getMessage();
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
|
@ -207,15 +208,14 @@ public class CatalogueResolver {
|
|||
linkURL += "?" + jsonRequest.getQuery_string();
|
||||
}
|
||||
|
||||
logger.info("Returning " + CatalogueResolver.class.getSimpleName() + " URL: " + linkURL);
|
||||
logger.info("Returining Catalogue URL: " + linkURL);
|
||||
return Response.ok(linkURL).header("Location", linkURL).build();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if (!(e instanceof WebApplicationException)) {
|
||||
// UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on creating the " + CatalogueResolver.class.getSimpleName()
|
||||
+ " URL. Please, contact the support!";
|
||||
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
|
||||
|
@ -246,7 +246,7 @@ public class CatalogueResolver {
|
|||
scopeBean = LoadingMapOfScopeCache.get(scopeName);
|
||||
} catch (ExecutionException | InvalidCacheLoadException e) {
|
||||
logger.error(
|
||||
"Error on getting the fullscope from cache for scopeName {}. Trying to load it from DetachedRE",
|
||||
"Error on getting the fullscope from cache for scopeName {}. Tryng to load it from DetachedRE",
|
||||
scopeName);
|
||||
|
||||
boolean isScopeDetached = false;
|
||||
|
|
|
@ -408,7 +408,7 @@ public class GeonetworkResolver {
|
|||
|
||||
// SPECIFIC HANDLER FOR GEONETWORK REQUEST: /srv/en/mef.export
|
||||
if (remainPath != null && remainPath.compareTo(SRV_EN_MEF_EXPORT) == 0) {
|
||||
logger.info("In case of mef.export, performing a custom handler");
|
||||
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) {
|
||||
|
|
|
@ -1,502 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
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.Response.Status;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
|
||||
import org.gcube.application.geoportalcommon.GeoportalCommon;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences;
|
||||
import org.gcube.application.geoportalcommon.shared.GeoportalItemReferences.SHARE_LINK_TO;
|
||||
import org.gcube.application.geoportaldatamapper.exporter.Geoportal_PDF_Exporter;
|
||||
import org.gcube.application.geoportaldatamapper.shared.ExporterProjectSource;
|
||||
import org.gcube.application.geoportaldatamapper.shared.FileReference;
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.user.User;
|
||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||
import org.gcube.datatransfer.resolver.geoportal.exporter.FetchPDF;
|
||||
import org.gcube.datatransfer.resolver.geoportal.exporter.GeoportalJsonResponse;
|
||||
import org.gcube.datatransfer.resolver.geoportal.exporter.Geoportal_HTML_Page;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.gcube.datatransfer.resolver.services.exceptions.BadRequestException;
|
||||
import org.gcube.datatransfer.resolver.util.SingleFileStreamingOutput;
|
||||
import org.gcube.datatransfer.resolver.util.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class GeoportalExporter.
|
||||
*
|
||||
* The Geoportal Exporter provides the facilities to export GIS projects stored in
|
||||
* the Geoportal system provided via D4Science VREs.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 16, 2024
|
||||
*/
|
||||
@Path("geoportal")
|
||||
public class GeoportalExporter {
|
||||
|
||||
private static final String JOB_CODE = "jobCode";
|
||||
|
||||
public static final String EXPORT_TYPE = "type";
|
||||
|
||||
public static final String PATH_PROJECT_ID = GeoportalResolver.PATH_PROJECT_ID;
|
||||
public static final String PATH_USECASE_ID = GeoportalResolver.PATH_USECASE_ID;
|
||||
public static final String PATH_VRE_NAME = GeoportalResolver.PATH_VRE_NAME;
|
||||
|
||||
public static final String QUERY_PARAMETER_AS_URL = "as-url";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalExporter.class);
|
||||
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#Geoportal_Resolver";
|
||||
|
||||
private static LinkedHashMap<String, FetchPDF> map = new LinkedHashMap<String, FetchPDF>();
|
||||
|
||||
/**
|
||||
* The Enum ACCEPTED_EXPORT_TYPE.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 22, 2024
|
||||
*/
|
||||
public enum ACCEPTED_EXPORT_TYPE {
|
||||
pdf
|
||||
}
|
||||
|
||||
/**
|
||||
* Export.
|
||||
*
|
||||
* @param req the req
|
||||
* @param export_type the export type. Must be a value of the enum
|
||||
* {#ACCEPTED_EXPORT_TYPE}
|
||||
* @param ucdID the ucd ID
|
||||
* @param projectID the project ID
|
||||
* @param asURL the as URL. If true returns the project exported as an URL
|
||||
* in the response
|
||||
* @return the response. Can be an URL or a Stream of the project exported.
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/export/{type}/{usecase_id}/{project_id}")
|
||||
@Produces({ MediaType.TEXT_HTML, MediaType.TEXT_PLAIN, MediaType.APPLICATION_OCTET_STREAM })
|
||||
public Response export(@Context HttpServletRequest req, @PathParam(EXPORT_TYPE) String export_type,
|
||||
@PathParam(PATH_USECASE_ID) String ucdID, @PathParam(PATH_PROJECT_ID) String projectID,
|
||||
@QueryParam(QUERY_PARAMETER_AS_URL) @Nullable String asURL) throws WebApplicationException {
|
||||
|
||||
String userAgentName = req.getHeader("User-Agent");
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " export - GET starts...");
|
||||
LOG.info("Params: [" + EXPORT_TYPE + ": {}, " + PATH_USECASE_ID + ": {}, " + PATH_PROJECT_ID + ": {}, "
|
||||
+ QUERY_PARAMETER_AS_URL + ": {}]", export_type, ucdID, projectID, asURL);
|
||||
|
||||
checkPathParameterNotNull(req, EXPORT_TYPE, export_type);
|
||||
checkPathParameterNotNull(req, PATH_USECASE_ID, ucdID);
|
||||
checkPathParameterNotNull(req, PATH_PROJECT_ID, projectID);
|
||||
|
||||
boolean getAsURL = false;
|
||||
try {
|
||||
getAsURL = Boolean.parseBoolean(asURL);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
||||
LOG.info("getAsURL is: {}", getAsURL);
|
||||
|
||||
checkExportType(req, export_type);
|
||||
|
||||
boolean checked = false;
|
||||
|
||||
SecretManager secreteManager = SecretManagerProvider.instance.get();
|
||||
final String context = secreteManager.getContext();
|
||||
if (context == null) {
|
||||
throw ExceptionManager.forbiddenException(req, "Cannot determine context (the scope)", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
final org.gcube.common.authorization.utils.user.User user = secreteManager.getUser();
|
||||
if (user == null) {
|
||||
throw ExceptionManager.forbiddenException(req, "Cannot determine user", this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
LOG.info("Identified caller {} in context {}", user.getUsername(), context);
|
||||
|
||||
try {
|
||||
Geoportal_PDF_Exporter pdfExporter = new Geoportal_PDF_Exporter();
|
||||
checked = pdfExporter.checkConfig();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing export", e);
|
||||
throw ExceptionManager
|
||||
.internalErrorException(req,
|
||||
"Error the " + Geoportal_PDF_Exporter.class.getSimpleName()
|
||||
+ " seems to be not configured in the context: " + context,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
// if the configuration exists in the context
|
||||
if (checked) {
|
||||
if (getAsURL) {
|
||||
try {
|
||||
LOG.info("Serving request as getAsURL...");
|
||||
FileReference pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user);
|
||||
String theURL = pdfRef.getStorageVolatileURL().toString();
|
||||
LOG.info("returning URL {}", theURL);
|
||||
return Response.ok(theURL).build();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing export by url", e);
|
||||
throw ExceptionManager.internalErrorException(req,
|
||||
"Sorry, error occurred when generating the project URL. Error is: " + e.getMessage(),
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
if (userAgentName != null) {
|
||||
LOG.info("Serving request as User-Agent {}", userAgentName);
|
||||
final String jobCode = ucdID + "_" + projectID + "_" + System.currentTimeMillis();
|
||||
final FetchPDF fetchPDF = new FetchPDF(null, jobCode, 0);
|
||||
map.put(jobCode, fetchPDF);
|
||||
try {
|
||||
Thread t = new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
LOG.info("exportAsPDF called in thread...");
|
||||
FileReference pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user);
|
||||
LOG.info("exportAsPDF setFileRef in thread for code: " + jobCode);
|
||||
fetchPDF.setFileRef(pdfRef);
|
||||
map.put(jobCode, fetchPDF);
|
||||
}
|
||||
|
||||
};
|
||||
t.start();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing export in thread", e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
String serviceViewPDF_URL = String.format("%s/%s/view/%s", Util.getServerURL(req), "geoportal",
|
||||
jobCode);
|
||||
|
||||
String entity = Geoportal_HTML_Page.entityHTMLMessage("Exporting as PDF...",
|
||||
"The project with id: " + projectID, true, serviceViewPDF_URL);
|
||||
|
||||
LOG.info("returning waiting HTML page");
|
||||
return Response.ok(entity).encoding("UTF-8").header(ConstantsResolver.CONTENT_TYPE, "text/html")
|
||||
.build();
|
||||
} else {
|
||||
LOG.info("Serving request as client...");
|
||||
FileReference pdfRef = exportAsPDF(req, ucdID, projectID, null, context, user);
|
||||
// returning as stream
|
||||
InputStream input = pdfRef.getStorageVolatileURL().openStream();
|
||||
StreamingOutput so = new SingleFileStreamingOutput(input);
|
||||
LOG.info("returning project streaming...");
|
||||
return Response.ok(so)
|
||||
.header(ConstantsResolver.CONTENT_DISPOSITION,
|
||||
"inline; filename=\"" + pdfRef.getFileName() + "\"")
|
||||
.header("Content-Type", pdfRef.getContentType()).build();
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing export", e);
|
||||
throw ExceptionManager.internalErrorException(req, "Sorry, error occurred when exporting the project",
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
} else {
|
||||
return Response
|
||||
.status(Status.NOT_FOUND).entity(GeoportalExporter.class.getSimpleName()
|
||||
+ "seems to be not configured in the context: " + context)
|
||||
.type(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Healthcheck. Checks if the export facility is configured in the context (i.e.
|
||||
* the scope read from input token).
|
||||
*
|
||||
* @param req the req
|
||||
* @param export_type the export type
|
||||
* @return an object of type {#GeoportalJsonResponse) that contains the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/export/{type}/healthcheck")
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_PLAIN, MediaType.TEXT_HTML })
|
||||
public Response healthcheck(@Context HttpServletRequest req, @PathParam(EXPORT_TYPE) String export_type)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " healthcheck - GET starts...");
|
||||
LOG.debug("param is: exportType: {}", export_type);
|
||||
|
||||
checkPathParameterNotNull(req, EXPORT_TYPE, export_type);
|
||||
|
||||
checkExportType(req, export_type);
|
||||
|
||||
try {
|
||||
|
||||
SecretManager cm = SecretManagerProvider.instance.get();
|
||||
String context = cm.getContext();
|
||||
if (context == null) {
|
||||
throw ExceptionManager.forbiddenException(req, "Cannot determine context (the scope)", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
org.gcube.common.authorization.utils.user.User user = cm.getUser();
|
||||
LOG.info("Identified caller {} in context {}", user.getUsername(), context);
|
||||
|
||||
Geoportal_PDF_Exporter pdfExporter = new Geoportal_PDF_Exporter();
|
||||
boolean checked = pdfExporter.checkConfig();
|
||||
GeoportalJsonResponse theJson = new GeoportalJsonResponse();
|
||||
if (checked) {
|
||||
theJson.setState("OK");
|
||||
theJson.setMessage(GeoportalExporter.class.getSimpleName() + " Config OK in the context: " + context);
|
||||
String jsonResponse = responseToString(theJson);
|
||||
return Response.ok(jsonResponse).build();
|
||||
} else {
|
||||
theJson.setState("KO");
|
||||
theJson.setMessage(GeoportalExporter.class.getSimpleName() + " Config "
|
||||
+ Status.NOT_FOUND.getReasonPhrase() + " in the context: " + context);
|
||||
String jsonResponse = responseToString(theJson);
|
||||
return Response.status(Status.NOT_FOUND).entity(jsonResponse).build();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on performing healthcheck", e);
|
||||
throw ExceptionManager.internalErrorException(req,
|
||||
"Error when performing " + GeoportalExporter.class.getSimpleName() + " healthcheck",
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* View job. Check the job export status.
|
||||
*
|
||||
* @param req the req
|
||||
* @param jobCode the job code. The job ID assigned by export facility that
|
||||
* returns a waiting HTML page
|
||||
* @return the response. It is a {#GeoportalJsonResponse} with the status of the
|
||||
* job. An export job completed contains the URL of the project
|
||||
* exported.
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/view/{jobCode}")
|
||||
@Produces({ MediaType.APPLICATION_JSON, MediaType.TEXT_HTML, MediaType.TEXT_PLAIN })
|
||||
public Response viewJob(@Context HttpServletRequest req, @PathParam(JOB_CODE) String jobCode)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " viewPDF - GET starts...");
|
||||
LOG.info("viewJob param " + JOB_CODE + ": {}", jobCode);
|
||||
|
||||
FetchPDF fetchedPDF = map.get(jobCode);
|
||||
LOG.info("viewJob FileReference at code {} is {}", jobCode, fetchedPDF);
|
||||
|
||||
String theURL = null;
|
||||
String messagge = null;
|
||||
String state = null;
|
||||
|
||||
GeoportalJsonResponse theJson = new GeoportalJsonResponse();
|
||||
theJson.setState(state);
|
||||
theJson.setUrl(theURL);
|
||||
theJson.setMessage(messagge);
|
||||
|
||||
String jsonReponse = null;
|
||||
|
||||
if (fetchedPDF == null) {
|
||||
theJson.setState(Status.NOT_FOUND.getReasonPhrase());
|
||||
theJson.setMessage("No job found with id: " + jobCode);
|
||||
try {
|
||||
jsonReponse = responseToString(theJson);
|
||||
LOG.info("viewJob returning not found: " + jsonReponse);
|
||||
return Response.status(Status.NOT_FOUND).entity(jsonReponse).build();
|
||||
} catch (JsonProcessingException e) {
|
||||
throw ExceptionManager.internalErrorException(req, "Error when returning "
|
||||
+ GeoportalExporter.class.getSimpleName() + " not found job for " + jobCode, this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
try {
|
||||
// File PDF is not available
|
||||
if (fetchedPDF.getFileRef() == null) {
|
||||
int attempt = fetchedPDF.incrementAttempt();
|
||||
if (fetchedPDF.getAttempt() < fetchedPDF.getMAX_RETRY()) {
|
||||
state = "OK";
|
||||
messagge = "Attempt #" + attempt;
|
||||
} else {
|
||||
state = "ERROR";
|
||||
messagge = "Sorry, an error occurred trying to create the PDF. Max retries reached";
|
||||
theJson.setState(state);
|
||||
}
|
||||
// updating map status
|
||||
map.put(jobCode, fetchedPDF);
|
||||
} else {
|
||||
// File PDF is available
|
||||
state = "OK";
|
||||
theURL = fetchedPDF.getFileRef().getStorageVolatileURL().toString();
|
||||
messagge = "PDF created correclty";
|
||||
// removing from map
|
||||
map.put(jobCode, null);
|
||||
}
|
||||
|
||||
theJson.setState(state);
|
||||
theJson.setUrl(theURL);
|
||||
theJson.setMessage(messagge);
|
||||
try {
|
||||
jsonReponse = responseToString(theJson);
|
||||
LOG.info("viewJob returning OK: " + jsonReponse);
|
||||
return Response.ok(jsonReponse).build();
|
||||
} catch (JsonProcessingException e) {
|
||||
throw ExceptionManager.internalErrorException(req,
|
||||
"Error when returning " + GeoportalExporter.class.getSimpleName() + " response for " + jobCode,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on checking job", e);
|
||||
throw ExceptionManager.internalErrorException(req,
|
||||
"Error when checking " + GeoportalExporter.class.getSimpleName() + " job view for " + jobCode,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String responseToString(GeoportalJsonResponse jsonResponse) throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
return mapper.writeValueAsString(jsonResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check path parameter not null.
|
||||
*
|
||||
* @param req the req
|
||||
* @param parameter the parameter
|
||||
* @param value the value
|
||||
* @throws BadRequestException the bad request exception
|
||||
*/
|
||||
public void checkPathParameterNotNull(HttpServletRequest req, String parameter, String value)
|
||||
throws BadRequestException {
|
||||
if (value == null || value.isEmpty()) {
|
||||
LOG.error("The path parameter {} not found or empty in the path", parameter);
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory path parameter " + parameter + " not found or empty", this.getClass(), helpURI);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check export type.
|
||||
*
|
||||
* @param req the req
|
||||
* @param export_type the export type
|
||||
* @return the accepted export type
|
||||
* @throws BadRequestException the bad request exception
|
||||
*/
|
||||
public ACCEPTED_EXPORT_TYPE checkExportType(HttpServletRequest req, String export_type) throws BadRequestException {
|
||||
ACCEPTED_EXPORT_TYPE exportType;
|
||||
try {
|
||||
exportType = ACCEPTED_EXPORT_TYPE.valueOf(export_type);
|
||||
} catch (Exception e) {
|
||||
throw ExceptionManager
|
||||
.wrongParameterException(req,
|
||||
"The path parameter " + EXPORT_TYPE + " has a bad value: " + export_type
|
||||
+ ". It must be value of " + ACCEPTED_EXPORT_TYPE.values(),
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
return exportType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export as PDF.
|
||||
*
|
||||
* @param req the req
|
||||
* @param profileID the profile ID
|
||||
* @param projectID the project ID
|
||||
* @param profileTitle the profile title
|
||||
* @param context the context
|
||||
* @param user the user
|
||||
* @return the file reference
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
public FileReference exportAsPDF(HttpServletRequest req, String profileID, String projectID, String profileTitle,
|
||||
String context, User user) throws WebApplicationException {
|
||||
LOG.info("exportAsPDF for profileID: " + profileID + ", projectID: " + projectID + "called");
|
||||
LOG.info("exportAsPDF context is {}, user is {}", context, user);
|
||||
|
||||
FileReference pdfRef = null;
|
||||
try {
|
||||
|
||||
Geoportal_PDF_Exporter gpdfe = new Geoportal_PDF_Exporter();
|
||||
ExporterProjectSource exportSource = new ExporterProjectSource();
|
||||
exportSource.setProfileID(profileID);
|
||||
exportSource.setProfileTitle(profileTitle);
|
||||
exportSource.setProjectID(projectID);
|
||||
exportSource.setScope(context);
|
||||
|
||||
GeoportalItemReferences geoportalItemReferences = new GeoportalItemReferences(projectID, profileID,
|
||||
SHARE_LINK_TO.DATA_VIEWER);
|
||||
GeoportalItemReferences gir = getPublicLinksFor(geoportalItemReferences, context);
|
||||
|
||||
if (user.isApplication()) {
|
||||
exportSource.setGisLink(gir.getOpenLink().getShortURL());
|
||||
exportSource.setAccountname(null);
|
||||
} else {
|
||||
exportSource.setGisLink(gir.getRestrictedLink().getShortURL());
|
||||
exportSource.setAccountname(user.getUsername());
|
||||
}
|
||||
|
||||
pdfRef = gpdfe.createPDFFile(exportSource);
|
||||
|
||||
} catch (Exception e1) {
|
||||
LOG.error("Error occurred when exporting the project", e1);
|
||||
throw ExceptionManager.internalErrorException(req, "Sorry, an error occurred when exporting the project",
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
return pdfRef;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the public links for.
|
||||
*
|
||||
* @param item the item
|
||||
* @param context the context
|
||||
* @return the public links for
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public GeoportalItemReferences getPublicLinksFor(GeoportalItemReferences item, String context) throws Exception {
|
||||
LOG.info("getPublicLinksFor called for: " + item);
|
||||
|
||||
try {
|
||||
|
||||
if (item == null)
|
||||
throw new Exception("Bad request, the item is null");
|
||||
|
||||
if (item.getProjectID() == null)
|
||||
throw new Exception("Bad request, the projectID is null");
|
||||
|
||||
if (item.getProfileID() == null)
|
||||
throw new Exception("Bad request, the profileID is null");
|
||||
|
||||
GeoportalCommon gc = new GeoportalCommon();
|
||||
return gc.getPublicLinksFor(context, item, true);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOG.error("Error on getPublicLinksFor for: " + item, e);
|
||||
throw new Exception("Share link not available for this item. Try later or contact the support. Error: "
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,494 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.datatransfer.resolver.ConstantsResolver;
|
||||
import org.gcube.datatransfer.resolver.caches.LoadingMapOfScopeCache;
|
||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants;
|
||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalConfigApplicationProfile;
|
||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalConfigApplicationProfileReader;
|
||||
import org.gcube.datatransfer.resolver.geoportal.GeoportalRequest;
|
||||
import org.gcube.datatransfer.resolver.geoportal.TargetAppGeoportalCodes;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.gcube.datatransfer.resolver.util.Util;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
|
||||
|
||||
/**
|
||||
* The GeoportalResolver is able to get/resolve a link to "Geoportal Viewer" or
|
||||
* "Geoportal Entry" Application.
|
||||
*
|
||||
* See more at
|
||||
* https://gcube.wiki.gcube-system.org/gcube/URI_Resolver#Geoportal_Resolver
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Apr 03, 2024
|
||||
*/
|
||||
@Path("geo")
|
||||
public class GeoportalResolver {
|
||||
|
||||
public static final String GEO_DE = "de"; // data-entry
|
||||
public static final String GEO = "geo"; // geoportal
|
||||
public static final String GEO_DV = "dv"; // data-viewer
|
||||
|
||||
public static final String QP_RESOLVE_AS = "res";
|
||||
public static final String PATH_PROJECT_ID = "project_id";
|
||||
public static final String PATH_USECASE_ID = "usecase_id";
|
||||
public static final String PATH_VRE_NAME = "vre_name";
|
||||
public static final String PATH_TARGET_APP = "targetAppId";
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(GeoportalResolver.class);
|
||||
private static String helpURI = "https://wiki.gcube-system.org/gcube/URI_Resolver#Geoportal_Resolver";
|
||||
|
||||
/**
|
||||
* The Enum RESOLVE_AS_PARAMETER.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Mar 24, 2023
|
||||
*/
|
||||
public static enum RESOLVE_AS {
|
||||
PUBLIC, PRIVATE
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve geoportal. Resolve a Geoportal Link to "Data-Viewer" App
|
||||
*
|
||||
* @param req the req
|
||||
* @param vreName the vre name
|
||||
* @param ucdID the ucd ID
|
||||
* @param projectID the project ID
|
||||
* @param resolveAs the resolve as
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/{vre_name}/{usecase_id}/{project_id}")
|
||||
public Response resolveGeoportalNoAppDef(@Context HttpServletRequest req, @PathParam(PATH_VRE_NAME) String vreName,
|
||||
@PathParam(PATH_USECASE_ID) String ucdID, @PathParam(PATH_PROJECT_ID) String projectID,
|
||||
@QueryParam(QP_RESOLVE_AS) String resolveAs) throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " resolveGeoportalNoAppDef - GET starts...");
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
|
||||
LOG.info("The target app is: " + targetAppGeoportalCodes);
|
||||
return genericResolveLink(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve geoportal. Resolve a Geoportal Link to "Data-Viewer" or "Data-Entry"
|
||||
* App
|
||||
*
|
||||
* @param req the req
|
||||
* @param targetAppId the target app id
|
||||
* @param vreName the vre name
|
||||
* @param ucdID the ucd ID
|
||||
* @param projectID the project ID
|
||||
* @param resolveAs the resolve as
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/{targetAppId}/{vre_name}/{usecase_id}/{project_id}")
|
||||
public Response resolveGeoportal(@Context HttpServletRequest req, @PathParam(PATH_TARGET_APP) String targetAppId,
|
||||
@PathParam(PATH_VRE_NAME) String vreName, @PathParam(PATH_USECASE_ID) String ucdID,
|
||||
@PathParam(PATH_PROJECT_ID) String projectID, @QueryParam(QP_RESOLVE_AS) String resolveAs)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " resolveGeoportal - GET starts...");
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, targetAppId);
|
||||
LOG.info("The target app is: " + targetAppGeoportalCodes);
|
||||
return genericResolveLink(req, targetAppGeoportalCodes, vreName, ucdID, projectID, resolveAs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve data viewer link.
|
||||
*
|
||||
* @param req the req
|
||||
* @param gcubeScope the gcube scope
|
||||
* @param itemId the item id
|
||||
* @param itemType the item type
|
||||
* @param resolveAs the resolve as
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/")
|
||||
public Response resolveDataViewerLink(@Context HttpServletRequest req,
|
||||
@QueryParam(GeoportalRequest.P_GCUBE_SCOPE) String gcubeScope,
|
||||
@QueryParam(GeoportalRequest.P_ITEM_ID) String itemId,
|
||||
@QueryParam(GeoportalRequest.P_ITEM_TYPE) String itemType, @QueryParam(QP_RESOLVE_AS) String resolveAs)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " resolveDataViewerLink - GET starts...");
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
|
||||
LOG.info("The target app is: " + targetAppGeoportalCodes);
|
||||
|
||||
if (gcubeScope == null || gcubeScope.isEmpty()) {
|
||||
|
||||
LOG.error("The query parameter '" + GeoportalRequest.P_GCUBE_SCOPE + "' not found or empty");
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory query parameter '" + GeoportalRequest.P_GCUBE_SCOPE + "' not found or empty",
|
||||
this.getClass(), helpURI);
|
||||
|
||||
}
|
||||
|
||||
String scope = gcubeScope.substring(gcubeScope.lastIndexOf("/") + 1, gcubeScope.length());
|
||||
return genericResolveLink(req, targetAppGeoportalCodes, scope, itemType, itemId, resolveAs);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Post geoportal. Create a Geoportal Link to "Data-Viewer" App
|
||||
*
|
||||
* @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 postGeoportalNoAppDef(@Context HttpServletRequest req, GeoportalRequest jsonRequest)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " postGeoportalNoAppDef - POST starts...");
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, null);
|
||||
LOG.info("The target app is: " + targetAppGeoportalCodes);
|
||||
String linkURL = genericCreateLink(req, jsonRequest, targetAppGeoportalCodes);
|
||||
return Response.ok(linkURL).header("Location", linkURL).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Post geoportal. Create a Geoportal Link to "Data-Viewer" or "Data-Entry" App
|
||||
*
|
||||
* @param req the req
|
||||
* @param targetAppId the target app id
|
||||
* @param jsonRequest the json request
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@POST
|
||||
@Path("/{targetAppId}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public Response postGeoportal(@Context HttpServletRequest req, @PathParam(PATH_TARGET_APP) String targetAppId,
|
||||
GeoportalRequest jsonRequest) throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " postGeoportal - POST starts...");
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = checkTargetApplictionID(req, targetAppId);
|
||||
LOG.info("The target app is: " + targetAppGeoportalCodes);
|
||||
String linkURL = genericCreateLink(req, jsonRequest, targetAppGeoportalCodes);
|
||||
return Response.ok(linkURL).header("Location", linkURL).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check target appliction ID.
|
||||
*
|
||||
* @param req the req
|
||||
* @param targetAppId the target app id
|
||||
* @return the target app geoportal codes
|
||||
*/
|
||||
private TargetAppGeoportalCodes checkTargetApplictionID(@Context HttpServletRequest req, String targetAppId) {
|
||||
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes = null;
|
||||
|
||||
if (targetAppId == null) {
|
||||
targetAppGeoportalCodes = TargetAppGeoportalCodes.GEO_DV;
|
||||
LOG.warn("Target application parameter is null, using default: " + targetAppGeoportalCodes);
|
||||
} else {
|
||||
|
||||
// IF the target application passed in the request. It must be proper.
|
||||
targetAppGeoportalCodes = TargetAppGeoportalCodes.valueOfId(targetAppId);
|
||||
|
||||
if (targetAppGeoportalCodes == null) {
|
||||
LOG.error("Target application parameter is malformed");
|
||||
List<String> targetApps = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
|
||||
.map(TargetAppGeoportalCodes::getTarget_app).collect(Collectors.toList());
|
||||
List<String> targetPaths = Arrays.asList(TargetAppGeoportalCodes.values()).stream()
|
||||
.map(TargetAppGeoportalCodes::getId).collect(Collectors.toList());
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Target application is wrong. Add a target path as /"+targetPaths+" to resolve towards the applications: " + targetApps, this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
}
|
||||
|
||||
return targetAppGeoportalCodes;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic resolve link.
|
||||
*
|
||||
* @param req the req
|
||||
* @param resoruceGeoportalCodes the resoruce geoportal codes
|
||||
* @param vreName the vre name
|
||||
* @param ucdID the ucd ID
|
||||
* @param projectID the project ID
|
||||
* @param resolveAs the resolve as
|
||||
* @return the response
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
public Response genericResolveLink(@Context HttpServletRequest req, TargetAppGeoportalCodes resoruceGeoportalCodes,
|
||||
@PathParam(PATH_VRE_NAME) String vreName, @PathParam(PATH_USECASE_ID) String ucdID,
|
||||
@PathParam(PATH_PROJECT_ID) String projectID, @QueryParam(QP_RESOLVE_AS) String resolveAs)
|
||||
throws WebApplicationException {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " genericResolveLink starts...");
|
||||
|
||||
try {
|
||||
InnerMethodName.instance.set("resolveGeoportalPublicLink");
|
||||
|
||||
LOG.info("Found target app: " + resoruceGeoportalCodes);
|
||||
|
||||
if (resoruceGeoportalCodes == null) {
|
||||
LOG.error("The path parameter '" + PATH_TARGET_APP + "' not found or empty in the path");
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory path parameter '" + PATH_TARGET_APP + "' not found or empty", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
if (vreName == null || vreName.isEmpty()) {
|
||||
LOG.error("The path parameter '" + PATH_VRE_NAME + "' not found or empty in the path");
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory path parameter '" + PATH_VRE_NAME + "' not found or empty", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
if (ucdID == null) {
|
||||
LOG.error("The path parameter '" + PATH_USECASE_ID + "' not found or empty in the path");
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory path parameter '" + PATH_USECASE_ID + "' not found or empty", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
if (projectID == null) {
|
||||
LOG.error("The path parameter '" + PATH_PROJECT_ID + "' not found or empty in the path");
|
||||
throw ExceptionManager.badRequestException(req,
|
||||
"Mandatory path parameter '" + PATH_PROJECT_ID + "' not found or empty", this.getClass(),
|
||||
helpURI);
|
||||
}
|
||||
|
||||
ScopeBean fullScopeBean = null;
|
||||
|
||||
// CHECKING IF THE INPUT VRE NAME IS REGISTRED IN THE INFRASTRUCTURE...
|
||||
try {
|
||||
fullScopeBean = LoadingMapOfScopeCache.get(vreName);
|
||||
} catch (ExecutionException | InvalidCacheLoadException e) {
|
||||
LOG.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);
|
||||
}
|
||||
|
||||
RESOLVE_AS resolveTO = RESOLVE_AS.PUBLIC;
|
||||
if (resolveAs != null) {
|
||||
switch (resolveAs.toLowerCase()) {
|
||||
case "public":
|
||||
resolveTO = RESOLVE_AS.PUBLIC;
|
||||
break;
|
||||
case "private":
|
||||
resolveTO = RESOLVE_AS.PRIVATE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
LOG.info("Found RESOLVE_AS_PARAMETER: " + resolveAs);
|
||||
|
||||
String originalScope = ScopeProvider.instance.get();
|
||||
GeoportalConfigApplicationProfileReader reader;
|
||||
String itemLink = null;
|
||||
String appID = null;
|
||||
|
||||
// Resolving towards Data-Viewer or Data-Entry Application
|
||||
switch (resoruceGeoportalCodes) {
|
||||
case GEO_DE: {
|
||||
appID = org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants.GEOPORTAL_DATA_ENTRY_APP_ID;
|
||||
break;
|
||||
}
|
||||
case GEO_DV:
|
||||
default: {
|
||||
appID = org.gcube.datatransfer.resolver.geoportal.GeoportalCommonConstants.GEOPORTAL_DATA_VIEWER_APP_ID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
String theScope = fullScopeBean.toString();
|
||||
LOG.info("Full scope is: " + theScope);
|
||||
ScopeProvider.instance.set(theScope);
|
||||
reader = new GeoportalConfigApplicationProfileReader(appID);
|
||||
} catch (Exception e) {
|
||||
String error = "Error on reading the generic resource with SecondaryType: "
|
||||
+ GeoportalConfigApplicationProfileReader.SECONDARY_TYPE + " and APP ID: " + appID
|
||||
+ " in the scope: " + appID;
|
||||
LOG.error(error, e);
|
||||
|
||||
throw ExceptionManager.internalErrorException(req, error + ". Please contact the support",
|
||||
this.getClass(), helpURI);
|
||||
} finally {
|
||||
if (originalScope != null && !originalScope.isEmpty()) {
|
||||
ScopeProvider.instance.set(originalScope);
|
||||
LOG.info("scope provider set to orginal scope: " + originalScope);
|
||||
} else {
|
||||
ScopeProvider.instance.reset();
|
||||
LOG.info("scope provider reset");
|
||||
}
|
||||
}
|
||||
|
||||
GeoportalConfigApplicationProfile geonaDataProfile = reader.getGeoportalConfigAppProfile();
|
||||
|
||||
switch (resolveTO) {
|
||||
case PUBLIC: {
|
||||
// Open Link
|
||||
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getOpenPortletURL(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_ID, projectID,
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
||||
break;
|
||||
}
|
||||
case PRIVATE: {
|
||||
|
||||
// Restricted Link
|
||||
itemLink = String.format("%s?%s=%s&%s=%s", geonaDataProfile.getRestrictedPortletURL(),
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_ID, projectID,
|
||||
GeoportalCommonConstants.GET_GEONA_ITEM_TYPE, ucdID);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
LOG.info("Returning link: " + itemLink);
|
||||
return Response.seeOther(new URL(itemLink).toURI()).build();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if (!(e instanceof WebApplicationException)) {
|
||||
// UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on resolving the " + GeoportalResolver.class.getSimpleName()
|
||||
+ " URL. 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
|
||||
LOG.error("Exception:", e);
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic create link.
|
||||
*
|
||||
* @param req the req
|
||||
* @param jsonRequest the json request
|
||||
* @param targetAppGeoportalCodes the target app geoportal codes
|
||||
* @return the URL
|
||||
*/
|
||||
protected String genericCreateLink(@Context HttpServletRequest req, GeoportalRequest jsonRequest,
|
||||
TargetAppGeoportalCodes targetAppGeoportalCodes) {
|
||||
|
||||
LOG.info(this.getClass().getSimpleName() + " genericCreateLink starts...");
|
||||
|
||||
try {
|
||||
|
||||
InnerMethodName.instance.set("postGeoportalPublicLink");
|
||||
LOG.info("The body contains the request: " + jsonRequest.toString());
|
||||
|
||||
if (jsonRequest.getGcubeScope() == null) {
|
||||
throw ExceptionManager.badRequestException(req, "Missing parameter " + GeoportalRequest.P_GCUBE_SCOPE,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if (jsonRequest.getItemID() == null) {
|
||||
throw ExceptionManager.badRequestException(req, "Missing parameter " + GeoportalRequest.P_ITEM_ID,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
if (jsonRequest.getItemType() == null) {
|
||||
throw ExceptionManager.badRequestException(req, "Missing parameter " + GeoportalRequest.P_ITEM_TYPE,
|
||||
this.getClass(), helpURI);
|
||||
}
|
||||
|
||||
// CHECK IF INPUT SCOPE IS VALID
|
||||
String scope = jsonRequest.getGcubeScope();
|
||||
if (!scope.startsWith(ConstantsResolver.SCOPE_SEPARATOR)) {
|
||||
LOG.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());
|
||||
ScopeBean fullScope = null;
|
||||
|
||||
// CHECK IF THE vreName has a valid scope, so it is a valid VRE
|
||||
try {
|
||||
fullScope = LoadingMapOfScopeCache.get(vreName);
|
||||
} catch (ExecutionException e) {
|
||||
LOG.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);
|
||||
|
||||
String linkURL = String.format("%s/%s/%s/%s/%s/%s", serverUrl, GEO, targetAppGeoportalCodes.getId(),
|
||||
vreName, jsonRequest.getItemType(), jsonRequest.getItemID());
|
||||
|
||||
if (jsonRequest.getQueryString() != null) {
|
||||
linkURL += "?" + jsonRequest.getQueryString();
|
||||
}
|
||||
|
||||
LOG.info("Returning " + GeoportalResolver.class.getSimpleName() + " URL: " + linkURL);
|
||||
return linkURL;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
if (!(e instanceof WebApplicationException)) {
|
||||
// UNEXPECTED EXCEPTION managing it as WebApplicationException
|
||||
String error = "Error occurred on creating the " + GeoportalResolver.class.getSimpleName()
|
||||
+ " URL. Please, contact the support!";
|
||||
throw ExceptionManager.internalErrorException(req, error, this.getClass(), helpURI);
|
||||
}
|
||||
// ALREADY MANAGED AS WebApplicationExceptiongetItemCatalogueURLs
|
||||
LOG.error("Exception:", e);
|
||||
throw (WebApplicationException) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,119 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
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.StreamingOutput;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.gcube.datatransfer.resolver.services.error.ExceptionManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class StaticImageController.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* May 2, 2024
|
||||
*/
|
||||
@Path("img")
|
||||
public class StaticImageController {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(StaticImageController.class);
|
||||
|
||||
// /**
|
||||
// * To doc.
|
||||
// *
|
||||
// * @param req the req
|
||||
// * @return the input stream
|
||||
// * @throws WebApplicationException the web application exception
|
||||
// */
|
||||
// @GET
|
||||
// @Path("/{any: .*}")
|
||||
// @Produces({ "image/png", "image/jpg", "image/gif" })
|
||||
// public InputStream toFile(@Context HttpServletRequest req) throws WebApplicationException {
|
||||
// logger.info(StaticImageController.class.getSimpleName() + " toFile called");
|
||||
//
|
||||
// String pathInfo = req.getPathInfo();
|
||||
// logger.debug("pathInfo {}", pathInfo);
|
||||
// try {
|
||||
//
|
||||
// logger.info("going 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 = 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;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
/**
|
||||
* To file out.
|
||||
*
|
||||
* @param req the req
|
||||
* @return the streaming output
|
||||
* @throws WebApplicationException the web application exception
|
||||
*/
|
||||
@GET
|
||||
@Path("/{any: .*}")
|
||||
@Produces({ "image/png", "image/jpg", "image/gif" })
|
||||
public StreamingOutput toFileOut(@Context HttpServletRequest req) throws WebApplicationException {
|
||||
logger.info(StaticImageController.class.getSimpleName() + " toFileOut called");
|
||||
String pathInfo = req.getPathInfo();
|
||||
logger.debug("pathInfo {}", pathInfo);
|
||||
try {
|
||||
final String realPath = req.getServletContext().getRealPath(pathInfo);
|
||||
logger.info("going to {}", pathInfo);
|
||||
return new StreamingOutput() {
|
||||
@Override
|
||||
public void write(OutputStream os) throws IOException, WebApplicationException {
|
||||
FileInputStream fileIS = null;
|
||||
try {
|
||||
fileIS = new FileInputStream(new File(realPath));
|
||||
IOUtils.copy(fileIS, os);
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
if(fileIS!=null)
|
||||
fileIS.close();
|
||||
} catch (Exception e2) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -14,10 +14,10 @@ import javax.ws.rs.WebApplicationException;
|
|||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.ResponseBuilder;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.StreamingOutput;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.gcube.contentmanagement.blobstorage.resource.MyFile;
|
||||
import org.gcube.contentmanagement.blobstorage.service.IClient;
|
||||
import org.gcube.contentmanager.storageclient.wrapper.AccessType;
|
||||
|
@ -169,9 +169,6 @@ public class StorageIDResolver {
|
|||
//Reading the content size
|
||||
size = metaFile.getSize();
|
||||
LOG.debug("Read size {} from {}", size, StorageMetadataFile.class.getSimpleName());
|
||||
}else {
|
||||
//Bug fixing #28276
|
||||
throw ExceptionManager.notFoundException(httpRequest, "Error on accessing the "+STORAGE_ID+ " '"+storageId+"'. Is it a valid id?", StorageIDResolver.class, help);
|
||||
}
|
||||
|
||||
//CHECKING TO DEFAULT METADATA
|
||||
|
@ -225,7 +222,7 @@ public class StorageIDResolver {
|
|||
//THIS IS FOR HPROXY CHECK
|
||||
if(hproxycheck){
|
||||
LOG.trace("returning status 200 for Hproxy check");
|
||||
ResponseBuilder response = Response.status(Status.OK);
|
||||
ResponseBuilder response = Response.status(HttpStatus.SC_OK);
|
||||
return response.build();
|
||||
}
|
||||
|
||||
|
@ -316,7 +313,7 @@ public class StorageIDResolver {
|
|||
if(c>0){
|
||||
LOG.info("at least 1 byte read, returning status 200");
|
||||
IOUtils.closeQuietly(streamToWrite);
|
||||
response = Response.status(Status.OK);
|
||||
response = Response.status(HttpStatus.SC_OK);
|
||||
}else
|
||||
throw ExceptionManager.notFoundException(httpRequest, "The file with id: "+storageId+" is missing in the storage", StorageIDResolver.class, help);
|
||||
}
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
package org.gcube.datatransfer.resolver.services;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.eclipse.microprofile.health.HealthCheck;
|
||||
import org.eclipse.microprofile.health.HealthCheckResponse;
|
||||
import org.eclipse.microprofile.health.HealthCheckResponse.Status;
|
||||
import org.eclipse.microprofile.health.Liveness;
|
||||
|
||||
/**
|
||||
* The Class UriResolverHealthCheck.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||
*
|
||||
* Oct 15, 2024
|
||||
*/
|
||||
@Path("health")
|
||||
public class UriResolverHealthCheck implements HealthCheck {
|
||||
|
||||
@GET
|
||||
@Path("")
|
||||
@Produces({ MediaType.TEXT_HTML, MediaType.APPLICATION_JSON })
|
||||
public Response check() {
|
||||
|
||||
HealthCheckResponse hcr = call();
|
||||
return Response.ok().entity(hcr).build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Call.
|
||||
*
|
||||
* @return the health check response
|
||||
*/
|
||||
@Liveness
|
||||
@Override
|
||||
public HealthCheckResponse call() {
|
||||
|
||||
return new HealthCheckResponse("uri-resolver", Status.UP, Optional.empty());
|
||||
}
|
||||
}
|
|
@ -46,7 +46,7 @@ public class UriResolverIndex {
|
|||
String indexFile = "/WEB-INF/jsp/index.jsp";
|
||||
|
||||
try {
|
||||
logger.debug(UriResolverIndex.class.getSimpleName() + " called");
|
||||
logger.info(UriResolverIndex.class.getSimpleName() + " called");
|
||||
String realPath = req.getServletContext().getRealPath(indexFile);
|
||||
return new FileInputStream(new File(realPath));
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -14,12 +14,11 @@ import javax.ws.rs.core.Context;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.datatransfer.resolver.UriResolverServices;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
|
||||
/**
|
||||
* The UriResolverResources. Show the resources as a JSON
|
||||
|
|
|
@ -9,10 +9,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Builder;
|
||||
|
||||
|
||||
@XmlRootElement(name="error")
|
||||
|
|
|
@ -10,10 +10,10 @@ import javax.xml.bind.annotation.XmlRootElement;
|
|||
import javax.xml.bind.annotation.XmlType;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.experimental.Builder;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,5 +7,4 @@
|
|||
<include>/knime/create/*</include>
|
||||
<include>/wekeo/gettoken/*</include>
|
||||
<include>/oat/get/*</include>
|
||||
<include>/geoportal/export/*</include>
|
||||
</application>
|
|
@ -6,7 +6,6 @@
|
|||
padding: 10px;
|
||||
background: white;
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
}
|
||||
|
||||
.navbar-fixed-top {
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 28 KiB |
Binary file not shown.
Before Width: | Height: | Size: 55 KiB |
|
@ -1,380 +0,0 @@
|
|||
package gis;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkReader;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||
import org.gcube.spatial.data.geonetwork.model.Account;
|
||||
import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
||||
|
||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse.GNMetadata;
|
||||
|
||||
/**
|
||||
* The Class GeonetworkQueryTest.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Aug 31, 2016
|
||||
*/
|
||||
public class GeonetworkQueryTest {
|
||||
|
||||
private static final int MAX = 30;
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/devVRE"};
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/StaTabTest"};
|
||||
|
||||
//private String[] scopes = {"/gcube/devsec/devVRE"};
|
||||
|
||||
//private String[] scopes = {"/pred4s/preprod/preVRE"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/fisheriesandecosystematmii"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu/D4Research"};
|
||||
|
||||
//private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/BlueBridgeProject"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/AquacultureAtlasGeneration"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/FrenchTropicalTunaAtlas"};
|
||||
|
||||
private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/BiodiversityLab"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/SIASPA"};
|
||||
|
||||
//private String[] scopes = {"/d4science.research-infrastructures.eu/gCubeApps/ICCAT_BFT-E"};
|
||||
|
||||
|
||||
|
||||
private LoginLevel loginLevel = LoginLevel.CKAN;
|
||||
|
||||
private Type accountType = Type.CKAN;
|
||||
|
||||
private String textToSearch = "geo_fea";
|
||||
|
||||
/**
|
||||
* Gets the count.
|
||||
*
|
||||
* @return the count
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//@Test
|
||||
public void getCount() throws Exception{
|
||||
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkPublisher reader=GeoNetwork.get();
|
||||
|
||||
Configuration config = reader.getConfiguration();
|
||||
Account account=config.getScopeConfiguration().getAccounts().get(accountType);
|
||||
|
||||
// Configuration config = gnInstance.getGeonetworkPublisher().getConfiguration();
|
||||
// Account account = config.getScopeConfiguration().getAccounts().get(Type.CKAN);
|
||||
|
||||
//System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
|
||||
System.out.println("USER: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
System.out.println("GN: "+config.getGeoNetworkEndpoint());
|
||||
try{
|
||||
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(account.getPassword());
|
||||
System.out.println("Decrypted Password: "+decryptedPassword);
|
||||
}catch(Exception e){
|
||||
System.out.println("ignoring exception during pwd decrypting");
|
||||
}
|
||||
|
||||
|
||||
// req.addParam("keyword", "Thredds");
|
||||
final GNSearchRequest req=new GNSearchRequest();
|
||||
// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
GNSearchResponse resp = reader.query(req);
|
||||
int publicCount=resp.getCount();
|
||||
System.out.println("Public UUIDs are: "+publicCount);
|
||||
Map<Long,String> publicUUIDs = getUUIDs(resp);
|
||||
System.out.println("Filled list of Public UUIDs with: "+publicUUIDs.size());
|
||||
System.out.println("Public layers are: ");
|
||||
printLayers(publicUUIDs);
|
||||
|
||||
reader.login(loginLevel);
|
||||
resp = reader.query(req);
|
||||
int totalCount=resp.getCount();
|
||||
System.out.println("All UUIDs are: "+totalCount);
|
||||
Map<Long,String> allUUIDs = getUUIDs(resp);
|
||||
System.out.println("Filled list of All UUIDs with: "+allUUIDs.size());
|
||||
|
||||
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
|
||||
System.out.println("Private layers are: ");
|
||||
allUUIDs.keySet().removeAll(publicUUIDs.keySet());
|
||||
printLayers(allUUIDs);
|
||||
|
||||
/*if(totalCount==0)
|
||||
return;
|
||||
try{
|
||||
int last = totalCount<MAX?totalCount:MAX;
|
||||
for(int i=0; i<last; i++){
|
||||
String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
|
||||
System.out.println(i+") UUID: "+resp.getMetadata(i).getUUID() + " ID: "+resp.getMetadata(i).getId());
|
||||
//System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
}
|
||||
|
||||
}catch(Exception e ){
|
||||
e.printStackTrace();
|
||||
}*/
|
||||
System.out.println("DONE!!!");
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prints the layers.
|
||||
*
|
||||
* @param layersUUIDs the layers UUI ds
|
||||
*/
|
||||
public void printLayers(Map<Long,String> layersUUIDs) {
|
||||
int index = 0;
|
||||
|
||||
for (Long key : layersUUIDs.keySet()) {
|
||||
index++;
|
||||
System.out.println(index+") ID: "+key+" - UUID: "+layersUUIDs.get(key));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the UUI ds.
|
||||
*
|
||||
* @param resp the resp
|
||||
* @return the UUI ds
|
||||
*/
|
||||
public static Map<Long,String> getUUIDs(GNSearchResponse resp){
|
||||
|
||||
Map<Long,String> listUUIDs = new HashMap<Long,String>();
|
||||
Iterator<GNMetadata> iterator = resp.iterator();
|
||||
while(iterator.hasNext()) {
|
||||
GNMetadata meta = iterator.next();
|
||||
//listUUIDs.add(new GN_META_REF(meta.getId(), meta.getUUID()));
|
||||
listUUIDs.put(meta.getId(), meta.getUUID());
|
||||
//System.out.println("Added: "+meta.getUUID());
|
||||
}
|
||||
|
||||
return listUUIDs;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the layers by search.
|
||||
*
|
||||
* @return the layers by search
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
//@Test
|
||||
public void getLayersBySearch() throws Exception{
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkPublisher reader=GeoNetwork.get();
|
||||
|
||||
|
||||
|
||||
Configuration config = reader.getConfiguration();
|
||||
Account account=config.getScopeConfiguration().getAccounts().get(accountType);
|
||||
|
||||
//System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
|
||||
|
||||
try{
|
||||
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(account.getPassword());
|
||||
System.out.println("Decrypted Password: "+decryptedPassword);
|
||||
}catch(Exception e){
|
||||
System.out.println("ignoring exception during pwd decrypting");
|
||||
}
|
||||
|
||||
|
||||
// req.addParam("keyword", "Thredds");
|
||||
//final GNSearchRequest req=new GNSearchRequest();
|
||||
final GNSearchRequest req = getRequest(true, textToSearch);
|
||||
// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
GNSearchResponse resp = reader.query(req);
|
||||
int publicCount=resp.getCount();
|
||||
reader.login(loginLevel);
|
||||
int totalCount=reader.query(req).getCount();
|
||||
System.out.println("QUERY "+textToSearch);
|
||||
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
|
||||
// if(totalCount==0)
|
||||
// return;
|
||||
// try{
|
||||
// int last = totalCount>MAX?totalCount:MAX;
|
||||
//
|
||||
// for(int i=0; i<last; i++){
|
||||
// //String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
|
||||
// GNMetadata xml = resp.getMetadata(i);
|
||||
// //System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
// System.out.println(xml.toString());
|
||||
// }
|
||||
// }catch(Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Contains string.
|
||||
*
|
||||
* @param txt the txt
|
||||
* @param value the value
|
||||
* @return true, if successful
|
||||
*/
|
||||
private boolean containsString(String txt, String value){
|
||||
return txt.contains(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the request.
|
||||
*
|
||||
* @param sortByTitle the sort by title
|
||||
* @param textToSearch the text to search
|
||||
* @return the request
|
||||
*/
|
||||
public GNSearchRequest getRequest(boolean sortByTitle, String textToSearch) {
|
||||
|
||||
GNSearchRequest req = new GNSearchRequest();
|
||||
|
||||
if(sortByTitle)
|
||||
req.addConfig(GNSearchRequest.Config.sortBy, "title");
|
||||
|
||||
if(textToSearch==null || textToSearch.isEmpty()){
|
||||
req.addParam(GNSearchRequest.Param.any, textToSearch);
|
||||
System.out.println("search by any text");
|
||||
}else{
|
||||
req.addParam(GNSearchRequest.Param.title, textToSearch);
|
||||
req.addConfig(GNSearchRequest.Config.similarity, "1");
|
||||
System.out.println("search by title");
|
||||
}
|
||||
System.out.println("text to search "+textToSearch);
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class GN_META_REF.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* May 20, 2019
|
||||
*/
|
||||
public static class GN_META_REF{
|
||||
Long id;
|
||||
String uuid;
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the uuid.
|
||||
*
|
||||
* @return the uuid
|
||||
*/
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the uuid.
|
||||
*
|
||||
* @param uuid the new uuid
|
||||
*/
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new gn meta ref.
|
||||
*
|
||||
* @param id the id
|
||||
* @param uuid the uuid
|
||||
*/
|
||||
public GN_META_REF(Long id, String uuid) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("GN_META_REF [id=");
|
||||
builder.append(id);
|
||||
builder.append(", uuid=");
|
||||
builder.append(uuid);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the count prod.
|
||||
*
|
||||
* @return the count prod
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
// @Test
|
||||
public void getCountProd() throws Exception{
|
||||
try{
|
||||
for(String scope:scopes){
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkReader reader=GeoNetwork.get();
|
||||
final GNSearchRequest req=new GNSearchRequest();
|
||||
// req.addParam("keyword", "Thredds");
|
||||
// req.addParam(GNSearchRequest.Param.any,"Oscar");
|
||||
int publicCount=reader.query(req).getCount();
|
||||
reader.login(loginLevel);
|
||||
int totalCount=reader.query(req).getCount();
|
||||
System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
}
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,267 +0,0 @@
|
|||
//package gis;
|
||||
//import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
//import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
//
|
||||
//import java.io.BufferedInputStream;
|
||||
//import java.io.BufferedReader;
|
||||
//import java.io.FileNotFoundException;
|
||||
//import java.io.FileReader;
|
||||
//import java.io.IOException;
|
||||
//import java.io.InputStream;
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.List;
|
||||
//import java.util.stream.Collectors;
|
||||
//
|
||||
//import javax.xml.parsers.DocumentBuilder;
|
||||
//import javax.xml.parsers.DocumentBuilderFactory;
|
||||
//
|
||||
//import org.gcube.common.encryption.StringEncrypter;
|
||||
//import org.gcube.common.scope.api.ScopeProvider;
|
||||
//import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
//import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
//import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
//import org.gcube.spatial.data.geonetwork.configuration.Configuration;
|
||||
//import org.gcube.spatial.data.geonetwork.model.Account;
|
||||
//import org.gcube.spatial.data.geonetwork.model.Account.Type;
|
||||
//import org.slf4j.Logger;
|
||||
//import org.slf4j.LoggerFactory;
|
||||
//import org.w3c.dom.Document;
|
||||
//import org.w3c.dom.Element;
|
||||
//import org.w3c.dom.NodeList;
|
||||
//
|
||||
///**
|
||||
// *
|
||||
// * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
// * Aug 31, 2016
|
||||
// */
|
||||
//public class ICCATQueryTest {
|
||||
//
|
||||
// private static final int MAX = 200;
|
||||
//
|
||||
// //private String[] scopes = {"/gcube/devNext/NextNext"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
//
|
||||
// private static String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/ICCAT_BFT-E"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu/gCubeApps/fisheriesandecosystematmii"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu/D4Research"};
|
||||
//
|
||||
// //private String[] scopesProd = {"/d4science.research-infrastructures.eu"};
|
||||
//
|
||||
// private static LoginLevel loginLevel = LoginLevel.CKAN;
|
||||
//
|
||||
// private static Type accountType = Type.SCOPE;
|
||||
//
|
||||
// private static String textToSearch = "geo_fea";
|
||||
//
|
||||
// private static Logger logger = LoggerFactory.getLogger(ICCATQueryTest.class);
|
||||
//
|
||||
// private static enum LAYER_TYPE {PRIVATE, PUBLIC, ALL}
|
||||
//
|
||||
//
|
||||
// public static List<String> getLayers(LAYER_TYPE type) throws Exception{
|
||||
//
|
||||
// try{
|
||||
// for(String scope:scopesProd){
|
||||
// ScopeProvider.instance.set(scope);
|
||||
// GeoNetworkPublisher reader=GeoNetwork.get();
|
||||
//
|
||||
// Configuration config = reader.getConfiguration();
|
||||
// Account account=config.getScopeConfiguration().getAccounts().get(accountType);
|
||||
//
|
||||
// //System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
// System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
|
||||
//
|
||||
// try{
|
||||
// String decryptedPassword = StringEncrypter.getEncrypter().decrypt(account.getPassword());
|
||||
// System.out.println("Decrypted Password: "+decryptedPassword);
|
||||
// }catch(Exception e){
|
||||
// System.out.println("ignoring exception during pwd decrypting");
|
||||
// }
|
||||
//
|
||||
//
|
||||
// // req.addParam("keyword", "Thredds");
|
||||
// final GNSearchRequest req=new GNSearchRequest();
|
||||
//// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
// GNSearchResponse resp = reader.query(req);
|
||||
// int publicCount=resp.getCount();
|
||||
//
|
||||
// List<String> publicLayers = new ArrayList<String>();
|
||||
// for(int i=0; i<publicCount; i++)
|
||||
// publicLayers.add(resp.getMetadata(i).getUUID());
|
||||
//
|
||||
// System.out.println("Public layers are: "+publicLayers.size());
|
||||
//
|
||||
// //PERFOMING LOGIN TO GET ALL LAYERS
|
||||
// reader.login(loginLevel);
|
||||
// resp = reader.query(req);
|
||||
// int totalCount=resp.getCount();
|
||||
// int privateCount = totalCount-publicCount;
|
||||
//
|
||||
// System.out.println("SCOPE "+scope+" found "+totalCount+" (public : "+publicCount+", private :"+privateCount+")");
|
||||
//
|
||||
// List<String> privateLayers = new ArrayList<String>();
|
||||
// for(int i=0; i<totalCount; i++){
|
||||
//
|
||||
// String uuid = resp.getMetadata(i).getUUID();
|
||||
// //System.out.println("Searching UUID: "+uuid);
|
||||
// if(!publicLayers.contains(uuid)){
|
||||
// privateLayers.add(uuid);
|
||||
// }
|
||||
//
|
||||
//// String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
|
||||
//// InputStream stream = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8));
|
||||
//// iccatGNUUID.add(toGetFileIdentifier(stream));
|
||||
//
|
||||
// //System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
// }
|
||||
//
|
||||
// System.out.println("Private layers are: "+privateLayers.size());
|
||||
//
|
||||
//
|
||||
// switch (type) {
|
||||
// case PUBLIC:
|
||||
// return publicLayers;
|
||||
// case PRIVATE:
|
||||
// return privateLayers;
|
||||
// case ALL:
|
||||
// publicLayers.addAll(privateLayers);
|
||||
// return publicLayers;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }catch(Exception e){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Override summary record.
|
||||
// *
|
||||
// * @param doc the doc
|
||||
// * @param identifier the identifier
|
||||
// * @return true, if successful
|
||||
// */
|
||||
// private static String getFileIdentifierValue(Document doc) {
|
||||
//
|
||||
// // <csw:SummaryRecord> list
|
||||
// NodeList nodes = doc.getElementsByTagName("gmd:MD_Metadata");
|
||||
// logger.debug("gmd:MD_Metadata are: " + nodes.getLength());
|
||||
// for (int i = 0; i < nodes.getLength(); i++) {
|
||||
// Element mdMetadata = (Element) nodes.item(i);
|
||||
//
|
||||
// // <dc:identifier>
|
||||
// NodeList fileIdentifierLst = mdMetadata.getElementsByTagName("gmd:fileIdentifier");
|
||||
// if(fileIdentifierLst==null || fileIdentifierLst.getLength()==0 || fileIdentifierLst.item(0)==null){
|
||||
// logger.info("skipping, it has not fileidentifier");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Element id = (Element) fileIdentifierLst.item(0);
|
||||
//
|
||||
// NodeList gcoLst = id.getElementsByTagName("gco:CharacterString");
|
||||
// if(gcoLst==null || gcoLst.getLength()==0 || gcoLst.item(0)==null){
|
||||
// logger.info("skipping, it has not gco:CharacterString");
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// Element gco = (Element) gcoLst.item(0);
|
||||
// String idValue = gco.getTextContent();
|
||||
// logger.trace("Summary gmd:fileIdentifier is: " + idValue);
|
||||
// return idValue;
|
||||
// }
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Removes the summary ids by list ids.
|
||||
// *
|
||||
// * @param getRecordsResponse the get records response
|
||||
// * @param idsToRemove the ids to remove
|
||||
// * @return the input stream
|
||||
// * @throws IOException Signals that an I/O exception has occurred.
|
||||
// */
|
||||
// public static String toGetFileIdentifier(InputStream getRecordResponse) throws IOException {
|
||||
//
|
||||
// try {
|
||||
// // logger.trace("getRecordsResponse is: "+IOUtils.toString(getRecordsResponse));
|
||||
// BufferedInputStream bis = new BufferedInputStream(getRecordResponse);
|
||||
// DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
// dbf.setValidating(false);
|
||||
// DocumentBuilder db = dbf.newDocumentBuilder();
|
||||
// Document doc = db.parse(bis);
|
||||
// return getFileIdentifierValue(doc);
|
||||
// }
|
||||
// catch (Exception e) {
|
||||
// logger.error("An error occurred during removing IDS by List: ", e);
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static List<String> fileReader() throws FileNotFoundException{
|
||||
//
|
||||
// String fileName = "iccat_name_catalogue.csv";
|
||||
//
|
||||
//// //read file into stream, try-with-resources
|
||||
//// try (Stream<String> stream = Files.lines(Paths.get(fileName))) {
|
||||
////
|
||||
//// stream.forEach(System.out::println);
|
||||
////
|
||||
//// } catch (IOException e) {
|
||||
//// e.printStackTrace();
|
||||
//// }
|
||||
//
|
||||
// FileReader reportReader = new FileReader(fileName);
|
||||
// //Stream<String> stream = reportBW.lines();
|
||||
// List<String> list = new ArrayList<>();
|
||||
// try (BufferedReader reportBW = new BufferedReader(reportReader)){
|
||||
//
|
||||
// list = reportBW.lines().collect(Collectors.toList());
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static void main(String[] args) {
|
||||
//
|
||||
// List<String> listCKAN;
|
||||
// try {
|
||||
// listCKAN = fileReader();
|
||||
// System.out.println("CKAN Layers are: "+listCKAN.size());
|
||||
//// for (String line : listCKAN) {
|
||||
//// System.out.println("CKAN UUID: "+line);
|
||||
//// }
|
||||
//
|
||||
// List<String> listLayersUUID = getLayers(LAYER_TYPE.PUBLIC);
|
||||
// System.out.println("List Layers UUID are: "+listLayersUUID.size());
|
||||
//// for (String line : listLayersUUID) {
|
||||
//// System.out.println("PRIVATE GN UUID: "+line);
|
||||
//// }
|
||||
//
|
||||
//
|
||||
// listCKAN.removeAll(listLayersUUID);
|
||||
//
|
||||
// System.out.println("\n\n\nCKAN contains other: "+listCKAN.size());
|
||||
// for (String line : listCKAN) {
|
||||
// System.out.println("CKAN UUID: "+line);
|
||||
// }
|
||||
//
|
||||
// }catch (Exception e) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// }
|
||||
//}
|
|
@ -1,168 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package gis;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
|
||||
import it.geosolutions.geonetwork.util.GNSearchRequest;
|
||||
import it.geosolutions.geonetwork.util.GNSearchResponse;
|
||||
import resources.GetAllInfrastructureScopes;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Mar 10, 2017
|
||||
*/
|
||||
public class LayersMatchingGN_CKAN {
|
||||
|
||||
//GN CONFIGURATIONS
|
||||
public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
//static String rootScope = "/pred4s";
|
||||
// static String rootScope = "/gcube";
|
||||
public static String platformName = "geonetwork";
|
||||
public static LoginLevel loginLevel = LoginLevel.ADMIN;
|
||||
//static Type accountType = Type.SCOPE;
|
||||
public static String textToSearch = "geo_fea";
|
||||
|
||||
public static PrintWriter reportPrintWriter;
|
||||
public static PrintWriter errorPrintWriter;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try{
|
||||
FileWriter reportWriter = new FileWriter(rootScope.substring(1,rootScope.length())+"_report_matching_gn_catalogue.csv", true);
|
||||
FileWriter errorWriter = new FileWriter(rootScope.substring(1,rootScope.length())+"_error_matching_gn_catalogue.csv", true);
|
||||
BufferedWriter reportBW = new BufferedWriter(reportWriter);
|
||||
BufferedWriter errorBW = new BufferedWriter(errorWriter);
|
||||
reportPrintWriter = new PrintWriter(reportBW);
|
||||
reportPrintWriter.println("NB.; SCOPE; GN Endpoint; TOTAL LAYERS; PUBLIC LAYERS; PRIVATE LAYERS");
|
||||
errorPrintWriter = new PrintWriter(errorBW);
|
||||
errorPrintWriter.println("SCOPE;");
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// final Path destination = Paths.get("report_matching_gn_catalogue.csv");
|
||||
// Files.w(re, destination);
|
||||
|
||||
List<String> scopesProd = new ArrayList<String>();
|
||||
|
||||
//RuntimeResourceReader readerRR;
|
||||
try {
|
||||
//MODE-1
|
||||
// readerRR = new RuntimeResourceReader(rootScope, platformName, null);
|
||||
// System.out.println(readerRR.toString());
|
||||
// System.out.println("Using GN: "+readerRR.getParameters());
|
||||
// System.out.println("Scopes are: "+readerRR.getScopes().size());
|
||||
// scopesProd.addAll(readerRR.getScopes());
|
||||
|
||||
//MODE-2
|
||||
Map<String,String> mapScopes = GetAllInfrastructureScopes.loadMapOfScopeNameToFullScope(rootScope);
|
||||
scopesProd.addAll(mapScopes.values());
|
||||
}
|
||||
catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Read "+scopesProd.size() +" VREs from root scope: "+rootScope);
|
||||
int i = 0;
|
||||
for (String vre : scopesProd) {
|
||||
System.out.println(++i +"; "+vre);
|
||||
}
|
||||
|
||||
System.out.println("Scope found: "+scopesProd.size());
|
||||
|
||||
int count = 0;
|
||||
try{
|
||||
|
||||
for(String scope:scopesProd){
|
||||
count++;
|
||||
System.out.println("\n\n#"+count+" of "+scopesProd.size()+ " - Fetching scope: "+scope);
|
||||
ScopeProvider.instance.set(scope);
|
||||
GeoNetworkPublisher reader = null;
|
||||
String gnEP = null;
|
||||
try{
|
||||
reader=GeoNetwork.get();
|
||||
gnEP = reader.getConfiguration().getGeoNetworkEndpoint();
|
||||
|
||||
}catch (Exception e) {
|
||||
System.out.println("GeoNetwork not instanciable in the scope: "+scope);
|
||||
writeError(count+"; "+scope+" ; "+e.getMessage());
|
||||
}
|
||||
|
||||
if(reader!=null){
|
||||
// Configuration config = reader.getConfiguration();
|
||||
// Account account=config.getScopeConfiguration().getAccounts().get(accountType);
|
||||
//
|
||||
// //System.out.println("User: "+account.getUser()+", Pwd: "+account.getPassword());
|
||||
// System.out.println("Admin: "+config.getAdminAccount().getUser()+", Pwd: "+config.getAdminAccount().getPassword());
|
||||
//
|
||||
// try{
|
||||
// String decryptedPassword = StringEncrypter.getEncrypter().decrypt(account.getPassword());
|
||||
// System.out.println("Decrypted Password: "+decryptedPassword);
|
||||
// }catch(Exception e){
|
||||
// System.out.println("ignoring exception during pwd decrypting");
|
||||
// }
|
||||
|
||||
|
||||
// req.addParam("keyword", "Thredds");
|
||||
final GNSearchRequest req=new GNSearchRequest();
|
||||
// req.addParam(GNSearchRequest.Param.any,"Thredds");
|
||||
GNSearchResponse resp = reader.query(req);
|
||||
int publicCount=resp.getCount();
|
||||
reader.login(loginLevel);
|
||||
int totalCount=reader.query(req).getCount();
|
||||
//System.out.println("SCOPE "+scope+" ; found "+totalCount+" (public : "+publicCount+", private :"+(totalCount-publicCount)+")");
|
||||
writeReport(count+"; "+scope+" ; "+gnEP+"; "+totalCount+" ; "+publicCount+"; "+(totalCount-publicCount));
|
||||
if(totalCount==0)
|
||||
return;
|
||||
// try{
|
||||
// int last = totalCount>MAX?totalCount:MAX;
|
||||
// for(int i=0; i<last; i++){
|
||||
// String xml = reader.getByIdAsRawString(resp.getMetadata(i).getUUID());
|
||||
// System.out.println(i+") is Thredds? "+containsString(xml, "Thredds"));
|
||||
// }
|
||||
// }catch(Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
}finally{
|
||||
if(reportPrintWriter!=null)
|
||||
reportPrintWriter.close();
|
||||
|
||||
if(errorPrintWriter!=null)
|
||||
errorPrintWriter.close();
|
||||
|
||||
System.out.println("Performed fetching from "+count+" scopes");
|
||||
System.out.println("FINISHED!!!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeReport(String newline){
|
||||
|
||||
reportPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
private static void writeError(String newline){
|
||||
|
||||
errorPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,188 +0,0 @@
|
|||
package gis;
|
||||
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
|
||||
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The Class RuntimeResourceReader.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 10, 2017
|
||||
*/
|
||||
public class RuntimeResourceReader {
|
||||
|
||||
// public static final String GEONETWORK_END_POINT =
|
||||
// "http://geonetwork.d4science.org/geonetwork";
|
||||
|
||||
public static final Logger logger = LoggerFactory.getLogger(RuntimeResourceReader.class);
|
||||
|
||||
// private List<String> scopes = new ArrayList<String>();
|
||||
|
||||
private List<ServiceEndpointBean> listSE = new ArrayList<ServiceEndpointBean>();
|
||||
|
||||
/**
|
||||
* Instantiates a new runtime resource reader.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param platformName the platform name
|
||||
* @param endPoint the end point
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public RuntimeResourceReader(String scope, String platformName, String category, String endPoint) throws Exception {
|
||||
read(scope, platformName, category, endPoint);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read.
|
||||
*
|
||||
* @param scope the scope
|
||||
* @param platformName the platform name
|
||||
* @param endPoint the end point
|
||||
* @return the server parameters
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
private List<ServiceEndpointBean> read(String scope, String platformName, String category, String endPoint)
|
||||
throws Exception {
|
||||
|
||||
String originalScope = null;
|
||||
try {
|
||||
|
||||
originalScope = ScopeProvider.instance.get();
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
|
||||
SimpleQuery query = queryFor(ServiceEndpoint.class);
|
||||
if (platformName != null)
|
||||
query.addCondition("$resource/Profile/Platform/Name/text() eq '" + platformName + "'");
|
||||
if (category != null)
|
||||
query.addCondition("$resource/Profile/Category/text() eq '" + category + "'");
|
||||
if (endPoint != null && !endPoint.isEmpty())
|
||||
query.addCondition("$resource/Profile/AccessPoint/Interface/Endpoint/text() eq '" + endPoint + "'");
|
||||
|
||||
// query.addVariable("$prop", "$resource/Profile/AccessPoint/Properties/Property")
|
||||
// .addCondition("$prop/Name/text() eq 'priority'")
|
||||
// .addCondition("$prop/Value/text() eq '1'");
|
||||
|
||||
logger.info("GeoRuntimeReader, using scope: " + scope + ", to get resource: " + platformName);
|
||||
|
||||
DiscoveryClient<ServiceEndpoint> client = clientFor(ServiceEndpoint.class);
|
||||
|
||||
List<ServiceEndpoint> listServiceEndpoint = client.submit(query);
|
||||
if (listServiceEndpoint == null || listServiceEndpoint.isEmpty())
|
||||
throw new Exception("Cannot retrieve the runtime resource: " + platformName);
|
||||
|
||||
for (ServiceEndpoint serviceEndpoint : listServiceEndpoint) {
|
||||
|
||||
ServiceEndpointBean seb = new ServiceEndpointBean();
|
||||
|
||||
seb.setRuntime(serviceEndpoint.profile().runtime());
|
||||
|
||||
List<AccessPoint> listAp = new ArrayList<ServiceEndpoint.AccessPoint>();
|
||||
try {
|
||||
for (AccessPoint accessPoint : serviceEndpoint.profile().accessPoints()) {
|
||||
listAp.add(accessPoint);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("Error on reading Access point not found");
|
||||
}
|
||||
|
||||
seb.setListAP(listAp);
|
||||
listSE.add(seb);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Sorry, an error occurred on reading parameters in Runtime Resources", e);
|
||||
} finally {
|
||||
if (originalScope != null && !originalScope.isEmpty()) {
|
||||
ScopeProvider.instance.set(originalScope);
|
||||
logger.info("scope provider setted to orginal scope: " + originalScope);
|
||||
} else {
|
||||
ScopeProvider.instance.reset();
|
||||
logger.info("scope provider reset");
|
||||
}
|
||||
}
|
||||
|
||||
return listSE;
|
||||
}
|
||||
|
||||
public List<ServiceEndpointBean> getListSE() {
|
||||
return listSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* The main method.
|
||||
*
|
||||
* @param args the arguments
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
|
||||
// String scope = "/pred4s/preprod/preVRE";
|
||||
// String scope = "/d4science.research-infrastructures.eu/D4OS/GNA";
|
||||
// String scope = "/gcube/devsec/devVRE";
|
||||
String scope = "/d4science.research-infrastructures.eu/gCubeApps/ProtectedAreaImpactMaps";
|
||||
// String scope = "/d4science.research-infrastructures.eu/gCubeApps/Esquiline";
|
||||
// String scope = "/d4science.research-infrastructures.eu/D4OS/ARIADNEplus_Project";
|
||||
|
||||
// String platformName = "geonetwork";
|
||||
// String category = "Gis";
|
||||
|
||||
String platformName = "GeoServer";
|
||||
String category = null;
|
||||
|
||||
// String platformName = "postgis";
|
||||
// String category = "Database";
|
||||
|
||||
// String platformName = "postgres";
|
||||
// String category = "Database";
|
||||
|
||||
// String platformName = "mongodb";
|
||||
// String category = "Database";
|
||||
|
||||
// scope = "/pred4s/preprod/preVRE";
|
||||
|
||||
// scope = "/d4science.research-infrastructures.eu/D4OS/Blue-Cloud2026Project";
|
||||
// platformName = "Zenodo";
|
||||
// category = "Repository";
|
||||
|
||||
RuntimeResourceReader reader;
|
||||
try {
|
||||
ScopeProvider.instance.set(scope);
|
||||
reader = new RuntimeResourceReader(scope, platformName, category, null);
|
||||
|
||||
for (ServiceEndpointBean seb : reader.getListSE()) {
|
||||
System.out.println("Found: " + seb);
|
||||
|
||||
List<AccessPoint> listAp = seb.getListAP();
|
||||
|
||||
for (AccessPoint ap : listAp) {
|
||||
System.out.println("username: " + ap.username());
|
||||
System.out.println("password: " + ap.password());
|
||||
try {
|
||||
String decryptedPassword = StringEncrypter.getEncrypter().decrypt(ap.password());
|
||||
System.out.println("Decrypted Password: " + decryptedPassword);
|
||||
} catch (Exception e) {
|
||||
System.out.println("ignoring exception during pwd decrypting");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package gis;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
|
||||
import resources.GetAllInfrastructureScopes;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Mar 10, 2017
|
||||
*/
|
||||
public class SE_Harvester_from_IS {
|
||||
|
||||
// GN CONFIGURATIONS
|
||||
public static String rootScope = "/d4science.research-infrastructures.eu";
|
||||
// static String rootScope = "/pred4s";
|
||||
// static String rootScope = "/gcube";
|
||||
public static final String platformName = "geoserver";
|
||||
public static final String category = "Gis";
|
||||
public static LoginLevel loginLevel = LoginLevel.ADMIN;
|
||||
|
||||
public static PrintWriter reportPrintWriter;
|
||||
public static PrintWriter errorPrintWriter;
|
||||
|
||||
public static HashSet<String> uniqueGNs = new HashSet<String>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
try {
|
||||
FileWriter reportWriter = new FileWriter(
|
||||
rootScope.substring(1, rootScope.length()) + "_report_" + platformName + "_harvester.csv", true);
|
||||
FileWriter errorWriter = new FileWriter(
|
||||
rootScope.substring(1, rootScope.length()) + "_error_" + platformName + "_harvester.csv", true);
|
||||
BufferedWriter reportBW = new BufferedWriter(reportWriter);
|
||||
BufferedWriter errorBW = new BufferedWriter(errorWriter);
|
||||
reportPrintWriter = new PrintWriter(reportBW);
|
||||
reportPrintWriter.println("NB.; SCOPE; SE Hosted_On; SE AccessPoint;");
|
||||
errorPrintWriter = new PrintWriter(errorBW);
|
||||
errorPrintWriter.println("SCOPE;");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// final Path destination = Paths.get("report_matching_gn_catalogue.csv");
|
||||
// Files.w(re, destination);
|
||||
|
||||
List<String> listScopes = new ArrayList<String>();
|
||||
|
||||
// RuntimeResourceReader readerRR;
|
||||
try {
|
||||
// MODE-1
|
||||
// readerRR = new RuntimeResourceReader(rootScope, platformName, null);
|
||||
// System.out.println(readerRR.toString());
|
||||
// System.out.println("Using GN: "+readerRR.getParameters());
|
||||
// System.out.println("Scopes are: "+readerRR.getScopes().size());
|
||||
// scopesProd.addAll(readerRR.getScopes());
|
||||
|
||||
// MODE-2
|
||||
Map<String, String> mapScopes = GetAllInfrastructureScopes.loadMapOfScopeNameToFullScope(rootScope);
|
||||
listScopes.addAll(mapScopes.values());
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Read " + listScopes.size() + " VREs from root scope: " + rootScope);
|
||||
int i = 0;
|
||||
for (String vre : listScopes) {
|
||||
System.out.println(++i + "; " + vre);
|
||||
}
|
||||
|
||||
System.out.println("Scope found: " + listScopes.size());
|
||||
try {
|
||||
|
||||
searchFor(listScopes, platformName, category);
|
||||
searchFor(listScopes, "GeoServer", category);
|
||||
|
||||
System.out.println("\n\nUnique " + platformName + " addresses");
|
||||
uniqueGNs.stream().forEach(s -> System.out.println(s));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (reportPrintWriter != null)
|
||||
reportPrintWriter.close();
|
||||
|
||||
if (errorPrintWriter != null)
|
||||
errorPrintWriter.close();
|
||||
|
||||
System.out.println("Performed fetching from " + listScopes.size() + " scopes");
|
||||
System.out.println("FINISHED!!!");
|
||||
}
|
||||
}
|
||||
|
||||
private static void searchFor(List<String> listScopes, String platformName, String category) {
|
||||
|
||||
int count = 0;
|
||||
int writerCount = 0;
|
||||
try {
|
||||
|
||||
for (String scope : listScopes) {
|
||||
count++;
|
||||
System.out.println("\n\n#" + count + " of " + listScopes.size() + " - Fetching scope: " + scope);
|
||||
|
||||
RuntimeResourceReader rrr = new RuntimeResourceReader(scope, platformName, category, null);
|
||||
|
||||
List<ServiceEndpointBean> listSE = rrr.getListSE();
|
||||
|
||||
for (ServiceEndpointBean seb : listSE) {
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (AccessPoint ap : seb.getListAP()) {
|
||||
sb.append(ap.address());
|
||||
sb.append(", ");
|
||||
|
||||
uniqueGNs.add(ap.address());
|
||||
}
|
||||
|
||||
sb.toString();
|
||||
writerCount++;
|
||||
writeReport(
|
||||
writerCount + "; " + scope + " ; " + seb.getRuntime().hostedOn() + "; " + sb.toString());
|
||||
|
||||
}
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
// if(count==10)
|
||||
// break;
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeReport(String newline) {
|
||||
|
||||
reportPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
private static void writeError(String newline) {
|
||||
|
||||
errorPrintWriter.println(newline);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package gis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
|
||||
|
||||
/**
|
||||
* The Class ServerParameters.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it May 16, 2017
|
||||
*/
|
||||
public class ServiceEndpointBean implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 2459971193655529274L;
|
||||
|
||||
protected org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime;
|
||||
protected List<AccessPoint> listAP;
|
||||
|
||||
public ServiceEndpointBean() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ServiceEndpointBean(org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime, List<AccessPoint> listAP) {
|
||||
super();
|
||||
this.runtime = runtime;
|
||||
this.listAP = listAP;
|
||||
}
|
||||
|
||||
public org.gcube.common.resources.gcore.ServiceEndpoint.Runtime getRuntime() {
|
||||
return runtime;
|
||||
}
|
||||
|
||||
public List<AccessPoint> getListAP() {
|
||||
return listAP;
|
||||
}
|
||||
|
||||
public void setRuntime(org.gcube.common.resources.gcore.ServiceEndpoint.Runtime runtime2) {
|
||||
this.runtime = runtime2;
|
||||
}
|
||||
|
||||
public void setListAP(List<AccessPoint> listAP) {
|
||||
this.listAP = listAP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("ServiceEndpoint [runtime=");
|
||||
builder.append(runtime);
|
||||
builder.append(", listAP=");
|
||||
builder.append(listAP);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
}
|
|
@ -49,7 +49,7 @@ public class GeonetworkResolverTest {
|
|||
/*String scopeValue ="/gcube/devsec/devVRE";
|
||||
String remainValue = "/srv/en/mef.export";
|
||||
String queryString = "scope=/gcube/devsec/devVRE&remainPath=/srv/en/mef.export&version=2.0.2&request=GetCapabilities&service=CSW";
|
||||
ServiceEndpointParameters geonetworkParams = new ServiceEndpointParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", "");
|
||||
ServerParameters geonetworkParams = new ServerParameters("http://geoserver-dev2.d4science-ii.research-infrastructures.eu/geonetwork", "", "");
|
||||
|
||||
String newQueryString = purgeScopeFromQueryString(scopeValue, queryString);
|
||||
logger.info("Purged query string from "+scopeValue+" is: "+newQueryString);
|
||||
|
|
|
@ -18,7 +18,7 @@ public class GisResolverTest {
|
|||
public static void main(String[] args) {
|
||||
GisResolver gisResolver = new GisResolver();
|
||||
ScopeProvider.instance.set(scope);
|
||||
//ServiceEndpointParameters geonetworkParams = getCachedServerParameters(scope);
|
||||
//ServerParameters geonetworkParams = getCachedServerParameters(scope);
|
||||
try {
|
||||
GisLayerItem gisLayerItem = gisResolver.getGisLayerForLayerUUID(null, scope, gisUUID);
|
||||
} catch (Exception e) {
|
||||
|
@ -33,7 +33,7 @@ public class GisResolverTest {
|
|||
String scope = "/gcube/devsec/devVRE";
|
||||
String UUID = "177e1c3c-4a22-4ad9-b015-bfc443d16cb8";
|
||||
try {
|
||||
ServiceEndpointParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
|
||||
ServerParameters geonetworkParams = gisResolver.getCachedServerParameters(scope);
|
||||
String wmsRequest = gisResolver.getLayerWmsRequest(scope, UUID, geonetworkParams);
|
||||
System.out.println("Final url is: " + wmsRequest);
|
||||
wmsRequest = URLEncoder.encode(wmsRequest, UTF_8);
|
||||
|
|
|
@ -84,7 +84,7 @@ public class ServiceEndpointReader {
|
|||
if (accessPointPwd != null) {
|
||||
accessPointPwd = StringEncrypter.getEncrypter().decrypt(accessPointPwd);
|
||||
LOG.info("Decrypted pwd registered into Access Point '" + accessPoint.name() + "' is: "
|
||||
+ accessPointPwd+"...");
|
||||
+ accessPointPwd.substring(0,accessPointPwd.length()/2)+"...");
|
||||
|
||||
System.out.println("AccessPoint pwd is: "+accessPointPwd);
|
||||
}
|
||||
|
|
|
@ -15,13 +15,11 @@ import java.nio.file.StandardCopyOption;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpStatus;
|
||||
import org.gcube.datatransfer.resolver.applicationprofile.ApplicationProfileReader;
|
||||
import org.gcube.datatransfer.resolver.util.HTTPCallsUtils;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -61,7 +59,7 @@ public class TestResolvers {
|
|||
System.out.println("header fields: "+con.getHeaderFields());
|
||||
String fileName = getFilename(con.getHeaderFields());
|
||||
System.out.println("Response status is: "+status);
|
||||
if(status==Status.OK.getStatusCode()){
|
||||
if(status==HttpStatus.SC_OK){
|
||||
Path target = Files.createTempFile(FilenameUtils.getBaseName(fileName), "."+FilenameUtils.getExtension(fileName));
|
||||
try (InputStream in = con.getInputStream()) {
|
||||
Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
@ -105,7 +103,7 @@ public class TestResolvers {
|
|||
//printHeaders(con.getHeaderFields());
|
||||
String fileName = getFilename(con.getHeaderFields());
|
||||
System.out.println("Response status is: "+status);
|
||||
if(status==Status.OK.getStatusCode()){
|
||||
if(status==HttpStatus.SC_OK){
|
||||
Path target = Files.createTempFile(FilenameUtils.getBaseName(fileName), "."+FilenameUtils.getExtension(fileName));
|
||||
try (InputStream in = con.getInputStream()) {
|
||||
Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
@ -148,7 +146,7 @@ public class TestResolvers {
|
|||
status = con.getResponseCode();
|
||||
//printHeaders(con.getHeaderFields());
|
||||
System.out.println("Response status is: "+status);
|
||||
if(status==Status.OK.getStatusCode()){
|
||||
if(status==HttpStatus.SC_OK){
|
||||
System.out.println("\nFile to URL: "+url +" is reachable via doHEAD");
|
||||
System.out.println(IOUtils.toString(con.getInputStream()));
|
||||
}else{
|
||||
|
@ -189,7 +187,7 @@ public class TestResolvers {
|
|||
con.connect();
|
||||
status = con.getResponseCode();
|
||||
System.out.println("Response status is: "+status);
|
||||
if(status==Status.OK.getStatusCode()){
|
||||
if(status==HttpStatus.SC_OK){
|
||||
System.out.println("Response: \n"+getContentReponse(con.getInputStream()));
|
||||
}else{
|
||||
System.out.println("\nError on resolving the Catalogue URL: "+toURL);
|
||||
|
@ -325,7 +323,7 @@ public class TestResolvers {
|
|||
status = con.getResponseCode();
|
||||
//printHeaders(con.getHeaderFields());
|
||||
System.out.println("Response status is: "+status);
|
||||
if(status==Status.SEE_OTHER.getStatusCode()){
|
||||
if(status==HttpStatus.SC_SEE_OTHER){
|
||||
System.out.println("\nResponse to URL: "+url);
|
||||
System.out.println(IOUtils.toString(con.getInputStream()));
|
||||
}else{
|
||||
|
|
|
@ -12,9 +12,3 @@
|
|||
/preprod.gcubekey
|
||||
/pred4s.gcubekey
|
||||
/log4j.properties
|
||||
/D4OS.gcubekey
|
||||
/D4Research.gcubekey
|
||||
/OpenAIRE.gcubekey
|
||||
/ParthenosVO.gcubekey
|
||||
/SmartArea.gcubekey
|
||||
/SoBigData.gcubekey
|
||||
|
|
Loading…
Reference in New Issue