From 977cf482b58ac6386610318f8c7f030c79657e87 Mon Sep 17 00:00:00 2001 From: Roberto Cirillo Date: Thu, 24 Oct 2013 10:06:06 +0000 Subject: [PATCH] branch from trunk git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/branches/vre-management/resourcemanager-client/1.0@83941 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 10 + .project | 23 ++ .settings/org.eclipse.core.resources.prefs | 7 + .settings/org.eclipse.jdt.core.prefs | 6 + .settings/org.eclipse.m2e.core.prefs | 5 + distro/INSTALL | 0 distro/LICENSE | 6 + distro/MAINTAINERS | 3 + distro/README | 44 +++ distro/changelog.xml | 5 + distro/descriptor.xml | 47 ++++ distro/profile.xml | 39 +++ distro/svnpath.txt | 1 + pom.xml | 80 ++++++ .../resourcemanager/client/Constants.java | 74 +++++ .../client/RMAdminLibrary.java | 56 ++++ .../client/RMBinderLibrary.java | 80 ++++++ .../client/RMControllerLibrary.java | 96 +++++++ .../client/RMReportingLibrary.java | 75 +++++ .../exceptions/InvalidOptionsException.java | 38 +++ .../exceptions/InvalidScopeException.java | 38 +++ .../exceptions/NoSuchReportException.java | 38 +++ .../ResourcesCreationException.java | 38 +++ .../exceptions/ResourcesRemovalException.java | 39 +++ .../client/fws/RMAdminServiceJAXWSStubs.java | 23 ++ .../client/fws/RMBinderServiceJAXWSStubs.java | 27 ++ .../fws/RMControllerServiceJAXWSStubs.java | 33 +++ .../fws/RMReportingServiceJAXWSStubs.java | 29 ++ .../resourcemanager/client/fws/Types.java | 262 ++++++++++++++++++ .../client/interfaces/RMAdminInterface.java | 15 + .../client/interfaces/RMBinderInterface.java | 19 ++ .../interfaces/RMControllerInterface.java | 23 ++ .../interfaces/RMReportingInterface.java | 19 ++ .../client/plugins/AbstractPlugin.java | 64 +++++ .../client/plugins/AdminPlugin.java | 39 +++ .../client/plugins/BinderPlugin.java | 39 +++ .../client/plugins/ControllerPlugin.java | 38 +++ .../client/plugins/ReportingPlugin.java | 38 +++ .../client/proxies/Proxies.java | 48 ++++ .../client/test/RMAdminLibraryTest.java | 30 ++ .../client/test/RMBinderLibraryTest.java | 90 ++++++ .../client/test/RMControllerLibraryTest.java | 84 ++++++ .../client/test/RMReportingLibraryTest.java | 52 ++++ src/test/resources/report.xml | 1 + 44 files changed, 1821 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 .settings/org.eclipse.core.resources.prefs create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 .settings/org.eclipse.m2e.core.prefs create mode 100644 distro/INSTALL create mode 100644 distro/LICENSE create mode 100644 distro/MAINTAINERS create mode 100644 distro/README create mode 100644 distro/changelog.xml create mode 100644 distro/descriptor.xml create mode 100644 distro/profile.xml create mode 100644 distro/svnpath.txt create mode 100644 pom.xml create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/Constants.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/RMAdminLibrary.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/RMBinderLibrary.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/RMControllerLibrary.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/RMReportingLibrary.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidOptionsException.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidScopeException.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/NoSuchReportException.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesCreationException.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesRemovalException.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMAdminServiceJAXWSStubs.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMBinderServiceJAXWSStubs.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMControllerServiceJAXWSStubs.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMReportingServiceJAXWSStubs.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/Types.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMAdminInterface.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMBinderInterface.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMControllerInterface.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMReportingInterface.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AbstractPlugin.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AdminPlugin.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/BinderPlugin.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ControllerPlugin.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ReportingPlugin.java create mode 100644 src/main/java/org/gcube/vremanagement/resourcemanager/client/proxies/Proxies.java create mode 100644 src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMAdminLibraryTest.java create mode 100644 src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMBinderLibraryTest.java create mode 100644 src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMControllerLibraryTest.java create mode 100644 src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMReportingLibraryTest.java create mode 100644 src/test/resources/report.xml diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..0f53f3e --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..ccedd6d --- /dev/null +++ b/.project @@ -0,0 +1,23 @@ + + + resourcemanager-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..5d96f91 --- /dev/null +++ b/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,7 @@ +#Tue Apr 23 11:22:06 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..d3ded3e --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +#Tue Apr 23 11:22:07 CEST 2013 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..ac7b805 --- /dev/null +++ b/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,5 @@ +#Tue Apr 23 11:22:04 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..630ba97 --- /dev/null +++ b/distro/LICENSE @@ -0,0 +1,6 @@ +gCube System - License +------------------------------------------------------------ + +The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl). +The software and documentation is provided by its authors/distributors "as is" and no expressed or +implied warranty is given for its use, quality or fitness for a particular case. diff --git a/distro/MAINTAINERS b/distro/MAINTAINERS new file mode 100644 index 0000000..c2a3625 --- /dev/null +++ b/distro/MAINTAINERS @@ -0,0 +1,3 @@ + +* Andrea Manzi (andrea.manzi@cern.ch), CERN + \ No newline at end of file diff --git a/distro/README b/distro/README new file mode 100644 index 0000000..8faba1b --- /dev/null +++ b/distro/README @@ -0,0 +1,44 @@ +The gCube System - GHNManager Service Client +------------------------------------------------------------ + + +This work has been partially supported by the following European projects: +DILIGENT (FP6-2003-IST-2), +D4Science (FP7-INFRA-2007-1.2.2), +D4Science-II (FP7-INFRA-2008-1.2.2), i +Marine (FP7-INFRASTRUCTURES-2011-2), and +EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil). + +Authors +------- + +* Andrea Manzi (andrea.manzi@cern.ch), CERN + + +Version and Release Date +------------------------ + +v. 1.0, 04/05/2012 + +Description +----------- + + +Download information +-------------------- + +Source code is available from SVN: +http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/GHNManager + +Binaries can be downloaded from: +http://www.gcube-system.org/ + +Documentation +------------- +Documentation is available on-line from the Projects Documentation Wiki: +https://gcube.wiki.gcube-system.org/gcube/index.php/GHN_Manager + +Licensing +--------- + +This software is licensed under the terms you may find in the file named "LICENSE" in this directory. diff --git a/distro/changelog.xml b/distro/changelog.xml new file mode 100644 index 0000000..106fb01 --- /dev/null +++ b/distro/changelog.xml @@ -0,0 +1,5 @@ + + + ported to maven + + \ No newline at end of file diff --git a/distro/descriptor.xml b/distro/descriptor.xml new file mode 100644 index 0000000..6152aa2 --- /dev/null +++ b/distro/descriptor.xml @@ -0,0 +1,47 @@ + + servicearchive + + tar.gz + + / + + + ${distroDirectory} + / + true + + README + LICENSE + INSTALL + MAINTAINERS + changelog.xml + + 755 + true + + + target/apidocs + /${artifactId}/doc/api + true + 755 + + + + + ${distroDirectory}/profile.xml + ./ + true + + + target/${build.finalName}.jar + /${artifactId} + + + ${distroDirectory}/svnpath.txt + /${artifactId} + true + + + \ No newline at end of file diff --git a/distro/profile.xml b/distro/profile.xml new file mode 100644 index 0000000..161aa46 --- /dev/null +++ b/distro/profile.xml @@ -0,0 +1,39 @@ + + + + + + + Service + + The Resource Manager Service Client Library + VREManagement + ${artifactId} + 1.0.0 + + + The Resource Manager 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..2fb679f --- /dev/null +++ b/pom.xml @@ -0,0 +1,80 @@ + + 4.0.0 + + maven-parent + org.gcube.tools + 1.0.0 + + org.gcube.resourcemanagement + resourcemanager-client + 1.0.0-SNAPSHOT + Resource Manager CL + + + org.gcube.core + common-fw-clients + [1.0.0-SNAPSHOT,) + + + junit + junit + 4.10 + test + + + + + 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/vremanagement/resourcemanager/client/Constants.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/Constants.java new file mode 100644 index 0000000..bbb578e --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/Constants.java @@ -0,0 +1,74 @@ +package org.gcube.vremanagement.resourcemanager.client; + +import static org.gcube.common.clients.stubs.jaxws.GCoreServiceBuilder.service; + +import javax.xml.namespace.QName; + +import org.gcube.common.clients.stubs.jaxws.GCoreService; +import org.gcube.vremanagement.resourcemanager.client.fws.*; + +/** + * + * @author andrea + * + */ +public class Constants { + + public static final String SERVICE_CLASS = "VREManagement"; + public static final String SERVICE_NAME = "ResourceManager"; + + public static final String NAMESPACE_ADMIN = "http://gcube-system.org/namespaces/vremanagement/resourcemanager/administration"; + public static final String PORT_TYPE_NAME_ADMIN = "gcube/vremanagement/resourcemanager/administration"; + + public static final String NAMESPACE_REPORTING = "http://gcube-system.org/namespaces/vremanagement/resourcemanager/reporting"; + public static final String PORT_TYPE_NAME_REPORTING = "gcube/vremanagement/resourcemanager/reporting"; + + public static final String NAMESPACE_BINDER = "http://gcube-system.org/namespaces/vremanagement/resourcemanager/binder"; + public static final String PORT_TYPE_NAME_BINDER = "gcube/vremanagement/resourcemanager/binder"; + + public static final String NAMESPACE_CONTROLLER = "http://gcube-system.org/namespaces/vremanagement/resourcemanager/controller"; + public static final String PORT_TYPE_NAME_CONTROLLER = "gcube/vremanagement/resourcemanager/scopecontroller"; + + + public static final String serviceAdminNS = NAMESPACE_ADMIN+"/service"; + public static final String serviceAdminLocalName = "ReportingService"; + public static final QName serviceAdminName = new QName(serviceAdminNS,serviceAdminLocalName); + + + public static final String serviceReportingNS = NAMESPACE_REPORTING+"/service"; + public static final String serviceReportingLocalName = "ReportingService"; + public static final QName serviceReportingName = new QName(serviceReportingNS,serviceReportingLocalName); + + + public static final String serviceBinderNS = NAMESPACE_BINDER+"/service"; + public static final String serviceBinderLocalName = "ResourceBinderService"; + public static final QName serviceBinderName = new QName(serviceBinderNS,serviceBinderLocalName); + + public static final String serviceControllerNS = NAMESPACE_CONTROLLER+"/service"; + public static final String serviceControllerLocalName = "ScopeControllerService"; + public static final QName serviceControllerName = new QName(serviceControllerNS,serviceControllerLocalName); + + + public static final String porttypeAdminLocalName = "AdministrationPortType"; + public static final String porttypeReportingLocalName = "ReportingPortType"; + public static final String porttypeBinderLocalName = "ResourceBinderPortType"; + public static final String porttypeControllerLocalName = "ScopeControllerPortType"; + + + public static final GCoreService rm_admin = service().withName(serviceAdminName) + .coordinates(SERVICE_CLASS,SERVICE_NAME) + .andInterface(RMAdminServiceJAXWSStubs.class); + + + public static final GCoreService rm_reporting = service().withName(serviceReportingName) + .coordinates(SERVICE_CLASS,SERVICE_NAME) + .andInterface(RMReportingServiceJAXWSStubs.class); + + public static final GCoreService rm_binder = service().withName(serviceBinderName) + .coordinates(SERVICE_CLASS,SERVICE_NAME) + .andInterface(RMBinderServiceJAXWSStubs.class); + + public static final GCoreService rm_controller = service().withName(serviceControllerName) + .coordinates(SERVICE_CLASS,SERVICE_NAME) + .andInterface(RMControllerServiceJAXWSStubs.class); +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMAdminLibrary.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMAdminLibrary.java new file mode 100644 index 0000000..bde5c6f --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMAdminLibrary.java @@ -0,0 +1,56 @@ +package org.gcube.vremanagement.resourcemanager.client; + +import org.gcube.common.clients.Call; +import org.gcube.common.clients.delegates.AsyncProxyDelegate; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.common.clients.exceptions.ServiceException; +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; + +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.fws.RMAdminServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.interfaces.RMAdminInterface; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class RMAdminLibrary implements RMAdminInterface { + + private final ProxyDelegate delegate; + + Logger logger = LoggerFactory.getLogger(this.getClass().toString()); + + + public RMAdminLibrary(ProxyDelegate delegate) { + this.delegate=delegate; + + } + + + @Override + public Empty cleanSoftwareState() throws InvalidScopeException { + + Call call = new Call() { + @Override + public Empty call(RMAdminServiceJAXWSStubs endpoint) throws Exception { + return endpoint.CleanSoftwareState(); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw new ServiceException (e); + } + + } + + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMBinderLibrary.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMBinderLibrary.java new file mode 100644 index 0000000..fdf8b5a --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMBinderLibrary.java @@ -0,0 +1,80 @@ +package org.gcube.vremanagement.resourcemanager.client; + +import org.gcube.common.clients.Call; +import org.gcube.common.clients.delegates.AsyncProxyDelegate; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesRemovalException; +import org.gcube.vremanagement.resourcemanager.client.fws.*; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.AddResourcesParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.RemoveResourcesParameters; +import org.gcube.vremanagement.resourcemanager.client.interfaces.RMBinderInterface; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import static org.gcube.common.clients.exceptions.FaultDSL.*; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class RMBinderLibrary implements RMBinderInterface{ + + private final ProxyDelegate delegate; + + Logger logger = LoggerFactory.getLogger(this.getClass().toString()); + + + public RMBinderLibrary(ProxyDelegate delegate) { + this.delegate=delegate; + + } + + + @Override + public String addResources(final AddResourcesParameters params) + throws ResourcesCreationException, InvalidScopeException { + + Call call = new Call() { + @Override + public String call(RMBinderServiceJAXWSStubs endpoint) throws Exception { + return endpoint.AddResources(params); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(ResourcesCreationException.class,InvalidScopeException.class); + } + + } + + + @Override + public String removeResources(final RemoveResourcesParameters params) + throws ResourcesRemovalException, InvalidScopeException { + + Call call = new Call() { + @Override + public String call(RMBinderServiceJAXWSStubs endpoint) throws Exception { + return endpoint.RemoveResources(params); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(ResourcesRemovalException.class,InvalidScopeException.class); + } + + } + + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMControllerLibrary.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMControllerLibrary.java new file mode 100644 index 0000000..396be48 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMControllerLibrary.java @@ -0,0 +1,96 @@ +package org.gcube.vremanagement.resourcemanager.client; + +import static org.gcube.common.clients.exceptions.FaultDSL.again; + +import org.gcube.common.clients.Call; +import org.gcube.common.clients.delegates.AsyncProxyDelegate; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidOptionsException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.fws.RMControllerServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.CreateScopeParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.OptionsParameters; +import org.gcube.vremanagement.resourcemanager.client.interfaces.RMControllerInterface; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class RMControllerLibrary implements RMControllerInterface{ + + private final ProxyDelegate delegate; + + Logger logger = LoggerFactory.getLogger(this.getClass().toString()); + + + public RMControllerLibrary(ProxyDelegate delegate) { + this.delegate=delegate; + + } + + + @Override + public Empty changeScopeOptions(final OptionsParameters options) + throws InvalidScopeException, InvalidOptionsException { + Call call = new Call() { + @Override + public Empty call(RMControllerServiceJAXWSStubs endpoint) throws Exception { + return endpoint.ChangeScopeOptions(options); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(InvalidOptionsException.class,InvalidScopeException.class); + } + } + + + @Override + public String disposeScope(final String scope) throws InvalidScopeException { + Call call = new Call() { + @Override + public String call(RMControllerServiceJAXWSStubs endpoint) throws Exception { + return endpoint.DisposeScope(scope); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(InvalidScopeException.class); + } + } + + + @Override + public Empty createScope(final CreateScopeParameters params) + throws InvalidScopeException, InvalidOptionsException { + Call call = new Call() { + @Override + public Empty call(RMControllerServiceJAXWSStubs endpoint) throws Exception { + return endpoint.CreateScope(params); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(InvalidScopeException.class,InvalidOptionsException.class); + } + } + + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMReportingLibrary.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMReportingLibrary.java new file mode 100644 index 0000000..d437b07 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/RMReportingLibrary.java @@ -0,0 +1,75 @@ +package org.gcube.vremanagement.resourcemanager.client; + +import static org.gcube.common.clients.exceptions.FaultDSL.again; + +import org.gcube.common.clients.Call; +import org.gcube.common.clients.delegates.AsyncProxyDelegate; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.NoSuchReportException; +import org.gcube.vremanagement.resourcemanager.client.fws.RMReportingServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.SendReportParameters; +import org.gcube.vremanagement.resourcemanager.client.interfaces.RMReportingInterface; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class RMReportingLibrary implements RMReportingInterface{ + + private final ProxyDelegate delegate; + + Logger logger = LoggerFactory.getLogger(this.getClass().toString()); + + + public RMReportingLibrary(ProxyDelegate delegate) { + this.delegate=delegate; + + } + + + @Override + public Empty sendReport(final SendReportParameters params) + throws InvalidScopeException { + Call call = new Call() { + @Override + public Empty call(RMReportingServiceJAXWSStubs endpoint) throws Exception { + return endpoint.SendReport(params); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(InvalidScopeException.class); + } + } + + + @Override + public String getReport(final String reportId) throws InvalidScopeException, + NoSuchReportException { + Call call = new Call() { + @Override + public String call(RMReportingServiceJAXWSStubs endpoint) throws Exception { + return endpoint.GetReport(reportId); + + } + }; + try { + return delegate.make(call); + } + + catch(Exception e) { + throw again(e).as(InvalidScopeException.class, NoSuchReportException.class); + } + } + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidOptionsException.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidOptionsException.java new file mode 100644 index 0000000..c9078e0 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidOptionsException.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.exceptions; + +import javax.xml.ws.WebFault; + +import org.gcube.common.clients.delegates.Unrecoverable; + +@Unrecoverable +@WebFault(name="InvalidOptionsFaultType") +public class InvalidOptionsException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance. + */ + public InvalidOptionsException() { + super(); + } + + /** + * Creates an instance with given message. + * @param msg the message + */ + public InvalidOptionsException(String msg) { + super(msg); + } + + /** + * Creates an instance with a given message and cause. + * @param msg the message + * @param cause the cause + */ + public InvalidOptionsException(String msg,Throwable cause) {super(msg,cause);} + + public InvalidOptionsException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidScopeException.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidScopeException.java new file mode 100644 index 0000000..075ee71 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/InvalidScopeException.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.exceptions; + +import javax.xml.ws.WebFault; + +import org.gcube.common.clients.delegates.Unrecoverable; + +@Unrecoverable +@WebFault(name="InvalidScopeFaultType") +public class InvalidScopeException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance. + */ + public InvalidScopeException() { + super(); + } + + /** + * Creates an instance with given message. + * @param msg the message + */ + public InvalidScopeException(String msg) { + super(msg); + } + + /** + * Creates an instance with a given message and cause. + * @param msg the message + * @param cause the cause + */ + public InvalidScopeException(String msg,Throwable cause) {super(msg,cause);} + + public InvalidScopeException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/NoSuchReportException.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/NoSuchReportException.java new file mode 100644 index 0000000..b5a8693 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/NoSuchReportException.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.exceptions; + +import javax.xml.ws.WebFault; + +import org.gcube.common.clients.delegates.Unrecoverable; + +@Unrecoverable +@WebFault(name="NoSuchReportFaultType") +public class NoSuchReportException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance. + */ + public NoSuchReportException() { + super(); + } + + /** + * Creates an instance with given message. + * @param msg the message + */ + public NoSuchReportException(String msg) { + super(msg); + } + + /** + * Creates an instance with a given message and cause. + * @param msg the message + * @param cause the cause + */ + public NoSuchReportException(String msg,Throwable cause) {super(msg,cause);} + + public NoSuchReportException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesCreationException.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesCreationException.java new file mode 100644 index 0000000..257dac5 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesCreationException.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.exceptions; + +import javax.xml.ws.WebFault; + +import org.gcube.common.clients.delegates.Unrecoverable; + +@Unrecoverable +@WebFault(name="ResourcesCreationFaultType") +public class ResourcesCreationException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance. + */ + public ResourcesCreationException() { + super(); + } + + /** + * Creates an instance with given message. + * @param msg the message + */ + public ResourcesCreationException(String msg) { + super(msg); + } + + /** + * Creates an instance with a given message and cause. + * @param msg the message + * @param cause the cause + */ + public ResourcesCreationException(String msg,Throwable cause) {super(msg,cause);} + + public ResourcesCreationException(Throwable cause) { + super(cause); + } +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesRemovalException.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesRemovalException.java new file mode 100644 index 0000000..7ca81d4 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/exceptions/ResourcesRemovalException.java @@ -0,0 +1,39 @@ +package org.gcube.vremanagement.resourcemanager.client.exceptions; + +import javax.xml.ws.WebFault; + +import org.gcube.common.clients.delegates.Unrecoverable; + +@Unrecoverable +@WebFault(name="ResourcesRemovalFaultType") +public class ResourcesRemovalException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates an instance. + */ + public ResourcesRemovalException() { + super(); + } + + /** + * Creates an instance with given message. + * @param msg the message + */ + public ResourcesRemovalException(String msg) { + super(msg); + } + + /** + * Creates an instance with a given message and cause. + * @param msg the message + * @param cause the cause + */ + public ResourcesRemovalException(String msg,Throwable cause) {super(msg,cause);} + + public ResourcesRemovalException(Throwable cause) { + super(cause); + } +} + diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMAdminServiceJAXWSStubs.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMAdminServiceJAXWSStubs.java new file mode 100644 index 0000000..923e535 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMAdminServiceJAXWSStubs.java @@ -0,0 +1,23 @@ +package org.gcube.vremanagement.resourcemanager.client.fws; + + +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.jws.soap.SOAPBinding.ParameterStyle; +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; + + + /** + * + * @author Andrea Manzi(CERN) + * + */ +@WebService(name=porttypeAdminLocalName,targetNamespace=NAMESPACE_ADMIN) +public interface RMAdminServiceJAXWSStubs { + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public Empty CleanSoftwareState(); + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMBinderServiceJAXWSStubs.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMBinderServiceJAXWSStubs.java new file mode 100644 index 0000000..88bbfaa --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMBinderServiceJAXWSStubs.java @@ -0,0 +1,27 @@ +package org.gcube.vremanagement.resourcemanager.client.fws; + +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; +import static org.gcube.vremanagement.resourcemanager.client.fws.Types.*; + + +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.jws.soap.SOAPBinding.ParameterStyle; + + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +@WebService(name=porttypeBinderLocalName,targetNamespace=NAMESPACE_BINDER) +public interface RMBinderServiceJAXWSStubs { + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public String AddResources(AddResourcesParameters params); + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public String RemoveResources(RemoveResourcesParameters params); + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMControllerServiceJAXWSStubs.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMControllerServiceJAXWSStubs.java new file mode 100644 index 0000000..50664ff --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMControllerServiceJAXWSStubs.java @@ -0,0 +1,33 @@ +package org.gcube.vremanagement.resourcemanager.client.fws; + +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; +import static org.gcube.vremanagement.resourcemanager.client.fws.Types.*; + + +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.jws.soap.SOAPBinding.ParameterStyle; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; + + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +@WebService(name=porttypeControllerLocalName,targetNamespace=NAMESPACE_CONTROLLER) +public interface RMControllerServiceJAXWSStubs { + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public Empty ChangeScopeOptions(OptionsParameters options); + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public String DisposeScope(String scope); + + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public Empty CreateScope(CreateScopeParameters params); + +} \ No newline at end of file diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMReportingServiceJAXWSStubs.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMReportingServiceJAXWSStubs.java new file mode 100644 index 0000000..2564139 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/RMReportingServiceJAXWSStubs.java @@ -0,0 +1,29 @@ +package org.gcube.vremanagement.resourcemanager.client.fws; + +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; +import static org.gcube.vremanagement.resourcemanager.client.fws.Types.*; + +import javax.jws.WebService; +import javax.jws.soap.SOAPBinding; +import javax.jws.soap.SOAPBinding.ParameterStyle; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +@WebService(name=porttypeReportingLocalName,targetNamespace=NAMESPACE_REPORTING) +public interface RMReportingServiceJAXWSStubs { + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public Empty SendReport(SendReportParameters params); + + @SOAPBinding(parameterStyle=ParameterStyle.BARE) + public String GetReport(String reportId); + + +} + + diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/Types.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/Types.java new file mode 100644 index 0000000..fd887fa --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/fws/Types.java @@ -0,0 +1,262 @@ +package org.gcube.vremanagement.resourcemanager.client.fws; + +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.XmlElementRef; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.ws.WebFault; + +import org.gcube.common.resources.gcore.common.Identity; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class Types { + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class AddResourcesParameters{ + + @XmlElement(name = "software") + public SoftwareList softwareList; + @XmlElement (name= "resources") + public ResourceList resources; + + @XmlElement (name= "targetScope") + public String targetScope; + + + + public SoftwareList getSoftwareList() { + return softwareList; + } + + + + public void setSoftwareList(SoftwareList softwareList) { + this.softwareList = softwareList; + } + + + + public ResourceList getResources() { + return resources; + } + + + + public void setResources(ResourceList resources) { + this.resources = resources; + } + + + + public String getTargetScope() { + return targetScope; + } + + + + public void setTargetScope(String targetScope) { + this.targetScope = targetScope; + } + + + + @Override + public String toString() { + return "AddResourcesParameters [scope=" + softwareList + ", resources=" + + resources + ", targetScope=" + targetScope + "]"; + } + + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class RemoveResourcesParameters{ + + @XmlElement(name = "software") + public SoftwareList softwareList; + @XmlElement (name= "resources") + public ResourceList resources; + @XmlElement (name= "targetScope") + public String targetScope; + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class SoftwareList{ + + @XmlElement(name="suggestedTargetGHNNames") + public ArrayList suggestedTargetGHNNames; + @XmlElement(name="software") + public ArrayList software; + + } + + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class ResourceList{ + + @XmlElement(name="resource") + public ArrayList resource; + + public ArrayList getResource() { + return resource; + } + + public void setResource(ArrayList resource) { + this.resource = resource; + } + + + + } + + + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class PackageItem{ + + @XmlElement(name="ServiceClass") + public String serviceClass; + @XmlElement(name="ServiceName") + public String serviceName; + @XmlElement(name="ServiceVersion") + public String serviceVersion; + @XmlElement(name="PackageName") + public String packageName; + @XmlElement(name="PackageVersion") + public String packageVersion; + @XmlElement(name="TargetGHNName") + public String targetGHNName; + + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class ResourceItem{ + + @XmlElement(name="ID") + public String id; + @XmlElement(name="Type") + public String type; + public String getId() { + return id; + } + public void setId(String id) { + this.id = id; + } + public String getType() { + return type; + } + public void setType(String type) { + this.type = type; + } + + + + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class OptionsParameters{ + + @XmlElement(name="targetScope") + public String targetScope; + + @XmlElement(name="scopeOptionList") + public ArrayList scopeOptionList; + + + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class ScopeOption{ + + @XmlElement + public String name; + @XmlElement + public String value; + + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class CreateScopeParameters{ + + @XmlElement + public String targetScope; + @XmlElement + public String serviceMap; + +// @XmlElement(name="optionParameters") + @XmlElementRef + public OptionsParameters optionParameters; + } + + @XmlRootElement + @XmlAccessorType(XmlAccessType.FIELD) + public static class SendReportParameters{ + + @XmlElement + public String callbackID; + + @XmlElement + public String report; + + @XmlElement + public String targetScope; + } + + @WebFault(name="InvalidOptionsFault") + public static class InvalidOptionsFault extends RuntimeException { + + public InvalidOptionsFault(String s) { + super(s); + } + } + + + @WebFault(name="InvalidScopeFault") + public static class InvalidScopeFault extends RuntimeException { + + public InvalidScopeFault(String s) { + super(s); + } + } + + @WebFault(name="NoSuchReportFault") + public static class NoSuchReportFault extends RuntimeException { + + public NoSuchReportFault(String s) { + super(s); + } + } + + @WebFault(name="ResourcesCreationFault") + public static class ResourcesCreationFault extends RuntimeException { + + public ResourcesCreationFault(String s) { + super(s); + } + } + + @WebFault(name="ResourcesRemovalFault") + public static class ResourcesRemovalFault extends RuntimeException { + + public ResourcesRemovalFault(String s) { + super(s); + } + } + + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMAdminInterface.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMAdminInterface.java new file mode 100644 index 0000000..84af0a4 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMAdminInterface.java @@ -0,0 +1,15 @@ +package org.gcube.vremanagement.resourcemanager.client.interfaces; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public interface RMAdminInterface { + + public Empty cleanSoftwareState() throws InvalidScopeException; + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMBinderInterface.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMBinderInterface.java new file mode 100644 index 0000000..f061311 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMBinderInterface.java @@ -0,0 +1,19 @@ +package org.gcube.vremanagement.resourcemanager.client.interfaces; + +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesRemovalException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.AddResourcesParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.RemoveResourcesParameters; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public interface RMBinderInterface { + + public String addResources(AddResourcesParameters params) throws ResourcesCreationException, InvalidScopeException; + + public String removeResources(RemoveResourcesParameters params) throws ResourcesRemovalException, InvalidScopeException; +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMControllerInterface.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMControllerInterface.java new file mode 100644 index 0000000..ff1ed1e --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMControllerInterface.java @@ -0,0 +1,23 @@ +package org.gcube.vremanagement.resourcemanager.client.interfaces; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidOptionsException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.CreateScopeParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.OptionsParameters; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public interface RMControllerInterface { + + public Empty changeScopeOptions(OptionsParameters options) throws InvalidScopeException, InvalidOptionsException; + + public String disposeScope(String scope) throws InvalidScopeException; + + public Empty createScope(CreateScopeParameters params) throws InvalidScopeException, InvalidOptionsException; + + +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMReportingInterface.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMReportingInterface.java new file mode 100644 index 0000000..f63ee2c --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/interfaces/RMReportingInterface.java @@ -0,0 +1,19 @@ +package org.gcube.vremanagement.resourcemanager.client.interfaces; + +import org.gcube.common.clients.stubs.jaxws.JAXWSUtils.Empty; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.NoSuchReportException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.SendReportParameters; + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public interface RMReportingInterface { + + public Empty sendReport(SendReportParameters params) throws InvalidScopeException; + + public String getReport(String reportId) throws InvalidScopeException, NoSuchReportException; +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AbstractPlugin.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AbstractPlugin.java new file mode 100644 index 0000000..38e2fc5 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AbstractPlugin.java @@ -0,0 +1,64 @@ +package org.gcube.vremanagement.resourcemanager.client.plugins; + +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.fw.plugin.Plugin; +import org.gcube.vremanagement.resourcemanager.client.Constants; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidOptionsException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.NoSuchReportException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesRemovalException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.*; + + +/** + * + * @author Andrea Manzi(CERN) + * + * @param + * @param

