Massimiliano Assante 9 years ago
parent
commit
74f72f488d
  1. 8
      .checkstyle
  2. 7
      .classpath
  3. 29
      .project
  4. 4
      .settings/org.eclipse.core.resources.prefs
  5. 13
      .settings/org.eclipse.jdt.core.prefs
  6. 5
      .settings/org.eclipse.m2e.core.prefs
  7. 1
      distro/INSTALL
  8. 8
      distro/LICENSE
  9. 2
      distro/MAINTAINERS
  10. 45
      distro/README
  11. 10
      distro/changelog.xml
  12. 48
      distro/descriptor.xml
  13. 25
      distro/profile.xml
  14. 1
      distro/svnpath.txt
  15. 4
      etc/build.properties
  16. 22
      etc/profile.xml
  17. 152
      pom.xml
  18. 48
      src/main/java/org/gcube/resourcemanagement/support/exceptions/AbstractResourceException.java
  19. 43
      src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceAccessException.java
  20. 55
      src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceOperationException.java
  21. 42
      src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceParameterException.java
  22. 56
      src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportBuilder.java
  23. 100
      src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportEntry.java
  24. 33
      src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportOperation.java
  25. 798
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/AbstractResourceManager.java
  26. 84
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/CollectionManager.java
  27. 210
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/GHNManager.java
  28. 203
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/GenericResourceManager.java
  29. 340
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/ManagementUtils.java
  30. 71
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/ResourceFactory.java
  31. 215
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/RunningInstanceManager.java
  32. 109
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/RuntimeResourceManager.java
  33. 83
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/ServiceManager.java
  34. 86
      src/main/java/org/gcube/resourcemanagement/support/managers/resources/ViewManager.java
  35. 236
      src/main/java/org/gcube/resourcemanagement/support/managers/scope/ScopeManager.java
  36. 187
      src/main/java/org/gcube/resourcemanagement/support/managers/services/SWRepositoryManager.java
  37. 571
      src/main/java/org/gcube/resourcemanagement/support/managers/services/SWRepositoryUpgrader.java
  38. 102
      src/main/java/org/gcube/resourcemanagement/support/managers/services/UpgradeListener.java
  39. 187
      src/main/java/org/gcube/resourcemanagement/support/tests/GenericTest.java
  40. 45
      src/main/java/org/gcube/resourcemanagement/support/tests/ScopeTest.java
  41. 31
      src/main/java/org/gcube/resourcemanagement/support/types/AllowedResourceTypes.java
  42. 65
      src/main/java/org/gcube/resourcemanagement/support/utils/Assertion.java
  43. 60
      src/main/java/org/gcube/resourcemanagement/support/utils/ServerConsole.java
  44. 62
      src/main/java/org/gcube/resourcemanagement/support/utils/persistence/PersistenceHandler.java
  45. 152
      src/main/java/org/gcube/resourcemanagement/support/utils/persistence/PersistentItem.java
  46. 46
      src/main/java/org/gcube/resourcemanagement/support/utils/persistence/TestPersistence.java
  47. 57
      test-suite/scopes/scopedata.xml
  48. 56
      test-suite/scopes/scopedata_admin.xml

8
.checkstyle

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<fileset-config file-format-version="1.2.0" simple-config="true" sync-formatter="false">
<fileset name="all" enabled="true" check-config-name="CustomChecks" local="false">
<file-match-pattern match-pattern="." include-pattern="true"/>
</fileset>
<filter name="UnOpenedFiles" enabled="true"/>
</fileset-config>

7
.classpath

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java"/>
<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>

29
.project

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ResourceManagementSupport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
</projectDescription>

4
.settings/org.eclipse.core.resources.prefs

@ -0,0 +1,4 @@
#Wed Dec 19 12:49:25 CET 2012
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding/<project>=UTF-8

13
.settings/org.eclipse.jdt.core.prefs

@ -0,0 +1,13 @@
#Wed Dec 19 12:49:25 CET 2012
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

5
.settings/org.eclipse.m2e.core.prefs

@ -0,0 +1,5 @@
#Wed Dec 19 12:41:58 CET 2012
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

1
distro/INSTALL

@ -0,0 +1 @@
Used as a Web service in the gCube Framework

8
distro/LICENSE

@ -0,0 +1,8 @@
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.

2
distro/MAINTAINERS

