branch for release 4.1

git-svn-id: https://svn.d4science-ii.research-infrastructures.eu/gcube/branches/vre-management/whn-manager-client/2.0@132306 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Lucio Lelii 2016-10-03 08:26:56 +00:00
commit 1a0faccd47
25 changed files with 533 additions and 0 deletions

37
.classpath Normal file
View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/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/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"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

23
.project Normal file
View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>whn-manager-client</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,7 @@
#Mon Apr 15 10:47:24 CEST 2013
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

View File

@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,5 @@
#Mon Apr 15 10:47:24 CEST 2013
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

0
distro/INSTALL Normal file
View File

2
distro/LICENSE Normal file
View File

@ -0,0 +1,2 @@
${gcube.license}

3
distro/MAINTAINERS Normal file
View File

@ -0,0 +1,3 @@
* Roberto Cirillo (roberto.cirillo@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".

BIN
distro/README Normal file

Binary file not shown.

8
distro/changelog.xml Normal file
View File

@ -0,0 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.common.vre-management.whnmanager-client.1-0-0" date="2013-xx-xx">
<Change>First release</Change>
</Changeset>
<Changeset component="org.gcube.common.vre-management.whnmanager-client.2-0-0" date="2016-09-30">
<Change>porting to WhnManager 2.0.0</Change>
</Changeset>
</ReleaseNotes>

42
distro/descriptor.xml Normal file
View File

@ -0,0 +1,42 @@
<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>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
<fileSet>
<directory>target/apidocs</directory>
<outputDirectory>/${artifactId}/doc/api</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<fileMode>755</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>./</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
</files>
</assembly>

36
distro/profile.xml Normal file
View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource>
<ID/>
<Type>Service</Type>
<Profile>
<Description>The WHNManager Service Client Library</Description>
<Class>VREManagement</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Description>The WHNManager Service Client Library</Description>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<MultiVersion value="true"/>
<Mandatory level="GHN"/>
<Shareable level="VO"/>
<GHNRequirements>
<Requirement category="Site" operator="ge" requirement="string" value="java1.5"/>
</GHNRequirements>
<SpecificData>text</SpecificData>
<Type>library</Type>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

1
distro/svnpath.txt Normal file
View File

@ -0,0 +1 @@
${scm.url}

116
pom.xml Normal file
View File

@ -0,0 +1,116 @@
<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.0.0</version>
</parent>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>whn-manager-client</artifactId>
<version>2.0.0-SNAPSHOT</version>
<name>WHN Manager CL</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.distribution</groupId>
<artifactId>gcube-bom</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-generic-clients</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-gcube-calls</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-jaxws-calls</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.0.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>whnmanager-api</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
</dependencies>
<properties>
<distroDirectory>distro</distroDirectory>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,38 @@
package org.gcube.common.vremanagement.whnmanager.client;
import java.util.concurrent.TimeUnit;
import javax.xml.namespace.QName;
import org.gcube.common.calls.jaxws.GcubeService;
import org.gcube.resourcemanagement.whnmanager.api.WhnManager;
import static org.gcube.common.calls.jaxws.GcubeService.service;
/**
*
* @author roberto cirillo (ISTI-CNR)
*
*/
public class Constants {
public static final String SERVICE_CLASS = "VREManagement";
public static final String SERVICE_NAME = "WhnManager";
public static final String NAMESPACE = "http://gcube-system.org/namespaces/common/vremanagement/whnmanager";
public static final String PORT_TYPE_NAME = "whn-manager/gcube/vremanagement/ws/whnmanager";
public static final String serviceNS = "http://gcube-system.org/namespaces/common/vremanagement/whnmanager/service";
public static final String serviceLocalName = "WHNManagerService";
public static final QName serviceName = new QName(serviceNS,serviceLocalName);
public static final String porttypeNS = "http://gcube-system.org/namespaces/common/vremanagement/whnmanager";
public static final String porttypeLocalName = "GHNManagerPortType";
public static final String CONTEX_SERVICE_NAME="whn-manager";
public static final int DEFAULT_TIMEOUT= (int) TimeUnit.SECONDS.toMillis(10);
public static final QName WHNMANAGER_QNAME = new QName(org.gcube.resourcemanagement.whnmanager.api.Costants.TNS, WhnManager.SERVICE_NAME);
public static final GcubeService<WhnManager> whnManager =service().withName(WHNMANAGER_QNAME).andInterface(WhnManager.class);
}

View File

@ -0,0 +1,44 @@
package org.gcube.common.vremanagement.whnmanager.client.plugins;
import org.gcube.common.clients.Plugin;
import org.gcube.common.clients.ProxyBuilder;
import org.gcube.common.clients.ProxyBuilderImpl;
import org.gcube.common.vremanagement.whnmanager.client.Constants;
import org.gcube.common.vremanagement.whnmanager.client.proxies.WHNManagerProxy;
import org.gcube.resourcemanagement.whnmanager.api.WhnManager;
public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
private static final WHNManagerServicePlugin whnmanager_plugin = new WHNManagerServicePlugin();
public static ProxyBuilder<WHNManagerProxy> whnmanager() {
return new ProxyBuilderImpl<WhnManager,WHNManagerProxy>(whnmanager_plugin);
}
public final String name;
public AbstractPlugin(String name) {
this.name=name;
}
@Override
public String serviceClass() {
return Constants.SERVICE_CLASS;
}
@Override
public String serviceName() {
return Constants.SERVICE_NAME;
}
@Override
public String namespace() {
return Constants.NAMESPACE;
}
@Override
public String name() {
return name;
}
}

View File