+ */ +public abstract class AbstractPlugin implements Plugin { + + public final String name; + + + 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 name() { + return name; + } + + @Override + public Exception convert(Exception fault, ProxyConfig config) { + + if (fault instanceof InvalidScopeFault) + return new InvalidScopeException(fault); + if (fault instanceof InvalidOptionsFault) + return new InvalidOptionsException(fault); + if (fault instanceof NoSuchReportFault) + return new NoSuchReportException(fault); + if (fault instanceof ResourcesCreationFault) + return new ResourcesCreationException(fault); + if (fault instanceof ResourcesRemovalFault) + return new ResourcesRemovalException(fault); + + return fault; + } + +} + diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AdminPlugin.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AdminPlugin.java new file mode 100644 index 0000000..b63c65a --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/AdminPlugin.java @@ -0,0 +1,39 @@ +package org.gcube.vremanagement.resourcemanager.client.plugins; + +import javax.xml.ws.EndpointReference; + +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.vremanagement.resourcemanager.client.Constants; +import org.gcube.vremanagement.resourcemanager.client.RMAdminLibrary; +import org.gcube.vremanagement.resourcemanager.client.fws.RMAdminServiceJAXWSStubs; +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; +import static org.gcube.common.clients.stubs.jaxws.StubFactory.*; + + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class AdminPlugin extends AbstractPlugin { + + public AdminPlugin() { + super(PORT_TYPE_NAME_ADMIN); + } + + public RMAdminServiceJAXWSStubs resolve(EndpointReference reference,ProxyConfig config) throws Exception { + return stubFor(Constants.rm_admin).at(reference); + } + + + public RMAdminLibrary newProxy(ProxyDelegate delegate) { + return new RMAdminLibrary(delegate); + } + + @Override + public String namespace() { + return NAMESPACE_ADMIN; + } +} + diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/BinderPlugin.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/BinderPlugin.java new file mode 100644 index 0000000..6e611eb --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/BinderPlugin.java @@ -0,0 +1,39 @@ +package org.gcube.vremanagement.resourcemanager.client.plugins; + +import static org.gcube.common.clients.stubs.jaxws.StubFactory.stubFor; +import static org.gcube.vremanagement.resourcemanager.client.Constants.NAMESPACE_BINDER; +import static org.gcube.vremanagement.resourcemanager.client.Constants.PORT_TYPE_NAME_BINDER; +import static org.gcube.vremanagement.resourcemanager.client.Constants.rm_binder; + +import javax.xml.ws.EndpointReference; + +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary; +import org.gcube.vremanagement.resourcemanager.client.fws.RMBinderServiceJAXWSStubs; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class BinderPlugin extends AbstractPlugin { + + public BinderPlugin() { + super(PORT_TYPE_NAME_BINDER); + } + + public RMBinderServiceJAXWSStubs resolve(EndpointReference reference,ProxyConfig config) throws Exception { + return stubFor(rm_binder).at(reference); + } + + + public RMBinderLibrary newProxy(ProxyDelegate delegate) { + return new RMBinderLibrary(delegate); + } + + @Override + public String namespace() { + return NAMESPACE_BINDER; + } +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ControllerPlugin.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ControllerPlugin.java new file mode 100644 index 0000000..35aa32d --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ControllerPlugin.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.plugins; + +import static org.gcube.common.clients.stubs.jaxws.StubFactory.stubFor; + +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; + +import javax.xml.ws.EndpointReference; + +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.vremanagement.resourcemanager.client.RMControllerLibrary; +import org.gcube.vremanagement.resourcemanager.client.fws.*; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class ControllerPlugin extends AbstractPlugin { + + public ControllerPlugin() { + super(PORT_TYPE_NAME_CONTROLLER); + } + + public RMControllerServiceJAXWSStubs resolve(EndpointReference reference,ProxyConfig config) throws Exception { + return stubFor(rm_controller).at(reference); + } + + + public RMControllerLibrary newProxy(ProxyDelegate delegate) { + return new RMControllerLibrary(delegate); + } + + @Override + public String namespace() { + return NAMESPACE_CONTROLLER; + } +} diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ReportingPlugin.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ReportingPlugin.java new file mode 100644 index 0000000..1c8d802 --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/plugins/ReportingPlugin.java @@ -0,0 +1,38 @@ +package org.gcube.vremanagement.resourcemanager.client.plugins; + +import static org.gcube.common.clients.stubs.jaxws.StubFactory.stubFor; +import static org.gcube.vremanagement.resourcemanager.client.Constants.*; + +import javax.xml.ws.EndpointReference; + +import org.gcube.common.clients.config.ProxyConfig; +import org.gcube.common.clients.delegates.ProxyDelegate; +import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary; +import org.gcube.vremanagement.resourcemanager.client.fws.RMReportingServiceJAXWSStubs; + +/** + * + * @author Andrea Manzi(CERN) + * + */ +public class ReportingPlugin extends AbstractPlugin { + + public ReportingPlugin() { + super(PORT_TYPE_NAME_REPORTING); + } + + public RMReportingServiceJAXWSStubs resolve(EndpointReference reference,ProxyConfig config) throws Exception { + return stubFor(rm_reporting).at(reference); + } + + + public RMReportingLibrary newProxy(ProxyDelegate delegate) { + return new RMReportingLibrary(delegate); + } + + @Override + public String namespace() { + return NAMESPACE_REPORTING; + } +} + diff --git a/src/main/java/org/gcube/vremanagement/resourcemanager/client/proxies/Proxies.java b/src/main/java/org/gcube/vremanagement/resourcemanager/client/proxies/Proxies.java new file mode 100644 index 0000000..320fd1d --- /dev/null +++ b/src/main/java/org/gcube/vremanagement/resourcemanager/client/proxies/Proxies.java @@ -0,0 +1,48 @@ +package org.gcube.vremanagement.resourcemanager.client.proxies; + +import org.gcube.common.clients.fw.builders.StatefulBuilder; +import org.gcube.common.clients.fw.builders.StatefulBuilderImpl; +import org.gcube.common.clients.fw.builders.StatelessBuilder; +import org.gcube.common.clients.fw.builders.StatelessBuilderImpl; +import org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary; +import org.gcube.vremanagement.resourcemanager.client.RMAdminLibrary; +import org.gcube.vremanagement.resourcemanager.client.RMControllerLibrary; +import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary; +import org.gcube.vremanagement.resourcemanager.client.fws.RMBinderServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.fws.RMControllerServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.fws.RMAdminServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.fws.RMReportingServiceJAXWSStubs; +import org.gcube.vremanagement.resourcemanager.client.plugins.AdminPlugin; +import org.gcube.vremanagement.resourcemanager.client.plugins.BinderPlugin; +import org.gcube.vremanagement.resourcemanager.client.plugins.ControllerPlugin; +import org.gcube.vremanagement.resourcemanager.client.plugins.ReportingPlugin; + +public class Proxies { + + private static final BinderPlugin binderPlugin = new BinderPlugin(); + + private static final AdminPlugin adminPlugin = new AdminPlugin(); + + private static final ControllerPlugin controllerPlugin = new ControllerPlugin(); + + private static final ReportingPlugin reportingPlugin = new ReportingPlugin(); + + + public static StatelessBuilder binderService() { + return new StatelessBuilderImpl(binderPlugin); + } + + public static StatelessBuilder adminService() { + return new StatelessBuilderImpl(adminPlugin); + } + + public static StatelessBuilder controllerService() { + return new StatelessBuilderImpl(controllerPlugin); + } + + public static StatelessBuilder reportingService() { + return new StatelessBuilderImpl(reportingPlugin); + } + + +} diff --git a/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMAdminLibraryTest.java b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMAdminLibraryTest.java new file mode 100644 index 0000000..7f17e1b --- /dev/null +++ b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMAdminLibraryTest.java @@ -0,0 +1,30 @@ +package org.gcube.vremanagement.resourcemanager.client.test; + + +import java.util.concurrent.TimeUnit; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.resourcemanager.client.RMAdminLibrary; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.proxies.Proxies; +import org.junit.Before; +import org.junit.Test; + +public class RMAdminLibraryTest { + + public static RMAdminLibrary library=null; + public static String rmHost="node13.d.d4science.research-infrastructures.eu"; + +// @Before + public void initialize(){ + ScopeProvider.instance.set("/gcube/devsec"); + library=Proxies.adminService().at("node13.d.d4science.research-infrastructures.eu", 8080).withTimeout(1, TimeUnit.MINUTES).build(); + } + +// @Test + public void cleanSoftwareStateTest() throws ResourcesCreationException, InvalidScopeException{ + library.cleanSoftwareState(); + } + + +} diff --git a/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMBinderLibraryTest.java b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMBinderLibraryTest.java new file mode 100644 index 0000000..2eaaa3e --- /dev/null +++ b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMBinderLibraryTest.java @@ -0,0 +1,90 @@ +package org.gcube.vremanagement.resourcemanager.client.test; + +import static org.junit.Assert.*; +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.resourcemanager.client.RMBinderLibrary; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesRemovalException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.AddResourcesParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.PackageItem; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.RemoveResourcesParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.ResourceItem; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.ResourceList; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.SoftwareList; +import org.gcube.vremanagement.resourcemanager.client.proxies.Proxies; +import org.junit.Before; +import org.junit.Test; + +public class RMBinderLibraryTest { + + public static RMBinderLibrary library=null; + public static String rmHost="node13.d.d4science.research-infrastructures.eu"; + public static String ghnHost="node12.d.d4science.research-infrastructures.eu:8080"; + public static String scope="/gcube/devsec"; + public static ArrayList packList; + public static ResourceItem resource; + public static ArrayList ghnList; + +// @Before + public void initialize(){ + ScopeProvider.instance.set("/gcube/devsec"); + library=Proxies.binderService()/*.at("node13.d.d4science.research-infrastructures.eu", 8080).withTimeout(1, TimeUnit.MINUTES)*/.build(); + resource=new ResourceItem(); + resource.id="de099260-9f43-11e1-ae32-9a6b727ba3fb"; + resource.type="Service"; + packList=new ArrayList(); + PackageItem pack= new PackageItem(); + pack.serviceClass="DataTransfer"; + pack.serviceName="agent-service"; + pack.serviceVersion="1.0.0"; + pack.packageName="agent-service"; + pack.packageVersion="2.0.0-SNAPSHOT"; + pack.targetGHNName=ghnHost; + packList.add(pack); + + } + +// @Test + public void addResourceTest() throws ResourcesCreationException, InvalidScopeException{ + AddResourcesParameters params=null; + params=new AddResourcesParameters(); + ResourceList resourceList=new ResourceList(); + ArrayList resources=new ArrayList(); + resources.add(resource); + resourceList.resource=resources; + params.resources=resourceList; + SoftwareList sl=new SoftwareList(); + sl.software=packList; + ghnList=new ArrayList(); + ghnList.add(ghnHost); + sl.suggestedTargetGHNNames=ghnList; + params.softwareList=sl; + params.targetScope=scope; + String result=library.addResources(params); + assertNotNull(result); + + } + +// @Test + public void removeResourceTest() throws ResourcesRemovalException, InvalidScopeException { + RemoveResourcesParameters params= new RemoveResourcesParameters(); + ResourceList resourceList=new ResourceList(); + ArrayList resources=new ArrayList(); + resources.add(resource); + resourceList.resource=resources; + params.resources=resourceList; + ghnList=new ArrayList(); + ghnList.add(ghnHost); + SoftwareList sl=new SoftwareList(); + sl.software=packList; + sl.suggestedTargetGHNNames=ghnList; + params.softwareList=sl; + params.targetScope=scope; + String result=library.removeResources(params); + assertNotNull(result); + } + +} diff --git a/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMControllerLibraryTest.java b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMControllerLibraryTest.java new file mode 100644 index 0000000..7c23a2a --- /dev/null +++ b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMControllerLibraryTest.java @@ -0,0 +1,84 @@ +package org.gcube.vremanagement.resourcemanager.client.test; + +import static org.junit.Assert.assertNotNull; + +import java.util.ArrayList; +import java.util.concurrent.TimeUnit; +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.resourcemanager.client.RMControllerLibrary; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidOptionsException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesCreationException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.ResourcesRemovalException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.CreateScopeParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.OptionsParameters; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.ScopeOption; +import org.gcube.vremanagement.resourcemanager.client.proxies.Proxies; +import org.junit.Before; +import org.junit.Test; + +public class RMControllerLibraryTest { + + public static RMControllerLibrary library=null; + protected static String[] optionNames = new String[] {"creator", "designer", "endTime", "startTime", + "description", "displayName", "securityenabled"}; + public static String scope="/gcube/devsec/devTest"; + + +// @Before + public void initialize(){ + ScopeProvider.instance.set("/gcube/devsec"); + library=Proxies.controllerService().at("node13.d.d4science.research-infrastructures.eu", 8080).withTimeout(1, TimeUnit.MINUTES).build(); + } + +// @Test + public void createScopeTest() throws ResourcesCreationException, InvalidScopeException, InvalidOptionsException{ + OptionsParameters options = new OptionsParameters(); + ArrayList scopeOptionList = new ArrayList(); + ScopeOption option=new ScopeOption(); + option.name="creator"; + option.value="roberto.cirillo"; + scopeOptionList.add(option); + option=new ScopeOption(); + option.name="description"; + option.value="resource-manager-client component: junit test"; + scopeOptionList.add(option); + option=new ScopeOption(); + option.name="displayName"; + option.value="/gcube/devsec/devTest"; + scopeOptionList.add(option); + options.scopeOptionList=scopeOptionList; + CreateScopeParameters create=new CreateScopeParameters(); + create.optionParameters=options; + create.serviceMap=""; + create.targetScope=scope; + library.createScope(create); + } + +// @Test + public void ChangeScopeOptionsTest() throws InvalidScopeException, InvalidOptionsException{ + ArrayList scopeOptionList = new ArrayList(); + ScopeOption option=new ScopeOption(); + option.name="creator"; + option.value="roberto.cirillo"; + scopeOptionList.add(option); + option=new ScopeOption(); + option.name="description"; + option.value="resource-manager-client component: junit test: changeOptions test"; + scopeOptionList.add(option); + scopeOptionList.add(option); + OptionsParameters options = new OptionsParameters(); + options.scopeOptionList=scopeOptionList; + options.targetScope=scope; + library.changeScopeOptions(options); + } + +// @Test + public void disposeScopeTest() throws ResourcesRemovalException, InvalidScopeException { + String report=library.disposeScope("/gcube/devsec/devTest"); + System.out.println("report for dispose scope "+scope+"\n "+report); + assertNotNull(report); + } + + +} diff --git a/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMReportingLibraryTest.java b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMReportingLibraryTest.java new file mode 100644 index 0000000..dce1b4b --- /dev/null +++ b/src/test/java/org/gcube/vremanagement/resourcemanager/client/test/RMReportingLibraryTest.java @@ -0,0 +1,52 @@ +package org.gcube.vremanagement.resourcemanager.client.test; + +import static org.junit.Assert.*; + +import java.io.InputStream; +import java.util.Scanner; +import java.util.concurrent.TimeUnit; + +import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.vremanagement.resourcemanager.client.RMReportingLibrary; +import org.gcube.vremanagement.resourcemanager.client.exceptions.InvalidScopeException; +import org.gcube.vremanagement.resourcemanager.client.exceptions.NoSuchReportException; +import org.gcube.vremanagement.resourcemanager.client.fws.Types.SendReportParameters; +import org.gcube.vremanagement.resourcemanager.client.proxies.Proxies; +import org.junit.Before; +import org.junit.Test; + +public class RMReportingLibraryTest { + + public static RMReportingLibrary library=null; + public static String scope="/gcube/devsec"; + public String report; + public String reportString; + +// @Before + public void initialize(){ + ScopeProvider.instance.set(scope); + library=Proxies.reportingService().at("node13.d.d4science.research-infrastructures.eu", 8080).withTimeout(1, TimeUnit.MINUTES).build(); + InputStream is=RMReportingLibraryTest.class.getResourceAsStream("/report.xml"); + reportString = new Scanner(is,"UTF-8").useDelimiter("\\A").next(); + } + +// @Test + public void sendReportTest() throws InvalidScopeException { + SendReportParameters params=new SendReportParameters(); + params.callbackID="5e638260-e4a6-11e2-aa29-a0666f165663"; + params.report=reportString; + params.targetScope=scope; + library.sendReport(params); + } + +// @Test + public void getReportTest() throws InvalidScopeException, NoSuchReportException{ + String id="5e638260-e4a6-11e2-aa29-a0666f165663"; + report= library.getReport(id); + System.out.println("report: "+report); + System.out.println("reportString: "+reportString); + assertNotNull(report); + } + + +} diff --git a/src/test/resources/report.xml b/src/test/resources/report.xml new file mode 100644 index 0000000..0587f8a --- /dev/null +++ b/src/test/resources/report.xml @@ -0,0 +1 @@ +http://node13.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/vremanagement/resourcemanager/reporting/gcube/devsec5e638260-e4a6-11e2-aa29-a0666f165663node12.d.d4science.research-infrastructures.eu:8080UNDEPLOYCLOSED2013-07-04T14:37:45+02:00org.gcube.executiongrs2library1.0.0grs2library2.1.0-2.15.0NOTUNDEPLOYABLEnode12.d.d4science.research-infrastructures.eu:8080no dynamic package grs2library found in the gHN state (it might be statically deployed) \ No newline at end of file