Roberto Cirillo 11 years ago
commit 977cf482b5

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>resourcemanager-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>

@ -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/<project>=UTF-8

@ -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

@ -0,0 +1,5 @@
#Tue Apr 23 11:22:04 CEST 2013
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

@ -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.

@ -0,0 +1,3 @@
* Andrea Manzi (andrea.manzi@cern.ch), CERN

@ -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.

@ -0,0 +1,5 @@
<ReleaseNotes>
<Changeset component="org.gcube.common.vre-management.resourcemanager-client.1-0-0" date="2012-xx-xx">
<Change>ported to maven</Change>
</Changeset>
</ReleaseNotes>

@ -0,0 +1,47 @@
<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>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.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>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:p1="http://schemas.xmlsoap.org/wsdl/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<?xml version="1.0" encoding="UTF-8"?>
<Resource>
<ID/>
<Type>Service</Type>
<Profile>
<Description>The Resource Manager Service Client Library</Description>
<Class>VREManagement</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Description>The Resource Manager 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>

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

@ -0,0 +1,80 @@
<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>resourcemanager-client</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Resource Manager CL</name>
<dependencies>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-fw-clients</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</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>

@ -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<RMAdminServiceJAXWSStubs> rm_admin = service().withName(serviceAdminName)
.coordinates(SERVICE_CLASS,SERVICE_NAME)
.andInterface(RMAdminServiceJAXWSStubs.class);
public static final GCoreService<RMReportingServiceJAXWSStubs> rm_reporting = service().withName(serviceReportingName)
.coordinates(SERVICE_CLASS,SERVICE_NAME)
.andInterface(RMReportingServiceJAXWSStubs.class);
public static final GCoreService<RMBinderServiceJAXWSStubs> rm_binder = service().withName(serviceBinderName)
.coordinates(SERVICE_CLASS,SERVICE_NAME)
.andInterface(RMBinderServiceJAXWSStubs.class);
public static final GCoreService<RMControllerServiceJAXWSStubs> rm_controller = service().withName(serviceControllerName)
.coordinates(SERVICE_CLASS,SERVICE_NAME)
.andInterface(RMControllerServiceJAXWSStubs.class);
}

@ -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<RMAdminServiceJAXWSStubs> delegate;
Logger logger = LoggerFactory.getLogger(this.getClass().toString());
public RMAdminLibrary(ProxyDelegate<RMAdminServiceJAXWSStubs> delegate) {
this.delegate=delegate;
}
@Override
public Empty cleanSoftwareState() throws InvalidScopeException {
Call<RMAdminServiceJAXWSStubs,Empty> call = new Call<RMAdminServiceJAXWSStubs,Empty>() {
@Override
public Empty call(RMAdminServiceJAXWSStubs endpoint) throws Exception {
return endpoint.CleanSoftwareState();
}
};
try {
return delegate.make(call);
}
catch(Exception e) {
throw new ServiceException (e);
}
}
}

@ -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<RMBinderServiceJAXWSStubs> delegate;
Logger logger = LoggerFactory.getLogger(this.getClass().toString());
public RMBinderLibrary(ProxyDelegate<RMBinderServiceJAXWSStubs> delegate) {
this.delegate=delegate;
}
@Override
public String addResources(final AddResourcesParameters params)
throws ResourcesCreationException, InvalidScopeException {
Call<RMBinderServiceJAXWSStubs,String> call = new Call<RMBinderServiceJAXWSStubs,String>() {
@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<RMBinderServiceJAXWSStubs,String> call = new Call<RMBinderServiceJAXWSStubs,String>() {
@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);
}
}
}

@ -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<RMControllerServiceJAXWSStubs> delegate;
Logger logger = LoggerFactory.getLogger(this.getClass().toString());
public RMControllerLibrary(ProxyDelegate<RMControllerServiceJAXWSStubs> delegate) {
this.delegate=delegate;
}
@Override
public Empty changeScopeOptions(final OptionsParameters options)
throws InvalidScopeException, InvalidOptionsException {
Call<RMControllerServiceJAXWSStubs,Empty> call = new Call<RMControllerServiceJAXWSStubs,Empty>() {
@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<RMControllerServiceJAXWSStubs,String> call = new Call<RMControllerServiceJAXWSStubs,String>() {
@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<RMControllerServiceJAXWSStubs,Empty> call = new Call<RMControllerServiceJAXWSStubs,Empty>() {
@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);
}
}
}

@ -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<RMReportingServiceJAXWSStubs> delegate;
Logger logger = LoggerFactory.getLogger(this.getClass().toString());
public RMReportingLibrary(ProxyDelegate<RMReportingServiceJAXWSStubs> delegate) {
this.delegate=delegate;
}
@Override
public Empty sendReport(final SendReportParameters params)
throws InvalidScopeException {
Call<RMReportingServiceJAXWSStubs,Empty> call = new Call<RMReportingServiceJAXWSStubs,Empty>() {
@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<RMReportingServiceJAXWSStubs,String> call = new Call<RMReportingServiceJAXWSStubs,String>() {
@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);
}
}
}

