ref 18964: Create a Generic Resource to record Dismissed VREs
https://support.d4science.org/issues/18964 Create a library to support the resource accesstask/19440
commit
ca1327f5c3
@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
|
||||
<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.nondependency" value=""/>
|
||||
</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/detachedres-library-1.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
@ -0,0 +1,2 @@
|
||||
/target/
|
||||
/test.log
|
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>detachedres-library</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
|
||||
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//src/main/java=UTF-8
|
||||
encoding//src/main/resources=UTF-8
|
||||
encoding//src/test/java=UTF-8
|
||||
encoding//src/test/resources=UTF-8
|
||||
encoding/<project>=UTF-8
|
||||
encoding/src=UTF-8
|
@ -0,0 +1,8 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
|
||||
<wb-module deploy-name="detachedres-library">
|
||||
<wb-resource deploy-path="/" source-path="/src/main/java"/>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/resources"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
</faceted-project>
|
@ -0,0 +1,2 @@
|
||||
disabled=06target
|
||||
eclipse.preferences.version=1
|
@ -0,0 +1,45 @@
|
||||
# DetachedREs Library
|
||||
|
||||
DetachedREs is a library for retrieve information relative to Detached Research Entities like Gateways, VOs and VREs from D4Science Infrastructure.
|
||||
|
||||
## Structure of the project
|
||||
|
||||
* The source code is present in the src folder.
|
||||
|
||||
## Built With
|
||||
|
||||
* [OpenJDK](https://openjdk.java.net/) - The JDK used
|
||||
* [Maven](https://maven.apache.org/) - Dependency Management
|
||||
|
||||
## Documentation
|
||||
|
||||
* Use of this library is described on [Wiki](https://wiki.gcube-system.org/gcube/DetachedREsLibrary).
|
||||
|
||||
## Change log
|
||||
|
||||
See [Releases](https://code-repo.d4science.org/gCubeSystem/detachedres-library/releases).
|
||||
|
||||
## Authors
|
||||
|
||||
* **Giancarlo Panichi** ([ORCID](http://orcid.org/0000-0001-8375-6644)) - [ISTI-CNR Infrascience Group](http://nemis.isti.cnr.it/groups/infrascience)
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the EUPL V.1.1 License - see the [LICENSE.md](LICENSE.md) file for details.
|
||||
|
||||
|
||||
## About the gCube Framework
|
||||
This software is part of the [gCubeFramework](https://www.gcube-system.org/ "gCubeFramework"): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of European Union programmes including:
|
||||
|
||||
- the Sixth Framework Programme for Research and Technological Development
|
||||
- DILIGENT (grant no. 004260);
|
||||
- the Seventh Framework Programme for research, technological development and demonstration
|
||||
- D4Science (grant no. 212488), D4Science-II (grant no.239019), ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine(grant no. 283644);
|
||||
- the H2020 research and innovation programme
|
||||
- BlueBRIDGE (grant no. 675680), EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant no. 654119), SoBigData (grant no. 654024),DESIRA (grant no. 818194), ARIADNEplus (grant no. 823914), RISIS2 (grant no. 824091), PerformFish (grant no. 727610), AGINFRAplus (grant no. 731001);
|
||||
|
@ -0,0 +1,7 @@
|
||||
<ReleaseNotes>
|
||||
<Changeset
|
||||
component="org.gcube.infrastructure.detachedres.detachedres-library.1-0-0"
|
||||
date="2020-04-01">
|
||||
<Change>First release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
@ -0,0 +1,31 @@
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>servicearchive</id>
|
||||
<formats>
|
||||
<format>tar.gz</format>
|
||||
</formats>
|
||||
<baseDirectory>/</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README.md</include>
|
||||
<include>LICENSE.md</include>
|
||||
<include>changelog.xml</include>
|
||||
<include>profile.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/${build.finalName}.${project.packaging}</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
|
||||
</files>
|
||||
</assembly>
|
@ -0,0 +1,240 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<version>1.1.0</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.gcube.infrastructure.detachedres</groupId>
|
||||
<artifactId>detachedres-library</artifactId>
|
||||
<name>detachedres-library</name>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<description>Detached Resource Entities Library</description>
|
||||
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</connection>
|
||||
<developerConnection>scm:git:https://code-repo.d4science.org/gCubeSystem/${project.artifactId}.git</developerConnection>
|
||||
<url>https://code-repo.d4science.org/gCubeSystem/${project.artifactId}</url>
|
||||
</scm>
|
||||
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>Giancarlo Panichi</name>
|
||||
<email>g.panichi@isti.cnr.it</email>
|
||||
<organization>CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"</organization>
|
||||
<roles>
|
||||
<role>architect</role>
|
||||
<role>developer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<configDirectory>config</configDirectory>
|
||||
|
||||
<!-- Java -->
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
||||
<!-- GWT configuration -->
|
||||
<gwt.version>2.6.1</gwt.version>
|
||||
<gwt.log.version>3.3.2</gwt.log.version>
|
||||
<gwt.runTarget>DetachedREs.html</gwt.runTarget>
|
||||
<gwt.module.name>org.gcube.infrastructure.detachedres.detachedreslibrary.detachedreslib</gwt.module.name>
|
||||
|
||||
<KEYS>${env.KEYS}</KEYS>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>localRun</id>
|
||||
<dependencies>
|
||||
<!-- Logger -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>xerces</groupId>
|
||||
<artifactId>xerces</artifactId>
|
||||
<version>2.4.0</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- Authorization -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-authorization</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-client</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- Information System Client IC-Client -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
<artifactId>ic-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- LOGGING -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.5</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- JUnit TEST -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<build>
|
||||
<!-- Generate compiled stuff in the folder used for developing mode -->
|
||||
<outputDirectory>${webappDirectory}/WEB-INF/classes</outputDirectory>
|
||||
<sourceDirectory>src/main/java</sourceDirectory>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>**/*.*</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
|
||||
<plugins>
|
||||
|
||||
|
||||
<!-- GWT Maven Plugin -->
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>gwt-maven-plugin</artifactId>
|
||||
<version>${gwt.version}</version>
|
||||
<configuration>
|
||||
<strict>true</strict>
|
||||
<testTimeOut>180</testTimeOut>
|
||||
<mode>htmlunit</mode>
|
||||
<includes>**/*GwtTest.java</includes>
|
||||
<logLevel>INFO</logLevel>
|
||||
<runTarget>${gwt.runTarget}</runTarget>
|
||||
<hostedWebapp>${webappDirectory}</hostedWebapp>
|
||||
<module>${gwt.module.name}</module>
|
||||
<generateJsInteropExports>true</generateJsInteropExports>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>resources</goal>
|
||||
</goals>
|
||||
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${maven.compiler.source}</source>
|
||||
<target>${maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>descriptor.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>servicearchive</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource>
|
||||
<ID></ID>
|
||||
<Type>Service</Type>
|
||||
<Profile>
|
||||
<Description>${project.description}</Description>
|
||||
<Class>Infrastructure</Class>
|
||||
<Name>${project.name}</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Description>${project.description}</Description>
|
||||
<Name>${project.name}</Name>
|
||||
<Version>${version}</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</MavenCoordinates>
|
||||
<Type>library</Type>
|
||||
<Files>
|
||||
<File>${project.build.finalName}.${project.packaging}</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
||||
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='detachedreslib'>
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
<inherits name="com.google.gwt.http.HTTP" />
|
||||
|
||||
|
||||
<!--
|
||||
<entry-point
|
||||
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
|
||||
-->
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
-->
|
||||
|
||||
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
@ -0,0 +1,73 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server;
|
||||
|
||||
import static org.gcube.common.authorization.client.Constants.authorizationService;
|
||||
|
||||
import org.gcube.common.authorization.library.AuthorizationEntry;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.DetachedREsBuilder;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DetachedREsClient {
|
||||
|
||||
private Logger logger = LoggerFactory.getLogger(DetachedREsClient.class);
|
||||
private String token;
|
||||
private String userName;
|
||||
private String scope;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DetachedREsClient() {
|
||||
|
||||
}
|
||||
|
||||
public DetachedREsClient(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public DetachedREs getDetachedREs() throws Exception {
|
||||
retrieveAuthInfo();
|
||||
return DetachedREsBuilder.build(scope);
|
||||
|
||||
}
|
||||
|
||||
private void retrieveAuthInfo() throws Exception {
|
||||
if (Constants.DEBUG_MODE) {
|
||||
logger.debug("Debug Mode");
|
||||
userName = Constants.DEFAULT_USER;
|
||||
scope = Constants.DEFAULT_SCOPE;
|
||||
token = Constants.DEFAULT_TOKEN;
|
||||
|
||||
|
||||
} else {
|
||||
logger.debug("Production Mode");
|
||||
try {
|
||||
if (token == null) {
|
||||
logger.debug("Retrieving token credentials");
|
||||
token = SecurityTokenProvider.instance.get();
|
||||
}
|
||||
logger.debug("Use token: " + token);
|
||||
AuthorizationEntry entry = authorizationService().get(token);
|
||||
userName = entry.getClientInfo().getId();
|
||||
scope = entry.getContext();
|
||||
} catch (Exception e) {
|
||||
logger.error("Error Retrieving token credentials: " + e.getLocalizedMessage(), e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
logger.debug("Use: [userName={}, scope={}, token={}]",userName,scope,token);
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,142 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.DetachedREsJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.GatewayJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VOJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VREJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.Gateway;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VO;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.VRE;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DetachedREsBuilder {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DetachedREsBuilder.class);
|
||||
|
||||
public static DetachedREs build(String scope) throws Exception {
|
||||
logger.info("Build DetachedREs");
|
||||
DetachedREs detachedREs = null;
|
||||
|
||||
if (Constants.DEBUG_MODE) {
|
||||
logger.info("DetachedREsBuilder: use debug configuration.");
|
||||
detachedREs = useDefaultConfiguration();
|
||||
} else {
|
||||
DetachedREsJAXB detachedREsJAXB = null;
|
||||
try {
|
||||
detachedREsJAXB = InformationSystemUtils.retrieveDetachedREs(scope);
|
||||
} catch (Exception e) {
|
||||
logger.debug(e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
if (detachedREsJAXB != null) {
|
||||
logger.info("DetachedREsBuilder: use configuration in scope: " + scope);
|
||||
|
||||
detachedREs = new DetachedREs();
|
||||
logger.info("DetachedREsBuilder: configuration enabled: " + detachedREsJAXB.isEnabled());
|
||||
detachedREs.setEnabled(detachedREsJAXB.isEnabled());
|
||||
|
||||
List<GatewayJAXB> gatewaysJAXB = detachedREsJAXB.getGateways();
|
||||
logger.info("DetachedREsBuilder: Gateways configuration: " + gatewaysJAXB);
|
||||
if (gatewaysJAXB != null && !gatewaysJAXB.isEmpty()) {
|
||||
ArrayList<Gateway> gateways = new ArrayList<>();
|
||||
for (GatewayJAXB gatewayJAXB : gatewaysJAXB) {
|
||||
|
||||
Gateway gateway = new Gateway(gatewayJAXB.getScope(), gatewayJAXB.getName(),
|
||||
gatewayJAXB.getDescription());
|
||||
if (gatewayJAXB.getVos() != null && !gatewayJAXB.getVos().isEmpty()) {
|
||||
ArrayList<VO> vos = retrieveVOs(gatewayJAXB);
|
||||
gateway.setVos(vos);
|
||||
}
|
||||
gateways.add(gateway);
|
||||
}
|
||||
detachedREs.setGateways(gateways);
|
||||
|
||||
} else {
|
||||
logger.info("DetachedREsBuilder: Gateways are not present in" + " resource for scope: " + scope);
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.info("DetachedREsBuilder: DetachedREsData resource is not present in scope: " + scope);
|
||||
}
|
||||
}
|
||||
|
||||
logger.debug("DetachedREsBuilder: DetachedREs retrieved: " + detachedREs);
|
||||
return detachedREs;
|
||||
}
|
||||
|
||||
private static DetachedREs useDefaultConfiguration() {
|
||||
Gateway blueBridgeGateway = new Gateway("-1", "BlueBridge Gateway");
|
||||
VO gCubeApps = new VO("/d4science.research-infrastructures.eu/gCubeApps", "gCubeApps");
|
||||
VRE blueBridgeProject = new VRE("/d4science.research-infrastructures.eu/gCubeApps/BlueBridgeProject",
|
||||
"BlueBridgeProject");
|
||||
|
||||
ArrayList<VRE> vres = new ArrayList<>();
|
||||
vres.add(blueBridgeProject);
|
||||
gCubeApps.setVres(vres);
|
||||
|
||||
ArrayList<VO> vos = new ArrayList<>();
|
||||
vos.add(gCubeApps);
|
||||
blueBridgeGateway.setVos(vos);
|
||||
|
||||
ArrayList<Gateway> gateways = new ArrayList<>();
|
||||
gateways.add(blueBridgeGateway);
|
||||
|
||||
DetachedREs detachedREs = new DetachedREs(true, gateways);
|
||||
return detachedREs;
|
||||
}
|
||||
|
||||
private static ArrayList<VO> retrieveVOs(GatewayJAXB gatewayJAXB) throws Exception {
|
||||
try {
|
||||
ArrayList<VO> vos = new ArrayList<>();
|
||||
for (VOJAXB voJAXB : gatewayJAXB.getVos()) {
|
||||
VO vo = new VO(voJAXB.getScope(), voJAXB.getName(), voJAXB.getDescription());
|
||||
if (voJAXB.getVres() != null && !voJAXB.getVres().isEmpty()) {
|
||||
ArrayList<VRE> vres = retrieveVREs(voJAXB);
|
||||
vo.setVres(vres);
|
||||
}
|
||||
vos.add(vo);
|
||||
}
|
||||
return vos;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Invalid DetachedREs configuration. Error retrieving VO info: " + e.getLocalizedMessage(), e);
|
||||
throw new Exception(
|
||||
"Invalid DetachedREs configuration. Error retrieving VO info: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static ArrayList<VRE> retrieveVREs(VOJAXB voJAXB) throws Exception {
|
||||
try {
|
||||
ArrayList<VRE> vres = new ArrayList<>();
|
||||
for (VREJAXB vreJAXB : voJAXB.getVres()) {
|
||||
VRE vre = new VRE(vreJAXB.getScope(), vreJAXB.getName(), vreJAXB.getDescription());
|
||||
vres.add(vre);
|
||||
}
|
||||
return vres;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
logger.error("Invalid DetachedREs configuration. Error retrieving VRE info: " + e.getLocalizedMessage(), e);
|
||||
throw new Exception(
|
||||
"Invalid DetachedREs configuration. Error retrieving VRE info: " + e.getLocalizedMessage(), e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.common.resources.gcore.GenericResource;
|
||||
import org.gcube.common.resources.gcore.ScopeGroup;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.DetachedREsJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
|
||||
import org.gcube.resources.discovery.client.api.DiscoveryClient;
|
||||
import org.gcube.resources.discovery.client.impl.JAXBParser;
|
||||
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
|
||||
import org.gcube.resources.discovery.icclient.ICFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class InformationSystemUtils {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(InformationSystemUtils.class);
|
||||
|
||||
public static DetachedREsJAXB retrieveDetachedREs(String scope) throws Exception {
|
||||
try {
|
||||
|
||||
if (scope == null || scope.length() == 0)
|
||||
return null;
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
logger.debug("Retrieve DetachedREs in scope: " + scope);
|
||||
|
||||
SimpleQuery query = ICFactory.queryFor(GenericResource.class);
|
||||
query.addCondition("$resource/Profile/SecondaryType/text() eq '" + Constants.DETACHED_RES_CATEGORY + "'")
|
||||
.addCondition("$resource/Profile/Name/text() eq '" + Constants.DETACHED_RES_NAME + "'")
|
||||
.setResult("$resource");
|
||||
|
||||
DiscoveryClient<GenericResource> client = ICFactory.clientFor(GenericResource.class);
|
||||
List<GenericResource> detachedREsDataResources = client.submit(query);
|
||||
logger.debug("Resources: " + detachedREsDataResources);
|
||||
|
||||
DetachedREsJAXB detachedREsJAXB = null;
|
||||
|
||||
for (GenericResource genericResource : detachedREsDataResources) {
|
||||
if (genericResource.scopes() != null) {
|
||||
ScopeGroup<String> scopes = genericResource.scopes();
|
||||
Iterator<String> iterator = scopes.iterator();
|
||||
String scopeFound = null;
|
||||
boolean found = false;
|
||||
while (iterator.hasNext() && !found) {
|
||||
scopeFound = iterator.next();
|
||||
if (scopeFound.compareTo(scope) == 0) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if (found) {
|
||||
try {
|
||||
JAXBParser<DetachedREsJAXB> parser = new JAXBParser<DetachedREsJAXB>(DetachedREsJAXB.class);
|
||||
logger.debug("Body: " + genericResource.profile().bodyAsString());
|
||||
detachedREsJAXB = (DetachedREsJAXB) parser.parse(genericResource.profile().bodyAsString());
|
||||
logger.debug("DetachedREs: " + detachedREsJAXB);
|
||||
} catch (Throwable e) {
|
||||
String error = "Error in discovery DetachedREs in scope " + scope + ". "
|
||||
+ "Resource parsing failed!";
|
||||
logger.error(error);
|
||||
logger.error(
|
||||
"Error {resource=" + genericResource + ", error=" + e.getLocalizedMessage() + "}");
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
throw new Exception(error, e);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return detachedREsJAXB;
|
||||
|
||||
} catch (Exception e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
String error = "Error in discovery DetachedREs in scope: " + scope;
|
||||
logger.error(error, e);
|
||||
throw new Exception(error, e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "detachedres")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class DetachedREsJAXB {
|
||||
|
||||
@XmlElement(name = "enabled")
|
||||
private boolean enabled;
|
||||
|
||||
@XmlElementWrapper(name = "gateways", required = false)
|
||||
@XmlElement(name = "gateway", required = false)
|
||||
private ArrayList<GatewayJAXB> gateways;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public ArrayList<GatewayJAXB> getGateways() {
|
||||
return gateways;
|
||||
}
|
||||
|
||||
public void setGateways(ArrayList<GatewayJAXB> gateways) {
|
||||
this.gateways = gateways;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DetachedREsJAXB [enabled=" + enabled + ", gateways=" + gateways + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "gateway")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class GatewayJAXB {
|
||||
@XmlElement
|
||||
private String scope;
|
||||
|
||||
@XmlElement
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "description", required = false)
|
||||
private String description;
|
||||
|
||||
@XmlElementWrapper(name = "vos", required = false)
|
||||
@XmlElement(name = "vo", required = false)
|
||||
private ArrayList<VOJAXB> vos;
|
||||
|
||||
@XmlElement(name = "startdate", required = false)
|
||||
private Calendar startDate;
|
||||
|
||||
@XmlElement(name = "enddate", required = false)
|
||||
private Calendar endDate;
|
||||
|
||||
@XmlElement(name = "catalogurl", required = false)
|
||||
private String catalogUrl;
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<VOJAXB> getVos() {
|
||||
return vos;
|
||||
}
|
||||
|
||||
public void setVos(ArrayList<VOJAXB> vos) {
|
||||
this.vos = vos;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GatewayJAXB [scope=" + scope + ", name=" + name + ", description=" + description + ", vos=" + vos
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "vo")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class VOJAXB {
|
||||
@XmlElement
|
||||
private String scope;
|
||||
|
||||
@XmlElement
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "description", required = false)
|
||||
private String description;
|
||||
|
||||
@XmlElementWrapper(name = "vres", required = false)
|
||||
@XmlElement(name = "vre", required = false)
|
||||
private ArrayList<VREJAXB> vres;
|
||||
|
||||
@XmlElement(name = "startdate", required = false)
|
||||
private Calendar startDate;
|
||||
|
||||
@XmlElement(name = "enddate", required = false)
|
||||
private Calendar endDate;
|
||||
|
||||
@XmlElement(name = "catalogurl", required = false)
|
||||
private String catalogUrl;
|
||||
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<VREJAXB> getVres() {
|
||||
return vres;
|
||||
}
|
||||
|
||||
public void setVres(ArrayList<VREJAXB> vres) {
|
||||
this.vres = vres;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VOJAXB [scope=" + scope + ", name=" + name + ", description=" + description + ", vres=" + vres
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
@XmlRootElement(name = "vre")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class VREJAXB {
|
||||
@XmlElement
|
||||
private String scope;
|
||||
|
||||
@XmlElement
|
||||
private String name;
|
||||
|
||||
@XmlElement(name = "description", required = false)
|
||||
private String description;
|
||||
|
||||
@XmlElementWrapper(name = "managers", required = false)
|
||||
@XmlElement(name = "manager", required = false)
|
||||
private ArrayList<String> managers;
|
||||
|
||||
@XmlElement(name = "startdate", required = false)
|
||||
private Calendar startDate;
|
||||
|
||||
@XmlElement(name = "enddate", required = false)
|
||||
private Calendar endDate;
|
||||
|
||||
@XmlElement(name = "catalogurl", required = false)
|
||||
private String catalogUrl;
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<String> getManagers() {
|
||||
return managers;
|
||||
}
|
||||
|
||||
public void setManagers(ArrayList<String> managers) {
|
||||
this.managers = managers;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VREJAXB [scope=" + scope + ", name=" + name + ", description=" + description + ", managers=" + managers
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.shared;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class Constants {
|
||||
|
||||
public static final boolean DEBUG_MODE = false;
|
||||
public static final boolean TEST_ENABLE = false;
|
||||
|
||||
public static final String DEFAULT_USER = "giancarlo.panichi";
|
||||
// public static final String DEFAULT_SCOPE = "/gcube/devNext/NextNext";
|
||||
public static final String DEFAULT_SCOPE = "/gcube";
|
||||
public static final String DEFAULT_TOKEN = "";
|
||||
public static final String DEFAULT_ROLE = "OrganizationMember";
|
||||
|
||||
// IS Resource
|
||||
public static final String DETACHED_RES_CATEGORY = "DetachedREs";
|
||||
public static final String DETACHED_RES_NAME = "DetachedREsData";
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class DetachedREs implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private boolean enabled;
|
||||
private ArrayList<Gateway> gateways;
|
||||
|
||||
public DetachedREs() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DetachedREs(boolean enabled, ArrayList<Gateway> gateways) {
|
||||
super();
|
||||
this.enabled = enabled;
|
||||
this.gateways = gateways;
|
||||
}
|
||||
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public ArrayList<Gateway> getGateways() {
|
||||
return gateways;
|
||||
}
|
||||
|
||||
public void setGateways(ArrayList<Gateway> gateways) {
|
||||
this.gateways = gateways;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DetachedREs [enabled=" + enabled + ", gateways=" + gateways + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class Gateway implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
private ArrayList<VO> vos;
|
||||
private Calendar startDate;
|
||||
private Calendar endDate;
|
||||
private String catalogUrl;
|
||||
|
||||
public Gateway() {
|
||||
super();
|
||||
}
|
||||
|
||||
public Gateway(String scope, String name) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Gateway(String scope, String name, String description) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Gateway(String scope, String name, String description, ArrayList<VO> vos) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.vos = vos;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<VO> getVos() {
|
||||
return vos;
|
||||
}
|
||||
|
||||
public void setVos(ArrayList<VO> vos) {
|
||||
this.vos = vos;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Gateway [scope=" + scope + ", name=" + name + ", description=" + description + ", vos=" + vos
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class VO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
private ArrayList<VRE> vres;
|
||||
private Calendar startDate;
|
||||
private Calendar endDate;
|
||||
private String catalogUrl;
|
||||
|
||||
public VO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VO(String scope, String name) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public VO(String scope, String name, String description) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public VO(String scope, String name, String description, ArrayList<VRE> vres) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.vres = vres;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<VRE> getVres() {
|
||||
return vres;
|
||||
}
|
||||
|
||||
public void setVres(ArrayList<VRE> vres) {
|
||||
this.vres = vres;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VO [scope=" + scope + ", name=" + name + ", description=" + description + ", vres=" + vres
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*/
|
||||
public class VRE implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 2238683459962419017L;
|
||||
private String scope;
|
||||
private String name;
|
||||
private String description;
|
||||
private ArrayList<String> managers;
|
||||
private Calendar startDate;
|
||||
private Calendar endDate;
|
||||
private String catalogUrl;
|
||||
|
||||
public VRE() {
|
||||
super();
|
||||
}
|
||||
|
||||
public VRE(String scope, String name) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public VRE(String scope, String name, String description) {
|
||||
super();
|
||||
this.scope = scope;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getScope() {
|
||||
return scope;
|
||||
}
|
||||
|
||||
public void setScope(String scope) {
|
||||
this.scope = scope;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public ArrayList<String> getManagers() {
|
||||
return managers;
|
||||
}
|
||||
|
||||
public void setManagers(ArrayList<String> managers) {
|
||||
this.managers = managers;
|
||||
}
|
||||
|
||||
public Calendar getStartDate() {
|
||||
return startDate;
|
||||
}
|
||||
|
||||
public void setStartDate(Calendar startDate) {
|
||||
this.startDate = startDate;
|
||||
}
|
||||
|
||||
public Calendar getEndDate() {
|
||||
return endDate;
|
||||
}
|
||||
|
||||
public void setEndDate(Calendar endDate) {
|
||||
this.endDate = endDate;
|
||||
}
|
||||
|
||||
public String getCatalogUrl() {
|
||||
return catalogUrl;
|
||||
}
|
||||
|
||||
public void setCatalogUrl(String catalogUrl) {
|
||||
this.catalogUrl = catalogUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "VRE [scope=" + scope + ", name=" + name + ", description=" + description + ", managers=" + managers
|
||||
+ ", startDate=" + startDate + ", endDate=" + endDate + ", catalogUrl=" + catalogUrl + "]";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module rename-to='detachedreslib'>
|
||||
<inherits name='com.google.gwt.user.User' />
|
||||
<inherits name="com.google.gwt.http.HTTP" />
|
||||
|
||||
|
||||
<!--
|
||||
<entry-point
|
||||
class='org.gcube.portlets.widgets.dataminermanagerwidget.client.DataMinerManager' />
|
||||
-->
|
||||
<!-- <set-property name="log_ConsoleLogger" value="ENABLED" /> <set-property
|
||||
name="log_DivLogger" value="ENABLED" /> <set-property name="log_GWTLogger"
|
||||
value="ENABLED" /> <set-property name="log_SystemLogger" value="ENABLED"
|
||||
/> -->
|
||||
|
||||
<!--
|
||||
<set-property name="log_ConsoleLogger" value="DISABLED" />
|
||||
<set-property name="log_DivLogger" value="DISABLED" />
|
||||
<set-property name="log_GWTLogger" value="DISABLED" />
|
||||
<set-property name="log_SystemLogger" value="DISABLED" />
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<source path='client' />
|
||||
<source path='shared' />
|
||||
|
||||
</module>
|
@ -0,0 +1,133 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.infrastructure.detachedres.detachedreslibrary;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.StringWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.DetachedREsClient;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.DetachedREsJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.GatewayJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VOJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.server.is.obj.VREJAXB;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.Constants;
|
||||
import org.gcube.infrastructure.detachedres.detachedreslibrary.shared.re.DetachedREs;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Giancarlo Panichi
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class DetachedREsTest extends TestCase {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DetachedREsTest.class);
|
||||
|
||||
@Test
|
||||
public void testDetachedREsResource() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test Enabled");
|
||||
|
||||
try {
|
||||
DetachedREsClient detachedREsClient=new DetachedREsClient();
|
||||
DetachedREs detachedREs= detachedREsClient.getDetachedREs();
|
||||
logger.debug("DetachedREs: " + detachedREs);
|
||||
assertTrue(true);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
assertTrue("Error searching the resource!", false);
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.debug("Test Disabled");
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDetachedREsMarshaller() {
|
||||
if (Constants.TEST_ENABLE) {
|
||||
logger.debug("Test Enabled");
|
||||
|
||||
try {
|
||||
logger.info("Check Marshalling");
|
||||
|
||||
GatewayJAXB blueBridgeGateway = new GatewayJAXB();
|
||||
blueBridgeGateway.setScope("-1");
|
||||
blueBridgeGateway.setName("BlueBridge Gateway");
|
||||
|
||||
VOJAXB gCubeApps = new VOJAXB();
|
||||
gCubeApps.setScope("/d4science.research-infrastructures.eu/gCubeApps");
|
||||
gCubeApps.setName("gCubeApps");
|
||||
|
||||
VREJAXB blueBridgeProject = new VREJAXB();
|
||||
blueBridgeProject.setScope("/d4science.research-infrastructures.eu/gcubeApps/BlueBridgeProject");
|
||||
blueBridgeProject.setName("BlueBridgeProject");
|
||||
|
||||
ArrayList<VREJAXB> vres=new ArrayList<>();
|
||||
vres.add(blueBridgeProject);
|
||||
gCubeApps.setVres(vres);
|
||||
|
||||
ArrayList<VOJAXB> vos=new ArrayList<>();
|
||||
vos.add(gCubeApps);
|
||||
blueBridgeGateway.setVos(vos);
|
||||
|
||||
ArrayList<GatewayJAXB> gateways=new ArrayList<>();
|
||||
gateways.add(blueBridgeGateway);
|
||||
|
||||
DetachedREsJAXB detachedREs = new DetachedREsJAXB();
|
||||
detachedREs.setEnabled(true);
|
||||
detachedREs.setGateways(gateways);
|
||||
|
||||
JAXBContext jaxbContext = JAXBContext.newInstance(DetachedREsJAXB.class);
|
||||
Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
|
||||
jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
|
||||
|
||||
// Print XML String to Console
|
||||
StringWriter sw = new StringWriter();
|
||||
|
||||
// Write XML to StringWriter
|
||||
jaxbMarshaller.marshal(detachedREs, sw);
|
||||
|
||||
// Verify XML Content
|
||||
String xmlContent = sw.toString();
|
||||
logger.debug(xmlContent);
|
||||
|
||||
logger.info("Check Unmarshalling");
|
||||
Path path = Files.createTempFile("DetachedREsData", ".xml");
|
||||
File file = path.toFile();
|
||||
jaxbMarshaller.marshal(detachedREs, file);
|
||||
|
||||
Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
|
||||
DetachedREsJAXB configUnmarshalled = (DetachedREsJAXB) jaxbUnmarshaller
|
||||
.unmarshal(file);
|
||||
logger.debug("DetachedREs unmarshallded: " + configUnmarshalled);
|
||||
file.delete();
|
||||
logger.info("Success!");
|
||||
assertTrue(true);
|
||||
|
||||
} catch (Throwable e) {
|
||||
logger.error(e.getLocalizedMessage(), e);
|
||||
assertTrue("Error in DetachedREs Marshal!", false);
|
||||
}
|
||||
} else {
|
||||
logger.debug("Test Disabled");
|
||||
assertTrue(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
# A default log4j configuration for log4j users.
|
||||
#
|
||||
# To use this configuration, deploy it into your application's WEB-INF/classes
|
||||
# directory. You are also encouraged to edit it as you like.
|
||||
|
||||
log4j.rootLogger=DEBUG, stdout, rollingFile
|
||||
|
||||
# Redirect log messages to console
|
||||
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
log4j.appender.stdout.Target=System.out
|
||||
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
|
||||
log4j.appender.rollingFile=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.rollingFile.File=test.log
|
||||
log4j.appender.rollingFile.MaxFileSize=20MB
|
||||
log4j.appender.rollingFile.MaxBackupIndex=2
|
||||
log4j.appender.rollingFile.layout = org.apache.log4j.PatternLayout
|
||||
log4j.appender.rollingFile.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
Loading…
Reference in New Issue