@ -0,0 +1,2 @@
Daniele Strollo (daniele.strollo@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"

45
distro/README

@ -0,0 +1,45 @@
The gCube System
------------------------------------------------------------
This work is partially funded by the European Commission in the
context of the D4Science project (www.d4science.eu), under the 1st
call of FP7 IST priority.
Authors
-------
* Daniele Strollo (daniele.strollo@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
Version and Release Date
------------------------
version 1.0.0 (20-05-2010)
Description
--------------------
Consists of a gcube service able to properly manage the scheduling and
the deployment planning of services in a gcube infrastructure.
Download information
--------------------
Source code is available from SVN:
http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vre-management/ResourceBroker/org.gcube.vremanagement.resourcebroker/
Binaries can be downloaded from:
http://software.d4science.research-infrastructures.eu/
Documentation
-------------
VREManager documentation is available on-line from the Projects Documentation Wiki:
https://gcube.wiki.gcube-system.org/gcube/index.php/Resource_Broker
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

10
distro/changelog.xml

@ -0,0 +1,10 @@
<ReleaseNotes
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd/changelog.xsd">
<Changeset component="org.gcube.resourcemanagement.support.1-0-0" date="2010-10-15">
<Change>First release</Change>
</Changeset>
<Changeset component="org.gcube.resourcemanagement.support.1-1-0" date="2010-10-24">
<Change>For 1.2.0 of resource management</Change>
</Changeset>
</ReleaseNotes>

48
distro/descriptor.xml

@ -0,0 +1,48 @@
<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>

25
distro/profile.xml

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID></ID>
<Type>Library</Type>
<Profile>
<Description>Resource Management Portlet Common IS Operations Support Library</Description>
<Class>PortletsAdmin</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

1
distro/svnpath.txt

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

4
etc/build.properties

@ -0,0 +1,4 @@
name = ResourceManagerSupport
package = org.gcube.resourcemanagement.support
package.dir = org/gcube/resourcemanagement/support
lib.dir = ResourceManagementPortlet/war/WEB-INF/lib

22
etc/profile.xml

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../xsd/service.xsd">
<ID/>
<Type>Library</Type>
<Profile>
<Description>ResourceManagement Support Library</Description>
<Class>portlet</Class>
<Name>ResourceManagementSupport</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Description>ResourceManagement Support Library</Description>
<Name>ResourceManagement-support</Name>
<Version>1.0.1</Version>
<Files>
<File>org.gcube.resourcemanagement.support.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

152
pom.xml

@ -0,0 +1,152 @@
<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>
<relativePath />
</parent>
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>rmp-common-library</artifactId>
<version>1.0.0-SNAPSHOT</version>
<name>Resource Management Portlet Common IS Operations Support Library</name>
<properties>
<distroDirectory>distro</distroDirectory>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.*</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<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>
<version>2.2</version>
<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>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>gcf</artifactId>
<version>[1.4.0,1.5.0]</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslcore</artifactId>
<version>3.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.3.1</version>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>softwarerepository-stubs</artifactId>
<version>1.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>resource-manager-stubs</artifactId>
<version>2.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.gcube.resourcemanagement</groupId>
<artifactId>ghnmanager-stubs</artifactId>
<version>1.5.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

48
src/main/java/org/gcube/resourcemanagement/support/exceptions/AbstractResourceException.java

@ -0,0 +1,48 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: AbstractResourceException.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.exceptions;
/**
* Represents the basic type of exception thrown by functionalities exposed
* in this library.
*
* The reason is to provide an access point for serialization issues
* (e.g. for GWT based portlets that require additional serialization
* annotations).
*
* @author Daniele Strollo (ISTI-CNR)
*/
public class AbstractResourceException extends Exception {
private static final long serialVersionUID = 4851998460190622583L;
public AbstractResourceException() {
super();
}
public AbstractResourceException(final String message, final Throwable cause) {
super(message, cause);
}
public AbstractResourceException(final String message) {
super(message);
}
public AbstractResourceException(final Throwable cause) {
super(cause);
}
}

43
src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceAccessException.java

@ -0,0 +1,43 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ResourceAccessException.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.exceptions;
/**
* Thrown when is required an operation the user is not allowed to execute.
*
* @author Daniele Strollo (ISTI-CNR)
*/
public class ResourceAccessException extends AbstractResourceException {
private static final long serialVersionUID = -4491094127600507185L;
public ResourceAccessException() {
super();
}
public ResourceAccessException(final String message, final Throwable cause) {
super(message, cause);
}
public ResourceAccessException(final String message) {
super(message);
}
public ResourceAccessException(final Throwable cause) {
super(cause);
}
}

55
src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceOperationException.java

@ -0,0 +1,55 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ResourceOperationException.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.exceptions;
/**
* If an operation of the library internally fails.
* @author Daniele Strollo (ISTI-CNR)
*/
public class ResourceOperationException extends AbstractResourceException {
private static final long serialVersionUID = -8748539948441128210L;
/**
*
*/
public ResourceOperationException() {
super();
}
/**
* @param message
*/
public ResourceOperationException(final String message) {
super(message);
}
/**
* @param cause
*/
public ResourceOperationException(final Throwable cause) {
super(cause);
}
/**
* @param message
* @param cause
*/
public ResourceOperationException(final String message, final Throwable cause) {
super(message, cause);
}
}

42
src/main/java/org/gcube/resourcemanagement/support/exceptions/ResourceParameterException.java

@ -0,0 +1,42 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ResourceParameterException.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.exceptions;
/**
* Wrong parameters provided by the user.
* @author Daniele Strollo (ISTI-CNR)
*/
public class ResourceParameterException extends AbstractResourceException {
private static final long serialVersionUID = -1117521050663690780L;
public ResourceParameterException() {
super();
}
public ResourceParameterException(final String message, final Throwable cause) {
super(message, cause);
}
public ResourceParameterException(final String message) {
super(message);
}
public ResourceParameterException(final Throwable cause) {
super(cause);
}
}

56
src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportBuilder.java

@ -0,0 +1,56 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ReportBuilder.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.managers.report;
import java.util.List;
import java.util.Vector;
/**
* @author Daniele Strollo (ISTI-CNR)
*
*/
public class ReportBuilder {
private List<ReportEntry> entries = null;
public ReportBuilder() {
entries = new Vector<ReportEntry>();
}
public final void addEntry(final ReportEntry entry) {
this.entries.add(entry);
}
public final int size() {
return this.entries.size();
}
public final String getXML() {
StringBuilder builder = new StringBuilder();
builder.append("<Report>\n");
for (ReportEntry entry : this.entries) {
builder.append(entry.toXML());
}
builder.append("</Report>\n");
return builder.toString();
}
@Override
public final String toString() {
return this.getXML();
}
}

100
src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportEntry.java

@ -0,0 +1,100 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ReportEntry.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.managers.report;
import org.gcube.resourcemanagement.support.exceptions.AbstractResourceException;
import org.gcube.resourcemanagement.support.managers.resources.AbstractResourceManager;
/**
* @author Daniele Strollo (ISTI-CNR)
*
*/
public class ReportEntry {
private ReportOperation operation = null;
private AbstractResourceManager resource = null;
private boolean success = false;
private String message = null;
public ReportEntry(
final ReportOperation operation,
final AbstractResourceManager resource
) throws AbstractResourceException {
this(operation, resource, null, false);
}
public ReportEntry(
final ReportOperation operation,
final AbstractResourceManager resource,
final boolean success
) throws AbstractResourceException {
this(operation, resource, null, success);
}
public ReportEntry(
final ReportOperation operation,
final AbstractResourceManager resource,
final String message,
final boolean success
) throws AbstractResourceException {
this.operation = operation;
this.resource = resource;
this.success = success;
this.message = message;
}
public final ReportOperation getOperation() {
return operation;
}
public final AbstractResourceManager getResource() {
return resource;
}
public final boolean isSuccess() {
return success;
}
public final void setSuccess(final boolean success) {
this.success = success;
}
public final void setMessage(final String message) {
this.message = message;
}
public final void setMessage(final Throwable ex) {
this.message = ex.getMessage();
}
@Override
public final String toString() {
return this.toXML();
}
public final String toXML() {
return
"\t<Operation type=\"" + this.getOperation().getLabel() + "\">\n" +
"\t\t<Status>" + (this.isSuccess() ? "SUCCESS" : "FAILURE") + "</Status>\n" +
"\t\t<Resource>\n" +
"\t\t\t<ID>" + this.getResource().getID() + "</ID>\n" +
// If the resource has a name
(this.getResource().getName() != null ?
"\t\t\t<Name>" + this.getResource().getName() + "</Name>\n" : "") +
"\t\t\t<Type>" + this.getResource().getType() + "</Type>\n" +
// If a message is present
(this.message != null ?
"\t\t\t<Message>\n\t\t\t\t" + this.message.trim() + "\n\t\t\t</Message>\n" : "") +
"\t\t</Resource>\n" +
"\t</Operation>\n";
}
}

33
src/main/java/org/gcube/resourcemanagement/support/managers/report/ReportOperation.java

@ -0,0 +1,33 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ReportOperation.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.managers.report;
/**
* @author Daniele Strollo (ISTI-CNR)
*
*/
public enum ReportOperation {
AddToScope("Add To Scope");
private String label = null;
private ReportOperation(final String label) {
this.label = label;
}
public final String getLabel() {
return this.label;
}
}

798
src/main/java/org/gcube/resourcemanagement/support/managers/resources/AbstractResourceManager.java

@ -0,0 +1,798 @@
/****************************************************************************
* This software is part of the gCube Project.
* Site: http://www.gcube-system.org/
****************************************************************************
* 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.
****************************************************************************
* Filename: ResourceManager.java
****************************************************************************
* @author <a href="mailto:daniele.strollo@isti.cnr.it">Daniele Strollo</a>
***************************************************************************/
package org.gcube.resourcemanagement.support.managers.resources;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Vector;
import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.informationsystem.client.AtomicCondition;
import org.gcube.common.core.informationsystem.client.ISClient;
import org.gcube.common.core.informationsystem.client.XMLResult;
import org.gcube.common.core.informationsystem.client.queries.GCUBEGenericQuery;
import org.gcube.common.core.informationsystem.client.queries.GCUBERIQuery;
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBERunningInstance;
import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.scope.GCUBEScope.Type;
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.resourcemanagement.support.exceptions.AbstractResourceException;
import org.gcube.resourcemanagement.support.exceptions.ResourceAccessException;
import org.gcube.resourcemanagement.support.exceptions.ResourceOperationException;
import org.gcube.resourcemanagement.support.exceptions.ResourceParameterException;
import org.gcube.resourcemanagement.support.managers.report.ReportBuilder;
import org.gcube.resourcemanagement.support.managers.report.ReportEntry;
import org.gcube.resourcemanagement.support.managers.report.ReportOperation;
import org.gcube.resourcemanagement.support.managers.scope.ScopeManager;
import org.gcube.resourcemanagement.support.types.AllowedResourceTypes;
import org.gcube.resourcemanagement.support.utils.Assertion;
import org.gcube.resourcemanagement.support.utils.ServerConsole;
import org.gcube.vremanagement.resourcemanager.stubs.binder.AddResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.binder.RemoveResourcesParameters;
import org.gcube.vremanagement.resourcemanager.stubs.binder.ResourceBinderPortType;
import org.gcube.vremanagement.resourcemanager.stubs.binder.ResourceItem;
import org.gcube.vremanagement.resourcemanager.stubs.binder.ResourceList;
import org.gcube.vremanagement.resourcemanager.stubs.binder.service.ResourceBinderServiceAddressingLocator;
import org.gcube.vremanagement.resourcemanager.stubs.reporting.ReportingPortType;
import org.gcube.vremanagement.resourcemanager.stubs.reporting.service.ReportingServiceAddressingLocator;
/**
* The minimal interface all the resource managers must implement.
* Here is implemented the greatest part of the operations exposed in the
* <a href="https://gcube.wiki.gcube-system.org/gcube/index.php/Programmatic_Administration_Interface">
* official wiki</a>.
* @author Daniele Strollo (ISTI-CNR)
*/
public abstract class AbstractResourceManager {
private String id = null;
private String name = null;
private AllowedResourceTypes type = null;
private String subType = null;
private ISClient client = null;
private GCUBESecurityManagerImpl managerSec = null;
private ISPublisher publisher = null;
private static final String LOG_PREFIX = "[AbstractResMgr]";
/**
* @deprecated discouraged use. With no ID some operations cannot be accessed. For internal use only.
*/
public AbstractResourceManager(final AllowedResourceTypes type)
throws ResourceParameterException, ResourceAccessException {
Assertion<ResourceParameterException> checker = new Assertion<ResourceParameterException>();
checker.validate(type != null, new ResourceParameterException("Invalid Parameter type"));
this.type = type;
/**
* Initially the security management is disabled.
*/
this.managerSec = new GCUBESecurityManagerImpl() {
public boolean isSecurityEnabled() {
return false;
}
};
try {
client = GHNContext.getImplementation(ISClient.class);
} catch (Exception e) {
throw new ResourceAccessException("Cannot instantiate the ISClient");
}
try {
this.publisher = GHNContext.getImplementation(ISPublisher.class);
} catch (Exception e) {
ServerConsole.error(LOG_PREFIX, e);
}
}
/**
* Instantiate the handler of a resource given its identifier and its type.
* Notice that this constructor is implicitly invoked when instantiating the
* concrete resource manager (e.g. new GHNManager(id)).
* @param id the identifier of the resource the manage
* @param type the type (GHN, RI, ...).
* @throws ResourceParameterException
* @throws ResourceAccessException
*/
public AbstractResourceManager(
final String id,
final AllowedResourceTypes type)
throws ResourceParameterException, ResourceAccessException {
this(type);
Assertion<ResourceParameterException> checker = new Assertion<ResourceParameterException>();
checker.validate(id != null && id.trim().length() > 0, new ResourceParameterException("Invalid Parameter id"));
this.id = id.trim();
}
public AbstractResourceManager(
final String id,
final String name,
final AllowedResourceTypes type)
throws ResourceParameterException, ResourceAccessException {
this(id, type);
Assertion<ResourceParameterException> checker = new Assertion<ResourceParameterException>();
checker.validate(name != null && name.trim().length() > 0, new ResourceParameterException("Invalid Parameter name"));
this.name = name;
}
public AbstractResourceManager(
final String id,
final String name,
final AllowedResourceTypes type,
final String subtype)
throws ResourceParameterException, ResourceAccessException {
this(id, name, type);
if (subtype != null) {
this.subType = subtype.trim();
}
}
/**
* The singleton ISClient instance is preferred.
* All resource managers can internally access this instance
* to make queries to the IS.
* @return
*/
protected final ISClient getISClient() {
return this.client;
}
/**
* The singleton ISPublisher instance is preferred.
* All resource managers can internally access this instance
* to interact with ISPublisher to handle resources.
* @return
*/
public final ISPublisher getISPublisher() {
return publisher;
}
public final void setSecurityManager(final GCUBESecurityManagerImpl securityManager) {
this.managerSec = securityManager;
}
/**
* The security manager is initially instantiated with empty permissions.
* The {@link AbstractResourceManager#setSecurityManager} can be used to
* change it.
* @return
*/
public final GCUBESecurityManagerImpl getSecurityManager() {
return this.managerSec;
}
/**
* All resources must be identifiable through an unique ID.
* <br/>
* <b>This field is mandatory</b>
* @return
*/
public final String getID() {
return this.id;
}
public final void setID(final String id) {
this.id = id;
}
/**
* All resources must have a valid name.
* </br>
* <b>This field is mandatory</b>
* @return
*/
public final String getName() {
return this.name;
}
/**
* All resources have a type.
* </br>
* <b>This field is mandatory</b>
* @return
*/
public final AllowedResourceTypes getType() {
return this.type;
}
/**
* Resources can have a subtype (e.g. for GHNs is the domain).
* </br>
* <b>This field is optional</b>
* @return
*/
public final String getSubType() {
return this.subType;
}
/**
* Internally used by {@link AbstractResourceManager#getResourceManager(GCUBEScope)}.
* @param scope
* @return a raw list of resource manager descriptors.
* @throws Exception
*/
private List<GCUBERunningInstance> getResourceManagerFromScope(final GCUBEScope scope)
throws Exception {
GCUBERIQuery query = this.client.getQuery(GCUBERIQuery.class);
query.addAtomicConditions(new AtomicCondition("//Profile/ServiceClass", "VREManagement"));
query.addAtomicConditions(new AtomicCondition("//Profile/ServiceName", "ResourceManager"));
List<GCUBERunningInstance> result = client.execute(query, scope);
List<GCUBERunningInstance> toReturn = new ArrayList<GCUBERunningInstance>();
for (GCUBERunningInstance ri : result) {
if (ri.getScopes().containsValue(scope)) {
toReturn.add(ri);
}
}
return toReturn;
}
/**
* The the list of resource managers able to handle the resource in a given scope.
* @param scope the scope in which to operate
* @return all the available managers
* @throws ResourceAccessException if no manager can be instantiated
* @throws ResourceParameterException if the parameters are invalid
*/
public final List<ResourceBinderPortType> getResourceManagers(final GCUBEScope scope) throws ResourceAccessException, ResourceParameterException {
Assertion<ResourceParameterException> checker = new Assertion<ResourceParameterException>();
checker.validate(scope != null, new ResourceParameterException("Invalid scope"));
List<GCUBERunningInstance> resourceManagerList = null;
try {
resourceManagerList = this.getResourceManagerFromScope(scope);
} catch (Exception e) {
e.printStackTrace();
throw new ResourceAccessException("Cannot retrieve the managers for resource: " + this.getID());
}
List<ResourceBinderPortType> retval = new Vector<ResourceBinderPortType>();
if (resourceManagerList.isEmpty()) {
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
}
EndpointReferenceType endpoint = null;
ResourceBinderPortType pt = null;
for (GCUBERunningInstance resourceManager : resourceManagerList) {
try {
endpoint = resourceManager.getAccessPoint().getEndpoint("gcube/vremanagement/resourcemanager/binder");
pt = GCUBERemotePortTypeContext.getProxy(
new ResourceBinderServiceAddressingLocator()
.getResourceBinderPortTypePort(endpoint),
scope,
this.managerSec);
if (pt != null) {
retval.add(pt);
}
} catch (Throwable e) {
// trying on next entry
ServerConsole.error(LOG_PREFIX, e);
}
}
if (retval != null && retval.size() > 0) {
// Return a random manager from the available ones
return retval;
}
// no managers found
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getID() + "in scope: " + scope.toString());
}
/**
* The the list of resource report managers able to handle the resource in a given scope.
* @param scope the scope in which to operate
* @return all the available managers
* @throws ResourceAccessException if no manager can be instantiated
* @throws ResourceParameterException if the parameters are invalid
*/
public final List<ReportingPortType> getResourceReportManagers(final GCUBEScope scope) throws ResourceAccessException, ResourceParameterException {
Assertion<ResourceParameterException> checker = new Assertion<ResourceParameterException>();
checker.validate(scope != null, new ResourceParameterException("Invalid scope"));
List<GCUBERunningInstance> resourceManagerList = null;
try {
resourceManagerList = this.getResourceManagerFromScope(scope);
} catch (Exception e) {
e.printStackTrace();
throw new ResourceAccessException("Cannot retrieve the managers for resource: " + this.getID());
}
List<ReportingPortType> retval = new Vector<ReportingPortType>();
if (resourceManagerList.isEmpty()) {
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
}
EndpointReferenceType endpoint = null;
ReportingPortType pt = null;
for (GCUBERunningInstance resourceManager : resourceManagerList) {
try {
endpoint = resourceManager.getAccessPoint().getEndpoint("gcube/vremanagement/resourcemanager/reporting");
pt = GCUBERemotePortTypeContext.getProxy(
new ReportingServiceAddressingLocator().getReportingPortTypePort(endpoint),
scope,
this.managerSec);
if (pt != null) {
retval.add(pt);
}
} catch (Throwable e) {
// trying on next entry
ServerConsole.error(LOG_PREFIX, e);
}
}
if (retval != null && retval.size() > 0) {
// Return a random report manager from the available ones
return retval;
}
// no managers found
throw new ResourceAccessException("Unable to find ReportResourceManagers for resource " + this.getID() + "in scope: " + scope.toString());
}
/**
* The resource manager needed to handle the resource in a given scope.
* @param scope the scope in which to operate
* @return a random chosen manager from the avaiable ones
* @throws ResourceAccessException if no manager can be instantiated
* @throws ResourceParameterException if the parameters are invalid
*/
public final ResourceBinderPortType getResourceManager(final GCUBEScope scope)
throws AbstractResourceException {
ServerConsole.info(LOG_PREFIX, "Getting Resource Manager in scope [" + scope.toString() + "]");
List<ResourceBinderPortType> retval = this.getResourceManagers(scope);
if (retval != null && retval.size() > 0) {
Random generator = new Random();
// Return a random manager from the available ones
ResourceBinderPortType manager = retval.get(generator.nextInt(retval.size()));
return manager;
}
// no managers found
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
}
/**
* The report resource manager needed to handle the resource in a given scope.
* @param scope the scope in which to operate
* @return a random chosen manager from the avaiable ones
* @throws ResourceAccessException if no manager can be instantiated
* @throws ResourceParameterException if the parameters are invalid
*/
public final ReportingPortType getReportResourceManager(final GCUBEScope scope)
throws AbstractResourceException {
ServerConsole.info(LOG_PREFIX, "Getting Resource Manager in scope [" + scope.toString() + "]");
List<ReportingPortType> retval = this.getResourceReportManagers(scope);
if (retval != null && retval.size() > 0) {
Random generator = new Random();
// Return a random manager from the available ones
ReportingPortType manager = retval.get(generator.nextInt(retval.size()));
return manager;
}
// no managers found
throw new ResourceAccessException("Unable to find ResourceManagers for resource " + this.getType() + " in scope: " + scope.toString());
}
/**
* Once the conditions for binding a resource to a target scope are satisfied
* (see the
* <a href="https://gcube.wiki.gcube-system.org/gcube/index.php/Programmatic_Administration_Interface">
* official wiki</a>
* for scope binding rules) this method is internally called.
* @param targetScope
* @return
* @throws ResourceOperationException
*/
private String bindToScope(final GCUBEScope targetScope) throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(targetScope != null, new ResourceParameterException("Invalid parameter targetScope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid resource ID. null not allowed."));
ServerConsole.trace(
LOG_PREFIX,
"[BIND-SCOPE-ENTER] Adding " + this.getType() + " " + this.getID() + " to scope [" +
targetScope.toString() + "]");
AddResourcesParameters addParam = new AddResourcesParameters();
ResourceItem toAdd = new ResourceItem();
toAdd.setID(this.getID());
toAdd.setType(this.getType().name());
ResourceList r = new ResourceList();
r.setResource(new ResourceItem[]{toAdd});
addParam.setResources(r);
addParam.setTargetScope(targetScope.toString());
ResourceBinderPortType manager = this.getResourceManager(targetScope);
try {
String reportID = manager.addResources(addParam);
ServerConsole.trace(
LOG_PREFIX,
"[BIND-SCOPE-EXIT] Applyed Adding " + this.getType() + " " + this.getID() + " to scope [" +
targetScope.toString() + "]... reportID: " + reportID);
ReportingPortType pt = this.getReportResourceManager(targetScope);
return pt.getReport(reportID);
} catch (Exception e) {
e.printStackTrace();
ServerConsole.trace(
LOG_PREFIX,
"[BIND-SCOPE-EXIT] [FAILURE]");
throw new ResourceOperationException("During resource::addToScope: " + e.getMessage());
}
}
/**
* Add a scope to a gHN and the related Service Map is already available on the gHN.
* @param nestingPublication true for resources different from gHN and RI.
* @return the reportID generated
*/
public final String addToExistingScope(
final GCUBEScope sourceScope, final GCUBEScope targetScope)
throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(sourceScope != null, new ResourceParameterException("Invalid parameter sourceScope. null not allowed."));
checker.validate(targetScope != null, new ResourceParameterException("Invalid parameter targetScope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid resource ID. null not allowed."));
ReportBuilder report = new ReportBuilder();
ServerConsole.trace(
LOG_PREFIX,
"[ADD-ToExistingScope] Adding from scope [" +
sourceScope.toString() +
"] to existing scope [" +
targetScope.toString() +
"] " + this.getType() + " " + this.getID());
// If not RI or GHN and the scopes are sibling and VO copyFromToVO
if (!(this.getType() == AllowedResourceTypes.GHN) &&
!(this.getType() == AllowedResourceTypes.RunningInstance) &&
sourceScope.getType() == Type.VO && targetScope.getType() == Type.VO) {
return copyFromToVO(sourceScope, targetScope);
}
// Add a gCube Resource to
// (i) a VRE scope from the parent VO or
// (ii) a VO scope from the infrastructure scope
if (!targetScope.isEnclosedIn(sourceScope)) {
throw new ResourceOperationException(
"You are not allowed to apply to this scope. Target scope is not enclosed in the source one.");
}
report.addEntry(new ReportEntry(ReportOperation.AddToScope, this,
"Added " + this.getType() + " " + this.getID() + " to parent scope " +
targetScope.toString() + " the remote report ID is: " +
this.bindToScope(targetScope), true));
return report.getXML();
}
/**
* Similar to the {@link AbstractResourceManager#addToExistingScope} method but involves
* two scopes of type VO.
* Notice that this operation in reserved for resources different from gHN and RI.
* See
* <a href="https://gcube.wiki.gcube-system.org/gcube/index.php/Programmatic_Administration_Interface#Add_a_gCube_Resource_from_a_VO_to_another_VO">
* here</a> for further details.
* @param sourceScope
* @param targetScope
* @return
* @throws AbstractResourceException
*/
public final String copyFromToVO(final GCUBEScope sourceScope, final GCUBEScope targetScope)
throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(
sourceScope != null && sourceScope.getType() == Type.VO,
new ResourceParameterException("The sourceScope is invalid or not of type VO."));
checker.validate(
targetScope != null && targetScope.getType() == Type.VO,
new ResourceParameterException("The targetScope is invalid or not of type VO."));
checker.validate(
sourceScope.getEnclosingScope() == targetScope.getEnclosingScope(),
new ResourceParameterException("The sourceScope and targetScope must be children of the same root VO."));
checker.validate(this.getType() != AllowedResourceTypes.GHN && this.getType() != AllowedResourceTypes.RunningInstance,
new ResourceAccessException("Operation not allowed for RI and GHNs."));
checker.validate(this.getID() != null,
new ResourceAccessException("Operation not allowed on resources with no ID."));
// Phase 1. retrieve the resource to copy
GCUBEResource resStub = this.getGCUBEResource(sourceScope);
// Phase 2. Before to register the resource, the scope must be
// bound to the local GCUBEResource
this.bindToScope(targetScope);
// Phase 3. Register to the new VO through the ISPublisher
try {
return this.getISPublisher().registerGCUBEResource(resStub, targetScope, this.getSecurityManager());
} catch (Exception e) {
throw new ResourceAccessException(e.getMessage());
}
}
/**
* Given the XML profile representation of a gcube resource, its GCUBEResource is built.
* Since it depends on the type of the resource, each concrete implementation of resource
* managers must implement it.
* @param xmlRepresentation
* @return
* @throws AbstractResourceException
*/
protected abstract GCUBEResource buildGCUBEResource(final String xmlRepresentation) throws AbstractResourceException;
/**
* From a resource retrieves its GCUBEResource depending on the scope in which it is
* published.
* @param scope
* @return
* @throws AbstractResourceException
*/
public final GCUBEResource getGCUBEResource(final GCUBEScope scope) throws AbstractResourceException {
return this.buildGCUBEResource(this.getXMLDescription(scope));
}
/**
* Returns the XML profile of a resource (given its ID that is encapsulated inside the resource
* manager).
* @param scope
* @return
* @throws AbstractResourceException
*/
protected final String getXMLDescription(final GCUBEScope scope) throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(this.getID() != null, new ResourceAccessException("Cannot execute on resources with no ID."));
// Phase 1. retrieve the resource to copy
GCUBEGenericQuery query = null;
try {
query = this.getISClient().getQuery(GCUBEGenericQuery.class);
query.setExpression(
"for $resource in collection('/db/Profiles/" + this.getType().name() + "')//Resource " +
"where ( $resource/ID/string() eq '" +
this.getID() +
"') " +
"return $resource"
);
} catch (Exception e) {
throw new ResourceAccessException(e);
}
XMLResult resDescription = null;
try {
resDescription = this.getISClient().execute(query, scope).get(0);
return resDescription.toString();
} catch (Exception e) {
throw new ResourceAccessException("Cannot retrieve the IS profile for resource: " + this.getID() +
" in scope: " + scope.toString());
}
}
/**
* The first phase of remove form scope.
* This is common to all the resources (RI and GHNs).
* @param scope
* @return
* @throws AbstractResourceException
*/
private String basicRemoveFromScope(final GCUBEScope scope)
throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
ServerConsole.trace(LOG_PREFIX, "[REMOVE-FROM-SCOPE] Removing from scope [" + scope.toString() + "] " + this.getType() + " " + this.getID());
String retval = null;
RemoveResourcesParameters params = new RemoveResourcesParameters();
ResourceItem toRemove = new ResourceItem();
toRemove.setID(this.getID());
toRemove.setType(this.getType().name());
ResourceList resourcesToRemove = new ResourceList();
resourcesToRemove.setResource(new ResourceItem[]{toRemove});
params.setResources(resourcesToRemove);
params.setTargetScope(scope.toString());
ServerConsole.trace(LOG_PREFIX, "[REMOVE-FROM-SCOPE] Sending the Remove Resource request....");
try {
ResourceBinderPortType manager = this.getResourceManager(scope);
retval = manager.removeResources(params);
} catch (Exception e) {
throw new ResourceOperationException("During removeFrom scope of "
+ this.getType()
+ " " + this.getID() + ": " + e.getMessage());
}
return retval;
}
/**
* Removes the current resource from the scope.
* @param nestingRemoval true for resources different from gHN and RI
*/
public final String removeFromScope(final GCUBEScope scope)
throws AbstractResourceException {
Assertion<AbstractResourceException> checker = new Assertion<AbstractResourceException>();
checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed."));
checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed."));
String retval = this.basicRemoveFromScope(scope);
// -- PHASE 2 - optional
// Builds the stub without the removed scope
GCUBEResource resStub = this.getGCUBEResource(scope);
// Refreshes the local profile
resStub.removeScope(scope);
/*
* These steps are for resources different from GHN and RI
*/
if (!this.getType().equals(AllowedResourceTypes.GHN.name()) &&
!this.getType().equals(AllowedResourceTypes.RunningInstance.name())) {
// Phase 1
// if the resource joins only the c