commit 1a0faccd478a13ff80095b817b1b2455d21d92d9 Author: Lucio Lelii Date: Mon Oct 3 08:26:56 2016 +0000 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 diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..a5a04fa --- /dev/null +++ b/.classpath @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..ebdaba6 --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + whn-manager-client + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.m2e.core.maven2Nature + + diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..bc1b25f --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -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/=UTF-8 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..ec4300d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..78f81ba --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Mon Apr 15 10:47:24 CEST 2013 +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/distro/INSTALL b/distro/INSTALL new file mode 100644 index 0000000..e69de29 diff --git a/distro/LICENSE b/distro/LICENSE new file mode 100644 index 0000000..7bca8c8 --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,2 @@ +${gcube.license} + diff --git a/distro/MAINTAINERS b/distro/MAINTAINERS new file mode 100644 index 0000000..2ed4c06 --- /dev/null +++ b/distro/MAINTAINERS @@ -0,0 +1,3 @@ + +* Roberto Cirillo (roberto.cirillo@isti.cnr.it), CNR Pisa, + Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo". \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..0136490 Binary files /dev/null and b/distro/README differ diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..8e0666c --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,8 @@ + + + First release + + + porting to WhnManager 2.0.0 + + \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..43f8877 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,42 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + changelog.xml + profile.xml + + 755 + true + + + target/apidocs + /${artifactId}/doc/api + true + 755 + + + + + ${distroDirectory}/profile.xml + ./ + true + + + target/${build.finalName}.jar + /${artifactId} + + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..1fd273d --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,36 @@ + + + + Service + + The WHNManager Service Client Library + VREManagement + ${artifactId} + 1.0.0 + + + The WHNManager Service Client Library + ${artifactId} + ${version} + + ${groupId} + ${artifactId} + ${version} + + + + + + + + text + library + + ${build.finalName}.jar + + + + + + + diff --git a/distro/svnpath.txt b/distro/svnpath.txt new file mode 100644 index 0000000..f416f9d --- /dev/null +++ b/distro/svnpath.txt @@ -0,0 +1 @@ +${scm.url} diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..314b0c3 --- /dev/null +++ b/pom.xml @@ -0,0 +1,116 @@ + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + org.gcube.resourcemanagement + whn-manager-client + 2.0.0-SNAPSHOT + WHN Manager CL + + + + + org.gcube.distribution + gcube-bom + 1.0.0-SNAPSHOT + pom + import + + + + + + + + org.gcube.core + common-generic-clients + + + org.gcube.core + common-gcube-calls + + + org.gcube.core + common-jaxws-calls + + + org.slf4j + slf4j-api + + + junit + junit + 4.11 + test + + + ch.qos.logback + logback-classic + 1.0.13 + test + + + org.gcube.resourcemanagement + whnmanager-api + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + + + + + distro + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + + copy-profile + install + + copy-resources + + + target + + + ${distroDirectory} + true + + profile.xml + + + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + ${distroDirectory}/descriptor.xml + + + + + servicearchive + install + + single + + + + + + + + \ No newline at end of file diff --git a/src/main/java/org/gcube/common/vremanagement/whnmanager/client/Constants.java b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/Constants.java new file mode 100644 index 0000000..763234f --- /dev/null +++ b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/Constants.java @@ -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 =service().withName(WHNMANAGER_QNAME).andInterface(WhnManager.class); + +} diff --git a/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/AbstractPlugin.java b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/AbstractPlugin.java new file mode 100644 index 0000000..f0d44cd --- /dev/null +++ b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/AbstractPlugin.java @@ -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 implements Plugin { + + private static final WHNManagerServicePlugin whnmanager_plugin = new WHNManagerServicePlugin(); + + public static ProxyBuilder whnmanager() { + return new ProxyBuilderImpl(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; + } +} diff --git a/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/WHNManagerServicePlugin.java b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/WHNManagerServicePlugin.java new file mode 100644 index 0000000..f9bebaf --- /dev/null +++ b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/plugins/WHNManagerServicePlugin.java @@ -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 { + + 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 delegate) { + return new DefaultWHNManagerProxy(delegate); + } + + @Override + public WhnManager resolve(EndpointReference address, + ProxyConfig config) throws Exception { + return stubFor(whnManager).at(address); + } + + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/DefaultWHNManagerProxy.java b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/DefaultWHNManagerProxy.java new file mode 100644 index 0000000..21798a3 --- /dev/null +++ b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/DefaultWHNManagerProxy.java @@ -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 delegate; + + private static Logger logger = LoggerFactory.getLogger(DefaultWHNManagerProxy.class); + + public DefaultWHNManagerProxy(ProxyDelegate config) { + this.delegate = config; + } + + @Override + public boolean removeFromContext(final String context) throws GCUBEUnrecoverableException { + Call call = new Call() { + + @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 call = new Call() { + + @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(); + } + } + + +} diff --git a/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/WHNManagerProxy.java b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/WHNManagerProxy.java new file mode 100644 index 0000000..44801d7 --- /dev/null +++ b/src/main/java/org/gcube/common/vremanagement/whnmanager/client/proxies/WHNManagerProxy.java @@ -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{ + + +} diff --git a/src/test/java/org/gcube/common/vremanagement/whnmanager/client/test/WHNManagerClientTest.java b/src/test/java/org/gcube/common/vremanagement/whnmanager/client/test/WHNManagerClientTest.java new file mode 100644 index 0000000..1b09b22 --- /dev/null +++ b/src/test/java/org/gcube/common/vremanagement/whnmanager/client/test/WHNManagerClientTest.java @@ -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")); + } + +} diff --git a/test-suite/addGHNToScope.sh b/test-suite/addGHNToScope.sh new file mode 100755 index 0000000..792f204 --- /dev/null +++ b/test-suite/addGHNToScope.sh @@ -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 diff --git a/test-suite/addRIToScope.sh b/test-suite/addRIToScope.sh new file mode 100755 index 0000000..f03b302 --- /dev/null +++ b/test-suite/addRIToScope.sh @@ -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 diff --git a/test-suite/removeGHNFromScope.sh b/test-suite/removeGHNFromScope.sh new file mode 100755 index 0000000..b334b8e --- /dev/null +++ b/test-suite/removeGHNFromScope.sh @@ -0,0 +1 @@ +java -cp .:./lib/org.gcube.common.vremanagement.ghnmanager.testsuite.jar:$CLASSPATH org.gcube.common.vremanagement.ghnmanager.testsuite.RemoveGHNFromScopeTest $1 $2 $3 diff --git a/test-suite/removeRIFromScope.sh b/test-suite/removeRIFromScope.sh new file mode 100755 index 0000000..9e01503 --- /dev/null +++ b/test-suite/removeRIFromScope.sh @@ -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 diff --git a/test-suite/shutdown.sh b/test-suite/shutdown.sh new file mode 100644 index 0000000..25cbc05 --- /dev/null +++ b/test-suite/shutdown.sh @@ -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