@ -0,0 +1,45 @@
package org.gcube.common.vremanagement.whnmanager.client.plugins;
import static org.gcube.common.calls.jaxws.StubFactory.stubFor;
import static org.gcube.common.vremanagement.whnmanager.client.Constants.whnManager;
import javax.xml.ws.EndpointReference;
import org.gcube.common.clients.config.ProxyConfig;
import org.gcube.common.clients.delegates.ProxyDelegate;
import org.gcube.common.vremanagement.whnmanager.client.Constants;
import org.gcube.common.vremanagement.whnmanager.client.proxies.DefaultWHNManagerProxy;
import org.gcube.common.vremanagement.whnmanager.client.proxies.WHNManagerProxy;
import org.gcube.resourcemanagement.whnmanager.api.WhnManager;
/**
*
* @author roberto cirillo (CNR - ISTI)
*
*/
public class WHNManagerServicePlugin extends AbstractPlugin<WhnManager,WHNManagerProxy> {
public WHNManagerServicePlugin() {
super(Constants.CONTEX_SERVICE_NAME+"/"+WhnManager.SERVICE_NAME);
}
@Override
public Exception convert(Exception fault, ProxyConfig<?, ?> proxy) {
return fault;
}
@Override
public WHNManagerProxy newProxy(ProxyDelegate<WhnManager> delegate) {
return new DefaultWHNManagerProxy(delegate);
}
@Override
public WhnManager resolve(EndpointReference address,
ProxyConfig<?, ?> config) throws Exception {
return stubFor(whnManager).at(address);
}
}

View File

@ -0,0 +1,62 @@
package org.gcube.common.vremanagement.whnmanager.client.proxies;
import static org.gcube.common.clients.exceptions.FaultDSL.again;
import org.gcube.common.clients.Call;
import org.gcube.common.clients.delegates.ProxyDelegate;
import org.gcube.resourcemanagement.whnmanager.api.WhnManager;
import org.gcube.resourcemanagement.whnmanager.api.exception.GCUBEUnrecoverableException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import org.gcube.resourcemanagement.whnmanager.api.Types.ScopeRIParams;
public class DefaultWHNManagerProxy implements WHNManagerProxy{
ProxyDelegate<WhnManager> delegate;
private static Logger logger = LoggerFactory.getLogger(DefaultWHNManagerProxy.class);
public DefaultWHNManagerProxy(ProxyDelegate<WhnManager> config) {
this.delegate = config;
}
@Override
public boolean removeFromContext(final String context) throws GCUBEUnrecoverableException {
Call<WhnManager, Boolean> call = new Call<WhnManager, Boolean>() {
@Override
public Boolean call(WhnManager endpoint) throws Exception {
return endpoint.removeFromContext(context);
}
};
try{
return delegate.make(call);
}catch (GCUBEUnrecoverableException e) {
logger.error("no task found with id {}",context);
throw e;
}catch (Exception e) {
throw again(e).asServiceException();
}
}
@Override
public boolean addToContext(final String context) throws GCUBEUnrecoverableException {
Call<WhnManager, Boolean> call = new Call<WhnManager, Boolean>() {
@Override
public Boolean call(WhnManager endpoint) throws Exception {
return endpoint.addToContext(context);
}
};
try{
return delegate.make(call);
}catch (GCUBEUnrecoverableException e) {
logger.error("no task found with id {}", context);
throw e;
}catch (Exception e) {
throw again(e).asServiceException();
}
}
}

View File

@ -0,0 +1,14 @@
package org.gcube.common.vremanagement.whnmanager.client.proxies;
import org.gcube.resourcemanagement.whnmanager.api.WhnManager;
/**
*
* @author Roberto Cirillo (CNR)
*
*/
public interface WHNManagerProxy extends WhnManager{
}

View File

@ -0,0 +1,40 @@
package org.gcube.common.vremanagement.whnmanager.client.test;
import static org.gcube.common.vremanagement.whnmanager.client.plugins.AbstractPlugin.whnmanager;
import static org.junit.Assert.assertTrue;
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.vremanagement.whnmanager.client.proxies.WHNManagerProxy;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class WHNManagerClientTest {
Logger logger = LoggerFactory.getLogger(WHNManagerClientTest.class);
WHNManagerProxy proxy;
@Before
public void init(){
ScopeProvider.instance.set("/gcube/devNext");
//SecurityTokenProvider.instance.set("dd476d92-22cd-4144-9f77-46e6414133ac|98187548");
proxy = whnmanager().at("dlib29.isti.cnr.it", 8080).build();
Assert.assertNotNull(proxy);
}
@Test
public void addScopeToGHN() throws Exception{
assertTrue(proxy.addToContext("/gcube/devNext/NextNext"));
}
@Test
public void removeScopeFromGhn() throws Exception{
assertTrue(proxy.removeFromContext("/gcube/devNext/NextNext"));
}
}

1
test-suite/addGHNToScope.sh Executable file
View File

@ -0,0 +1 @@
java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.AddGHNToScopeTest $1 $2 $3 $4 $5

1
test-suite/addRIToScope.sh Executable file
View File

@ -0,0 +1 @@
java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.AddRIToScopeTest $1 $2 $3 $4 $5 $6

View File

@ -0,0 +1 @@
java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.RemoveGHNFromScopeTest $1 $2 $3

View File

@ -0,0 +1 @@
java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.RemoveRIFromScopeTest $1 $2 $3 $4 $5 $6

1
test-suite/shutdown.sh Normal file
View File

@ -0,0 +1 @@
java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.Shutdown $1 $2 $3 $4 $5