@ -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);
}
}

@ -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);
}
}

@ -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);
}
}

@ -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);
}
}

@ -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);
}
}

@ -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();
}

@ -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);
}

@ -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);
}

@ -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);
}

@ -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<String> suggestedTargetGHNNames;
@XmlElement(name="software")
public ArrayList<PackageItem> software;
}
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class ResourceList{
@XmlElement(name="resource")
public ArrayList<ResourceItem> resource;
public ArrayList<ResourceItem> getResource() {
return resource;
}
public void setResource(ArrayList<ResourceItem> 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<ScopeOption> 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);
}
}
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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 <S>
* @param <P>
*/
public abstract class AbstractPlugin<S,P> implements Plugin<S,P> {
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;
}
}

@ -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<RMAdminServiceJAXWSStubs,RMAdminLibrary> {
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<RMAdminServiceJAXWSStubs> delegate) {
return new RMAdminLibrary(delegate);
}
@Override
public String namespace() {
return NAMESPACE_ADMIN;
}
}

@ -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<RMBinderServiceJAXWSStubs,RMBinderLibrary> {
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<RMBinderServiceJAXWSStubs> delegate) {
return new RMBinderLibrary(delegate);
}
@Override
public String namespace() {
return NAMESPACE_BINDER;
}
}

@ -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<RMControllerServiceJAXWSStubs,RMControllerLibrary> {
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<RMControllerServiceJAXWSStubs> delegate) {
return new RMControllerLibrary(delegate);
}
@Override
public String namespace() {
return NAMESPACE_CONTROLLER;
}
}

@ -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<RMReportingServiceJAXWSStubs,RMReportingLibrary> {
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<RMReportingServiceJAXWSStubs> delegate) {
return new RMReportingLibrary(delegate);
}
@Override
public String namespace() {
return NAMESPACE_REPORTING;
}
}

@ -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<RMBinderLibrary> binderService() {
return new StatelessBuilderImpl<RMBinderServiceJAXWSStubs,RMBinderLibrary>(binderPlugin);
}
public static StatelessBuilder <RMAdminLibrary> adminService() {
return new StatelessBuilderImpl<RMAdminServiceJAXWSStubs,RMAdminLibrary>(adminPlugin);
}
public static StatelessBuilder <RMControllerLibrary> controllerService() {
return new StatelessBuilderImpl<RMControllerServiceJAXWSStubs,RMControllerLibrary>(controllerPlugin);
}
public static StatelessBuilder <RMReportingLibrary> reportingService() {
return new StatelessBuilderImpl<RMReportingServiceJAXWSStubs,RMReportingLibrary>(reportingPlugin);
}
}

@ -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();
}
}

@ -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<PackageItem> packList;
public static ResourceItem resource;
public static ArrayList<String> 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>();
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<ResourceItem> resources=new ArrayList<ResourceItem>();
resources.add(resource);
resourceList.resource=resources;
params.resources=resourceList;
SoftwareList sl=new SoftwareList();
sl.software=packList;
ghnList=new ArrayList<String>();
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<ResourceItem> resources=new ArrayList<ResourceItem>();
resources.add(resource);
resourceList.resource=resources;
params.resources=resourceList;
ghnList=new ArrayList<String>();
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);
}
}

@ -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<ScopeOption> scopeOptionList = new ArrayList<ScopeOption>();
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<ScopeOption> scopeOptionList = new ArrayList<ScopeOption>();
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);
}
}

@ -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);
}
}

@ -0,0 +1 @@
<?xml version='1.0' encoding='' standalone='yes' ?><Report><Caller>http://node13.d.d4science.research-infrastructures.eu:8080/wsrf/services/gcube/vremanagement/resourcemanager/reporting</Caller><CallerScope>/gcube/devsec</CallerScope><CallbackID>5e638260-e4a6-11e2-aa29-a0666f165663</CallbackID><GHN>node12.d.d4science.research-infrastructures.eu:8080</GHN><Type>UNDEPLOY</Type><Status>CLOSED</Status><LastUpdate>2013-07-04T14:37:45+02:00</LastUpdate><Packages><Package><ServiceClass>org.gcube.execution</ServiceClass><ServiceName>grs2library</ServiceName><ServiceVersion>1.0.0</ServiceVersion><PackageName>grs2library</PackageName><PackageVersion>2.1.0-2.15.0</PackageVersion><Status>NOTUNDEPLOYABLE</Status><Host>node12.d.d4science.research-infrastructures.eu:8080</Host><Message>no dynamic package grs2library found in the gHN state (it might be statically deployed)</Message></Package></Packages></Report>
Loading…
Cancel
Save