You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by ma...@redhat.com on 2011/05/31 12:44:11 UTC
[PATCH] Adds Andre Dietisheim's updated java client (andre.dietisheim@gmail.com)
From: marios <ma...@redhat.com>
Signed-off-by: marios <ma...@redhat.com>
---
.../org.apache.deltacloud.client.test/.gitignore | 2 +
.../org.apache.deltacloud.client.test/ChangeLog | 32 +
.../META-INF/MANIFEST.MF | 9 +
.../java/org.apache.deltacloud.client.test/NOTICE | 8 +
.../java/org.apache.deltacloud.client.test/pom.xml | 45 +
.../test/DeltaCloudClientIntegrationTestSuite.java | 43 +
.../internal/test/DeltaCloudClientTestSuite.java | 44 +
.../test/client/APIDomUnmarshallingTest.java | 56 +
.../HardwareProfileDomUnmarshallingTest.java | 97 ++
.../test/client/ImageDomUnmarshallingTest.java | 70 ++
.../test/client/ImageMockIntegrationTest.java | 93 ++
.../test/client/InstanceDomUnmarshallingTest.java | 99 ++
.../test/client/InstanceMockIntegrationTest.java | 280 ++++++
.../test/client/KeyDomUnmarshallingTest.java | 97 ++
.../test/client/KeyMockIntegrationTest.java | 172 ++++
.../test/client/ProfileMockIntegrationTest.java | 80 ++
.../test/client/RealmDomUnmarshallingTest.java | 88 ++
.../test/client/RealmMockIntegrationTest.java | 79 ++
.../test/client/ServerTypeMockIntegrationTest.java | 136 +++
.../test/context/MockIntegrationTestContext.java | 165 +++
.../internal/test/fakes/APIResponseFakes.java | 64 ++
.../test/fakes/HardwareProfileResponseFakes.java | 145 +++
.../internal/test/fakes/ImageResponseFakes.java | 72 ++
.../internal/test/fakes/InstanceResponseFakes.java | 163 +++
.../internal/test/fakes/KeyResponseFakes.java | 106 ++
.../internal/test/fakes/RealmResponseFakes.java | 93 ++
.../client/internal/test/fakes/ServerFake.java | 94 ++
.../internal/test/fakes/ServerResponseFakes.java | 32 +
.../client/internal/test/utils/UrlBuilderTest.java | 75 ++
.../java/org.apache.deltacloud.client/.gitignore | 2 +
.../java/org.apache.deltacloud.client/ChangeLog | 1049 ++++++++++++++++++++
.../META-INF/MANIFEST.MF | 7 +
clients/java/org.apache.deltacloud.client/NOTICE | 8 +
clients/java/org.apache.deltacloud.client/pom.xml | 32 +
.../src/org/apache/deltacloud/client/API.java | 64 ++
.../src/org/apache/deltacloud/client/Action.java | 94 ++
.../org/apache/deltacloud/client/ActionAware.java | 111 ++
.../org/apache/deltacloud/client/AddressList.java | 58 ++
.../client/DeltaCloudAuthClientException.java | 44 +
.../apache/deltacloud/client/DeltaCloudClient.java | 171 ++++
.../client/DeltaCloudClientException.java | 43 +
.../deltacloud/client/DeltaCloudClientImpl.java | 255 +++++
.../client/DeltaCloudNotFoundClientException.java | 44 +
.../apache/deltacloud/client/HardwareProfile.java | 103 ++
.../org/apache/deltacloud/client/HttpMethod.java | 24 +
.../apache/deltacloud/client/HttpStatusCode.java | 42 +
.../apache/deltacloud/client/HttpStatusRange.java | 41 +
.../src/org/apache/deltacloud/client/IdAware.java | 46 +
.../src/org/apache/deltacloud/client/Image.java | 92 ++
.../src/org/apache/deltacloud/client/Instance.java | 201 ++++
.../src/org/apache/deltacloud/client/Key.java | 81 ++
.../src/org/apache/deltacloud/client/Property.java | 171 ++++
.../src/org/apache/deltacloud/client/Realm.java | 88 ++
.../apache/deltacloud/client/ResourceAction.java | 39 +
.../org/apache/deltacloud/client/StateAware.java | 55 +
.../client/request/AbstractDeltaCloudRequest.java | 70 ++
.../client/request/AbstractListObjectsRequest.java | 48 +
.../client/request/CreateInstanceRequest.java | 72 ++
.../client/request/CreateKeyRequest.java | 46 +
.../client/request/DeltaCloudRequest.java | 41 +
.../client/request/ListHardwareProfileRequest.java | 49 +
.../request/ListHardwareProfilesRequest.java | 32 +
.../client/request/ListImageRequest.java | 44 +
.../client/request/ListImagesRequest.java | 32 +
.../client/request/ListInstanceRequest.java | 43 +
.../client/request/ListInstancesRequest.java | 32 +
.../deltacloud/client/request/ListKeyRequest.java | 43 +
.../deltacloud/client/request/ListKeysRequest.java | 40 +
.../client/request/ListRealmRequest.java | 43 +
.../client/request/ListRealmsRequest.java | 32 +
.../client/request/PerformActionRequest.java | 56 +
.../deltacloud/client/request/TypeRequest.java | 40 +
.../client/transport/AbstractHttpTransport.java | 91 ++
.../deltacloud/client/transport/Base64Coder.java | 226 +++++
.../client/transport/IHttpTransport.java | 38 +
.../client/transport/URLConnectionTransport.java | 186 ++++
.../client/unmarshal/APIUnmarshaller.java | 40 +
.../unmarshal/AbstractActionAwareUnmarshaller.java | 69 ++
.../client/unmarshal/AbstractDOMUnmarshaller.java | 135 +++
.../AbstractDeltaCloudObjectUnmarshaller.java | 53 +
.../AbstractDeltaCloudObjectsUnmarshaller.java | 61 ++
.../client/unmarshal/ActionUnmarshaller.java | 44 +
.../unmarshal/HardwareProfileUnmarshaller.java | 106 ++
.../unmarshal/HardwareProfilesUnmarshaller.java | 40 +
.../unmarshal/IDeltaCloudObjectUnmarshaller.java | 31 +
.../client/unmarshal/ImageUnmarshaller.java | 42 +
.../client/unmarshal/ImagesUnmarshaller.java | 41 +
.../client/unmarshal/InstanceUnmarshaller.java | 96 ++
.../client/unmarshal/InstancesUnmarshaller.java | 41 +
.../client/unmarshal/KeyUnmarshaller.java | 85 ++
.../client/unmarshal/KeysUnmarshaller.java | 41 +
.../client/unmarshal/RealmUnmarshaller.java | 41 +
.../client/unmarshal/RealmsUnmarshaller.java | 40 +
.../org/apache/deltacloud/client/utils/Assert.java | 41 +
.../deltacloud/client/utils/StreamUtils.java | 52 +
.../deltacloud/client/utils/StringUtils.java | 115 +++
.../apache/deltacloud/client/utils/UrlBuilder.java | 152 +++
97 files changed, 8174 insertions(+), 0 deletions(-)
create mode 100644 clients/java/org.apache.deltacloud.client.test/.gitignore
create mode 100644 clients/java/org.apache.deltacloud.client.test/ChangeLog
create mode 100644 clients/java/org.apache.deltacloud.client.test/META-INF/MANIFEST.MF
create mode 100644 clients/java/org.apache.deltacloud.client.test/NOTICE
create mode 100644 clients/java/org.apache.deltacloud.client.test/pom.xml
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientIntegrationTestSuite.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientTestSuite.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/APIDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/HardwareProfileDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ProfileMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmDomUnmarshallingTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java
create mode 100644 clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java
create mode 100644 clients/java/org.apache.deltacloud.client/.gitignore
create mode 100644 clients/java/org.apache.deltacloud.client/ChangeLog
create mode 100644 clients/java/org.apache.deltacloud.client/META-INF/MANIFEST.MF
create mode 100644 clients/java/org.apache.deltacloud.client/NOTICE
create mode 100644 clients/java/org.apache.deltacloud.client/pom.xml
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/API.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Action.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ActionAware.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/AddressList.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudAuthClientException.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClient.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientException.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudNotFoundClientException.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HardwareProfile.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpMethod.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusCode.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusRange.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/IdAware.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Image.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Instance.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Key.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Property.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Realm.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ResourceAction.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/StateAware.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractDeltaCloudRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractListObjectsRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateInstanceRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateKeyRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/DeltaCloudRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfileRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfilesRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImageRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImagesRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstanceRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstancesRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeyRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeysRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmsRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/PerformActionRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/TypeRequest.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/AbstractHttpTransport.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/Base64Coder.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/IHttpTransport.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/URLConnectionTransport.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/APIUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractActionAwareUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDOMUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ActionUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfileUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfilesUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/IDeltaCloudObjectUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImageUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImagesUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstanceUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstancesUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeyUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeysUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmsUnmarshaller.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/Assert.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StreamUtils.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StringUtils.java
create mode 100644 clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/UrlBuilder.java
diff --git a/clients/java/org.apache.deltacloud.client.test/.gitignore b/clients/java/org.apache.deltacloud.client.test/.gitignore
new file mode 100644
index 0000000..934e0e0
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/target
diff --git a/clients/java/org.apache.deltacloud.client.test/ChangeLog b/clients/java/org.apache.deltacloud.client.test/ChangeLog
new file mode 100644
index 0000000..6809f31
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/ChangeLog
@@ -0,0 +1,32 @@
+2011-03-12 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ [JBIDE-8562] extracted client tests to their own plugin
+
+2011-01-11 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/internal/deltacloud/test/core/client/ImageDomUnmarshallingTest.java:
+ [JBIDE-7935] created tests for image unmarshalling
+ * src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceDomUnmarshallingTest.java:
+ [JBIDE-7935] created tests for instance unmarshalling
+
+2010-12-15 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/test/core/job/SchedulingRulesTest.java:
+ [JBIDE-7594] created tests for all scheduling rules
+
+2010-11-19 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/test/core/client/InstanceMockIntegrationTest.java:
+ * src/org/jboss/tools/internal/deltacloud/test/context/MockIntegrationTestContext.java:
+ [JBIDE-7678] renamed State to InstanceState, added property isRunning, testing for ShowInRemoteSystemExplorerHandler
+
+2010-10-21 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/test/DeltaCloudMockClientIntegrationTest.java
+ [JBIDE-7371] (reports404OnUnknownResource): added test for reporting 404 on bad requests
+
+2010-10-20 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/internal/deltacloud/test/DeltaCloudClientTest.java:
+ * src/org/jboss/tools/internal/deltacloud/test/fakes/ServerFake.java:
+ [JBIDE-7371] tests for server type implemented
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client.test/META-INF/MANIFEST.MF b/clients/java/org.apache.deltacloud.client.test/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..24d50e4
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Deltacloud client tests
+Bundle-SymbolicName: org.apache.deltacloud.client.test
+Bundle-Version: 1.0.1.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Require-Bundle: org.apache.deltacloud.client;bundle-version="0.1.0",
+ org.junit;bundle-version="[4.8.0,5.0.0)"
+Bundle-Vendor: Apache Software Foundation
diff --git a/clients/java/org.apache.deltacloud.client.test/NOTICE b/clients/java/org.apache.deltacloud.client.test/NOTICE
new file mode 100644
index 0000000..cd3f48a
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/NOTICE
@@ -0,0 +1,8 @@
+Apache Deltacloud Java Client
+Copyright 2010 The Apache Software Foundation
+
+This product includes software developed at The Apache Software Foundation
+(http://www.apache.org/).
+
+This product includes software developed by Red Hat,
+Inc. (http://www.redhat.com/)
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client.test/pom.xml b/clients/java/org.apache.deltacloud.client.test/pom.xml
new file mode 100644
index 0000000..4b0105f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/pom.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <groupId>org.apache.deltacloud.client</groupId>
+ <artifactId>org.apache.deltacloud.client.test</artifactId>
+ <version>1.0.1-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Tests for Deltacloud client</name>
+ <description>The tests for the java Deltacloud client</description>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <testSourceDirectory>src</testSourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <encoding>utf-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.8.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.deltacloud.client</groupId>
+ <artifactId>client</artifactId>
+ <version>0.2.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientIntegrationTestSuite.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientIntegrationTestSuite.java
new file mode 100644
index 0000000..bece299
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientIntegrationTestSuite.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test;
+
+import org.apache.deltacloud.client.internal.test.client.ImageMockIntegrationTest;
+import org.apache.deltacloud.client.internal.test.client.InstanceMockIntegrationTest;
+import org.apache.deltacloud.client.internal.test.client.KeyMockIntegrationTest;
+import org.apache.deltacloud.client.internal.test.client.ProfileMockIntegrationTest;
+import org.apache.deltacloud.client.internal.test.client.RealmMockIntegrationTest;
+import org.apache.deltacloud.client.internal.test.client.ServerTypeMockIntegrationTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Andre Dietisheim
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ ImageMockIntegrationTest.class,
+ InstanceMockIntegrationTest.class,
+ KeyMockIntegrationTest.class,
+ ServerTypeMockIntegrationTest.class,
+ RealmMockIntegrationTest.class,
+ ProfileMockIntegrationTest.class
+})
+public class DeltaCloudClientIntegrationTestSuite {
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientTestSuite.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientTestSuite.java
new file mode 100644
index 0000000..2c5d38c
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/DeltaCloudClientTestSuite.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test;
+
+import org.apache.deltacloud.client.internal.test.client.APIDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.client.HardwareProfileDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.client.ImageDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.client.InstanceDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.client.KeyDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.client.RealmDomUnmarshallingTest;
+import org.apache.deltacloud.client.internal.test.utils.UrlBuilderTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * @author Andre Dietisheim
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ KeyDomUnmarshallingTest.class,
+ InstanceDomUnmarshallingTest.class,
+ ImageDomUnmarshallingTest.class,
+ HardwareProfileDomUnmarshallingTest.class,
+ APIDomUnmarshallingTest.class,
+ RealmDomUnmarshallingTest.class,
+ UrlBuilderTest.class})
+public class DeltaCloudClientTestSuite {
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/APIDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/APIDomUnmarshallingTest.java
new file mode 100644
index 0000000..b381a15
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/APIDomUnmarshallingTest.java
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.net.MalformedURLException;
+
+import org.apache.deltacloud.client.API;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.API.Driver;
+import org.apache.deltacloud.client.internal.test.fakes.APIResponseFakes.APIResponse;
+import org.apache.deltacloud.client.unmarshal.APIUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class APIDomUnmarshallingTest {
+
+ @Test
+ public void ec2DriverIsUnmarshalled() throws MalformedURLException, DeltaCloudClientException {
+ API api = new API();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(APIResponse.apiResponse.getBytes());
+ new APIUnmarshaller().unmarshall(inputStream, api);
+ assertNotNull(api);
+ assertEquals(APIResponse.driver, api.getDriver().name().toLowerCase());
+ }
+
+ @Test
+ public void invalidDriverUnmarshalledToUnknown() throws MalformedURLException, DeltaCloudClientException {
+ API api = new API();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(APIResponse.invalidDriverApiResponse.getBytes());
+ new APIUnmarshaller().unmarshall(inputStream, api);
+ assertNotNull(api);
+ assertEquals(Driver.UNKNOWN, api.getDriver());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/HardwareProfileDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/HardwareProfileDomUnmarshallingTest.java
new file mode 100644
index 0000000..9cca3a0
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/HardwareProfileDomUnmarshallingTest.java
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.HardwareProfile;
+import org.apache.deltacloud.client.Property;
+import org.apache.deltacloud.client.internal.test.fakes.HardwareProfileResponseFakes.HardwareProfile1Response;
+import org.apache.deltacloud.client.internal.test.fakes.HardwareProfileResponseFakes.HardwareProfile2Response;
+import org.apache.deltacloud.client.internal.test.fakes.HardwareProfileResponseFakes.HardwareProfilesResponse;
+import org.apache.deltacloud.client.unmarshal.HardwareProfileUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.HardwareProfilesUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileDomUnmarshallingTest {
+
+ @Test
+ public void HardwareProfilesCanBeUnmarshalled() throws MalformedURLException, JAXBException,
+ DeltaCloudClientException {
+ List<HardwareProfile> profiles = new ArrayList<HardwareProfile>();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(HardwareProfilesResponse.response.getBytes());
+ new HardwareProfilesUnmarshaller().unmarshall(inputStream, profiles);
+ assertEquals(2, profiles.size());
+ }
+
+ @Test
+ public void fixedPropertyHardwareProfileMayBeUnmarshalled() throws MalformedURLException, JAXBException,
+ DeltaCloudClientException {
+ HardwareProfile profile = new HardwareProfile();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(HardwareProfile1Response.response.getBytes());
+ new HardwareProfileUnmarshaller().unmarshall(inputStream, profile);
+ assertNotNull(profile);
+ assertEquals(HardwareProfile1Response.id, profile.getId());
+ assertEquals(HardwareProfile1Response.propMemValue + ' ' + HardwareProfile1Response.propMemUnit,
+ profile.getMemory());
+ assertEquals(HardwareProfile1Response.propStorageValue + ' ' + HardwareProfile1Response.propStorageUnit,
+ profile.getStorage());
+ assertEquals(HardwareProfile1Response.propCPUValue, profile.getCPU());
+ assertEquals(HardwareProfile1Response.propArchValue, profile.getArchitecture());
+ }
+
+ @Test
+ public void mixedPropertiesHardwareProfileMayBeUnmarshalled() throws MalformedURLException, JAXBException,
+ DeltaCloudClientException {
+ HardwareProfile profile = new HardwareProfile();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(HardwareProfile2Response.response.getBytes());
+ new HardwareProfileUnmarshaller().unmarshall(inputStream, profile);
+ assertNotNull(profile);
+ assertEquals(HardwareProfile2Response.id, profile.getId());
+ assertEquals(HardwareProfile2Response.propMemValue + ' ' + HardwareProfile2Response.propMemUnit,
+ profile.getMemory());
+ Property property = profile.getNamedProperty(Property.Names.MEMORY);
+ assertNotNull(property);
+ assertEquals(HardwareProfile2Response.propMemRangeFirst, property.getRange().getFirst());
+ assertEquals(HardwareProfile2Response.propMemRangeLast, property.getRange().getLast());
+ assertEquals(HardwareProfile2Response.propStorageValue + ' ' + HardwareProfile2Response.propStorageUnit,
+ profile.getStorage());
+ property = profile.getNamedProperty(Property.Names.STORAGE);
+ assertNotNull(property);
+ assertNotNull(property.getEnums());
+ assertEquals(2, property.getEnums().size());
+ assertEquals(HardwareProfile2Response.propStorageEnum1, property.getEnums().get(0));
+ assertEquals(HardwareProfile2Response.propStorageEnum2, property.getEnums().get(1));
+ assertEquals(HardwareProfile2Response.propCPUValue, profile.getCPU());
+ assertEquals(HardwareProfile2Response.propArchValue, profile.getArchitecture());
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageDomUnmarshallingTest.java
new file mode 100644
index 0000000..723f1a5
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageDomUnmarshallingTest.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.internal.test.fakes.ImageResponseFakes.ImageResponse;
+import org.apache.deltacloud.client.internal.test.fakes.ImageResponseFakes.ImagesResponse;
+import org.apache.deltacloud.client.unmarshal.ImageUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.ImagesUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class ImageDomUnmarshallingTest {
+
+ @Test
+ public void imageMayBeUnmarshalled() throws DeltaCloudClientException {
+ Image image = new Image();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(ImageResponse.response.getBytes());
+ new ImageUnmarshaller().unmarshall(inputStream, image);
+ assertNotNull(image);
+ assertEquals(ImageResponse.id, image.getId());
+ assertEquals(ImageResponse.name, image.getName());
+ assertEquals(ImageResponse.ownerId, image.getOwnerId());
+ assertEquals(ImageResponse.description, image.getDescription());
+ assertEquals(ImageResponse.architecture, image.getArchitecture());
+ }
+
+ @Test
+ public void imagesMayBeUnmarshalled() throws DeltaCloudClientException {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(ImagesResponse.response.getBytes());
+ List<Image> images = new ArrayList<Image>();
+ new ImagesUnmarshaller().unmarshall(inputStream, images);
+ assertEquals(2, images.size());
+
+ Image image = images.get(0);
+ assertEquals(ImagesResponse.id1, image.getId());
+ assertEquals(ImagesResponse.name1, image.getName());
+
+ image = images.get(1);
+ assertEquals(ImagesResponse.id2, image.getId());
+ assertEquals(ImagesResponse.name2, image.getName());
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageMockIntegrationTest.java
new file mode 100644
index 0000000..d248f82
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ImageMockIntegrationTest.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * An integration test that test various image related operations in DeltaCloudClient
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#listImages()
+ * @see DeltaCloudClientImpl#listImages(String)
+ *
+ */
+public class ImageMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void cannotListIfNotAuthenticated() throws MalformedURLException, DeltaCloudClientException {
+ DeltaCloudClientImpl client = new DeltaCloudClientImpl(MockIntegrationTestContext.DELTACLOUD_URL, "badUser", "badPassword");
+ client.listImages();
+ }
+
+ @Test
+ public void assertDefaultImages() throws DeltaCloudClientException {
+ List<Image> images = testSetup.getClient().listImages();
+ assertEquals(3, images.size());
+ assertImage("img1", "Fedora 10", "fedoraproject", "Fedora 10", "x86_64", getImage("img1", images));
+ assertImage("img2", "Fedora 10", "fedoraproject", "Fedora 10", "i386", getImage("img2", images) );
+ assertImage("img3", "JBoss", "mockuser", "JBoss", "i386", getImage("img3", images));
+ }
+
+ private Image getImage(String id, Collection<Image> images) {
+ for (Image image : images) {
+ if (id.equals(image.getId())) {
+ return image;
+ }
+ }
+ fail("image " + id + " was not found");
+ return null;
+ }
+
+ private void assertImage(String id, String name, String owner, String description, String architecture, Image image) {
+ assertEquals(id, image.getId());
+ assertEquals(name, image.getName());
+ assertEquals(owner, image.getOwnerId());
+ assertEquals(architecture, image.getArchitecture());
+ assertEquals(description, image.getDescription());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceDomUnmarshallingTest.java
new file mode 100644
index 0000000..fb27edb
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceDomUnmarshallingTest.java
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Instance;
+import org.apache.deltacloud.client.internal.test.fakes.InstanceResponseFakes.InstanceActionResponse;
+import org.apache.deltacloud.client.internal.test.fakes.InstanceResponseFakes.InstanceResponse;
+import org.apache.deltacloud.client.internal.test.fakes.InstanceResponseFakes.InstancesResponse;
+import org.apache.deltacloud.client.unmarshal.ActionUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.InstanceUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.InstancesUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceDomUnmarshallingTest {
+
+ @Test
+ public void instanceActionMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
+ Action<Instance> instanceAction = new Action<Instance>();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(InstanceActionResponse.response.getBytes());
+ new ActionUnmarshaller<Instance>().unmarshall(inputStream, instanceAction);
+ assertNotNull(instanceAction);
+ assertEquals(InstanceActionResponse.name, instanceAction.getName());
+ assertEquals(InstanceActionResponse.url, instanceAction.getUrl().toString());
+ assertEquals(InstanceActionResponse.method.toUpperCase(), instanceAction.getMethod().toString().toUpperCase());
+ }
+
+ @Test
+ public void instanceMayBeUnmarshalled() throws DeltaCloudClientException {
+ Instance instance = new Instance();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(InstanceResponse.response.getBytes());
+ new InstanceUnmarshaller().unmarshall(inputStream, instance);
+ assertNotNull(instance);
+ assertEquals(InstanceResponse.id1, instance.getId());
+ assertEquals(InstanceResponse.name1, instance.getName());
+ assertEquals(InstanceResponse.ownerId1, instance.getOwnerId());
+ assertEquals(InstanceResponse.image1Id, instance.getImageId());
+ assertEquals(InstanceResponse.hardwareProfile1Id, instance.getProfileId());
+ assertEquals(InstanceResponse.realm1Id, instance.getRealmId());
+ assertEquals(InstanceResponse.state, instance.getState());
+ assertEquals(InstanceResponse.keyname1, instance.getKeyId());
+ assertEquals(2, instance.getActions().size());
+ assertEquals(InstanceResponse.actionNameStop, instance.getActions().get(0).getName());
+ assertEquals(InstanceResponse.actionNameReboot, instance.getActions().get(1).getName());
+ assertEquals(1, instance.getPublicAddresses().size());
+ assertEquals(InstanceResponse.publicAddress1, instance.getPublicAddresses().get(0));
+ assertEquals(1, instance.getPrivateAddresses().size());
+ assertEquals(InstanceResponse.privateAddress1, instance.getPrivateAddresses().get(0));
+
+ }
+
+ @Test
+ public void instancesMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(InstancesResponse.response.getBytes());
+ List<Instance> instances = new ArrayList<Instance>();
+ new InstancesUnmarshaller().unmarshall(inputStream, instances);
+ assertEquals(2, instances.size());
+
+ Instance instance = instances.get(0);
+ assertEquals(InstancesResponse.id1, instance.getId());
+ assertEquals(InstancesResponse.name1, instance.getName());
+
+ instance = instances.get(1);
+ assertEquals(InstancesResponse.id2, instance.getId());
+ assertEquals(InstancesResponse.name2, instance.getName());
+ assertEquals(2, instance.getActions().size());
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceMockIntegrationTest.java
new file mode 100644
index 0000000..77185a3
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/InstanceMockIntegrationTest.java
@@ -0,0 +1,280 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.MalformedURLException;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.DeltaCloudClient;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.Instance;
+import org.apache.deltacloud.client.StateAware.State;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for instance related methods in
+ * {@link DeltaCloudClientImpl}.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#listInstances()
+ * @see DeltaCloudClientImpl#createInstance(String)
+ * @see DeltaCloudClientImpl#destroyInstance(String)
+ * @see DeltaCloudClientImpl#startInstance(String)
+ * @see DeltaCloudClientImpl#shutdownInstance(String)
+ */
+public class InstanceMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ /**
+ * #listInstance contains the test instance created in {@link #setUp()}
+ *
+ * @throws DeltaCloudClientException
+ * the delta cloud client exception
+ */
+
+ @Test
+ public void listContainsTestInstance() throws DeltaCloudClientException {
+ DeltaCloudClient client = testSetup.getClient();
+ List<Instance> instances = client.listInstances();
+ assertTrue(instances.size() > 0);
+ Instance testInstance = testSetup.getTestInstance();
+ assertNotNull(testSetup.getInstanceById(testInstance.getId(), client));
+ }
+
+ @Test
+ public void listTestInstance() throws DeltaCloudClientException {
+ Instance instance = testSetup.getClient().listInstances(testSetup.getTestInstance().getId());
+ assertNotNull(instance);
+ Instance testInstance = testSetup.getTestInstance();
+ assertEquals(testInstance.getId(), instance.getId());
+ assertInstance(
+ testInstance.getName()
+ , testInstance.getOwnerId()
+ , testInstance.getImageId()
+ , testInstance.getRealmId()
+ , testInstance.getProfileId()
+ , testInstance.getMemory()
+ , testInstance.getPrivateAddresses()
+ , testInstance.getPublicAddresses()
+ , instance);
+ }
+
+ @Test(expected = DeltaCloudNotFoundClientException.class)
+ public void listDestroyedInstanceThrowsException() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ testSetup.quietlyDestroyInstance(testInstance);
+ testSetup.getClient().listInstances(testInstance.getId());
+ }
+
+ private void assertInstance(String name, String owner, String ImageId, String realmId, String profile,
+ String memory, List<String> privateAddresses, List<String> publicAddresses, Instance instance) {
+ assertNotNull("instance " + name + " was not found", instance);
+ assertEquals(name, instance.getName());
+ assertEquals(owner, instance.getOwnerId());
+ assertEquals(realmId, instance.getRealmId());
+ assertEquals(profile, instance.getProfileId());
+ assertEquals(memory, instance.getMemory());
+ assertTrue(privateAddresses.equals(instance.getPrivateAddresses()));
+ assertTrue(publicAddresses.equals(instance.getPublicAddresses()));
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void cannotDestroyIfNotAuthenticated() throws MalformedURLException, DeltaCloudClientException {
+ DeltaCloudClientImpl unauthenticatedClient = new DeltaCloudClientImpl(
+ MockIntegrationTestContext.DELTACLOUD_URL,
+ "badUser", "badPassword");
+ Image image = testSetup.getFirstImage(unauthenticatedClient);
+ unauthenticatedClient.createInstance(image.getId());
+ }
+
+ @Test
+ public void canCreateInstance() throws DeltaCloudClientException {
+ Instance instance = null;
+ try {
+ Image image = testSetup.getFirstImage(testSetup.getClient());
+ instance = testSetup.getClient().createInstance(image.getId());
+ assertTrue(instance != null);
+ assertEquals(image.getId(), instance.getImageId());
+ assertEquals(State.RUNNING, instance.getState());
+ } finally {
+ testSetup.quietlyDestroyInstance(instance);
+ }
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void cannotDestroyUnknownImageId() throws DeltaCloudClientException {
+ testSetup.getClient().createInstance("dummy");
+ }
+
+ @Test(expected=DeltaCloudClientException.class)
+ public void canDestroy() throws DeltaCloudClientException {
+ Image image = testSetup.getFirstImage(testSetup.getClient());
+ DeltaCloudClient client = testSetup.getClient();
+ Instance instance = client.createInstance(image.getId());
+ instance.stop(client);
+ instance.destroy(client);
+ client.listInstances(instance.getId());
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void destroyThrowsExceptionOnUnknowInstanceId() throws DeltaCloudClientException, IllegalArgumentException,
+ InstantiationException, IllegalAccessException, InvocationTargetException, SecurityException,
+ NoSuchMethodException {
+ DeltaCloudClient client = testSetup.getClient();
+ client.performAction(
+ createInstanceAction(
+ "destroy",
+ MockIntegrationTestContext.DELTACLOUD_URL,
+ HttpMethod.POST,
+ new Instance()));
+ }
+
+ private Action<Instance> createInstanceAction(String name, String url, HttpMethod method, Instance instance) {
+ Action<Instance> action = new Action<Instance>();
+ action.setName(name);
+ action.setMethod(method);
+ action.setOwner(instance);
+ return action;
+ }
+
+ @SuppressWarnings("unused")
+ private class InstanceActionProxy implements InvocationHandler {
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ if (method.getName().equals("getUrl")) {
+ return MockIntegrationTestContext.DELTACLOUD_URL;
+ } else if (method.getName().equals("getMethod")) {
+ return HttpMethod.POST;
+ } else {
+ return null;
+ }
+ }
+
+ }
+
+ @Test
+ public void canShutdownInstance() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ testInstance.stop(client);
+ testInstance = client.listInstances(testInstance.getId()); // reload!
+ assertEquals(State.STOPPED, testInstance.getState());
+ }
+
+ @Test
+ public void canStartInstance() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ if (testInstance.getState() == State.RUNNING) {
+ testInstance.stop(client);
+ }
+ testInstance.start(client);
+ testInstance = client.listInstances(testInstance.getId()); // reload!
+ assertEquals(State.RUNNING, testInstance.getState());
+ }
+
+ @Test
+ public void canStartInstanceByAction() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ if (testInstance.getState() == State.RUNNING) {
+ testInstance.stop(client);
+ }
+ assertTrue(testInstance.start(client));
+ testInstance = client.listInstances(testInstance.getId()); // reload!
+ assertEquals(State.RUNNING, testInstance.getState());
+ }
+
+ @Test
+ public void cannotStartRunningInstance() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ testInstance.start(client);
+ assertFalse(testInstance.start(client));
+ }
+
+ @Test
+ public void cannotStopStoppedInstance() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ testInstance.stop(client);
+ assertFalse(testInstance.stop(client));
+ } finally {
+ testInstance.start(client);
+ }
+ }
+
+ @Test
+ public void cannotDestroyRunningInstance() throws DeltaCloudClientException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ testInstance = client.listInstances(testInstance.getId()); // reload
+ assertTrue(testInstance.getState() == State.RUNNING);
+ assertFalse(testInstance.destroy(client));
+ }
+
+ @Test
+ public void cannotRebootStoppedInstance() throws DeltaCloudClientException, InterruptedException,
+ ExecutionException {
+ Instance testInstance = testSetup.getTestInstance();
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ testInstance.stop(client);
+ testInstance = client.listInstances(testInstance.getId()); // reload
+ assertTrue(testInstance.getState() == State.STOPPED);
+ assertFalse(testInstance.reboot(client));
+ } finally {
+ testInstance.start(client);
+ client.listInstances(testInstance.getId()); // reload
+ }
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyDomUnmarshallingTest.java
new file mode 100644
index 0000000..1669a95
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyDomUnmarshallingTest.java
@@ -0,0 +1,97 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBException;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.Key;
+import org.apache.deltacloud.client.internal.test.fakes.KeyResponseFakes;
+import org.apache.deltacloud.client.internal.test.fakes.KeyResponseFakes.KeyActionResponse;
+import org.apache.deltacloud.client.internal.test.fakes.KeyResponseFakes.KeyResponse;
+import org.apache.deltacloud.client.internal.test.fakes.KeyResponseFakes.KeysResponse;
+import org.apache.deltacloud.client.unmarshal.ActionUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.KeyUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.KeysUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class KeyDomUnmarshallingTest {
+
+ @Test
+ public void keyActionMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
+ Action<Key> keyAction = new Action<Key>();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(KeyActionResponse.keyActionResponse.getBytes());
+ new ActionUnmarshaller<Key>().unmarshall(inputStream, keyAction);
+ assertNotNull(keyAction);
+ assertEquals(KeyActionResponse.name, keyAction.getName());
+ assertEquals(KeyActionResponse.url, keyAction.getUrl().toString());
+ assertEquals(KeyActionResponse.method.toUpperCase(), keyAction.getMethod().toString().toUpperCase());
+ }
+
+ @Test
+ public void keyMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
+ Key key = new Key();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(KeyResponse.keyResponse.getBytes());
+ new KeyUnmarshaller().unmarshall(inputStream, key);
+ assertNotNull(key);
+ assertEquals(KeyResponseFakes.KeyResponse.id, key.getId());
+ assertEquals(KeyResponse.fingerprint, key.getFingerprint());
+ assertEquals(new URL(KeyResponse.url), key.getUrl());
+ assertEquals(KeyResponse.pem, key.getPem());
+ assertEquals(1, key.getActions().size());
+ Action<Key> action = key.getActions().get(0);
+ assertNotNull(action);
+ assertEquals(KeyResponse.url, action.getUrl().toString());
+ assertEquals(KeyResponse.name, action.getName());
+ assertEquals(HttpMethod.valueOf(KeyResponse.method.toUpperCase()), action.getMethod());
+ }
+
+ @Test
+ public void keysMayBeUnmarshalled() throws MalformedURLException, JAXBException, DeltaCloudClientException {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(KeysResponse.keysResponse.getBytes());
+ List<Key> keys = new ArrayList<Key>();
+ new KeysUnmarshaller().unmarshall(inputStream, keys);
+ assertEquals(2, keys.size());
+ Key key = keys.get(0);
+ assertEquals(KeysResponse.id1, key.getId());
+ assertEquals(KeysResponse.fingerprint1, key.getFingerprint());
+ assertEquals(new URL(KeysResponse.url1), key.getUrl());
+ assertEquals(KeysResponse.pem1, key.getPem());
+ assertEquals(1, key.getActions().size());
+ Action<Key> action = key.getActions().get(0);
+ assertNotNull(action);
+ assertEquals(KeysResponse.url1, action.getUrl().toString());
+ assertEquals(KeysResponse.name1, action.getName());
+ assertEquals(HttpMethod.valueOf(KeysResponse.method1.toUpperCase()), action.getMethod());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyMockIntegrationTest.java
new file mode 100644
index 0000000..8591c7c
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/KeyMockIntegrationTest.java
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClient;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.Key;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for key related operations in delta cloud client.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#createKey(String, String)
+ * @see DeltaCloudClientImpl#deleteKey(String)
+ */
+public class KeyMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ @Test
+ public void canCreateKey() throws DeltaCloudClientException {
+ String id = "test" + System.currentTimeMillis();
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ Key key = client.createKey(id);
+ assertNotNull(key);
+ assertEquals(id, key.getId());
+ } finally {
+ quietlyDeleteKey(id);
+ }
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void createDuplicateKeyThrowsException() throws DeltaCloudClientException {
+ String id = "test" + System.currentTimeMillis();
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ client.createKey(id);
+ client.createKey(id);
+ } finally {
+ quietlyDeleteKey(id);
+ }
+ }
+
+ /**
+ * Checks if a key may be deleted.
+ */
+ @Test(expected = DeltaCloudNotFoundClientException.class)
+ public void canDeleteKey() throws DeltaCloudClientException {
+ String id = "test" + System.currentTimeMillis();
+ DeltaCloudClient client = testSetup.getClient();
+ Key key = client.createKey(id);
+ assertNotNull(key);
+ assertEquals(id, key.getId());
+ key.destroy(client);
+ client.listKey(key.getId());
+ }
+
+ /**
+ * checks if the client throws a {@link DeltaCloudNotFoundClientException}
+ * if an unknown key is requested.
+ *
+ * @throws DeltaCloudClientException
+ */
+ @Test(expected = DeltaCloudNotFoundClientException.class)
+ public void listUnknownKeyThrowsException() throws DeltaCloudClientException {
+ String id = String.valueOf(System.currentTimeMillis());
+ testSetup.getClient().listKey(id);
+ }
+
+ @Test
+ public void canListKey() throws DeltaCloudClientException {
+ String id = String.valueOf(System.currentTimeMillis());
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ Key createdKey = client.createKey(id);
+ Key listedKey = client.listKey(id);
+ assertEquals(createdKey.getId(), listedKey.getId());
+ } finally {
+ quietlyDeleteKey(id);
+ }
+ }
+
+ @Test
+ public void canListKeys() throws DeltaCloudClientException {
+ String id = String.valueOf(System.currentTimeMillis());
+ DeltaCloudClient client = testSetup.getClient();
+ try {
+ final Key createdKey = client.createKey(id);
+ List<Key> keys = client.listKeys();
+ assertNotNull(keys);
+ assertThat(keys, hasItem(new BaseMatcher<Key>() {
+
+ @Override
+ public boolean matches(Object item) {
+ if (item instanceof Key) {
+ Key listedKey = (Key) item;
+ return
+ createdKey.getId().equals(listedKey.getId())
+ && createdKey.getFingerprint().equals(listedKey.getFingerprint())
+ && createdKey.getPem().equals(listedKey.getPem())
+ && createdKey.getUrl().equals(listedKey.getUrl())
+ && createdKey.getActions().size() == listedKey.getActions().size();
+ }
+ return false;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ // TODO Auto-generated method stub
+
+ }
+ }));
+ } finally {
+ quietlyDeleteKey(id);
+ }
+ }
+
+ private void quietlyDeleteKey(String id) {
+ try {
+ DeltaCloudClient client = testSetup.getClient();
+ Key key = client.listKey(id);
+ key.destroy(client);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ProfileMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ProfileMockIntegrationTest.java
new file mode 100644
index 0000000..d54ae23
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ProfileMockIntegrationTest.java
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.HardwareProfile;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for key related operations in delta cloud client.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#listProfiles()
+ * @see DeltaCloudClientImpl#listProfie(String)
+ */
+public class ProfileMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ @Test
+ public void canListProfiles() throws DeltaCloudClientException {
+ List<HardwareProfile> hardwareProfiles = testSetup.getClient().listProfiles();
+ assertNotNull(hardwareProfiles);
+ assertTrue(hardwareProfiles.size() > 0);
+ }
+
+ @Test
+ public void canGetProfile() throws DeltaCloudClientException {
+ // get a profile seen in the web UI
+ HardwareProfile profile = testSetup.getClient().listProfile("m1-small");
+ assertNotNull(profile);
+ assertHardWareProfile("i386", "1740.8 MB", "160 GB", "1", profile);
+ }
+
+ public void assertHardWareProfile(String architecture, String memory, String storage, String cpu, HardwareProfile profile) {
+ assertEquals(architecture, profile.getArchitecture());
+ assertEquals(memory, profile.getMemory());
+ assertEquals(storage, profile.getStorage());
+ assertEquals(cpu, profile.getCPU());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmDomUnmarshallingTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmDomUnmarshallingTest.java
new file mode 100644
index 0000000..ec841a3
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmDomUnmarshallingTest.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Realm;
+import org.apache.deltacloud.client.Realm.RealmState;
+import org.apache.deltacloud.client.internal.test.fakes.RealmResponseFakes;
+import org.apache.deltacloud.client.internal.test.fakes.RealmResponseFakes.RealmsResponse;
+import org.apache.deltacloud.client.unmarshal.RealmUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.RealmsUnmarshaller;
+import org.junit.Test;
+
+/**
+ * @author André Dietisheim
+ */
+public class RealmDomUnmarshallingTest {
+
+ @Test
+ public void realmMayBeUnmarshalled() throws DeltaCloudClientException {
+ Realm realm = new Realm();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(RealmResponseFakes.realmResponse.response.getBytes());
+ new RealmUnmarshaller().unmarshall(inputStream, realm);
+ assertNotNull(realm);
+ assertEquals(RealmResponseFakes.realmResponse.id, realm.getId());
+ assertEquals(RealmResponseFakes.realmResponse.name, realm.getName());
+ assertEquals(RealmState.valueOf(RealmResponseFakes.realmResponse.state.toUpperCase()), realm.getState());
+ assertEquals(RealmResponseFakes.realmResponse.getIntLimit(), realm.getLimit());
+ }
+
+ @Test
+ public void emptyLimitSetsDefaultLimit() throws DeltaCloudClientException {
+ Realm realm = new Realm();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(RealmResponseFakes.invalidLimitRealmResponse.response.getBytes());
+ new RealmUnmarshaller().unmarshall(inputStream, realm);
+ assertNotNull(realm);
+ assertEquals(Realm.LIMIT_DEFAULT, realm.getLimit());
+ }
+
+ @Test
+ public void invalidStateSetsUNKNOWNState() throws DeltaCloudClientException {
+ Realm realm = new Realm();
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(RealmResponseFakes.invalidLimitRealmResponse.response.getBytes());
+ new RealmUnmarshaller().unmarshall(inputStream, realm);
+ assertNotNull(realm);
+ assertEquals(Realm.LIMIT_DEFAULT, realm.getLimit());
+ }
+
+ @Test
+ public void realmsMayBeUnmarshalled() throws DeltaCloudClientException {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(RealmsResponse.response.getBytes());
+ List<Realm> realms = new ArrayList<Realm>();
+ new RealmsUnmarshaller().unmarshall(inputStream, realms);
+ assertEquals(2, realms.size());
+
+ Realm realm = realms.get(0);
+ assertEquals(RealmsResponse.id1, realm.getId());
+ assertEquals(RealmsResponse.name1, realm.getName());
+
+ realm = realms.get(1);
+ assertEquals(RealmsResponse.id2, realm.getId());
+ assertEquals(RealmsResponse.name2, realm.getName());
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmMockIntegrationTest.java
new file mode 100644
index 0000000..82648df
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/RealmMockIntegrationTest.java
@@ -0,0 +1,79 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.Realm;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for key related operations in delta cloud client.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#listRealms()
+ * @see DeltaCloudClientImpl#listRealm(String)
+ */
+public class RealmMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ @Test
+ public void canListRealms() throws DeltaCloudClientException {
+ List<Realm> realms = testSetup.getClient().listRealms();
+ assertNotNull(realms);
+ assertTrue(realms.size() > 0);
+ }
+
+ @Test
+ public void canGetProfile() throws DeltaCloudClientException {
+ // get a profile seen in the web UI
+ Realm realm = testSetup.getClient().listRealms("eu");
+ assertNotNull(realm);
+ assertRealm("Europe", Realm.RealmState.AVAILABLE, Realm.LIMIT_DEFAULT, realm);
+ }
+
+ public void assertRealm(String name, Realm.RealmState state, int limit, Realm realm) {
+ assertEquals(name, realm.getName());
+ assertEquals(state, realm.getState());
+ assertEquals(limit, realm.getLimit());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java
new file mode 100644
index 0000000..93d99d9
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/client/ServerTypeMockIntegrationTest.java
@@ -0,0 +1,136 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.client;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.API.Driver;
+import org.apache.deltacloud.client.internal.test.context.MockIntegrationTestContext;
+import org.apache.deltacloud.client.internal.test.fakes.ServerFake;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Integration tests for {@link DeltaCloudClientImpl#getServerType()}.
+ *
+ * @author Andre Dietisheim
+ *
+ * @see DeltaCloudClientImpl#getServerType()
+ */
+public class ServerTypeMockIntegrationTest {
+
+ private MockIntegrationTestContext testSetup;
+
+ @Before
+ public void setUp() throws IOException, DeltaCloudClientException {
+ this.testSetup = new MockIntegrationTestContext();
+ testSetup.setUp();
+ }
+
+ @After
+ public void tearDown() {
+ testSetup.tearDown();
+ }
+
+ @Test
+ public void recognizesDeltaCloud() throws IOException {
+ assertEquals(Driver.MOCK, testSetup.getClient().getServerType());
+ }
+
+ /**
+ *
+ * #getServerType reports {@link DeltaCloudClient.DeltaCloudType#UNKNOWN) if it queries a fake server that responds with a unknown answer.
+ *
+ * @throws IOException
+ * Signals that an I/O exception has occurred.
+ * @throws DeltaCloudClientException
+ */
+ @Test
+ public void reportsUnknownUrl() throws IOException, DeltaCloudClientException {
+ ServerFake serverFake =
+ new ServerFake(
+ new URL(MockIntegrationTestContext.SERVERFAKE_URL).getPort(),
+ "<dummy></dummy>");
+ serverFake.start();
+ try {
+ assertEquals(
+ Driver.UNKNOWN,
+ new DeltaCloudClientImpl(
+ MockIntegrationTestContext.SERVERFAKE_URL, MockIntegrationTestContext.DELTACLOUD_USER,
+ MockIntegrationTestContext.DELTACLOUD_PASSWORD).getServerType());
+ } finally {
+ serverFake.stop();
+ }
+ }
+
+ @Test(expected = DeltaCloudClientException.class)
+ public void listImages_cannotListIfNotAuthenticated() throws MalformedURLException, DeltaCloudClientException {
+ DeltaCloudClientImpl client = new DeltaCloudClientImpl(MockIntegrationTestContext.DELTACLOUD_URL, "badUser",
+ "badPassword");
+ client.listImages();
+ }
+
+ @Test
+ public void throwsDeltaCloudClientExceptionOnUnknownResource() {
+ try {
+ DeltaCloudClientImpl errorClient = new DeltaCloudClientImpl(MockIntegrationTestContext.DELTACLOUD_URL) {
+ @Override
+ public List<Image> listImages() throws DeltaCloudClientException {
+ request(new DeltaCloudRequest() {
+
+ @Override
+ public URL getUrl() throws MalformedURLException {
+ return new URL(MockIntegrationTestContext.DELTACLOUD_URL + "/DUMMY");
+ }
+
+ @Override
+ public HttpMethod getHttpMethod() {
+ return HttpMethod.GET;
+ }
+
+ @Override
+ public String getUrlString() {
+ return null;
+ }
+ }
+ );
+ return Collections.emptyList();
+ }
+ };
+ errorClient.listImages();
+ fail("no exception catched");
+ } catch (Exception e) {
+ assertEquals(DeltaCloudNotFoundClientException.class, e.getClass());
+ }
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java
new file mode 100644
index 0000000..ca126e1
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/context/MockIntegrationTestContext.java
@@ -0,0 +1,165 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.context;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.List;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+import org.apache.deltacloud.client.DeltaCloudClient;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudClientImpl;
+import org.apache.deltacloud.client.Image;
+import org.apache.deltacloud.client.Instance;
+import org.apache.deltacloud.client.StateAware.State;
+
+/**
+ * A class that holds the integration test context
+ *
+ * @author Andre Dietisheim
+ *
+ */
+public class MockIntegrationTestContext {
+
+ public static final String DELTACLOUD_URL = "http://localhost:3001";
+ public static final String SERVERFAKE_URL = "http://localhost:3002";
+ public static final String DELTACLOUD_USER = "mockuser";
+ public static final String DELTACLOUD_PASSWORD = "mockpassword";
+ private static final long TIMEOUT = 5000;
+
+ private DeltaCloudClient client;
+ private Instance testInstance;
+
+ private ExecutorService executor = Executors.newSingleThreadExecutor();
+
+ public void setUp() throws IOException, DeltaCloudClientException {
+ ensureDeltaCloudIsRunning();
+ this.client = new DeltaCloudClientImpl(DELTACLOUD_URL, DELTACLOUD_USER, DELTACLOUD_PASSWORD);
+ Image image = getFirstImage(client);
+ this.testInstance = createTestInstance(image);
+ }
+
+ private Instance createTestInstance(Image image) throws DeltaCloudClientException {
+ assertNotNull(image);
+ Instance instance = client.createInstance(image.getId());
+ return instance;
+ }
+
+ public void ensureDeltaCloudIsRunning() throws IOException {
+ try {
+ URLConnection connection = new URL(DELTACLOUD_URL).openConnection();
+ connection.connect();
+ } catch (ConnectException e) {
+ fail("Local DeltaCloud instance is not running. Please start a DeltaCloud instance before running these tests.");
+ }
+ }
+
+ public DeltaCloudClient getClient() {
+ return client;
+ }
+
+ public Instance getTestInstance() {
+ return testInstance;
+ }
+
+ public Image getFirstImage(DeltaCloudClient client) throws DeltaCloudClientException {
+ List<Image> images = client.listImages();
+ assertTrue(images.size() >= 1);
+ Image image = images.get(0);
+ return image;
+ }
+
+ public Instance getInstanceById(String id, DeltaCloudClient client) throws DeltaCloudClientException {
+ for (Instance availableInstance : client.listInstances()) {
+ if (id.equals(availableInstance.getId())) {
+ return availableInstance;
+ }
+ }
+ return null;
+ }
+
+ public void tearDown() {
+ quietlyDestroyInstance(testInstance);
+ executor.shutdownNow();
+ }
+
+ public void quietlyDestroyInstance(Instance instance) {
+ if (instance != null) {
+ try {
+ if (instance.getState() == Instance.State.RUNNING) {
+ instance.stop(client);
+ }
+ instance = waitForInstanceState(instance.getId(), Instance.State.STOPPED, TIMEOUT);
+ assertNotNull("Could not stop instance " + instance.getName(), instance);
+ assertTrue("Could not destroy instance " + instance.getName(), instance.destroy(client));
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ /**
+ * Waits for an instance to get the given state for a given timeout.
+ *
+ * @param instanceId
+ * the id of the instance to watch
+ * @param state
+ * the state to wait for
+ * @param timeout
+ * the timeout to wait for
+ * @return <code>true</code>, if the state was reached while waiting for
+ * timeout, <code>false</code> otherwise
+ * @throws ExecutionException
+ * @throws InterruptedException
+ */
+ public Instance waitForInstanceState(final String instanceId, final State state, final long timeout)
+ throws InterruptedException, ExecutionException {
+ final long startTime = System.currentTimeMillis();
+ Callable<Instance> waitingCallable = new Callable<Instance>() {
+
+ @Override
+ public Instance call() throws Exception {
+ try {
+ while (System.currentTimeMillis() < startTime + timeout) {
+ Instance instance = client.listInstances(instanceId);
+ if (instance.getState() == state) {
+ return instance;
+ }
+ Thread.sleep(200);
+ }
+ return null;
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ };
+ return executor.submit(waitingCallable).get();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java
new file mode 100644
index 0000000..828f544
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/APIResponseFakes.java
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class APIResponseFakes {
+
+ public static class APIResponse {
+ public static final String url = "http://localhost:3001/api/keys/test1292840175447";
+ public static final String driver = "ec2";
+
+ public static final String apiResponse = getApiResponseXML(url, driver);
+ public static final String invalidDriverApiResponse = getApiResponseXML(url, "foo");
+ }
+
+ private static final String getApiResponseXML(String url, String driver) {
+ return "<api driver='" + driver + "' version='0.1'>"
+ + " <link href='" + url + "realms' rel='realms'>"
+ + " </link>"
+ + " <link href='" + url + "images' rel='images'>"
+ + " <feature name='owner_id'></feature>"
+ + " </link>"
+ + " <link href='" + url + "instance_states' rel='instance_states'>"
+ + " </link>"
+ + " <link href='" + url + "instances' rel='instances'>"
+ + " <feature name='user_data'></feature>"
+ + " <feature name='authentication_key'></feature>"
+ + " <feature name='public_ip'></feature>"
+ + " <feature name='security_group'></feature>"
+ + " </link>"
+ + " <link href='" + url + "hardware_profiles' rel='hardware_profiles'>"
+ + " </link>"
+ + " <link href='" + url + "storage_snapshots' rel='storage_snapshots'>"
+ + " </link>"
+ + " <link href='" + url + "storage_volumes' rel='storage_volumes'>"
+ + " </link>"
+ + " <link href='" + url + "keys' rel='keys'>"
+ + " </link>"
+ + " <link href='" + url + "buckets' rel='buckets'>"
+ + " <feature name='bucket_location'></feature>"
+ + " </link>"
+ + "</api>";
+
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java
new file mode 100644
index 0000000..a0d3cd6
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/HardwareProfileResponseFakes.java
@@ -0,0 +1,145 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.Property;
+import org.apache.deltacloud.client.Property.UNIT;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileResponseFakes {
+
+ public static class HardwareProfile1Response {
+ public static final String id = "m1-small";
+ public static final String propMemKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propMemUnit = UNIT.MB.name();
+ public static final String propMemValue = "1740.8";
+ public static final String propStorageKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propStorageUnit = UNIT.GB.name();
+ public static final String propStorageValue = "160";
+ public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propCPUUnit = UNIT.COUNT.name().toLowerCase();
+ public static final String propCPUValue = "1";
+ public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propArchUnit = UNIT.LABEL.name().toLowerCase();
+ public static final String propArchValue = "i386";
+
+ public static final String response = getHardwareProfileResponseXML(
+ id,
+ new String[] {
+ getFixedPropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit, propMemValue),
+ getFixedPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+ propStorageValue),
+ getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit, propCPUValue),
+ getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(), propArchUnit,
+ propArchValue)
+ });
+ }
+
+ public static class HardwareProfile2Response {
+ public static final String id = "m1-large";
+ public static final String propMemKind = Property.Kind.RANGE.name().toLowerCase();
+ public static final String propMemUnit = UNIT.MB.name();
+ public static final String propMemValue = "10240";
+ public static final String propMemRangeFirst = "7680.0";
+ public static final String propMemRangeLast = "15360";
+ public static final String propStorageKind = Property.Kind.ENUM.name().toLowerCase();
+ public static final String propStorageUnit = UNIT.GB.name();
+ public static final String propStorageValue = "160";
+ public static final String propStorageEnum1 = "850";
+ public static final String propStorageEnum2 = "1024";
+ public static final String propCPUKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propCPUUnit = UNIT.COUNT.name().toLowerCase();
+ public static final String propCPUValue = "2";
+ public static final String propArchKind = Property.Kind.FIXED.name().toLowerCase();
+ public static final String propArchUnit = UNIT.LABEL.name().toLowerCase();
+ public static final String propArchValue = "x86_64";
+
+ public static final String response = getHardwareProfileResponseXML(
+ id,
+ new String[] {
+ getRangePropertyXML(Property.Names.MEMORY.name().toLowerCase(), propMemUnit, propMemValue,
+ propMemRangeFirst, propMemRangeLast),
+ getEnumPropertyXML(Property.Names.STORAGE.name().toLowerCase(), propStorageUnit,
+ propStorageValue, propStorageEnum1, propStorageEnum2),
+ getFixedPropertyXML(Property.Names.CPU.name().toLowerCase(), propCPUUnit, propCPUValue),
+ getFixedPropertyXML(Property.Names.ARCHITECTURE.name().toLowerCase(), propArchUnit,
+ propArchValue)
+ });
+ }
+
+ public static class HardwareProfilesResponse {
+
+ public static final String response =
+ "<hardware_profiles>"
+ + HardwareProfile1Response.response
+ + HardwareProfile2Response.response
+ +"</hardware_profiles>";
+ }
+
+ private static final String getHardwareProfileResponseXML(String id, String[] properties) {
+ StringBuilder builder = new StringBuilder();
+ for (String propertyString : properties) {
+ builder.append(propertyString);
+ }
+ return getHardwareProfileResponseXML(id, builder.toString());
+ }
+
+ private static final String getHardwareProfileResponseXML(String id, String properties) {
+ return new StringBuilder()
+ .append("<hardware_profile href=\"fakeUrl\" id=\"").append(id).append("\">")
+ .append("<name>fakeName</name>")
+ .append(properties)
+ .append("</hardware_profile>")
+ .toString();
+ }
+
+ private static String getFixedPropertyXML(String name, String unit, String value) {
+ return getPropertyXML(name, "fixed", unit, value)
+ + getClodingPropertyTag();
+ }
+
+ private static String getRangePropertyXML(String name, String unit, String value, String first, String last) {
+ return getPropertyXML(name, "range", unit, value)
+ + "<range first='" + first + "' last='" + last + "'/>"
+ + getClodingPropertyTag();
+ }
+
+ private static String getEnumPropertyXML(String name, String unit, String value, String... enumValues) {
+ StringBuilder builder = new StringBuilder(getPropertyXML(name, "enum", unit, value));
+ builder.append("<enum>");
+ for (String enumValue : enumValues) {
+ builder.append("<entry value='").append(enumValue).append("' />");
+ }
+ builder.append("</enum>");
+ builder.append(getClodingPropertyTag());
+ return builder.toString();
+ }
+
+ private static String getPropertyXML(String name, String kind, String unit, String value) {
+ return "<property kind=\"" + kind + "\" name=\"" + name + "\" unit=\"" + unit + "\" value=\"" + value + "\">";
+ }
+
+ private static String getClodingPropertyTag() {
+ return "</property>";
+
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java
new file mode 100644
index 0000000..3f27a62
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ImageResponseFakes.java
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+
+/**
+ * @author André Dietisheim
+ */
+public class ImageResponseFakes {
+
+ public static class ImageResponse {
+ public static final String url = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3577f";
+ public static final String id = "ami-16a3577f";
+ public static final String name = "sles-10-sp3-v1.00.i386";
+ public static final String ownerId = "013907871322";
+ public static final String description = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v1.00)";
+ public static final String architecture = "i386";
+
+ public static final String response = getImageResponseXML(url, id, name, ownerId, description, architecture);
+ }
+
+ public static class ImagesResponse {
+
+ public static final String url1 = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3577f";
+ public static final String id1 = "ami-16a3577f";
+ public static final String name1 = "sles-10-sp3-v1.00.i386";
+ public static final String ownerId1 = "013907871322";
+ public static final String description1 = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v1.00)";
+ public static final String architecture1 = "i386";
+
+ public static final String url2 = "http://try.steamcannon.org/deltacloud/api/images/ami-16a3578f";
+ public static final String id2 = "ami-16a3578f";
+ public static final String name2 = "sles-10-sp3-v2.00.i686";
+ public static final String ownerId2 = "013907871422";
+ public static final String description2 = "SUSE Linux Enterprise Server 10 Service Pack 3 for x86 (v2.00)";
+ public static final String architecture2 = "i686";
+
+ public static final String response =
+ "<images>"
+ + getImageResponseXML(url1, id1, name1, ownerId1, description1, architecture1)
+ + getImageResponseXML(url2, id2, name2, ownerId2, description2, architecture2)
+ + "</images>";
+
+ }
+
+ private static String getImageResponseXML(String url, String id, String name, String ownerId,
+ String description, String architecture) {
+ return "<image href='" + url + "' id='" + id + "'>"
+ + "<name>" + name + "</name>"
+ + "<owner_id>" + ownerId + "</owner_id>"
+ + "<description>" + description + "</description>"
+ + "<architecture>" + architecture + "</architecture>"
+ + "<state></state>"
+ + "</image>";
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java
new file mode 100644
index 0000000..3db1370
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/InstanceResponseFakes.java
@@ -0,0 +1,163 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.StateAware.State;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceResponseFakes {
+
+ public static class InstanceActionResponse {
+ public static final String url = "http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503/start";
+ public static final String method = "post";
+ public static final String name = "start";
+ public static final String response = ServerResponseFakes.getActionXML(url, method, name);
+ }
+
+ public static class InstanceResponse {
+ public static final String url1 = "http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503";
+ public static final String id1 = "i-6f16e503";
+ public static final String name1 = "ami-7d07ec14";
+ public static final String ownerId1 = "357159121505";
+ public static final String image1Url = "http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec14";
+ public static final String image1Id = "ami-7d07ec14";
+ public static final String realm1Url = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public static final String realm1Id = "us-east-1a";
+ public static final State state = State.RUNNING;
+ public static final String hardwareProfile1Url = "http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.small";
+ public static final String hardwareProfile1Id = "m1.small";
+ public static final String keyname1 = "ad10";
+ public static final String actionNameStop = "stop";
+ public static final String actionNameReboot = "reboot";
+ public static final String publicAddress1 = "ec2-50-16-108-18.compute-1.amazonaws.com";
+ public static final String privateAddress1 = "ec2-50-16-108-18.compute-1.amazonaws.com";
+
+ public static final String response = getInstanceResponseXML(url1, id1, name1, ownerId1, image1Url,
+ image1Id, realm1Url, realm1Id, state, hardwareProfile1Url, hardwareProfile1Id, keyname1,
+ actionNameStop, actionNameReboot, publicAddress1, privateAddress1);
+ }
+
+ public static class InstancesResponse {
+
+ public static final String url1 = "http://try.steamcannon.org/deltacloud/api/instances/i-6f16e503";
+ public static final String id1 = "i-6f16e503";
+ public static final String name1 = "ami-7d07ec14";
+ public static final String ownerId1 = "357159121505";
+ public static final String image1Url = "http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec14";
+ public static final String image1Id = "ami-7d07ec14";
+ public static final String realm1Url = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public static final String realm1Id = "us-east-1a";
+ public static final State state = State.RUNNING;
+ public static final String hardwareProfile1Url = "http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.small";
+ public static final String hardwareProfile1Id = "m1.small";
+ public static final String keyname1 = "ad10";
+ public static final String actionNameStop = "stop";
+ public static final String actionNameReboot = "reboot";
+ public static final String publicAddress1 = "ec2-50-16-108-18.compute-1.amazonaws.com";
+ public static final String privateAddress1 = "ec2-50-16-108-18.compute-1.amazonaws.com";
+
+ public static final String url2 = "http://try.steamcannon.org/deltacloud/api/instances/i-6f16e553";
+ public static final String id2 = "i-6f16e503";
+ public static final String name2 = "ami-7d07ec14";
+ public static final String ownerId2 = "357159121505";
+ public static final String image2Url = "http://try.steamcannon.org/deltacloud/api/images/ami-7d07ec17";
+ public static final String image2Id = "ami-7d07ec14";
+ public static final String realm2Url = "http://try.steamcannon.org/deltacloud/api/realms/us-east-2a";
+ public static final String realm2Id = "us-east-2a";
+ public static final State state2 = State.STOPPED;
+ public static final String hardwareProfile2Url = "http://try.steamcannon.org/deltacloud/api/hardware_profiles/m1.large";
+ public static final String hardwareProfile2Id = "m1.large";
+ public static final String keyname2 = "ad11";
+ public static final String publicAddress2 = "ec2-50-16-108-19.compute-2.amazonaws.com";
+ public static final String privateAddress2 = "ec2-50-16-108-19.compute-2.amazonaws.com";
+
+ public static final String response =
+ "<instances>"
+ + getInstanceResponseXML(url1, id1, name1, ownerId1, image1Url,
+ image1Id, realm1Url, realm1Id, state, hardwareProfile1Url, hardwareProfile1Id,
+ keyname1,
+ actionNameStop, actionNameReboot, publicAddress1, privateAddress1)
+ + getInstanceResponseXML(url2, id2, name2, ownerId2, image2Url,
+ image2Id, realm2Url, realm2Id, state, hardwareProfile2Url, hardwareProfile2Id,
+ keyname2,
+ actionNameReboot, actionNameReboot, publicAddress2, privateAddress2)
+ + "</instances>";
+
+ }
+
+ private static final String getInstanceResponseXML(String url, String id, String name, String owner,
+ String imageUrl, String imageId, String realmUrl, String realmId, State state,
+ String hardwareProfileUrl, String hardwareProfileId, String keyname, String actionName1,
+ String actionName2, String publicAddress, String privateAddress) {
+ return "<instance href=\""
+ + url
+ + "\" id=\""
+ + id
+ + "\">"
+ + "<name>"
+ + name
+ + "</name>"
+ + "<owner_id>"
+ + owner
+ + "</owner_id>"
+ + "<image href=\""
+ + imageUrl
+ + "\" id=\""
+ + imageId
+ + "\"/>"
+ + getRealmResponseXML(realmUrl, realmId)
+ + "<state>"
+ + state.toString()
+ + "</state>"
+ + getHardwareProfileXML(hardwareProfileUrl, hardwareProfileId)
+ + "<actions>"
+ + ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacloud/api/instances/" + id
+ + "/reboot", "post", actionName1)
+ + ServerResponseFakes.getActionXML("http://try.steamcannon.org/deltacloud/api/instances/" + id
+ + "/stop", "post", actionName2)
+ + "</actions>"
+ + "<public_addresses>"
+ + getAddressXML(publicAddress)
+ + "</public_addresses>"
+ + "<private_addresses>"
+ + getAddressXML(privateAddress)
+ + "</private_addresses>"
+ + "<authentication type='key'>"
+ + "<login>"
+ + "<keyname>" + keyname + "</keyname>"
+ + "</login>"
+ + "</authentication>"
+ + "</instance>";
+ }
+
+ private static String getAddressXML(String address) {
+ return "<address>" + address + "</address>";
+ }
+
+ private static String getHardwareProfileXML(String url, String id) {
+ return "<hardware_profile href=\"" + url + "\" id=\"" + id + "\"></hardware_profile>";
+ }
+
+ private static String getRealmResponseXML(String url, String id) {
+ return "<realm href=\"" + url + "\" id=\"" + id + "\"/>";
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java
new file mode 100644
index 0000000..8b45a96
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/KeyResponseFakes.java
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class KeyResponseFakes {
+
+ public static class KeyActionResponse {
+ public static final String url = "http://localhost:3001/api/keys/test1292840175447";
+ public static final String method = "delete";
+ public static final String name = "destroy";
+ public static final String keyActionResponse = ServerResponseFakes.getActionXML(url, method, name);
+ }
+
+ public static class KeyResponse {
+ public static final String url = "http://localhost:3001/api/keys/test1292840175447";
+ public static final String method = "delete";
+ public static final String id = "test1292840175447";
+ public static final String name = "destroy";
+ public static final String fingerprint = "60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem =
+ "-----BEGIN RSA PRIVATE KEY-----"
+ + "YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n"
+ + "xE6gTMsqqTrDkGmAwhiGLsgORkQyxEthGyDfA40YaBf5/5F=Cvuj2zpnp63JIrUrqoqI1FQYhnA\n"
+ + "U34yKaj8+3/0AqsdEmWsWLMbV4HXaRtGZOPbERnJE28EhLlq/v+9wC59hpIZt6s4K0eRBYxCWz/\n"
+ + "xvEG=7wZJi7WE0/tsH9YIAHaLRqyxV7H5kRqaYExZhUpBgf/x745KJlPpr1I20BJSrj6Fw4z4P5\n"
+ + "DIUPDWit8aQdnBpO2fq9eQLGZKyWmj5xpzFm5DxbV1K=bdmqCnC6XHTLcfV4fqW1egYg2DK5WCj\n"
+ + "nsl+mQjn4CNvEdymhna7+Bw0D3JcPcW/EGUrsBGEGLT/suQbEi8x0vQscpBEAizq5GZaKZ6Kec9\n"
+ + "7MOHpx7qDqIAPjH9Y3ben7EaR0O3laY/OPrFREw8jP=mptePHF2r07s52QkdqkbU4ePC5BSWOcb\n"
+ + "bhOqypbbv9V8YssYLyt6m3VOJFHOoERaDJQ2fMmqTDuFc87lxDrChJk4cw0q9o6Q+YzEnjTqGQo\n"
+ + "XcwTtutpL97f1HjO34XlcHn3B1iZ8lsQGJWry9MWaiCdjj02v0mfN+UpbIQNBX452Xllf8YM//0\n"
+ + "Kaylt3GZvr2bJsJ=lQIUIxVzREHd7ym/hRNTBx5qK2/=8h57IdyQHZSnjDT05qDRsSPcm5nQmbM\n"
+ + "dgivv0/vXogWg9ehbym4DNez38QVkQaoJuKd/ESBIU2p8PIEXWC13HHzIMDbkbM235nFn3Roj59\n"
+ + "xt2AJoQnltdfuhA4+5ApnnIYcWzgkd8vWZPhNL2u40Sw1ZPrM+g4n7H48IdwtE3vZ0XfF3Lpdee\n"
+ + "IReubErRzxIMNVz=PrLQMAOhukYNJeH63PdxfSsJf7rtGwA1qEF1WcZ1ibvAuFr0G3KQalGCgCh\n"
+ + "zkF63HCWcjafUTJ3jE6/U5ZPu8GrhAQQqu=r3NyzLgoTBaNwfe7ybxvBBofjdmD9xPipOhrQjDC\n"
+ + "PDeaMDZ6XzwAddh4fd1K3kl29DXNBmPAgfaG8CgdnHVc/gQgAv40RvWDNnYae0/MGE+qrLN0XXF\n"
+ + "1g3qHLkmqdtg88nCH=X7kf6FZZ3LE+bLKIF2Y4Xh3X8sqHlImLWSlKvKu6/CuB4GsrfLxu1VLdc\n"
+ + "ee3DxUIaqz3LmkERnT7ALcMBjBjRNp=DR=x7zON0f0Nht0gIj1vvDWQmEzRqGxgTwS2PtGL3bOZ\n"
+ + "v2hiV3G3+S/9SAD9rfiW9Ws1YLH5mVDcHcKWhHXoM/UqPj3ob3yGzvYgR+X/dIg7tug/k=TTtD8\n"
+ + "1wkG4gTjHkfEhCs05/+PZ4rFG15nVpv06e/a3nXtyDQ77qH3irRPsLZDp/CWFdt=Poe4NLX46gE\n"
+ + "nU07L+ueqgZUa8Tq6A9oG7QUyjtJh4ZxkShYkIullvUksW0yppaIeB32Xxw2XVEtdu/v=rFHSHh\n"
+ + "HwoZ1A/=ku7ICdMg5gD6U+Zg0YlxniHDaSJ8A6kdt2iUaPaZQQcH8T4yh90CKHhbl5NzhxAu3Jz\n"
+ + "dc=oRQqdzizw9UrN84wEmQ6r9hDHUq2x14PR=xBzwLGzR2dh73GdjxF5OmOrp3m4yCkw\n"
+ + "-----END RSA PRIVATE KEY-----\n";
+ public static final String keyResponse = getKeyResponseXML(id, fingerprint, pem, url, method, name);
+ }
+
+ public static class KeysResponse {
+
+ public static final String url1 = "http://localhost:3001/api/keys/test1292840175417";
+ public static final String method1 = "delete";
+ public static final String id1 = "test1292840175447";
+ public static final String name1 = "destroy";
+ public static final String fingerprint1 = "60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem1 = "-----BEGIN RSA PRIVATE KEY-----"
+ + "YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u\n";
+
+ public static final String url2 = "http://localhost:3001/api/keys/test1292840175427";
+ public static final String method2 = "delete";
+ public static final String id2 = "test1292840175447";
+ public static final String name2 = "destroy";
+ public static final String fingerprint2 = "60:7c:f6:9e:e0:a1:52:bc:c0:9a:11:80:a7:1b:f6:8b:c6:55:cd:1f";
+ public static final String pem2 =
+ "-----BEGIN RSA PRIVATE KEY-----"
+ + "YkFqsstgVJqYc=sxypCDk=qJbHOmhQNYxaQR4vna=ccPbj68MuxQSZ9tiyu+Z8yAog0DI65/j6u";
+
+ public static final String keysResponse =
+ "<keys>"
+ + getKeyResponseXML(id1, fingerprint1, pem1, url1, method1, name1)
+ + getKeyResponseXML(id2, fingerprint2, pem2, url2, method2, name2)
+ + "</keys>";
+ }
+
+ private static final String getKeyResponseXML(String id, String fingerprint, String pem, String url, String method,
+ String name) {
+ return "<key href='" + url + "' id='" + id + "' type='key'>"
+ + "<actions>"
+ + ServerResponseFakes.getActionXML(url, method, name)
+ + "</actions>"
+ + "<fingerprint>" + fingerprint + "</fingerprint>"
+ + "<pem><pem>" + pem + "</pem></pem>"
+ + "<state></state>"
+ + "</key>";
+
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java
new file mode 100644
index 0000000..3df545f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/RealmResponseFakes.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import org.apache.deltacloud.client.Realm.RealmState;
+
+/**
+ * @author André Dietisheim
+ */
+public class RealmResponseFakes {
+
+ public static final RealmResponse realmResponse = new RealmResponse(
+ "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a",
+ "us-east-1a",
+ "us-east-1a",
+ RealmState.AVAILABLE.toString().toLowerCase(),
+ "22");
+ public static final RealmResponse invalidLimitRealmResponse = new RealmResponse(
+ "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a",
+ "us-east-1a",
+ "us-east-1a",
+ RealmState.AVAILABLE.toString().toLowerCase(),
+ "aa");
+
+ public static class RealmResponse {
+
+ public RealmResponse(String url, String id, String name, String state, String limit) {
+ this.url = url;
+ this.id = id;
+ this.name = name;
+ this.state = state;
+ this.limit = limit;
+ this.response = getRealmResponseXML(url, id, name, state, limit);
+ }
+
+ public String url = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public String id = "us-east-1a";
+ public String name = "us-east-1a";
+ public String state = RealmState.AVAILABLE.toString().toLowerCase();
+ public String limit = "22";
+ public String response = getRealmResponseXML(url, id, name, state, limit);
+
+ public int getIntLimit() {
+ return Integer.parseInt(limit);
+ }
+ }
+
+ public static class RealmsResponse {
+
+ public static final String url1 = "http://try.steamcannon.org/deltacloud/api/realms/us-east-1a";
+ public static final String id1 = "us-east-1a";
+ public static final String name1 = "us-east-1a";
+ public static final String state1 = RealmState.AVAILABLE.toString().toLowerCase();
+ public static final String limit1 = "2";
+
+ public static final String url2 = "http://try.steamcannon.org/deltacloud/api/realms/us-east-2a";
+ public static final String id2 = "us-east-2a";
+ public static final String name2 = "us-east-2a";
+ public static final String state2 = RealmState.AVAILABLE.toString().toLowerCase();
+ public static final String limit2 = "12";
+
+ public static final String response =
+ "<realms>"
+ + getRealmResponseXML(url1, id1, name1, state1, limit1)
+ + getRealmResponseXML(url2, id2, name2, state2, limit2)
+ + "</realms>";
+
+ }
+
+ private static String getRealmResponseXML(String url, String id, String name, String state, String limit) {
+ return "<realm href='" + url + "' id='" + id + "'>"
+ + "<name>" + name + "</name>"
+ + "<state>" + state + "</state>"
+ + "<limit>" + limit + "</limit>"
+ + "</realm>";
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java
new file mode 100644
index 0000000..6cecf54
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerFake.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+public class ServerFake {
+
+ public static final int DEFAULT_PORT = 3003;
+ private ExecutorService executor;
+ private int port;
+ private String response;
+ private ServerFakeSocket serverSocket;
+
+ public ServerFake(String response) {
+ this(DEFAULT_PORT, response);
+ }
+
+ public ServerFake(int port, String response) {
+ this.port = port;
+ this.response = response;
+ }
+
+ public void start() {
+ executor = Executors.newFixedThreadPool(1);
+ this.serverSocket = new ServerFakeSocket(port, response);
+ executor.submit(serverSocket);
+ }
+
+ public void stop() {
+ executor.shutdownNow();
+ serverSocket.shutdown();
+ }
+
+ private class ServerFakeSocket implements Runnable {
+ private String response;
+ private ServerSocket serverSocket;
+
+ private ServerFakeSocket(int port, String response) {
+
+ this.response = response;
+
+ try {
+ this.serverSocket = new ServerSocket(port);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void shutdown() {
+ try {
+ this.serverSocket.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void run() {
+ Socket socket;
+ try {
+ socket = serverSocket.accept();
+ OutputStream outputStream = socket.getOutputStream();
+ outputStream.write(response.getBytes());
+ outputStream.flush();
+ outputStream.close();
+ socket.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java
new file mode 100644
index 0000000..44fd007
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/fakes/ServerResponseFakes.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.fakes;
+
+/**
+ * @author André Dietisheim
+ */
+public class ServerResponseFakes {
+
+ public static final String getActionXML(String url, String method, String name) {
+ return "<link "
+ + "method='" + method + "' "
+ + "href='" + url + "' "
+ + "rel='" + name + "' />";
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java
new file mode 100644
index 0000000..81ef46a
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client.test/src/org/apache/deltacloud/client/internal/test/utils/UrlBuilderTest.java
@@ -0,0 +1,75 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.internal.test.utils;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.deltacloud.client.utils.UrlBuilder;
+import org.junit.Test;
+
+public class UrlBuilderTest {
+
+ @Test
+ public void buildsHost() {
+ String host = "jboss.org";
+ assertEquals(host, new UrlBuilder(host).toString());
+ }
+
+ @Test
+ public void buildsHostWithPort() {
+ assertEquals(
+ "jboss.org:8080",
+ new UrlBuilder("jboss.org")
+ .port(8080)
+ .toString());
+ }
+
+ @Test
+ public void buildsWithPath() {
+ assertEquals(
+ "jboss.org:8080/tools",
+ new UrlBuilder("jboss.org")
+ .port(8080)
+ .path("tools")
+ .toString());
+ }
+
+ @Test
+ public void buildsWith2Paths() {
+ assertEquals(
+ "jboss.org:8080/tools/usage",
+ new UrlBuilder("jboss.org")
+ .port(8080)
+ .path("tools")
+ .path("usage")
+ .toString());
+ }
+
+ @Test
+ public void buildsWithParameters() {
+ assertEquals(
+ "jboss.org:8080/tools/usage?parameter=dummy",
+ new UrlBuilder("jboss.org")
+ .port(8080)
+ .path("tools")
+ .path("usage")
+ .parameter("parameter", "dummy")
+ .toString());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/.gitignore b/clients/java/org.apache.deltacloud.client/.gitignore
new file mode 100644
index 0000000..934e0e0
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/.gitignore
@@ -0,0 +1,2 @@
+/bin
+/target
diff --git a/clients/java/org.apache.deltacloud.client/ChangeLog b/clients/java/org.apache.deltacloud.client/ChangeLog
new file mode 100644
index 0000000..7538650
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/ChangeLog
@@ -0,0 +1,1049 @@
+2011-03-29 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (request):
+ (DeltaCloudClientImpl):
+ [JBIDE-8635] removed http client and replaced by urlConnection
+
+2011-03-11 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/StateAware.java:
+ * src/org/jboss/tools/deltacloud/core/client/ActionAware.java
+ (reboot):
+ (destroy):
+ (stop):
+ (start):
+ (doUpdate):
+ (update):
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (doUpdate):
+ * src/org/jboss/tools/deltacloud/core/client/Key.java: (doUpdate):
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (performAction):
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (performAction):
+ [JBIDE-8565] refreshing instance and key after performing action
+
+2011-02-18 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
+ (loadCloud):
+ (printCloud):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (lastRealmName):
+ (lastProfileId):
+ (setLastProfileId):
+ (getLastProfileId):
+ (getLastRealmName):
+ (setLastRealmName):
+ [JBIDE-8333]
+
+2011-02-15 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (update):
+ [JBIDE-8420] storing credentials before loading children
+ (was: loaded children and stored afterwards. storing was skipped since loading threw an exception)
+
+2011-02-07 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (waitForState):
+ [JBIDE-8343] increased wait delay for refreshing instance, waiting before refreshing (was: refreshed first and waited afterwards)
+
+2011-02-03 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java:
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java:
+ * src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java:
+ [JBIDE-8187] added capability to filter for instance alias
+
+2011-01-27 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (getServerType):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getDriver):
+ [JBIDE-8250]
+ - renamed Driver to DeltaCloudDriver, renamed ServerType to Driver
+ - moved driver unmarshalling to APIUnmarshaller
+ - added tests for APIUnmarshaller
+ * src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java (UNAUTHORIZED):
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (throwOnHttpErrors):
+ [JBIDE-8250] authorization error is status code 401 (was: 403)
+
+2011-01-11 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (listRealms):
+ [JBIDE-7935] moved realms unmarshalling to separate classes (and added tests).
+ * src/org/jboss/tools/deltacloud/core/client/request/TypeRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/PerformInstanceActionRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListRealmsRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListRealmRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListKeysRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListKeyRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListInstancesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListInstanceRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListImagesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListImageRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListHardwareProfilesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListHardwareProfileRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/DeleteKeyRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/CreateKeyRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/CreateInstanceRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/AbstractListObjectsRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/AbstractDeltaCloudRequest.java:
+ (urlString):
+ (url):
+ (getUrl):
+ (toString):
+ (getUrlString):
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (request):
+ [JBIDE-7695] delayed URL creation to request time. Gained capability to store invalid urls and report them at request time.
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/ImagesUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/ImageUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (listImages):
+ (listImages):
+ [JBIDE-7935] moved image unmarshalling to its own class (and created tests for it)
+
+2011-01-10 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/HardwareProfileUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (listProfile):
+ [JBIDE-7935] moved HardwareProfile unmarshalling to HardwareProfileUnmarshaller
+
+2011-01-04 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstancesRepository.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (loadInstances):
+ [JBIDE-7294] added factory for DeltaCloudInstance instances, removed functionality from DeltaCloudInstanceRepository
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (createInstance):
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (createInstance):
+ * src/org/jboss/tools/deltacloud/core/client/request/CreateInstanceRequest.java (doCreateUrl):
+ [JBIDE-7294] removed name parameter from request since DeltaCloud does not honor the name you choose
+ * src/org/jboss/tools/deltacloud/core/IInstanceAliasMapping.java:
+ * src/org/jboss/tools/deltacloud/core/InstanceAliasMapping.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
+ (setAlias):
+ (getAlias):
+
+2011-01-03 adietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (createInstance):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
+ (getAlias):
+ (setAlias):
+ [JBIDE-7294] implementing alias support
+
+2010-12-27 adietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (isValid):
+ [JBIDE-7864] added isValid property tester to offer "launch instance" on valid clouds only
+
+2010-12-23 adietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java (CLOUDELEMENT.KEYS):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (createKey):
+ (getKeys):
+ [JBIDE-7763] added methods to DeltaCloud to get all keys and to create a key on the server
+
+2010-12-22 adietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (DeltaCloudClientImpl):
+ [JBIDE-7981] need to create a documentbuilder on each new parsing to avoid threads using the same builder.
+ * src/org/jboss/tools/deltacloud/core/FieldMatcher.java (FieldMatcher):
+ [JBIDE-7981] set filter to filter in case insensitive manner
+
+2010-12-21 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/KeysUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/KeyActionUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDOMUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/unmarshal/AbstractDeltaCloudObjectUnmarshaller.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListKeysRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/Key.java:
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (createKey):
+ (listKeys):
+ (listKey):
+ [JBIDE-7763][JBIDE-7371] implemented keys related methods & tests, now returning Key object
+
+2010-12-17 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (createKey):
+ [JBIDE-7371] added #createKey method that now returns a key instance
+
+2010-12-16 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/request/ListKeysRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/CreateKeyRequest.java:
+ [JBIDE-7371] implementing listing keys with deltacloud client
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (testCredentials):
+ [JBIDE-7911] corrected: throws exceptions on error (internal server error, connection error etc)
+
+2010-12-15 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (Driver):
+ [JBIDE-7864] replacing cloud type strings by Driver enum
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (getInstanceJob):
+ (waitWhilePending):
+ (registerInstanceJob):
+ [JBIDE-7912] removed since job concurrency is dealt with job scheduling rules now
+ * src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java (isConflicting):
+ * src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java (isConflicting):
+ * src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java (isConflicting):
+ [JBIDE-7594] corrected scheduling rules to have correct blocking across the scheduling class hierarchy
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (createSecurePasswordStore):
+ [JBIDE-7594] created #createSecurePasswordStore to be able to fake store in tests
+
+2010-12-14 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (updateInstance):
+ [JBIDE-7889] now also set pulic_adresses and private_adresses when updating instances
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (refreshInstance):
+ [JBIDE-7889] removed code that replaced instances in the local cache.
+ I now set a new instance to the DeltaCloudInstance (DeltaCloudInstance#setInstance)
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (setInstance):
+ [JBIDE-7889] added #setInstance to be able to refresh instances
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (toString):
+ [JBIDE-7889] added #toString to facilitate debuggin
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getActions):
+ [JBIDE-7889] changed #getActions to return DeltaCloudInstance#Action (and not strings)
+ * src/org/jboss/tools/deltacloud/core/job/InstanceSchedulingRule.java:
+ * src/org/jboss/tools/deltacloud/core/job/InstanceStateJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/InstanceActionJob.java:
+ [JBIDE-7594] added instance related job & scheduling rule
+ (blocks instance jobs on same instance and superclass jobs on same cloud & element)
+ * src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java (isOnSameElement):
+ [JBIDE-7594] corrected scheduling rule to block superclass scheduling rule on the same cloud
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java (CLOUDELEMENT):
+ [JBIDE-7594] added scheduling element that reflects cloud properties being processed (instances, images, realms, profiles)
+
+2010-12-13 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (loadInstances):
+ (loadImages):
+ [JBIDE-7880] clear images and clear instances before loading them.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (PROP_INSTANCES_ADDED):
+ (createInstance):
+ [JBIDE-7877] added notification for instances that are added
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (IInstanceStateMatcher.matchesState):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (State):
+ (Action):
+ (getState):
+ (performInstanceAction):
+ [JBIDE-7877] replaced state- and action-strings in DeltaCloudInstace by enums
+
+2010-12-10 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (loadImages):
+ [JBIDE-7738] made #loadImages public, RefreshImagesHandler needs access to it
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (loadInstances):
+ [JBIDE-7738] made #loadInstances public, RefreshInstancesHandler needs access to it
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (update):
+ [JBIDE-7863] need to store the password if either connection name, username, pw or url changes
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (notifyCloudRename):
+ [JBIDE-7856] removed notifyCloudRename since DeltaCloud now notifies about changes in its properties (images, instances, name)
+ * src/org/jboss/tools/internal/deltacloud/core/observable/ObservablePojo.java:
+ [JBIDE-7856] switched the observer pattern in DeltaCloud to PropertyChangeSupport, moved ObservablePojo
+ to core to get PropertyChangeSupport in DeltaCloud.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java:
+ [JBIDE-7856] switched the observer pattern in DeltaCloud to PropertyChangeSupport, removed
+ IInstanceListListener and IImageListlistener.
+ (update):
+ (setName):
+ (updateConnectionProperties):
+ (updateInstanceFilter):
+ (updateImageFilter):
+ (loadInstances):
+ (clearImages):
+ (clearInstances):
+ (replaceInstance):
+ (performInstanceAction):
+ (loadImages):
+ (createInstance):
+ [JBIDE-7856] switched the observer pattern in DeltaCloud to PropertyChangeSupport, fireing changes when name is changed.
+ Loading instances and images only if url, username, pw change.
+
+2010-12-09 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (loadImages):
+ (loadInstances):
+ (getInstances):
+ (getImages):
+ [JBIDE-7848] separated the usecases: actively getting images/instances and passive updates. You now get the images and dont need to trigger getting and get the update of it.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java:
+ [JBIDE-7849] removed shadowing instance variable to DeltaCloud
+
+2010-12-08 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/AbstractCloudJob.java:
+ * src/org/jboss/tools/deltacloud/core/job/CloudElementSchedulingRule.java:
+ * src/org/jboss/tools/deltacloud/core/job/CloudSchedulingRule.java:
+ [JBIDE-7594] started scheduling rules. need further refinement.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getImage):
+ [JBIDE-7834] implemented #getLastImage(id) that queries the local cache and the server (fallback),
+ removed #getImage(String id), #loadImage(String imageId), removed #findInstanceById
+
+2010-12-06 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java (InstanceFilter):
+ * src/org/jboss/tools/deltacloud/core/GetImagesCommand.java:
+ * src/org/jboss/tools/deltacloud/core/AbstractDeltaCloudCommand.java:
+ [JBIDE-7688][JBIDE-7813] now getting images and instances in async manner by commands
+ * src/org/jboss/tools/deltacloud/core/AbstractCloudElementFilter.java
+ (filter):
+ (AbstractCloudElementFilter):
+ (getCloud):
+ (getCloudElements):
+ * src/org/jboss/tools/deltacloud/core/AllImageFilter.java (AllImageFilter):
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java
+ (ImageFilter):
+ (getCloudElements):
+ * src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java (AllInstanceFilter):
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java
+ (InstanceFilter):
+ (getCloudElements):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (createInstanceFilter):
+ (createImageFilter):
+ * src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java (filter):
+ [JBIDE-7688][JBIDE-7813] CloudElementFilter#filter is now cloud instance specific (is instantiated with a reference to a cloud)
+
+2010-12-03 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/AllImageFilter.java:
+ * src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java:
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java:
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java:
+ * src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java:
+ [JBIDE-7688] provide common superclass and interface to ImageFilter and InstanceFilter
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java:
+ * src/org/jboss/tools/deltacloud/core/AbstractDeltaCloudElement.java:
+ * src/org/jboss/tools/deltacloud/core/IDeltaCloudElement.java:
+ [JBIDE-7688] provide common superclass and interface to DeltaCloudImage and DeltaCloudInstance
+
+2010-11-26 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/SecurePasswordStore.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudPasswordStorageKey.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java:
+ (editCloud):
+ (getPassword):
+ (createClient):
+ (dispose):
+ (loadImage):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud):
+ [JBIDE-7731] extracted password storage to its own class (removed duplicate code in EditCloudConnectionWizard, NewCloudConnectionWizard and DeltaCloud)
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java:
+ (loadImage):
+ [JBIDE-7694] removed duplicate loadImage(id) / getImage(id) methods
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (images):
+ (instances)
+ (getImages):
+ (getInstances):
+ (loadImages):
+ (loadInstances):
+ [JBIDE-7694] corrected lazy initialisation (to signal correctly that no instances had been loaded so far)
+
+2010-11-25 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImagesRepository.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstancesRepository.java:
+ * src/org/jboss/tools/deltacloud/core/AbstractDeltaCloudObjectRepository.java:
+ [JBIDE-7694] revamped synchronization in class DeltaCloud: extracted image- and instance-list to their own classes
+ (and could drop all synchronization in deltacloud)
+
+2010-11-19 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java:
+ (isRunning):
+ [JBIDE-7678] renamed State to InstanceState, added property isRunning, testing for ShowInRemoteSystemExplorerHandler
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (InstanceState):
+ (isRunning):
+ [JBIDE-7678] renamed State to InstanceState, added property isRunning, testing for ShowInRemoteSystemExplorerHandler
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadCloud):
+ [JBIDE-7663] removed loading of images and instances on startup
+
+2010-11-18 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/ICloudManagerListener.java (cloudsChanged):
+ [JBIDE-7628] renamed notification method (to better reflect what it notifies)
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud):
+ [JBIDE-7628] loadClouds made private -> no explicit loading by clients, clouds should be loaded if needed
+ (saveClouds):
+ (notifyCloudRename):
+ [JBIDE-7628] added proper throwing (no swallowing any more)
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud):
+ [JBIDE-7628] cleanup (removed duplicate notification code)
+ * src/org/jboss/tools/deltacloud/core/client/request/DeltaCloudRequest.java (getUrl):
+ * src/org/jboss/tools/deltacloud/core/client/request/AbstractDeltaCloudRequest.java (getUrl):
+ [JBIDE-7593] need to return URL (not String)
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (addCredentials):
+ [JBIDE-7593] need to use URL (not String)
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
+ (sendRequest):
+ [JBIDE-7593] need to add credentials using the url that is effectively used in the request (which may be either the baseURL or the url in the action)
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud):
+ [JBIDE-7625] store password in the constructor
+ (editCloud):
+ [JBIDE-7625] have to create new client when cloud was edited
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud):
+ [JBIDE-7625] removed check for pw on identical url any more since we now save the pw with the name of the cloud
+ [JBIDE-7627] reinitialize cloud list when loading clouds (otherwise clouds loaded will simply get added to the existing ones)
+ (loadClouds):
+
+2010-11-17 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
+ (createInstance):
+ (createKey):
+ (deleteKey):
+ [JBIDE-7597] added missing methods to interface
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
+ (loadCloud):
+ (loadClouds):
+ [JBIDE-7597] continue loading clouds even if a single cloud fails
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (loadImages):
+ (loadInstances):
+ [JBIDE-7597] added proper error messages to exceptions thrown
+ (editCloud):
+ (updateInstanceFilter):
+ (updateImageFilter):
+ [JBIDE-7597] removed saving (ring dependency DeltaCloud <--> DeltaCloudManager) in DeltaCloud.
+ Ideal solution would be dirty notification to DeltaCloud -> DeltaCloudManager
+ (getClient):
+ [JBIDE-7597] delayed client creation after instantiation so that DeltaCloud may be created without throwing exceptions.
+ (loadChildren):
+ [JBIDE-7597] made sure loading instances and images throw exceptions individually. Collecting them in a multi exception
+ (getProfiles):
+ [JBIDE-7597] removed exception swalloing, made sure exceptions get thrown
+ (testConnection):
+ [JBIDE-7597] made sure no DeltaCloudClientException gets outside of DeltaCloud
+ (destroyInstance):
+ [JBIDE-7597] added exception to destroy instance
+ (clearInstances):
+ (clearImages):
+ (loadInstances):
+ (loadImages):
+ (loadChildren):
+ [JBIDE-7544] clearing images and instances before refreshing them (to avoid conflicting user actions)
+
+2010-11-16 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (DeltaCloudManager):
+ [JBIDE-7597] removed implicit loading of persisted connections. moved to explicit loading.
+ (loadClouds):
+ [JBIDE-7597] collecting exceptions are returning them as errors.
+ * src/org/jboss/tools/deltacloud/core/client/Image.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java:
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java
+ [JBIDE-7617] removed equals and hash code since it resulted in odd behaviors towards selection
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java
+ (canStart):
+ (canStop):
+ (canReboot):
+ (canDestroy):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
+ (canStart):
+ (canStop):
+ (canReboot):
+ (canDestroy):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java
+ (registerInstanceJob):
+ (getInstanceJob):
+ (registerInstanceJob):
+ (removeInstanceJob):
+ [JBIDE-7603] renamed instance job related methods from action job to instance job (since jobs are not only used for actions)
+ (waitWhilePending):
+ (waitForState):
+ [JBIDE-7603] moved (duplicate) instance state waiting code to delta cloud and removed duplication
+ (loadChildren):
+ (loadInstances):
+ (getCurrInstances):
+ (refreshInstance):
+ [JBIDE-7597] load images / instances now throw of DeltaCloudExceptions (exceptions are not swallowed any longer)
+
+2010-11-11 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (DeltaCloudInstance):
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (refreshInstance):
+ (loadInstances):
+ (createInstance):
+ [JBIDE-7516] added reference to DeltaCloud in DeltaCloudInstance
+
+2010-11-10 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/utils/UrlBuilder.java:
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (DeltaCloudClientImpl):
+ (sendRequest):
+ (createRequest):
+ (getServerType):
+ (createInstance):
+ (createInstance):
+ (createInstance):
+ (createInstance):
+ (listProfile):
+ (listProfiles):
+ (listImages):
+ (listImages):
+ (listInstances):
+ (listInstances):
+ (listRealms):
+ (listRealms):
+ (createKey):
+ (createInstanceActions):
+ (listDeltaCloudObjects):
+ (getDocument):
+ (performInstanceAction):
+ * src/org/jboss/tools/deltacloud/core/client/request/TypeRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/PerformInstanceActionRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListRealmsRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListRealmRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListKeyRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListInstancesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListInstanceRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListImagesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListImageRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListHardwareProfilesRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/ListHardwareProfileRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/DeltaCloudRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/DeleteKeyRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/CreateInstanceRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/AbstractListObjectsRequest.java:
+ * src/org/jboss/tools/deltacloud/core/client/request/AbstractDeltaCloudRequest.java:
+ [JBIDE-7537] Created classes for each request type.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java (createInstanceActions):
+ [JBIDE-7537] removed base url stripping
+
+2010-11-09 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java
+ (hashCode):
+ (equals):
+ [JBIDE-7513] added equals and hascode methods to be able to match new instances to old ones
+ (so that I can keep the selection in the cloud viewer)
+ * src/org/jboss/tools/deltacloud/core/client/Image.java
+ (hashCode):
+ (equals):
+ [JBIDE-7513] added equals and hascode methods to be able to match new instances to old ones
+ (so that I can keep the selection in the cloud viewer)
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java (setRules):
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java
+ (setRules):
+ (createRule):
+ [JBIDE-7518] removed duplicate code for matcher creation
+ (createRule):
+ (setRules):
+ [JBIDE-7518] removed duplicate code for matcher creation
+ * src/org/jboss/tools/deltacloud/core/ICloudElementFilter.java:
+ * src/org/jboss/tools/deltacloud/core/IImageFilter.java:
+ * src/org/jboss/tools/deltacloud/core/IInstanceFilter.java
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (editCloud):
+ [JBIDE-7521] storing cloud after it has been edited
+ (editCloud):
+ [JBIDE-7518] added notification after cloud was edited
+ (DeltaCloud):
+ (createImageFilter):
+ (updateImageFilter):
+ (createInstanceFilter):
+ (updateInstanceFilter):
+ [JBIDE-7518] cleanup code duplication (imageFilter and instanceFilter creation)
+ (editCloud):
+ [JBIDE-7518] load images and instances after editing the cloud -> notifies listeners of changes
+
+2010-11-05 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (performInstanceAction):
+ [JBIDE-7503] added instance notification
+
+2010-11-04 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java:
+ * src/org/jboss/tools/deltacloud/core/client/InstanceAction.java:
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java:
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (start), (stop), (destroy), (reboot):
+ [JBIDE-7484] removed instance related methods from client, unified funtionality in #performAction and offered additional methods on
+ Instance (#start, #stop, #destroy, #reboot). Furthermore update instance upon action responses from server.
+
+2010-10-29 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java: extracted and put in a 2 enums:
+ HttpStatusCode, HttpStatusRange (server-, client-error)
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
+ (listDeltaCloudObjects): rethrows DeltaCloudClientException (was catching and wrapping)
+ (getDocument): refactored and split #listDeltaCloudObjects implementation into parts
+
+2010-10-26 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (testConnection):
+ [JBIDE-7407] now returns <code>false</code> if listing instances fails with a DeltaCloudClientException
+
+2010-10-25 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java: Move cloud type constants
+ here as the DeltaCloud contains the type field.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: Move cloud type constants
+ from here to DeltaCloud.
+
+2010-10-25 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Fix constructor
+ typo caused by copying so that type is passed when it is offered.
+
+2010-10-22 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Don't add
+ "api" to URL in constructor as the client is adding this as well.
+
+2010-10-22 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
+ (shutdownInstance): [JBIDE-7401] changed to POST (api break in dc 0.0.8)
+ (startInstance): [JBIDE-7401] changed to POST (api break in dc 0.0.8)
+
+2010-10-22 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (listProfile): Fix to
+ wrap the xml result in a StringReader before trying to unmarshal.
+ (listImages): Ditto.
+ (listRealms): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getLastImageId): New method.
+ (setLastImageId): Ditto.
+ (getLastKeyname): Ditto.
+ (setLastKeyname): Ditto.
+ (getImage): Ditto.
+ (save): Make public.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add code to get
+ the last keyname and last imageid used for the cloud.
+ (saveClouds): Save the last keyname and last imageid used for instance launching.
+
+2010-10-21 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
+ (getRequest): extracted to its own method, changed to switch (from if-else)
+ (sendRequest): added http status code check (latest deltacloud 0.0.8 now reports 404 on missing resource)
+
+2010-10-20 André Dietisheim <ad...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (getDeltaCloudType): moved from UI to deltacloud client
+ (DCNS): Added API enum (for api requests)
+ (getServerType): moved to instance method, reuse existing client code (instead of duplication)
+
+2010-10-12 Jeff Johnston <jj...@redhat.com>
+
+ * build.properties: Remove lib/deltacloudclient jar specification as it
+ no longer exists in the lib directory.
+
+2010-10-08 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/AllInstanceFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/IInstanceFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/InstanceFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java (toString): Switch back
+ to non-regex, just a wildcard.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Add instance
+ filter rules to constructor.
+ (getInstanceFilter): New method.
+ (createInstanceFilter): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add instance
+ filter support.
+ (saveClouds): Ditto.
+ * src/org/jboss/tools/deltacloud/core/FieldMatcher.java (FieldMatcher): Use the input
+ string to form a regex where all non-alphanumeric characters are escaped and wildcards
+ are expanded to a reluctant any character matcher.
+ (transform): New method to transform the input rule into a regex.
+ * src/org/jboss/tools/deltacloud/core/IImageFilter.java: Fix ALL_STRING.
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java (setRules): Fix checking for
+ AllFieldMatchers.
+
+2010-10-07 Jeff Johnston <jj...@redhat.com>
+
+ [JBIDE-7181]
+ * src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java (toString): Fix to
+ return proper regex for ALL text.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Default to
+ ALL rules if image filter regex does not parse.
+ * src/org/jboss/tools/deltacloud/core/FieldMatcher.java (FieldMatcher): Add a
+ throws statement.
+ * src/org/jboss/tools/deltacloud/core/IImageFilter.java: Fix ALL string.
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java (setRules): Adds a
+ throws statement.
+
+2010-10-07 André Dietisheim <ad...@redhat.com>
+
+ * lib/deltacloudclient-1.0.jar: [JBIDE-7259] removed unneeded jar from classpath
+
+2010-10-06 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/AllFieldMatcher.java: New file.
+ * src/org/jboss/tools/deltacloud/core/AllImageFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/FieldMatcher.java: New file.
+ * src/org/jboss/tools/deltacloud/core/IFieldMatcher.java: New file.
+ * src/org/jboss/tools/deltacloud/core/IImageFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/ImageFilter.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (save): New method.
+ (createImageFilter): Ditto.
+ (getImageFilter): Ditto.
+ (DeltaCloud): Add a image filter rules parameter.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add
+ check for image filtering rules.
+ (saveClouds): Save image filtering rules.
+
+2010-09-17 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (editCloud): New method.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (notifyCloudRename): Ditto.
+ * src/org/jboss/tools/deltacloud/core/ICloudManagerListener.java: Add rename event.
+
+2010-09-08 Jeff Johnston <jj...@redhat.com>
+
+ * .classpath: Fix to remove error messages.
+ * META-INF/MANIFEST.MF: Move deltaclient.jar to end of dependencies.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getActionJob): New method.
+ (registerActionJob): Ditto.
+ (removeActionJob): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (removeCloud): Use cached
+ username and url.
+
+2010-09-03 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (addReplaceInstance): New method.
+
+2010-09-01 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (deleteKey): Change
+ arguments to just the key name is given. Don't delete any file.
+ (createKey): Change the directory argument to just be a String instead of an IPath.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (deleteKey): New method.
+ (createKey): Ditto.
+ (refreshInstance): Remove stack trace on error since a pending cloud start will
+ result in not found until the cloud actually is running.
+
+2010-08-30 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/Activator.java: Add Copyright and License info.
+ * src/org/jboss/tools/deltacloud/core/client/AddressList.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/API.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthException.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/Image.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/Property.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/Realm.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudException.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudRealm.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/ICloudManagerListener.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/IImageListListener.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/IInstanceListListener.java: Ditto.
+ * META-INF/MANIFEST.MF: Back-leveling to 0.0.1 as not in 1.0.0 state yet.
+
+2010-08-27 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildInstance): Add
+ call to getAuthentication method.
+ (getAuthentication): New method to get authentication items such as keyname.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getCurrInstances): Synchronize on
+ new instanceLock object.
+ (getInstances): Ditto.
+ (performInstanceAction): Do not do any special actions for EC2 clouds, namely
+ deleting a key if stopping.
+ (refreshInstance): Do not reset the key.
+ (createInstance): Do not look for EC2 type, do not create a key, but just check if a keyname is specified.
+ Do not save the key if specified as this is done when creating the instance.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: Add MOCK type.
+
+2010-08-26 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (createKey): Remove
+ any empty lines so the key will work with RSE.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (notifyImageListListeners): Pass new
+ cloud argument to listeners.
+ (notifyInstanceListListeners): Ditto.
+ (refreshInstance): Fix the check for states to be in the String realm rather than
+ the State realm.
+ * src/org/jboss/tools/deltacloud/core/IImageListListener.java: Add new cloud argument
+ to listChanged notifier method.
+ * src/org/jboss/tools/deltacloud/core/IInstanceListListener.java: Ditto.
+
+2010-08-23 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (getKey): New method.
+ (setKey): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getCurrInstances): Fix to
+ call getInstances if there aren't any instances yet.
+ (getCurrImages): New method.
+ (refreshInstance): Pass any instance key into the new instance.
+ (getImages): Synchronize on imageLock.
+ (loadChildren): New method that loads the children in a thread.
+ (createInstance): Save the key if generated into the instance.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getKey): New method.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Ditto.
+
+2010-08-20 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (DCNS): Add KEYS.
+ (deleteKey): New method to delete a keypair.
+ (createKey): New method to create a keypair.
+ (checkForErrors): Add extra check for status 404.
+ (createInstance): New method with additional keyname parameter to create instance using a
+ specified keypair.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getType): New method.
+ (DeltaCloud): Add type parameter and add keys collection.
+ (performInstanceAction): Add check for EC2 STOP action in which case look for a key in the key
+ collection and if found, delete it.
+ (createInstance): If EC2 cloud, create a key and pass the name to the new client createInstance
+ API that takes a keypair name.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (setGivenName): New method to store
+ the name chosen by the user in the dialog.
+ (getGivenName): New method to get the name chosen by the user in the dialog.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds): Add type support.
+ (saveClouds): Ditto.
+
+2010-08-18 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (checkForErrors): Make
+ the code smarter and look for status node. There are some internal errors that don't need
+ to be stopped for.
+ (buildInstance): Throw DeltaCloudClientException instead of returning null if an
+ unexpected type of Exception occurs.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (setState): Set to BOGUS
+ if the state is not expected.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (performInstanceAction): Throw
+ a DeltaCloudException if an low-level exception occurs.
+ (refreshInstance): Ignore a transition to a BOGUS state.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: Add new TERMINATED and
+ BOGUS state strings.
+
+2010-08-17 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getOwnerId): New method.
+
+2010-08-17 Jeff Johnston <jj...@redhat.com>
+
+ * lib/log4j-1.2.14.jar: New file.
+ * .classpath: Add log4j jar.
+ * build.properties: Ditto.
+ * META-INF/MANIFEST.MF: Remove org.apache.log4j as dependency
+ and add stored jar to classpath.
+
+2010-08-17 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (createInstance): New
+ API that takes a memory and storage setting for the hardware profile.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (createInstance): Change API to
+ accept memory and storage settings.
+
+2010-08-16 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildHardwareProfile): Remove
+ extraneous statements that cause unused warning.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java: Remove extraneous import
+ that causes warning.
+
+2010-08-16 Jeff Johnston <jj...@redhat.com>
+
+ * META-INF/MANIFEST.MF: Add dependency on org.eclipse.equinox.security.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Store
+ the password for the cloud using Secure Preferences using the cloud's url
+ and username to form the key.
+ (getPreferencesKey): New static method to formulate a preferences key used
+ to store and retrieve a password for a cloud.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (loadClouds):
+ New method to get persisted clouds.
+ (getClouds): Remove test stuff that creates a sample connection to the
+ mock cloud.
+ (saveClouds): New method to persist clouds minus passwords.
+ (DeltaCloudManager): Add call to loadClouds at construction.
+ (addCloud): Call saveClouds after modifying list.
+ (removeCloud): Ditto.
+
+2010-08-13 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (DeltaCloud): Take the
+ url as a String input. Create the URL when constructing the client and add
+ "/api" to the user-specified url.
+ (getURL): Return the url directly.
+
+2010-08-12 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (destroyInstance): Fix to use
+ DELETE request.
+ (sendRequest): Fix to allow DELETE request.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (destroyInstance): New method.
+
+2010-08-11 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (performInstanceAction): New method.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (getActionNames): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getCurrInstances): Ditto.
+ (performInstanceAction): Ditto.
+ (refreshInstance): Add notification.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getActions): New method.
+
+2010-08-11 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getInstances): Make
+ instances a private field instead of local to the method.
+ (refreshInstance): New method.
+ (createInstance): Add notification to IInstanceListListeners.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: Add static
+ strings for the various states.
+
+2010-08-09 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getHostName): New method.
+
+2010-08-06 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (sendRequest): Add
+ exception handling.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (createInstance): New method.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudRealm.java: Add state constants.
+
+2010-08-05 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java (getKind): Fix to
+ upper-case the low-level value before converting to an enum.
+
+2010-08-04 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProfile.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudHardwareProperty.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java (getArchitecture): Return
+ the value instead of using toString method.
+ (getNamedProperty): Verify that properties is not null before accessing.
+ (getCPU): Return value instead of using toString.
+ * src/org/jboss/tools/deltacloud/core/client/Property.java (Range.Range): New class.
+ (getRange): New method.
+ (Range.getLast): Ditto.
+ (Range.getFirst): Ditto.
+ (getEnums): Ditto.
+ (toString): Fix to not include unit if it is "label".
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getProfiles): New method.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildHardwareProfile): Fix
+ bug with getting enum properties.
+
+2010-08-04 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthException.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudException.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudRealm.java: New file.
+ * src/org/jboss/tools/deltacloud/core/Activator.java (logErrorMessage): Ditto.
+ (log): Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (listDeltaCloudObjects):
+ Check for errors.
+ (checkForErrors): New method to check for connection errors.
+ (buildHardwareProfile): Check for errors and change so method throws exceptions.
+ (buildInstance): Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java (getInstances): Log error instead of
+ printing stack trace.
+ (getImages): Ditto.
+ (getRealms): New method.
+ (testConnection): Ditto.
+
+2010-08-03 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (getClouds): Remove default
+ cloud connection that was set up for testing.
+
+2010-07-29 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (buildHardwareProfile): XML
+ has changed element name to hardware_profile from hardware-profile.
+ (buildInstance): Ditto.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java (getId): Denote as
+ XMLAttribute now that id is no longer an element.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (publicAddresses): Change
+ XML element name to public_addresses from public-addresses.
+ (privateAddresses): Similar except for private-addresses to private_addresses.
+
+2010-07-28 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java (findCloud): New
+ method to find a cloud by name.
+
+2010-07-27 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/Property.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java (getProfileProperties): Renamed
+ from setProfileProperties and cpu support added.
+ (buildDeltaCloudObject): Add support for HardwareProfile.
+ (buildHardwareProfile): New method to build up a hardware profile.
+ (buildInstance): Add hardware profile support.
+ (createInstance): Change to use getProfileProperties which was renamed.
+ * src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java (getArchitecture): New method.
+ (getNamedProperty): Ditto.
+ (getCPU): Ditto.
+ (toString): Ditto.
+ (getProperties): Ditto.
+ (getMemory): Change to get the memory property.
+ (getStorage): Change to get the storage property.
+ (HardwareProfile): Make private.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java (setCPU): New method.
+ (getCPU): Ditto.
+ (toString): Add cpu support.
+
+2010-07-26 Jeff Johnston <jj...@redhat.com>
+
+ * src/org/jboss/tools/deltacloud/core/client/AddressList.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/API.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/DeltaCloudObject.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/Image.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/Instance.java: New file.
+ * src/org/jboss/tools/deltacloud/core/client/Realm.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java: Import classes from new
+ client package.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java: Ditto.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (getProfileId): New
+ method.
+
+2010-07-23 Jeff Johnston <jj...@redhat.com>
+
+ * .classpath: New file.
+ * .project: New file.
+ * .settings/org.eclipse.jdt.core.prefs: New file.
+ * .settings/org.eclipse.pde.core.prefs: New file.
+ * build.properties: New file.
+ * lib/apache-mime4j-0.6.jar: New file.
+ * lib/commons-codec-1.3.jar: New file.
+ * lib/commons-logging-1.1.1.jar: New file.
+ * lib/deltacloudclient-1.0.jar: New file.
+ * lib/httpclient-4.0.1.jar: New file.
+ * lib/httpcore-4.0.1.jar: New file.
+ * lib/httpcore-nio-4.0.1.jar: New file.
+ * lib/httpmime-4.0.1.jar: New file.
+ * META-INF/MANIFEST.MF: New file.
+ * src/org/jboss/tools/deltacloud/core/Activator.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloud.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudImage.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java: New file.
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java: New file.
+ * src/org/jboss/tools/deltacloud/core/ICloudManagerListener.java: New file.
+ * src/org/jboss/tools/deltacloud/core/IImageListListener.java: New file.
+ * src/org/jboss/tools/deltacloud/core/IInstanceListListener.java: New file.
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/META-INF/MANIFEST.MF b/clients/java/org.apache.deltacloud.client/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..d4b4e0d
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/META-INF/MANIFEST.MF
@@ -0,0 +1,7 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: DeltaCloud Client
+Bundle-Vendor: Apache Software Foundation
+Bundle-SymbolicName: org.apache.deltacloud.client
+Bundle-Version: 0.2.0.qualifier
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/clients/java/org.apache.deltacloud.client/NOTICE b/clients/java/org.apache.deltacloud.client/NOTICE
new file mode 100644
index 0000000..cd3f48a
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/NOTICE
@@ -0,0 +1,8 @@
+Apache Deltacloud Java Client
+Copyright 2010 The Apache Software Foundation
+
+This product includes software developed at The Apache Software Foundation
+(http://www.apache.org/).
+
+This product includes software developed by Red Hat,
+Inc. (http://www.redhat.com/)
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/pom.xml b/clients/java/org.apache.deltacloud.client/pom.xml
new file mode 100644
index 0000000..ef44bc6
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/pom.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+ <groupId>org.apache.deltacloud.client</groupId>
+ <artifactId>client</artifactId>
+ <version>0.2.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>Deltacloud java client</name>
+ <description>The java Deltacloud client</description>
+ <licenses>
+ <license>
+ <name>The Apache Software License, Version 2.0</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+ </license>
+ </licenses>
+ <build>
+ <sourceDirectory>src</sourceDirectory>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <encoding>utf-8</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/API.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/API.java
new file mode 100644
index 0000000..3687d2f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/API.java
@@ -0,0 +1,64 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class API extends IdAware {
+
+ private static final long serialVersionUID = 1L;
+
+ public static enum Driver {
+ UNKNOWN, MOCK, EC2;
+
+ public static Driver checkedValueOf(String name) {
+ for (Driver driver : values()) {
+ if (driver.name().equals(name)) {
+ return driver;
+ }
+ }
+ return UNKNOWN;
+ }
+
+ }
+
+ private Driver driver;
+
+ public API() {
+ }
+
+ public void setDriver(Driver driver) {
+ this.driver = driver;
+ }
+
+ public void setDriver(String driver) {
+ setDriver(Driver.checkedValueOf(driver.toUpperCase()));
+ }
+
+ public Driver getDriver() {
+ return driver;
+ }
+
+ @Override
+ public String toString() {
+ return "API [driver=" + driver.name() + super.toString() + "]";
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Action.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Action.java
new file mode 100644
index 0000000..7060b6e
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Action.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * An action that may be performed on a resource
+ *
+ * @author André Dietisheim
+ */
+public class Action<OWNER> {
+
+ public static final String START_NAME = "start";
+ public static final String STOP_NAME = "stop";
+ public static final String REBOOT_NAME = "reboot";
+ public static final String DESTROY_NAME = "destroy";
+
+ private String name;
+ private String url;
+ private HttpMethod method;
+ private OWNER owner;
+
+ public HttpMethod getMethod() {
+ return method;
+ }
+
+ public void setMethodString(String method) {
+ this.method = HttpMethod.valueOf(method.toUpperCase());
+ }
+
+ public void setMethod(HttpMethod method) {
+ this.method = method;
+ }
+
+ public void setMethod(String method) {
+ this.method = HttpMethod.valueOf(method.toUpperCase());
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setOwner(OWNER owner) {
+ this.owner = owner;
+ }
+
+ public OWNER getOwner() {
+ return owner;
+ }
+
+ public boolean isStart() {
+ return START_NAME.equals(getName());
+ }
+
+ public boolean isStop() {
+ return STOP_NAME.equals(getName());
+ }
+
+ public boolean isReboot() {
+ return REBOOT_NAME.equals(getName());
+ }
+
+ public boolean isDestroy() {
+ return DESTROY_NAME.equals(getName());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ActionAware.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ActionAware.java
new file mode 100644
index 0000000..31c47eb
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ActionAware.java
@@ -0,0 +1,111 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Martyn Taylor
+ * @author André Dietisheim
+ */
+public abstract class ActionAware<OWNER> extends IdAware {
+
+ private List<Action<OWNER>> actions;
+
+ public Action<OWNER> getAction(String name) {
+ if (name == null) {
+ return null;
+ }
+
+ for (Action<OWNER> action : getActions()) {
+ if (name.equals(action.getName())) {
+ return action;
+ }
+ }
+ return null;
+ }
+
+ public List<String> getActionNames() {
+ ArrayList<String> names = new ArrayList<String>();
+ for (Action<OWNER> action : getActions()) {
+ names.add(action.getName());
+ }
+ return names;
+ }
+
+ public boolean start(DeltaCloudClient client) throws DeltaCloudClientException {
+ InputStream in = client.performAction(getAction(Action.START_NAME));
+ update(in);
+ return in != null;
+ }
+
+ public boolean stop(DeltaCloudClient client) throws DeltaCloudClientException {
+ InputStream in = client.performAction(getAction(Action.STOP_NAME));
+ update(in);
+ return in != null;
+ }
+
+ public boolean destroy(DeltaCloudClient client) throws DeltaCloudClientException {
+ InputStream in = client.performAction(getAction(Action.DESTROY_NAME));
+ return in != null;
+ }
+
+ public boolean reboot(DeltaCloudClient client) throws DeltaCloudClientException {
+ InputStream in = client.performAction(getAction(Action.REBOOT_NAME));
+ update(in);
+ return in != null;
+ }
+
+ protected void update(InputStream in) throws DeltaCloudClientException {
+ if (in == null) {
+ return;
+ }
+
+ doUpdate(in);
+ }
+
+ protected abstract void doUpdate(InputStream in) throws DeltaCloudClientException;
+
+ public boolean canStart() {
+ return getAction(Action.START_NAME) != null;
+ }
+
+ public boolean canStop() {
+ return getAction(Action.STOP_NAME) != null;
+ }
+
+ public boolean canReboot() {
+ return getAction(Action.REBOOT_NAME) != null;
+ }
+
+ public boolean canDestroy() {
+ return getAction(Action.DESTROY_NAME) != null;
+ }
+
+ public void setActions(List<Action<OWNER>> actions) {
+ this.actions = actions;
+ }
+
+ public List<Action<OWNER>> getActions() {
+ return actions;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/AddressList.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/AddressList.java
new file mode 100644
index 0000000..19a91d8
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/AddressList.java
@@ -0,0 +1,58 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.util.List;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlList;
+import javax.xml.bind.annotation.XmlType;
+
+/**
+ * @author Martyn Taylor
+ * @author André Dietisheim
+ */
+@XmlType
+public class AddressList
+{
+ private static final long serialVersionUID = 1L;
+
+ @XmlElement
+ @XmlList
+ private List<String> addresses;
+
+ public AddressList()
+ {
+ }
+
+ public AddressList(List<String> addresses)
+ {
+ setAddress(addresses);
+ }
+
+ protected void setAddress(List<String> addresses)
+ {
+ this.addresses = addresses;
+ }
+
+ public List<String> getAddress()
+ {
+ return addresses;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudAuthClientException.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudAuthClientException.java
new file mode 100644
index 0000000..783d037
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudAuthClientException.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DeltaCloudAuthClientException extends DeltaCloudClientException {
+
+ private static final long serialVersionUID = 1L;
+
+ public DeltaCloudAuthClientException(String message, Throwable cause)
+ {
+ super(message, cause);
+ }
+
+ public DeltaCloudAuthClientException(Throwable cause)
+ {
+ super(cause);
+ }
+
+ public DeltaCloudAuthClientException(String message)
+ {
+ super(message);
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClient.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClient.java
new file mode 100644
index 0000000..c30ac1d
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClient.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.deltacloud.client.API.Driver;
+
+/**
+ * @author Martyn Taylor
+ * @author Andre Dietisheim
+ */
+public interface DeltaCloudClient {
+
+ /**
+ * Returns the server type this client is connected to.
+ *
+ * @return the server type
+ *
+ * @see DeltaCloudServerType
+ */
+ public Driver getServerType();
+
+ /**
+ * Returns a list of Delta Cloud Realms
+ *
+ * @return List of Delta Cloud Realms
+ * @throws DeltaCloudClientException
+ */
+ public List<Realm> listRealms() throws DeltaCloudClientException;
+
+ /**
+ * Returns a single Delta Cloud Realm given its ID
+ *
+ * @param realmId
+ * @return Delta Cloud Realm
+ * @throws DeltaCloudClientException
+ */
+ public Realm listRealms(String realmId) throws DeltaCloudClientException;
+
+ public List<HardwareProfile> listProfiles() throws DeltaCloudClientException;
+
+ /**
+ * Returns a Delta Cloud Flavors
+ *
+ * @param flavorId
+ * @return Delta Cloud Flavor
+ * @throws DeltaCloudClientException
+ */
+ public HardwareProfile listProfile(String profileId) throws DeltaCloudClientException;
+
+ /**
+ * Returns a List of Delta Cloud Images
+ *
+ * @return List of Delta Cloud Images
+ * @throws DeltaCloudClientException
+ */
+ public List<Image> listImages() throws DeltaCloudClientException;
+
+ /**
+ * Returns a Delta Cloud Image given its ID
+ *
+ * @param imageId
+ * @return
+ * @throws DeltaCloudClientException
+ */
+ public Image listImages(String imageId) throws DeltaCloudClientException;
+
+ /**
+ * Returns a list of all Instances from the Delta Cloud Provider
+ *
+ * @return
+ * @throws DeltaCloudClientException
+ */
+ public List<Instance> listInstances() throws DeltaCloudClientException;
+
+ /**
+ * Returns an Instance from the Delta Cloud Provider given on the Instances
+ * ID
+ *
+ * @param instanceId
+ * @return
+ * @throws DeltaCloudClientException
+ */
+ public Instance listInstances(String instanceId) throws DeltaCloudClientException;
+
+ /**
+ * Creates a new Delta Cloud Instance based on the Image specified by the
+ * Image ID. Default parameters are used for the Flavor, Realm and Name.
+ * These are specified by the Delta Cloud Provider
+ *
+ * @param imageId
+ * @return The newly created Delta Cloud Instance
+ * @throws DeltaCloudClientException
+ */
+ public Instance createInstance(String imageId) throws DeltaCloudClientException;
+
+ /**
+ * Creates a new Delta Cloud Instance, the instance will be based on the
+ * Image specified by the instance ID. It will be of type flavor and in the
+ * location realm
+ *
+ * @param imageId
+ * @param flavor
+ * @param realm
+ * @param name
+ * @return
+ * @throws DeltaCloudClientException
+ */
+ public Instance createInstance(String name, String imageId, String profileId, String realmId, String memory, String storage)
+ throws DeltaCloudClientException;
+
+ public Instance createInstance(String name, String imageId, String profileId, String realmId, String keyname, String memory,
+ String storage) throws DeltaCloudClientException;
+
+ /**
+ * Creates a key for a given name on the deltacloud server.
+ *
+ * @param keyname
+ * the name of the key to retrieve from the server
+ * @param keyStoreLocation
+ * the path to the file to store the key in
+ * @throws DeltaCloudClientException
+ * the delta cloud client exception
+ */
+ public Key createKey(String keyname) throws DeltaCloudClientException;
+
+ /**
+ * Lists all keys available on the deltacloud server this client is
+ * connected to.
+ *
+ * @return the keys that are available
+ * @throws DeltaCloudClientException
+ *
+ */
+ public List<Key> listKeys() throws DeltaCloudClientException;
+
+ /**
+ * Returns a key with the given name if it is available on the server.
+ * Throws a DeltaCloudException if it is not available.
+ */
+ public Key listKey(String id) throws DeltaCloudClientException;
+
+ /**
+ * Performs the given action.
+ *
+ * @param action the action to execute
+ * @return true, if successful
+ * @throws DeltaCloudClientException the delta cloud client exception
+ * @see Action
+ */
+ public InputStream performAction(Action<?> action) throws DeltaCloudClientException;
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientException.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientException.java
new file mode 100644
index 0000000..b98b099
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientException.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Martyn Taylor
+ */
+public class DeltaCloudClientException extends Exception
+{
+ private static final long serialVersionUID = 1L;
+
+ public DeltaCloudClientException(String message, Throwable clause)
+ {
+ super(message, clause);
+ }
+
+ public DeltaCloudClientException(Throwable clause)
+ {
+ super(clause);
+ }
+
+ public DeltaCloudClientException(String message)
+ {
+ super(message);
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java
new file mode 100644
index 0000000..bd66e7e
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudClientImpl.java
@@ -0,0 +1,255 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.API.Driver;
+import org.apache.deltacloud.client.request.CreateInstanceRequest;
+import org.apache.deltacloud.client.request.CreateKeyRequest;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+import org.apache.deltacloud.client.request.ListHardwareProfileRequest;
+import org.apache.deltacloud.client.request.ListHardwareProfilesRequest;
+import org.apache.deltacloud.client.request.ListImageRequest;
+import org.apache.deltacloud.client.request.ListImagesRequest;
+import org.apache.deltacloud.client.request.ListInstanceRequest;
+import org.apache.deltacloud.client.request.ListInstancesRequest;
+import org.apache.deltacloud.client.request.ListKeyRequest;
+import org.apache.deltacloud.client.request.ListKeysRequest;
+import org.apache.deltacloud.client.request.ListRealmRequest;
+import org.apache.deltacloud.client.request.ListRealmsRequest;
+import org.apache.deltacloud.client.request.PerformActionRequest;
+import org.apache.deltacloud.client.request.TypeRequest;
+import org.apache.deltacloud.client.transport.IHttpTransport;
+import org.apache.deltacloud.client.transport.URLConnectionTransport;
+import org.apache.deltacloud.client.unmarshal.APIUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.HardwareProfileUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.HardwareProfilesUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.ImageUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.ImagesUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.InstanceUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.InstancesUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.KeyUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.KeysUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.RealmUnmarshaller;
+import org.apache.deltacloud.client.unmarshal.RealmsUnmarshaller;
+
+/**
+ * @author Andre Dietisheim (based on prior implementation by Martyn Taylor)
+ */
+public class DeltaCloudClientImpl implements DeltaCloudClient {
+
+ private String baseUrl;
+ private IHttpTransport transport;
+
+ public DeltaCloudClientImpl(String url) throws MalformedURLException, DeltaCloudClientException {
+ this(url, null, null);
+ }
+
+ public DeltaCloudClientImpl(String url, String username, String password) throws MalformedURLException,
+ DeltaCloudClientException {
+ this(url, new URLConnectionTransport(username, password));
+ }
+
+ public DeltaCloudClientImpl(String url, IHttpTransport transport) throws DeltaCloudClientException {
+ this.baseUrl = url;
+ this.transport = transport;
+ }
+
+ protected InputStream request(DeltaCloudRequest deltaCloudRequest) throws DeltaCloudClientException {
+ return transport.request(deltaCloudRequest);
+ }
+
+ public Driver getServerType() {
+ try {
+ InputStream response = request(new TypeRequest(baseUrl));
+ API api = new APIUnmarshaller().unmarshall(response, new API());
+ return api.getDriver();
+ } catch (DeltaCloudClientException e) {
+ return Driver.UNKNOWN;
+ }
+ }
+
+ @Override
+ public Instance createInstance(String imageId) throws DeltaCloudClientException {
+ try {
+ InputStream response = request(new CreateInstanceRequest(baseUrl, imageId));
+ return new InstanceUnmarshaller().unmarshall(response, new Instance());
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+
+ }
+
+ public Instance createInstance(String name, String imageId, String profileId, String realmId, String memory,
+ String storage) throws DeltaCloudClientException {
+ return createInstance(name, imageId, profileId, realmId, null, memory, storage);
+ }
+
+ public Instance createInstance(String name, String imageId, String profileId, String realmId, String keyId,
+ String memory, String storage) throws DeltaCloudClientException {
+ try {
+ InputStream response = request(
+ new CreateInstanceRequest(baseUrl, name, imageId, profileId, realmId, keyId, memory, storage));
+ Instance instance = new InstanceUnmarshaller().unmarshall(response, new Instance());
+ // TODO: WORKAROUND for
+ // https://issues.jboss.org/browse/JBIDE-8005
+ if (keyId != null) {
+ instance.setKeyId(keyId);
+ }
+ // TODO: WORKAROUND for
+ // https://issues.jboss.org/browse/JBIDE-8005
+ return instance;
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+
+ @Override
+ public HardwareProfile listProfile(String profileId) throws DeltaCloudClientException {
+ try {
+ InputStream response = request(new ListHardwareProfileRequest(baseUrl, profileId));
+ return new HardwareProfileUnmarshaller().unmarshall(response, new HardwareProfile());
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+
+ @Override
+ public List<HardwareProfile> listProfiles() throws DeltaCloudClientException {
+ try {
+ InputStream response = request(new ListHardwareProfilesRequest(baseUrl));
+ List<HardwareProfile> profiles = new ArrayList<HardwareProfile>();
+ new HardwareProfilesUnmarshaller().unmarshall(response, profiles);
+ return profiles;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(MessageFormat.format("could not get realms on cloud at \"{0}\"",
+ baseUrl), e);
+ }
+ }
+
+ @Override
+ public List<Image> listImages() throws DeltaCloudClientException {
+ InputStream response = request(new ListImagesRequest(baseUrl));
+ List<Image> images = new ArrayList<Image>();
+ new ImagesUnmarshaller().unmarshall(response, images);
+ return images;
+ }
+
+ @Override
+ public Image listImages(String imageId) throws DeltaCloudClientException {
+ InputStream response = request(new ListImageRequest(baseUrl, imageId));
+ return new ImageUnmarshaller().unmarshall(response, new Image());
+ }
+
+ @Override
+ public List<Instance> listInstances() throws DeltaCloudClientException {
+ InputStream inputStream = request(new ListInstancesRequest(baseUrl));
+ List<Instance> instances = new ArrayList<Instance>();
+ new InstancesUnmarshaller().unmarshall(inputStream, instances);
+ return instances;
+ }
+
+ @Override
+ public Instance listInstances(String instanceId) throws DeltaCloudClientException {
+ try {
+ InputStream response = request(new ListInstanceRequest(baseUrl, instanceId));
+ return new InstanceUnmarshaller().unmarshall(response, new Instance());
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+
+ @Override
+ public List<Realm> listRealms() throws DeltaCloudClientException {
+ try {
+ InputStream inputStream = request(new ListRealmsRequest(baseUrl));
+ List<Realm> realms = new ArrayList<Realm>();
+ new RealmsUnmarshaller().unmarshall(inputStream, realms);
+ return realms;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(
+ MessageFormat.format("could not get realms on cloud at \"{0}\"", baseUrl), e);
+ }
+ }
+
+ @Override
+ public Realm listRealms(String realmId) throws DeltaCloudClientException {
+ try {
+ InputStream response = request(new ListRealmRequest(baseUrl, realmId));
+ return new RealmUnmarshaller().unmarshall(response, new Realm());
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(
+ MessageFormat.format("could not get realms on cloud at \"{0}\"", baseUrl), e);
+ }
+ }
+
+ public Key createKey(String keyname) throws DeltaCloudClientException {
+ try {
+ CreateKeyRequest keyRequest = new CreateKeyRequest(baseUrl, keyname);
+ InputStream inputStream = request(keyRequest);
+ Key key = new KeyUnmarshaller().unmarshall(inputStream, new Key());
+ return key;
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+
+ public List<Key> listKeys() throws DeltaCloudClientException {
+ InputStream inputStream = request(new ListKeysRequest(baseUrl));
+ List<Key> keys = new ArrayList<Key>();
+ new KeysUnmarshaller().unmarshall(inputStream, keys);
+ return keys;
+ }
+
+ public Key listKey(String id) throws DeltaCloudClientException {
+ InputStream inputStream = request(new ListKeyRequest(baseUrl, id));
+ Key key = new KeyUnmarshaller().unmarshall(inputStream, new Key());
+ return key;
+ }
+
+ public InputStream performAction(Action<?> action) throws DeltaCloudClientException {
+ InputStream in = null;
+ if (action != null) {
+ try {
+ in = request(new PerformActionRequest(action.getUrl(), action.getMethod()));
+ } catch (DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+ return in;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudNotFoundClientException.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudNotFoundClientException.java
new file mode 100644
index 0000000..559c273
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/DeltaCloudNotFoundClientException.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class DeltaCloudNotFoundClientException extends DeltaCloudClientException {
+
+ private static final long serialVersionUID = 1L;
+
+ public DeltaCloudNotFoundClientException(String message, Throwable clause)
+ {
+ super(message, clause);
+ }
+
+ public DeltaCloudNotFoundClientException(Throwable clause)
+ {
+ super(clause);
+ }
+
+ public DeltaCloudNotFoundClientException(String message)
+ {
+ super(message);
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HardwareProfile.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HardwareProfile.java
new file mode 100644
index 0000000..87674ff
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HardwareProfile.java
@@ -0,0 +1,103 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.Property.Names;
+
+/**
+ * @author Martyn Taylor
+ * @author André Dietisheim
+ */
+public class HardwareProfile extends IdAware {
+ private static final long serialVersionUID = 1L;
+
+ private List<Property> properties;
+
+ public HardwareProfile() {
+ }
+
+ public void setProperties(List<Property> properties) {
+ this.properties = properties;
+ }
+
+ public List<Property> getProperties() {
+ if (properties == null)
+ properties = new ArrayList<Property>();
+ return properties;
+ }
+
+ public Property getNamedProperty(Names nameEnum) {
+ if (nameEnum == null) {
+ return null;
+ }
+ return getNamedProperty(nameEnum.name().toLowerCase());
+ }
+
+ public Property getNamedProperty(String name) {
+ if (properties != null) {
+ for (Property p : properties) {
+ if (p.getName().equals(name))
+ return p;
+ }
+ }
+ return null;
+ }
+
+ public String getArchitecture() {
+ Property p = getNamedProperty(Property.Names.ARCHITECTURE);
+ if (p != null)
+ return p.getValue();
+ return null;
+ }
+
+ public String getMemory() {
+ Property p = getNamedProperty("memory");
+ if (p != null)
+ return p.toString();
+ return null;
+ }
+
+ public String getStorage() {
+ Property p = getNamedProperty("storage");
+ if (p != null)
+ return p.toString();
+ return null;
+ }
+
+ public String getCPU() {
+ Property p = getNamedProperty("cpu");
+ if (p != null)
+ return p.getValue();
+ return null;
+ }
+
+ @Override
+ public String toString() {
+ String s = "";
+ s += "Hardware-profile:\t\t" + getId() + "\n";
+ for (Property p : properties) {
+ s += p.getName() + ":\t\t" + p.getValue() + "\n";
+ }
+ return s;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpMethod.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpMethod.java
new file mode 100644
index 0000000..966d4a4
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpMethod.java
@@ -0,0 +1,24 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+public enum HttpMethod {
+ GET, POST, PUT, DELETE, HEAD;
+}
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusCode.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusCode.java
new file mode 100644
index 0000000..95625ba
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusCode.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Andre Dietisheim
+ */
+public enum HttpStatusCode {
+
+ OK(200), NOT_FOUND(404), FORBIDDEN(403), UNAUTHORIZED(401);
+
+ private int code;
+
+ private HttpStatusCode(int code) {
+ this.code = code;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public boolean isStatus(int statusCode) {
+ return code == statusCode;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusRange.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusRange.java
new file mode 100644
index 0000000..b77eeee
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/HttpStatusRange.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Andre Dietisheim
+ */
+public enum HttpStatusRange {
+
+ CLIENT_ERROR(400, 499), SERVER_ERROR(500, 599);
+
+ private int start;
+ private int stop;
+
+ HttpStatusRange(int start, int stop) {
+ this.start = start;
+ this.stop = stop;
+ }
+
+ public boolean isInRange(int statusCode) {
+ return statusCode >= start
+ && statusCode <= stop;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/IdAware.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/IdAware.java
new file mode 100644
index 0000000..26b66da
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/IdAware.java
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import javax.xml.bind.annotation.XmlAttribute;
+
+/**
+ * @author Martyn Taylor
+ * @author André Dietisheim
+ */
+public abstract class IdAware {
+
+ protected String id;
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ @XmlAttribute
+ public String getId() {
+ return id;
+ }
+
+ @Override
+ public String toString() {
+ return "IdAware [id=" + id + "]";
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Image.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Image.java
new file mode 100644
index 0000000..2a86593
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Image.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+
+/**
+ * @author Martyn Taylor
+ */
+public class Image extends IdAware
+{
+ private static final long serialVersionUID = 1L;
+
+ private String ownerId;
+
+ private String name;
+
+ private String description;
+
+ private String architecture;
+
+ public Image()
+ {
+ }
+
+ public void setOwnerId(String ownerId)
+ {
+ this.ownerId = ownerId;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
+ public void setDescription(String description)
+ {
+ this.description = description;
+ }
+
+ public void setArchitecture(String architecture)
+ {
+ this.architecture = architecture;
+ }
+
+ public String getOwnerId()
+ {
+ return ownerId;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public String getArchitecture()
+ {
+ return architecture;
+ }
+
+ @Override
+ public String toString()
+ {
+ String s = "";
+ s += "Image:\t\t" + getId() + "\n";
+ s += "Owner:\t\t" + getOwnerId() + "\n";
+ s += "Name:\t\t" + getName() + "\n";
+ s += "Desc:\t\t" + getDescription() + "\n";
+ s += "Arch:\t\t" + getArchitecture() + "\n";
+ return s;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Instance.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Instance.java
new file mode 100644
index 0000000..07fdd1f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Instance.java
@@ -0,0 +1,201 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.io.InputStream;
+import java.util.List;
+
+import org.apache.deltacloud.client.unmarshal.InstanceUnmarshaller;
+
+/**
+ * @author Martyn Taylor
+ * @author Andre Dietisheim
+ */
+public class Instance extends StateAware<Instance> {
+
+ private static final long serialVersionUID = 1L;
+
+ private String ownerId;
+
+ private String name;
+
+ private String imageId;
+
+ private String profileId;
+
+ private String memory;
+
+ private String storage;
+
+ private String cpu;
+
+ private String realmId;
+
+ private String keyId;
+
+ private AddressList publicAddresses;
+
+ private AddressList privateAddresses;
+
+ public Instance() {
+ }
+
+ public void setOwnerId(String ownerId) {
+ this.ownerId = ownerId;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setImageId(String imageId) {
+ this.imageId = imageId;
+ }
+
+ public void setProfileId(String profileId) {
+ this.profileId = profileId;
+ }
+
+ protected void setMemory(String memory) {
+ this.memory = memory;
+ }
+
+ protected void setStorage(String storage) {
+ this.storage = storage;
+ }
+
+ protected void setCPU(String cpu) {
+ this.cpu = cpu;
+ }
+
+ public void setRealmId(String realmId) {
+ this.realmId = realmId;
+ }
+
+ public void setKeyId(String keyId) {
+ this.keyId = keyId;
+ }
+
+ public String getKeyId() {
+ return keyId;
+ }
+
+ public void setPrivateAddresses(AddressList privateAddresses) {
+ this.privateAddresses = privateAddresses;
+ }
+
+ public void setPublicAddresses(AddressList publicAddresses) {
+ this.publicAddresses = publicAddresses;
+ }
+
+ public String getOwnerId() {
+ return ownerId;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getImageId() {
+ return imageId;
+ }
+
+ public String getProfileId() {
+ return profileId;
+ }
+
+ public String getMemory() {
+ return memory;
+ }
+
+ public String getStorage() {
+ return storage;
+ }
+
+ public String getCPU() {
+ return cpu;
+ }
+
+ public String getRealmId() {
+ return realmId;
+ }
+
+ public List<String> getPublicAddresses() {
+ return publicAddresses.getAddress();
+ }
+
+ public List<String> getPrivateAddresses() {
+ return privateAddresses.getAddress();
+ }
+
+ @Override
+ protected void doUpdate(InputStream in) throws DeltaCloudClientException {
+ new InstanceUnmarshaller().unmarshall(in, this);
+ }
+
+
+ @Override
+ public String toString() {
+ String s = "";
+ s += "Instance:\t" + getId() + "\n";
+ s += "Owner:\t\t" + getOwnerId() + "\n";
+ s += "Image:\t\t" + getImageId() + "\n";
+ s += "Realm:\t\t" + getRealmId() + "\n";
+ s += "Profile:\t\t" + getProfileId() + "\n";
+ if (getMemory() != null)
+ s += "Memory:\t\t" + getMemory() + "\n";
+ if (getStorage() != null) {
+ s += "Storage:\t\t" + getStorage() + "\n";
+ }
+ if (getCPU() != null) {
+ s += "CPU:\t\t" + getCPU() + "\n";
+ }
+ s += "State:\t\t" + getState() + "\n";
+
+ List<Action<Instance>> actions = getActions();
+ if (actions != null) {
+ for (int i = 0; i < actions.size(); i++) {
+ if (i == 0) {
+ s += "Actions:\t" + actions.get(i) + "\n";
+ } else {
+ s += "\t\t" + actions.get(i) + "\n";
+ }
+ }
+ }
+
+ for (int i = 0; i < publicAddresses.getAddress().size(); i++) {
+ if (i == 0) {
+ s += "Public Addr:\t" + publicAddresses.getAddress().get(i) + "\n";
+ } else {
+ s += "\t\t" + publicAddresses.getAddress().get(i) + "\n";
+ }
+ }
+
+ for (int i = 0; i < publicAddresses.getAddress().size(); i++) {
+ if (i == 0) {
+ s += "Private Addr:\t" + publicAddresses.getAddress().get(i) + "\n";
+ } else {
+ s += "\t\t" + privateAddresses.getAddress().get(i) + "\n";
+ }
+ }
+
+ return s;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Key.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Key.java
new file mode 100644
index 0000000..80170f2
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Key.java
@@ -0,0 +1,81 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.deltacloud.client.unmarshal.KeyUnmarshaller;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class Key extends StateAware<Key> {
+
+ private static final long serialVersionUID = 1L;
+
+ private URL url;
+ private String pem;
+ private String fingerprint;
+ private String state;
+
+ public Key() {
+ }
+
+ public void setUrl(URL url) {
+ this.url = url;
+ }
+
+ public void setUrl(String url) throws MalformedURLException {
+ this.url = new URL(url);
+ }
+
+ public void setPem(String pem) {
+ this.pem = pem;
+ }
+
+ public void setFingerprint(String fingerprint) {
+ this.fingerprint = fingerprint;
+ }
+
+ public URL getUrl() {
+ return url;
+ }
+
+ public String getFingerprint() {
+ return fingerprint;
+ }
+
+ public String getPem() {
+ return pem;
+ }
+
+ @Override
+ protected void doUpdate(InputStream in) throws DeltaCloudClientException {
+ new KeyUnmarshaller().unmarshall(in, this);
+ }
+
+ @Override
+ public String toString() {
+ return "Key [url=" + url + ", pem=" + pem + ", fingerprint=" + fingerprint + ", state=" + state + ", actions="
+ + getActions() + ", toString()=" + super.toString() + "]";
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Property.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Property.java
new file mode 100644
index 0000000..7a2db4a
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Property.java
@@ -0,0 +1,171 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+import java.util.List;
+
+/**
+ * @author Martyn Taylor
+ */
+public class Property extends IdAware {
+
+ private static final long serialVersionUID = 1L;
+
+ public static enum Kind {
+ FIXED, RANGE, ENUM
+ };
+
+ public static enum Names {
+ MEMORY, STORAGE, CPU, ARCHITECTURE
+ }
+
+ public static enum UNIT {
+ MB {
+ public boolean matches(String value) {
+ return name().equals(value);
+ }},
+ GB{
+ public boolean matches(String value) {
+ return name().equals(value);
+ }},
+ LABEL{
+ public boolean matches(String value) {
+ return name().toLowerCase().equals(value);
+ }},
+ COUNT{
+ public boolean matches(String value) {
+ return name().toLowerCase().equals(value);
+ }};
+
+ public abstract boolean matches(String value);
+ }
+
+ public class Range {
+ private String first;
+ private String last;
+
+ public Range(String first, String last) {
+ this.first = first;
+ this.last = last;
+ }
+
+ public String getFirst() {
+ return first;
+ }
+
+ public String getLast() {
+ return last;
+ }
+ }
+
+ public Property() {
+ }
+
+ private String kind;
+
+ private String unit;
+
+ private String name;
+
+ private String value;
+
+ // For range
+ private String first;
+ private String last;
+
+ // For enum
+ private List<String> enums;
+
+ public String getKind() {
+ return kind;
+ }
+
+ public String getUnit() {
+ return unit;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public Range getRange() {
+ return new Range(first, last);
+ }
+
+ public List<String> getEnums() {
+ return enums;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public void setUnit(String unit) {
+ this.unit = unit;
+ }
+
+ public void setKind(String kind) {
+ this.kind = kind;
+ }
+
+ public void setRange(String first, String last) {
+ this.first = first;
+ this.last = last;
+ }
+
+ public void setEnums(List<String> enums) {
+ this.enums = enums;
+ }
+
+ public String toString() {
+ if (kind.equals("range")) {
+ // return first += "-" + last + "(default:" + value + ")";
+ return new StringBuilder()
+ .append(first)
+ .append('-').append(last)
+ .append("(default: ").append(value).append(")")
+ .toString();
+ } else if (kind.equals("enum")) {
+ String s = enums.get(0);
+ for (int i = 1; i < enums.size(); ++i) {
+ s += ", " + enums.get(i);
+ }
+ s += " (default:" + value + ")";
+ return s;
+ } else {
+ // return value += " " + (unit.equals("label") ? "" : unit);
+ StringBuilder builder = new StringBuilder();
+ builder.append(value);
+ if (!UNIT.LABEL.matches(unit)) {
+ builder.append(' ').append(unit);
+ }
+ return builder.toString();
+ }
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Realm.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Realm.java
new file mode 100644
index 0000000..2851c44
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/Realm.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+/**
+ * @author Martyn Taylor
+ * @author André Dietisheim
+ */
+public class Realm extends IdAware {
+ private static final long serialVersionUID = 1L;
+
+ public static final int LIMIT_DEFAULT = -1;
+
+ private String name;
+ private RealmState state;
+ private int limit;
+
+ public static enum RealmState {
+ AVAILABLE, UNAVAILABLE, UNKNOWN
+ }
+
+ public Realm() {
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ public void setLimit(int limit) {
+ this.limit = limit;
+ }
+
+ public void setLimit(String limit) {
+ try {
+ this.limit = Integer.parseInt(limit);
+ } catch (Exception e) {
+ this.limit = LIMIT_DEFAULT;
+ }
+ }
+
+ public int getLimit() {
+ return limit;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setState(String state) {
+ try {
+ this.state = RealmState.valueOf(state.toUpperCase());
+ } catch (Exception e) {
+ this.state = RealmState.UNKNOWN;
+ }
+ }
+
+ public RealmState getState() {
+ return state;
+ }
+
+ @Override
+ public String toString() {
+ String s = "";
+ s += "Realm:\t\t" + getId() + "\n";
+ s += "Name\t\t" + getName() + "\n";
+ s += "State:\t\t" + getState() + "\n";
+ s += "Limit:\t\t" + getLimit() + "\n";
+ return s;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ResourceAction.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ResourceAction.java
new file mode 100644
index 0000000..dd7693b
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/ResourceAction.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+
+/**
+ * @author André Dietisheim
+ */
+public interface ResourceAction<OWNER> {
+
+ public static final String DESTROY = "destroy";
+
+ public String getName();
+
+ public String getUrl();
+
+ public HttpMethod getMethod();
+
+ public OWNER getOwner();
+
+ public boolean isDestroy();
+}
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/StateAware.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/StateAware.java
new file mode 100644
index 0000000..d47af9f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/StateAware.java
@@ -0,0 +1,55 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client;
+
+
+/**
+ * @author André Dietisheim
+ *
+ * @param <OWNER>
+ */
+public abstract class StateAware<OWNER> extends ActionAware<OWNER> {
+
+ public static enum State {
+ RUNNING, STOPPED, PENDING, TERMINATED, BOGUS
+ };
+
+ private State state;
+
+ public void setState(String state) {
+ try {
+ this.state = State.valueOf(state);
+ } catch (Exception e) {
+ this.state = State.BOGUS;
+ }
+ }
+
+ public State getState() {
+ return state;
+ }
+
+ public boolean isRunning() {
+ return getState() == State.RUNNING;
+ }
+
+ public boolean isStopped() {
+ return getState() == State.STOPPED;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractDeltaCloudRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractDeltaCloudRequest.java
new file mode 100644
index 0000000..a509177
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractDeltaCloudRequest.java
@@ -0,0 +1,70 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractDeltaCloudRequest implements DeltaCloudRequest {
+
+ private String urlString;
+ private URL url;
+ private HttpMethod httpMethod;
+ private UrlBuilder urlBuilder;
+
+ protected AbstractDeltaCloudRequest(String baseURL, HttpMethod httpMethod) {
+ this.httpMethod = httpMethod;
+ this.urlBuilder = createUrlBuilder(baseURL);
+ }
+
+ protected abstract String doCreateUrl(UrlBuilder urlBuilder);
+
+ protected UrlBuilder createUrlBuilder(String baseUrl) {
+ return new UrlBuilder(baseUrl).path(API_PATH_SEGMENT);
+ }
+
+ public URL getUrl() throws MalformedURLException {
+ if (url == null) {
+ this.url = new URL(getUrlString());
+ }
+ return url;
+ }
+
+ public String getUrlString() {
+ if (urlString == null) {
+ this.urlString = doCreateUrl(urlBuilder);
+ }
+ return urlString;
+ }
+
+ public String toString() {
+ return getUrlString();
+ }
+
+ public HttpMethod getHttpMethod() {
+ return httpMethod;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractListObjectsRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractListObjectsRequest.java
new file mode 100644
index 0000000..53ac346
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/AbstractListObjectsRequest.java
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Lists images, instances, realms or profiles on the deltacloud server.
+ *
+ * @see ListRealmRequest
+ * @see ListHardwareProfilesRequest
+ * @see ListHardwareProfilesRequest
+ * @see ListInstancesRequest
+ *
+ * @author André Dietisheim
+ */
+public abstract class AbstractListObjectsRequest extends AbstractDeltaCloudRequest {
+
+ private String objectType;
+
+ public AbstractListObjectsRequest(String baseUrl, String objectType) {
+ super(baseUrl, HttpMethod.GET);
+ this.objectType = objectType;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path(objectType).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateInstanceRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateInstanceRequest.java
new file mode 100644
index 0000000..54c409a
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateInstanceRequest.java
@@ -0,0 +1,72 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Creates a new instance
+ *
+ * @author André Dietisheim
+ */
+public class CreateInstanceRequest extends AbstractDeltaCloudRequest {
+
+ private String name;
+ private String imageId;
+ private String profileId;
+ private String realmId;
+ private String keyname;
+ private String memory;
+ private String storage;
+
+ public CreateInstanceRequest(String baseUrl, String imageId) {
+ this(baseUrl, null, imageId, null, null, null, null, null);
+ }
+
+ public CreateInstanceRequest(String baseUrl, String name, String imageId, String profileId, String realmId,
+ String keyId, String memory, String storage) {
+ super(baseUrl, HttpMethod.POST);
+ this.name = name;
+ this.imageId = imageId;
+ this.profileId = profileId;
+ this.realmId = realmId;
+ this.keyname = keyId;
+ this.memory = memory;
+ this.storage = storage;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("instances")
+ .parameter("keyname", keyname)
+ // WORKAROUND for JBIDE-8005, STEAM-303
+ .parameter("key_name", keyname)
+ // WORKAROUND for JBIDE-8005, STEAM-303
+ .parameter("name", name)
+ .parameter("image_id", imageId)
+ .parameter("hwp_id", profileId)
+ .parameter("realm_id", realmId)
+ .parameter("hwp_memory", memory)
+ .parameter("hwp_storage", storage)
+ .parameter("commit", "create")
+ .toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateKeyRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateKeyRequest.java
new file mode 100644
index 0000000..0b4d4ac
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/CreateKeyRequest.java
@@ -0,0 +1,46 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Creates a key on the deltacloud server
+ *
+ * @author André Dietisheim
+ */
+public class CreateKeyRequest extends AbstractDeltaCloudRequest {
+
+ private String keyName;
+
+ public CreateKeyRequest(String baseUrl, String keyName) {
+ super(baseUrl, HttpMethod.POST);
+ this.keyName = keyName;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("keys")
+ .parameter("name", keyName)
+ .parameter("commit", "create")
+ .toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/DeltaCloudRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/DeltaCloudRequest.java
new file mode 100644
index 0000000..ee42dcd
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/DeltaCloudRequest.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.deltacloud.client.HttpMethod;
+
+/**
+ * @author André Dietisheim
+ */
+public interface DeltaCloudRequest {
+
+ public static final char PATH_SEPARATOR = '/';
+ public static final char PARAMETER_SEPARATOR = '?';
+ public static final String API_PATH_SEGMENT = "api";
+
+ public URL getUrl() throws MalformedURLException;
+
+ public String getUrlString();
+
+ public HttpMethod getHttpMethod();
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfileRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfileRequest.java
new file mode 100644
index 0000000..dddead3
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfileRequest.java
@@ -0,0 +1,49 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * A request for a hardware profile on a deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListHardwareProfileRequest extends AbstractDeltaCloudRequest {
+
+ private String profileId;
+
+ /**
+ * Instantiates a new type request.
+ *
+ * @param baseUrl the base url
+ * @param imageId
+ */
+ public ListHardwareProfileRequest(String baseUrl, String profileId) {
+ super(baseUrl, HttpMethod.GET);
+ this.profileId = profileId;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("hardware_profiles").path(profileId).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfilesRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfilesRequest.java
new file mode 100644
index 0000000..c147e89
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListHardwareProfilesRequest.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+/**
+ * Lists profiles on the deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListHardwareProfilesRequest extends AbstractListObjectsRequest {
+
+ public ListHardwareProfilesRequest(String baseUrl) {
+ super(baseUrl, "hardware_profiles");
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImageRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImageRequest.java
new file mode 100644
index 0000000..be0925c
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImageRequest.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+
+/**
+ * A request for an image on a deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListImageRequest extends AbstractDeltaCloudRequest {
+
+ private String imageId;
+
+ public ListImageRequest(String baseUrl, String imageId) {
+ super(baseUrl, HttpMethod.GET);
+ this.imageId = imageId;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("images").path(imageId).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImagesRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImagesRequest.java
new file mode 100644
index 0000000..294778f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListImagesRequest.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+/**
+ * Lists images on the deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListImagesRequest extends AbstractListObjectsRequest {
+
+ public ListImagesRequest(String baseUrl) {
+ super(baseUrl, "images");
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstanceRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstanceRequest.java
new file mode 100644
index 0000000..acd8838
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstanceRequest.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Lists an instance on the deltacloud server
+ *
+ * @author André Dietisheim
+ */
+public class ListInstanceRequest extends AbstractDeltaCloudRequest {
+
+ private String instanceId;
+
+ public ListInstanceRequest(String baseUrl, String instanceId) {
+ super(baseUrl, HttpMethod.GET);
+ this.instanceId = instanceId;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("instances").path(instanceId).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstancesRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstancesRequest.java
new file mode 100644
index 0000000..adf1aec
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListInstancesRequest.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+/**
+ * Lists instances on the deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListInstancesRequest extends AbstractListObjectsRequest {
+
+ public ListInstancesRequest(String baseUrl) {
+ super(baseUrl, "instances");
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeyRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeyRequest.java
new file mode 100644
index 0000000..e119d9f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeyRequest.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * List a key with a given name that is available on the deltacloud server
+ *
+ * @author André Dietisheim
+ */
+public class ListKeyRequest extends AbstractDeltaCloudRequest {
+
+ private String name;
+
+ public ListKeyRequest(String baseUrl, String name) {
+ super(baseUrl, HttpMethod.GET);
+ this.name = name;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("keys").path(name).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeysRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeysRequest.java
new file mode 100644
index 0000000..d49bbc2
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListKeysRequest.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Lists keys available on the deltacloud server
+ *
+ * @author André Dietisheim
+ */
+public class ListKeysRequest extends AbstractDeltaCloudRequest {
+
+ public ListKeysRequest(String baseUrl) {
+ super(baseUrl, HttpMethod.GET);
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("keys").toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmRequest.java
new file mode 100644
index 0000000..3a455b3
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmRequest.java
@@ -0,0 +1,43 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Lists a realm on the deltacloud server
+ *
+ * @author André Dietisheim
+ */
+public class ListRealmRequest extends AbstractDeltaCloudRequest {
+
+ private String realmId;
+
+ public ListRealmRequest(String baseUrl, String realmId) {
+ super(baseUrl, HttpMethod.GET);
+ this.realmId = realmId;
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.path("realms").path(realmId).toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmsRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmsRequest.java
new file mode 100644
index 0000000..23b5bbf
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/ListRealmsRequest.java
@@ -0,0 +1,32 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+/**
+ * Lists realms on the deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class ListRealmsRequest extends AbstractListObjectsRequest {
+
+ public ListRealmsRequest(String baseUrl) {
+ super(baseUrl, "realms");
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/PerformActionRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/PerformActionRequest.java
new file mode 100644
index 0000000..d725661
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/PerformActionRequest.java
@@ -0,0 +1,56 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * Performs an action on a resource of the deltacloud server. The typical
+ * actions are
+ * <ul>
+ * <li>START</li>
+ * <li>STOP</li>
+ * <li>DESTROY</li>
+ * <li>REBOOT</li>
+ * </ul>
+ *
+ * @author André Dietisheim
+ *
+ * @see Action
+ */
+public class PerformActionRequest extends AbstractDeltaCloudRequest {
+
+ public PerformActionRequest(String url, HttpMethod httpMethod) {
+ super(url, httpMethod);
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.toString();
+ }
+
+ @Override
+ protected UrlBuilder createUrlBuilder(String baseURL) {
+ return new UrlBuilder(baseURL);
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/TypeRequest.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/TypeRequest.java
new file mode 100644
index 0000000..7619908
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/request/TypeRequest.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.request;
+
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.utils.UrlBuilder;
+
+/**
+ * A request for the type of deltacloud server.
+ *
+ * @author André Dietisheim
+ */
+public class TypeRequest extends AbstractDeltaCloudRequest {
+
+ public TypeRequest(String baseUrl) {
+ super(baseUrl, HttpMethod.GET);
+ }
+
+ @Override
+ protected String doCreateUrl(UrlBuilder urlBuilder) {
+ return urlBuilder.parameter("format", "xml").toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/AbstractHttpTransport.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/AbstractHttpTransport.java
new file mode 100644
index 0000000..2c83315
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/AbstractHttpTransport.java
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.transport;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.MessageFormat;
+
+import org.apache.deltacloud.client.DeltaCloudAuthClientException;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.HttpStatusCode;
+import org.apache.deltacloud.client.HttpStatusRange;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+
+/**
+ * @author André Dietisheim
+ */
+public abstract class AbstractHttpTransport implements IHttpTransport {
+
+ private String username;
+ private String password;
+
+ public AbstractHttpTransport(String username, String password) {
+ this.username = username;
+ this.password = password;
+ }
+
+ @Override
+ public final InputStream request(DeltaCloudRequest request) throws DeltaCloudClientException {
+ try {
+ return doRequest(request);
+ } catch (MalformedURLException e) {
+ throw new DeltaCloudClientException(MessageFormat.format(
+ "Could not connect to \"{0}\". The url is invalid.", request.getUrlString()), e);
+ } catch(DeltaCloudClientException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new DeltaCloudClientException(e);
+ }
+ }
+
+ protected abstract InputStream doRequest(DeltaCloudRequest request) throws Exception;
+
+ protected void throwOnHttpErrors(int statusCode, String statusMessage, URL requestUrl)
+ throws DeltaCloudClientException {
+ if (HttpStatusCode.OK.isStatus(statusCode)) {
+ return;
+ } else if (HttpStatusCode.UNAUTHORIZED.isStatus(statusCode)) {
+ throw new DeltaCloudAuthClientException(
+ MessageFormat.format("The server reported an authorization error \"{0}\" on requesting \"{1}\"",
+ statusMessage, requestUrl));
+ } else if (HttpStatusCode.NOT_FOUND.isStatus(statusCode)) {
+ throw new DeltaCloudNotFoundClientException(MessageFormat.format(
+ "The server could not find the resource \"{0}\"",
+ requestUrl));
+ } else if (HttpStatusRange.CLIENT_ERROR.isInRange(statusCode)
+ || HttpStatusRange.SERVER_ERROR.isInRange(statusCode)) {
+ throw new DeltaCloudClientException(
+ MessageFormat.format("The server reported an error \"{0}\" on requesting \"{1}\"",
+ statusMessage, requestUrl));
+ }
+ }
+
+ protected String getUsername() {
+ return username;
+ }
+
+ protected String getPassword() {
+ return password;
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/Base64Coder.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/Base64Coder.java
new file mode 100644
index 0000000..16f5b46
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/Base64Coder.java
@@ -0,0 +1,226 @@
+// Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
+// www.source-code.biz, www.inventec.ch/chdh
+//
+// This module is multi-licensed and may be used under the terms
+// of any of the following licenses:
+//
+// EPL, Eclipse Public License, V1.0 or later, http://www.eclipse.org/legal
+// LGPL, GNU Lesser General Public License, V2.1 or later, http://www.gnu.org/licenses/lgpl.html
+// GPL, GNU General Public License, V2 or later, http://www.gnu.org/licenses/gpl.html
+// AL, Apache License, V2.0 or later, http://www.apache.org/licenses
+// BSD, BSD License, http://www.opensource.org/licenses/bsd-license.php
+//
+// Please contact the author if you need another license.
+// This module is provided "as is", without warranties of any kind.
+
+package org.apache.deltacloud.client.transport;
+
+/**
+* A Base64 encoder/decoder.
+*
+* <p>
+* This class is used to encode and decode data in Base64 format as described in RFC 1521.
+*
+* <p>
+* Project home page: <a href="http://www.source-code.biz/base64coder/java/">www.source-code.biz/base64coder/java</a><br>
+* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
+* Multi-licensed: EPL / LGPL / GPL / AL / BSD.
+*/
+public class Base64Coder {
+
+// The line separator string of the operating system.
+private static final String systemLineSeparator = System.getProperty("line.separator");
+
+// Mapping table from 6-bit nibbles to Base64 characters.
+private static char[] map1 = new char[64];
+ static {
+ int i=0;
+ for (char c='A'; c<='Z'; c++) map1[i++] = c;
+ for (char c='a'; c<='z'; c++) map1[i++] = c;
+ for (char c='0'; c<='9'; c++) map1[i++] = c;
+ map1[i++] = '+'; map1[i++] = '/'; }
+
+// Mapping table from Base64 characters to 6-bit nibbles.
+private static byte[] map2 = new byte[128];
+ static {
+ for (int i=0; i<map2.length; i++) map2[i] = -1;
+ for (int i=0; i<64; i++) map2[map1[i]] = (byte)i; }
+
+/**
+* Encodes a string into Base64 format.
+* No blanks or line breaks are inserted.
+* @param s A String to be encoded.
+* @return A String containing the Base64 encoded data.
+*/
+public static String encodeString (String s) {
+ return new String(encode(s.getBytes())); }
+
+/**
+* Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters.
+* This method is compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
+* @param in An array containing the data bytes to be encoded.
+* @return A String containing the Base64 encoded data, broken into lines.
+*/
+public static String encodeLines (byte[] in) {
+ return encodeLines(in, 0, in.length, 76, systemLineSeparator); }
+
+/**
+* Encodes a byte array into Base 64 format and breaks the output into lines.
+* @param in An array containing the data bytes to be encoded.
+* @param iOff Offset of the first byte in <code>in</code> to be processed.
+* @param iLen Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>.
+* @param lineLen Line length for the output data. Should be a multiple of 4.
+* @param lineSeparator The line separator to be used to separate the output lines.
+* @return A String containing the Base64 encoded data, broken into lines.
+*/
+public static String encodeLines (byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
+ int blockLen = (lineLen*3) / 4;
+ if (blockLen <= 0) throw new IllegalArgumentException();
+ int lines = (iLen+blockLen-1) / blockLen;
+ int bufLen = ((iLen+2)/3)*4 + lines*lineSeparator.length();
+ StringBuilder buf = new StringBuilder(bufLen);
+ int ip = 0;
+ while (ip < iLen) {
+ int l = Math.min(iLen-ip, blockLen);
+ buf.append (encode(in, iOff+ip, l));
+ buf.append (lineSeparator);
+ ip += l; }
+ return buf.toString(); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in An array containing the data bytes to be encoded.
+* @return A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in) {
+ return encode(in, 0, in.length); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in An array containing the data bytes to be encoded.
+* @param iLen Number of bytes to process in <code>in</code>.
+* @return A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in, int iLen) {
+ return encode(in, 0, iLen); }
+
+/**
+* Encodes a byte array into Base64 format.
+* No blanks or line breaks are inserted in the output.
+* @param in An array containing the data bytes to be encoded.
+* @param iOff Offset of the first byte in <code>in</code> to be processed.
+* @param iLen Number of bytes to process in <code>in</code>, starting at <code>iOff</code>.
+* @return A character array containing the Base64 encoded data.
+*/
+public static char[] encode (byte[] in, int iOff, int iLen) {
+ int oDataLen = (iLen*4+2)/3; // output length without padding
+ int oLen = ((iLen+2)/3)*4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int i2 = ip < iEnd ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '='; op++;
+ out[op] = op < oDataLen ? map1[o3] : '='; op++; }
+ return out; }
+
+/**
+* Decodes a string from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param s A Base64 String to be decoded.
+* @return A String containing the decoded data.
+* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static String decodeString (String s) {
+ return new String(decode(s)); }
+
+/**
+* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.
+* CR, LF, Tab and Space characters are ignored in the input data.
+* This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
+* @param s A Base64 String to be decoded.
+* @return An array containing the decoded data bytes.
+* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decodeLines (String s) {
+ char[] buf = new char[s.length()];
+ int p = 0;
+ for (int ip = 0; ip < s.length(); ip++) {
+ char c = s.charAt(ip);
+ if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
+ buf[p++] = c; }
+ return decode(buf, 0, p); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param s A Base64 String to be decoded.
+* @return An array containing the decoded data bytes.
+* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (String s) {
+ return decode(s.toCharArray()); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param in A character array containing the Base64 encoded data.
+* @return An array containing the decoded data bytes.
+* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (char[] in) {
+ return decode(in, 0, in.length); }
+
+/**
+* Decodes a byte array from Base64 format.
+* No blanks or line breaks are allowed within the Base64 encoded input data.
+* @param in A character array containing the Base64 encoded data.
+* @param iOff Offset of the first character in <code>in</code> to be processed.
+* @param iLen Number of characters to process in <code>in</code>, starting at <code>iOff</code>.
+* @return An array containing the decoded data bytes.
+* @throws IllegalArgumentException If the input is not valid Base64 encoded data.
+*/
+public static byte[] decode (char[] in, int iOff, int iLen) {
+ if (iLen%4 != 0) throw new IllegalArgumentException ("Length of Base64 encoded input string is not a multiple of 4.");
+ while (iLen > 0 && in[iOff+iLen-1] == '=') iLen--;
+ int oLen = (iLen*3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = iOff;
+ int iEnd = iOff + iLen;
+ int op = 0;
+ while (ip < iEnd) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iEnd ? in[ip++] : 'A';
+ int i3 = ip < iEnd ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+ throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+ throw new IllegalArgumentException ("Illegal character in Base64 encoded data.");
+ int o0 = ( b0 <<2) | (b1>>>4);
+ int o1 = ((b1 & 0xf)<<4) | (b2>>>2);
+ int o2 = ((b2 & 3)<<6) | b3;
+ out[op++] = (byte)o0;
+ if (op<oLen) out[op++] = (byte)o1;
+ if (op<oLen) out[op++] = (byte)o2; }
+ return out; }
+
+// Dummy constructor.
+private Base64Coder() {}
+
+} // end class Base64Coder
\ No newline at end of file
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/IHttpTransport.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/IHttpTransport.java
new file mode 100644
index 0000000..920ae5d
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/IHttpTransport.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.transport;
+
+import java.io.InputStream;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+
+/**
+ * An interface for http transport implementation to be used by the
+ * DeltaCloudClient.
+ *
+ * @author André Dietisheim
+ * @see URLConnectionTransport
+ */
+public interface IHttpTransport {
+
+ public InputStream request(DeltaCloudRequest request) throws DeltaCloudClientException;
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/URLConnectionTransport.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/URLConnectionTransport.java
new file mode 100644
index 0000000..fe67e79
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/transport/URLConnectionTransport.java
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+package org.apache.deltacloud.client.transport;
+
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.Authenticator;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.text.MessageFormat;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.deltacloud.client.DeltaCloudNotFoundClientException;
+import org.apache.deltacloud.client.HttpMethod;
+import org.apache.deltacloud.client.request.DeltaCloudRequest;
+
+public class URLConnectionTransport extends AbstractHttpTransport {
+
+ private static final char USERNAME_PASSWORD_DELIMITER = ':';
+ private static final String PROPERTY_AUTHORIZATION = "Authorization";
+ private static final String PROPERTY_ACCEPT = "Accept";
+ private static final String PREFIX_BASIC_AUTHENTICATION = "Basic ";
+ private static final int TIMEOUT = 10 * 1024;
+
+ public URLConnectionTransport(String username, String password) {
+ super(username, password);
+ }
+
+ @Override
+ protected InputStream doRequest(DeltaCloudRequest request) throws Exception {
+ HttpURLConnection connection = null;
+ try {
+ URL url = request.getUrl();
+ connection = (HttpURLConnection) url.openConnection();
+ connection.setUseCaches(false);
+ connection.setDoInput(true);
+ connection.setAllowUserInteraction(false);
+ connection.setConnectTimeout(TIMEOUT);
+ connection.setRequestProperty(PROPERTY_ACCEPT, "application/xml;q=1");
+ connection.setInstanceFollowRedirects(true);
+ addCredentials(connection);
+ setRequestMethod(request, connection);
+ BufferedInputStream in = new BufferedInputStream(connection.getInputStream());
+// return StreamUtils.writeTo(in, System.err);
+ return in; } catch (FileNotFoundException e) {
+ /*
+ * thrown by #connect when server resonds with 404
+ */
+ throw new DeltaCloudNotFoundClientException(
+ MessageFormat.format("Could not find resource {0}", request.getUrlString()));
+ } catch (IOException e) {
+ /*
+ * thrown by #connect when server resonds with 401.
+ */
+ HttpError httpError = HttpError.getInstance(e, connection);
+ if (httpError != null) {
+ throwOnHttpErrors(httpError.getStatusCode(), httpError.getStatusMessage(), request.getUrl());
+ }
+ throw e;
+ }
+
+ }
+
+ private void setRequestMethod(DeltaCloudRequest request, HttpURLConnection connection) throws IOException {
+ HttpMethod httpMethod = request.getHttpMethod();
+ connection.setRequestMethod(httpMethod.name());
+ switch (httpMethod) {
+ case PUT:
+ case POST:
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
+ connection.setRequestProperty("Content-Length", "0");// String.valueOf(request.getParametersLength()));
+ connection.setDoOutput(true);
+ connection.getOutputStream().flush();
+ break;
+ case GET:
+ connection.setDoOutput(false);
+ break;
+ }
+
+ }
+
+ /**
+ * Adds the credentials to the given http url connection.
+ *
+ * The current implementation uses low level API. Alternatively
+ * {@link Authenticator#setDefault(Authenticator)} could be used which would
+ * then rule all url connections in the same jvm.
+ *
+ * @param httpClient
+ * the http client
+ * @return the default http client
+ * @throws IOException
+ */
+ private void addCredentials(URLConnection urlConnection) throws IOException {
+ String username = getUsername();
+ String password = getPassword();
+ if (username != null && password != null) {
+ String credentials = new StringBuilder()
+ .append(PREFIX_BASIC_AUTHENTICATION)
+ .append(getAuthenticationValue(username, password))
+ .toString();
+ urlConnection.setRequestProperty(PROPERTY_AUTHORIZATION, credentials);
+ }
+
+ }
+
+ private String getAuthenticationValue(String username, String password) throws IOException {
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ out.write(username.getBytes());
+ out.write(USERNAME_PASSWORD_DELIMITER);
+ out.write(password.getBytes());
+ char[] encoded = Base64Coder.encode(out.toByteArray());
+ return new String(encoded);
+ }
+
+ private static final class HttpError {
+
+ private static final Pattern STATUS_REGEX = Pattern.compile(".+ HTTP response code: ([0-9]{3}) .+");
+ private int statusCode;
+ private String statusMessage;
+
+ private HttpError(int statusCode, String statusMessage) {
+ this.statusCode = statusCode;
+ this.statusMessage = statusMessage;
+ }
+
+ public static HttpError getInstance(IOException ioe, HttpURLConnection connection) throws IOException {
+ HttpError httpError = null;
+ try {
+ int statusCode = getStatusCode(ioe);
+ if (statusCode > -1) {
+ String statusMessage = connection.getResponseMessage();
+ httpError = new HttpError(statusCode, statusMessage);
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ return httpError;
+ }
+
+ public String getStatusMessage() {
+ return statusMessage;
+ }
+
+ private static int getStatusCode(IOException e) {
+ Matcher matcher = STATUS_REGEX.matcher(e.getMessage());
+ if (matcher.matches()) {
+ return getStatusCode(matcher.group(1));
+ }
+ return -1;
+ }
+
+ private static int getStatusCode(String statusCode) {
+ try {
+ return Integer.parseInt(statusCode);
+ } catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/APIUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/APIUnmarshaller.java
new file mode 100644
index 0000000..f15ec5f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/APIUnmarshaller.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.API;
+import org.w3c.dom.Element;
+
+/**
+ * @author André Dietisheim
+ */
+public class APIUnmarshaller extends AbstractDOMUnmarshaller<API> {
+
+ public APIUnmarshaller() {
+ super("api", API.class);
+ }
+
+ protected API doUnmarshall(Element element, API server) throws Exception {
+ if (element != null) {
+ server.setDriver(getAttributeText("driver", element));
+ }
+ return server;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractActionAwareUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractActionAwareUnmarshaller.java
new file mode 100644
index 0000000..976bb4b
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractActionAwareUnmarshaller.java
@@ -0,0 +1,69 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ *
+ * @param <DELTACLOUDOBJECT>
+ */
+public abstract class AbstractActionAwareUnmarshaller<DELTACLOUDOBJECT> extends AbstractDOMUnmarshaller<DELTACLOUDOBJECT>{
+
+ private String actionElementName;
+ public AbstractActionAwareUnmarshaller(String tagName, Class<DELTACLOUDOBJECT> type, String actionElementName) {
+ super(tagName, type);
+ this.actionElementName = actionElementName;
+ }
+
+ protected List<Action<DELTACLOUDOBJECT>> getActions(Element element, DELTACLOUDOBJECT owner) throws DeltaCloudClientException {
+ if (element == null) {
+ return null;
+ }
+ List<Action<DELTACLOUDOBJECT>> actions = new ArrayList<Action<DELTACLOUDOBJECT>>();
+ NodeList nodeList = element.getElementsByTagName(actionElementName);
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node linkNode = nodeList.item(i);
+ Action<DELTACLOUDOBJECT> action = createAction(linkNode);
+ if (action != null) {
+ action.setOwner(owner);
+ actions.add(action);
+ }
+ }
+ return actions;
+ }
+
+ protected Action<DELTACLOUDOBJECT> createAction(Node node) throws DeltaCloudClientException {
+ if (!(node instanceof Element)) {
+ return null;
+ }
+ return unmarshallAction((Element) node);
+ }
+
+ protected abstract Action<DELTACLOUDOBJECT> unmarshallAction(Element element) throws DeltaCloudClientException;
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDOMUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDOMUnmarshaller.java
new file mode 100644
index 0000000..933f190
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDOMUnmarshaller.java
@@ -0,0 +1,135 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author André Dietisheim
+ *
+ * @param <DELTACLOUDOBJECT>
+ */
+public abstract class AbstractDOMUnmarshaller<DELTACLOUDOBJECT> {
+
+ private Class<DELTACLOUDOBJECT> type;
+ private String tagName;
+
+ public AbstractDOMUnmarshaller(String tagName, Class<DELTACLOUDOBJECT> type) {
+ this.type = type;
+ this.tagName = tagName;
+ }
+
+ public DELTACLOUDOBJECT unmarshall(InputStream inputStream, DELTACLOUDOBJECT deltacloudObject) throws DeltaCloudClientException {
+ try {
+ Element element = getFirstElement(tagName, getDocument(inputStream));
+ if (element == null) {
+ return null;
+ }
+ return unmarshall(element, deltacloudObject);
+ } catch (Exception e) {
+ // TODO: internationalize strings
+ throw new DeltaCloudClientException(
+ MessageFormat.format("Could not unmarshall type \"{0}\"", type), e);
+ }
+
+ }
+
+ protected Document getDocument(InputStream inputStream) throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder documentBuilder = factory.newDocumentBuilder();
+ return documentBuilder.parse(inputStream);
+ }
+
+ public DELTACLOUDOBJECT unmarshall(Element element, DELTACLOUDOBJECT resource) throws DeltaCloudClientException {
+ try {
+ return doUnmarshall(element, resource);
+ } catch (Exception e) {
+ // TODO: internationalize strings
+ throw new DeltaCloudClientException(
+ MessageFormat.format("Could not unmarshall type \"{0}\"", type), e);
+ }
+ }
+
+ protected abstract DELTACLOUDOBJECT doUnmarshall(Element element, DELTACLOUDOBJECT resource) throws Exception;
+
+ protected String getFirstElementAttributeText(String elementName, String attributeId, Element element) {
+ Element firstElement = getFirstElement(elementName, element);
+ if (firstElement == null) {
+ return null;
+ }
+ return firstElement.getAttribute(attributeId);
+ }
+
+ protected String getFirstElementText(String elementName, Element element) {
+ Element firstElement = getFirstElement(elementName, element);
+ if (firstElement == null) {
+ return null;
+ }
+ return firstElement.getTextContent();
+ }
+
+ protected Element getFirstElement(String elementName, Element element) {
+ NodeList elements = element.getElementsByTagName(elementName);
+ if (elements != null
+ && elements.getLength() > 0) {
+ return (Element) elements.item(0);
+ }
+ return null;
+ }
+
+ protected Element getFirstElement(String elementName, Document document) {
+ NodeList elements = document.getElementsByTagName(elementName);
+ if (elements != null
+ && elements.getLength() > 0) {
+ return (Element) elements.item(0);
+ }
+ return null;
+ }
+
+ protected String getAttributeText(String attributeName, Element element) {
+ Node attribute = element.getAttributeNode(attributeName);
+ if (attribute != null) {
+ return attribute.getTextContent();
+ }
+ return null;
+ }
+
+ protected String stripText(String textContent) {
+ if (textContent == null || textContent.length() == 0) {
+ return textContent;
+ }
+ return textContent.trim();
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectUnmarshaller.java
new file mode 100644
index 0000000..a328577
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectUnmarshaller.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.io.InputStream;
+import java.text.MessageFormat;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+
+/**
+ * @author André Dietisheim
+ *
+ * @param <RESOURCE>
+ */
+public abstract class AbstractDeltaCloudObjectUnmarshaller<RESOURCE> implements IDeltaCloudObjectUnmarshaller<RESOURCE> {
+
+ private Class<RESOURCE> type;
+
+ public AbstractDeltaCloudObjectUnmarshaller(Class<RESOURCE> type) {
+ this.type = type;
+ }
+
+ public RESOURCE create(InputStream inputStream) throws DeltaCloudClientException {
+
+ try {
+ return doCreate(inputStream);
+ } catch (Exception e) {
+ // TODO: internationalize strings
+ throw new DeltaCloudClientException(
+ MessageFormat.format("Could not unmarshall resource of type \"{0}\"", type), e);
+ }
+ }
+
+ protected abstract RESOURCE doCreate(InputStream inputStream) throws Exception;
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
new file mode 100644
index 0000000..25e872b
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/AbstractDeltaCloudObjectsUnmarshaller.java
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.util.List;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ */
+@SuppressWarnings("rawtypes")
+public abstract class AbstractDeltaCloudObjectsUnmarshaller<CHILD> extends AbstractDOMUnmarshaller<List> {
+
+ private String childTag;
+
+ public AbstractDeltaCloudObjectsUnmarshaller(String parentTag, String childTag) {
+ super(parentTag, List.class);
+ this.childTag = childTag;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected List doUnmarshall(Element element, List children) throws Exception {
+ if (element != null) {
+ NodeList nodeList = element.getElementsByTagName(childTag);
+ if (nodeList != null
+ && nodeList.getLength() > 0) {
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (node instanceof Element) {
+ CHILD child = unmarshallChild(node);
+ children.add(child);
+ }
+ }
+ }
+ }
+ return children;
+ }
+
+ protected abstract CHILD unmarshallChild(Node node) throws DeltaCloudClientException;
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ActionUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ActionUnmarshaller.java
new file mode 100644
index 0000000..5f0c031
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ActionUnmarshaller.java
@@ -0,0 +1,44 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.Action;
+import org.w3c.dom.Element;
+
+/**
+ * @author André Dietisheim
+ */
+public class ActionUnmarshaller<OWNER> extends AbstractDOMUnmarshaller<Action<OWNER>> {
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public ActionUnmarshaller() {
+ super("link", (Class) Action.class);
+ }
+
+ @Override
+ protected Action<OWNER> doUnmarshall(Element element, Action<OWNER> action) throws Exception {
+ if (element != null) {
+ action.setMethod(getAttributeText("method", element));
+ action.setName(getAttributeText("rel", element));
+ action.setUrl(getAttributeText("href", element));
+ }
+ return action;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfileUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfileUnmarshaller.java
new file mode 100644
index 0000000..1f01edf
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfileUnmarshaller.java
@@ -0,0 +1,106 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.HardwareProfile;
+import org.apache.deltacloud.client.Property;
+import org.apache.deltacloud.client.Property.Kind;
+import org.apache.deltacloud.client.utils.Assert;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfileUnmarshaller extends
+ AbstractDOMUnmarshaller<HardwareProfile> {
+
+ public HardwareProfileUnmarshaller() {
+ super("hardware_profile", HardwareProfile.class);
+ }
+
+ @Override
+ protected HardwareProfile doUnmarshall(Element element,
+ HardwareProfile profile) throws Exception {
+ profile.setId(getAttributeText("id", element));
+ profile.setProperties(createProperties(element
+ .getElementsByTagName("property")));
+ return profile;
+ }
+
+ private List<Property> createProperties(NodeList propertiesList) {
+ List<Property> properties = new ArrayList<Property>();
+ for (int i = 0; i < propertiesList.getLength(); i++) {
+ Property property = createProperty(propertiesList.item(i));
+ properties.add(property);
+ }
+ return properties;
+ }
+
+ private Property createProperty(Node node) {
+ Assert.isTrue(node instanceof Element);
+ Element element = (Element) node;
+ Property property = new Property();
+ property.setName(element.getAttribute("name"));
+ property.setId(element.getAttribute("id"));
+ property.setUnit(element.getAttribute("unit"));
+ property.setValue(element.getAttribute("value"));
+ String kind = element.getAttribute("kind");
+ Assert.isTrue(kind != null);
+ kind = kind.toUpperCase();
+ property.setKind(kind);
+ if (Kind.RANGE.toString().equals(property.getKind())) {
+ setRange(element, property);
+ } else if (Kind.ENUM.toString().equals(property.getKind())) {
+ setEnum(element, property);
+ } else if (Kind.FIXED.toString().equals(property.getKind())) {
+ // no special treatement
+ }
+ return property;
+ }
+
+ private void setRange(Element propertyElement, Property property) {
+ Node node = propertyElement.getElementsByTagName("range").item(0);
+ Assert.isTrue(node instanceof Element);
+ Element rangeElement = (Element) node;
+ property.setRange(rangeElement.getAttribute("first"),
+ rangeElement.getAttribute("last"));
+ }
+
+ private void setEnum(Element propertyElement, Property property) {
+ Node node = propertyElement.getElementsByTagName("enum").item(0);
+ Assert.isTrue(node instanceof Element);
+ Element enumElement = (Element) node;
+ NodeList nodeList = enumElement.getElementsByTagName("entry");
+ ArrayList<String> enumValues = new ArrayList<String>();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node entryNode = nodeList.item(i);
+ Assert.isTrue(entryNode instanceof Element);
+ Element entryElement = (Element) entryNode;
+ enumValues.add(entryElement.getAttribute("value"));
+ }
+ property.setEnums(enumValues);
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfilesUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfilesUnmarshaller.java
new file mode 100644
index 0000000..fbbee3d
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/HardwareProfilesUnmarshaller.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.HardwareProfile;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class HardwareProfilesUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<HardwareProfile> {
+
+ public HardwareProfilesUnmarshaller() {
+ super("hardware_profiles", "hardware_profile");
+ }
+
+ @Override
+ protected HardwareProfile unmarshallChild(Node node) throws DeltaCloudClientException {
+ return new HardwareProfileUnmarshaller().unmarshall((Element) node, new HardwareProfile());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/IDeltaCloudObjectUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/IDeltaCloudObjectUnmarshaller.java
new file mode 100644
index 0000000..2db8b11
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/IDeltaCloudObjectUnmarshaller.java
@@ -0,0 +1,31 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.io.InputStream;
+
+/**
+ * @author André Dietisheim
+ */
+public interface IDeltaCloudObjectUnmarshaller<DELTACLOUDOBJECT> {
+
+ public DELTACLOUDOBJECT unmarshall(InputStream inputStream);
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImageUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImageUnmarshaller.java
new file mode 100644
index 0000000..205484d
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImageUnmarshaller.java
@@ -0,0 +1,42 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.Image;
+import org.w3c.dom.Element;
+
+/**
+ * @author André Dietisheim
+ */
+public class ImageUnmarshaller extends AbstractDOMUnmarshaller<Image> {
+
+ public ImageUnmarshaller() {
+ super("image", Image.class);
+ }
+
+ protected Image doUnmarshall(Element element, Image image) throws Exception {
+ image.setId(getAttributeText("id", element));
+ image.setName(getFirstElementText("name", element));
+ image.setOwnerId(getFirstElementText("owner_id", element));
+ image.setDescription(getFirstElementText("description", element));
+ image.setArchitecture(getFirstElementText("architecture", element));
+ return image;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImagesUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImagesUnmarshaller.java
new file mode 100644
index 0000000..22a1df2
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/ImagesUnmarshaller.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Image;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class ImagesUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<Image> {
+
+ public ImagesUnmarshaller() {
+ super("images", "image");
+ }
+
+ @Override
+ protected Image unmarshallChild(Node node) throws DeltaCloudClientException {
+ Image image = new ImageUnmarshaller().unmarshall((Element) node, new Image());
+ return image;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstanceUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstanceUnmarshaller.java
new file mode 100644
index 0000000..8f7cb82
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstanceUnmarshaller.java
@@ -0,0 +1,96 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.AddressList;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Instance;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstanceUnmarshaller extends AbstractActionAwareUnmarshaller<Instance> {
+
+ public InstanceUnmarshaller() {
+ super("instance", Instance.class, "link");
+ }
+
+ protected Instance doUnmarshall(Element element, Instance instance) throws Exception {
+ instance.setId(getAttributeText("id", element));
+ instance.setName(getFirstElementText("name", element));
+ instance.setOwnerId(getFirstElementText("owner_id", element));
+ instance.setOwnerId(getFirstElementText("owner_id", element));
+ instance.setImageId(getFirstElementAttributeText("image", "id", element));
+ instance.setProfileId(getFirstElementAttributeText("hardware_profile", "id", element));
+ instance.setRealmId(getFirstElementAttributeText("realm", "id", element));
+ instance.setState(getFirstElementText("state", element));
+ setKeyname(instance, element);
+ instance.setActions(getActions(element, instance));
+ instance.setPublicAddresses(getAddressList("public_addresses", element));
+ instance.setPrivateAddresses(getAddressList("private_addresses", element));
+ return instance;
+ }
+
+ private AddressList getAddressList(String elementName, Element element) {
+ Element addressElement = getFirstElement(elementName, element);
+ if (addressElement != null) {
+ NodeList addressList = addressElement.getChildNodes();
+ if (addressList != null) {
+ List<String> addresses = new ArrayList<String>();
+ for (int i = 0; i < addressList.getLength(); i++) {
+ Node addressNode = addressList.item(i);
+ if (addressNode != null) {
+ String address = stripText(addressNode.getTextContent());
+ if (address != null && address.length() > 0) {
+ addresses.add(address);
+ }
+ }
+ }
+ return new AddressList(addresses);
+ }
+ }
+ return new AddressList();
+ }
+
+ private void setKeyname(Instance instance, Element element) {
+ Element authenticationElement = getFirstElement("authentication", element);
+ if (authenticationElement != null) {
+ Element loginElement = getFirstElement("login", authenticationElement);
+ if (loginElement != null) {
+ String keyname = getFirstElementText("keyname", loginElement);
+ instance.setKeyId(keyname);
+ }
+ }
+ }
+
+ @Override
+ protected Action<Instance> unmarshallAction(Element element) throws DeltaCloudClientException {
+ Action<Instance> action = new Action<Instance>();
+ new ActionUnmarshaller<Instance>().unmarshall(element, action);
+ return action;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstancesUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstancesUnmarshaller.java
new file mode 100644
index 0000000..7ec4598
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/InstancesUnmarshaller.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Instance;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class InstancesUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<Instance> {
+
+ public InstancesUnmarshaller() {
+ super("instances", "instance");
+ }
+
+ @Override
+ protected Instance unmarshallChild(Node node) throws DeltaCloudClientException {
+ Instance instance = new InstanceUnmarshaller().unmarshall((Element) node, new Instance());
+ return instance;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeyUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeyUnmarshaller.java
new file mode 100644
index 0000000..78d75b2
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeyUnmarshaller.java
@@ -0,0 +1,85 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.apache.deltacloud.client.Action;
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Key;
+import org.w3c.dom.Element;
+
+/**
+ * @author André Dietisheim
+ */
+public class KeyUnmarshaller extends AbstractActionAwareUnmarshaller<Key> {
+
+ public KeyUnmarshaller() {
+ super("key", Key.class, "link");
+ }
+
+ protected Key doUnmarshall(Element element, Key key) throws Exception {
+ if (element != null) {
+ key.setId(getAttributeText("id", element));
+ key.setUrl(getAttributeText("href", element));
+ key.setState(getFirstElementText("state", element));
+ key.setFingerprint(getFirstElementText("fingerprint", element));
+ key.setPem(trimPem(getPem(element))); //$NON-NLS-1$
+ key.setActions(getActions(element, key));
+ }
+ return key;
+ }
+
+ private String getPem(Element element) {
+ Element pemElement = getFirstElement("pem", element);
+ if (pemElement != null) {
+ return getFirstElementText("pem", pemElement);
+ }
+ return null;
+ }
+
+ private String trimPem(String pem) throws IOException {
+ if (pem == null
+ || pem.length() <= 0) {
+ return null;
+ }
+ StringBuffer sb = new StringBuffer();
+ String line = null;
+ BufferedReader reader = new BufferedReader(new StringReader(pem));
+ while ((line = reader.readLine()) != null) {
+ // We must trim off the white-space from the xml
+ // Complete white-space lines are to be ignored.
+ String trimmedLine = line.trim();
+ if (trimmedLine.length() > 0) {
+ sb.append(trimmedLine).append('\n');
+ }
+ }
+ return sb.toString();
+ }
+
+ @Override
+ protected Action<Key> unmarshallAction(Element element) throws DeltaCloudClientException {
+ Action<Key> keyAction = new Action<Key>();
+ new ActionUnmarshaller<Key>().unmarshall(element, keyAction);
+ return keyAction;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeysUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeysUnmarshaller.java
new file mode 100644
index 0000000..b2ab118
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/KeysUnmarshaller.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Key;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class KeysUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<Key> {
+
+ public KeysUnmarshaller() {
+ super("keys", "key");
+ }
+
+ @Override
+ protected Key unmarshallChild(Node node) throws DeltaCloudClientException {
+ Key key = new KeyUnmarshaller().unmarshall((Element) node, new Key());
+ return key;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmUnmarshaller.java
new file mode 100644
index 0000000..814d49f
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmUnmarshaller.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.Realm;
+import org.w3c.dom.Element;
+
+/**
+ * @author André Dietisheim
+ */
+public class RealmUnmarshaller extends AbstractDOMUnmarshaller<Realm> {
+
+ public RealmUnmarshaller() {
+ super("realm", Realm.class);
+ }
+
+ protected Realm doUnmarshall(Element element, Realm realm) throws Exception {
+ realm.setId(getAttributeText("id", element));
+ realm.setName(getFirstElementText("name", element));
+ realm.setLimit(getFirstElementText("limit", element));
+ realm.setState(getFirstElementText("state", element));
+ return realm;
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmsUnmarshaller.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmsUnmarshaller.java
new file mode 100644
index 0000000..ef915df
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/unmarshal/RealmsUnmarshaller.java
@@ -0,0 +1,40 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.unmarshal;
+
+import org.apache.deltacloud.client.DeltaCloudClientException;
+import org.apache.deltacloud.client.Realm;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+/**
+ * @author André Dietisheim
+ */
+public class RealmsUnmarshaller extends AbstractDeltaCloudObjectsUnmarshaller<Realm> {
+
+ public RealmsUnmarshaller() {
+ super("realms", "realm");
+ }
+
+ @Override
+ protected Realm unmarshallChild(Node node) throws DeltaCloudClientException {
+ return new RealmUnmarshaller().unmarshall((Element) node, new Realm());
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/Assert.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/Assert.java
new file mode 100644
index 0000000..4055bf7
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/Assert.java
@@ -0,0 +1,41 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.utils;
+
+/**
+ * Various assertion utility methods.
+ *
+ * @author André Dietisheim
+ */
+public class Assert {
+
+ public static void isValidArgument(boolean assertionResult) {
+ if (!assertionResult) {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ public static void isTrue(boolean assertionResult) {
+ if (!assertionResult) {
+ throw new AssertionError();
+ }
+ }
+
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StreamUtils.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StreamUtils.java
new file mode 100644
index 0000000..dcfaf69
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StreamUtils.java
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.utils;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+
+public class StreamUtils {
+
+ /**
+ * Writes the content of the given input stream to the given output stream
+ * and returns and input stream that may still be used to read from.
+ *
+ * @param outputStream the output stream to write to
+ * @param inputStream the input stream to read from
+ * @return a new, unread input stream
+ * @throws IOException
+ */
+ public static InputStream writeTo(InputStream inputStream, OutputStream outputStream) throws IOException {
+ List<Byte> data = new ArrayList<Byte>();
+ for (int character = -1; (character = inputStream.read()) != -1;) {
+ data.add((byte) character);
+ outputStream.write(character);
+ }
+ byte[] byteArray = new byte[data.size()];
+ for (int i = byteArray.length - 1; i >= 0; i--) {
+ byteArray[i] = data.get(i);
+ }
+ return new ByteArrayInputStream(byteArray);
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StringUtils.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StringUtils.java
new file mode 100644
index 0000000..3f4cc67
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/StringUtils.java
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.utils;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class StringUtils {
+
+ /**
+ * Returns a formatted string for a collection of elements that get
+ * formatted by a user supplied element formatter.
+ *
+ * @param elements
+ * the elements to be processed
+ * @param elements
+ * the elements
+ * @param elementFormatter
+ * the formatter to apply on each element to be processed
+ * @return the formatted string
+ */
+ public static <E> String getFormattedString(Collection<E> elements, IElementFormatter<E> elementFormatter) {
+ StringBuilder builder = new StringBuilder();
+ for (E element : elements) {
+ String formattedElement = elementFormatter.format(element);
+ if (formattedElement != null && formattedElement.length() > 0) {
+ builder.append(formattedElement);
+ }
+ }
+ if (builder.length() > 0) {
+ return builder.toString();
+ } else {
+ return "";
+ }
+ }
+
+ public interface IElementFormatter<E> {
+ public String format(E element);
+ }
+
+ /**
+ * Returns a collection of formatted strings for the given collection of
+ * elements and given formatter
+ *
+ * @param <E>
+ * the type of elements that shall be processed
+ * @param elements
+ * the elements to be processed
+ * @param elementFormatter
+ * the formatter to apply on each element to be processed
+ * @return the formatted strings
+ */
+ public static <E> Collection<String> getFormattedStrings(Collection<E> elements,
+ IElementFormatter<E> elementFormatter) {
+ List<String> strings = new ArrayList<String>();
+ for (E element : elements) {
+ String formattedElement = elementFormatter.format(element);
+ if (formattedElement != null && formattedElement.length() > 0) {
+ strings.add(formattedElement);
+ }
+ }
+ return strings;
+ }
+
+ public static String null2EmptyString(String stringValue) {
+ if (stringValue == null) {
+ return "";
+ }
+ return stringValue;
+ }
+
+ public static String emptyString2Null(String stringValue) {
+ if (stringValue != null
+ && stringValue.length() == 0) {
+ return null;
+ }
+ return stringValue;
+ }
+
+ public static boolean isEmpty(String stringValue) {
+ return stringValue == null || stringValue.isEmpty();
+ }
+
+
+ public static String toString(InputStream inputStream) throws IOException {
+ StringBuilder builder = new StringBuilder();
+ for(int character = -1; (character = inputStream.read()) != -1; ) {
+ builder.append((char) character);
+ }
+ return builder.toString();
+ }
+}
diff --git a/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/UrlBuilder.java b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/UrlBuilder.java
new file mode 100644
index 0000000..25b29f7
--- /dev/null
+++ b/clients/java/org.apache.deltacloud.client/src/org/apache/deltacloud/client/utils/UrlBuilder.java
@@ -0,0 +1,152 @@
+/*************************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership. The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************************/
+
+package org.apache.deltacloud.client.utils;
+
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.Collection;
+
+/**
+ * A builder for an url. Currently no state checking is done, the user is
+ * responsible to build something that makes sense.
+ *
+ * @author André Dietisheim
+ */
+public class UrlBuilder {
+ private static final String URL_ENCODING = "UTF-8";
+ private static final String HOST_PROTOCOL_DELIMITER = ":";
+ private static final String HTTP_PROTOCOL_PREFIX = "http://";
+ private static final char PARAMETER_URL_DELIMITER = '?';
+ private static final char PARAMETER_DELIMITER = '&';
+ private static final char PARAMETER_NAME_VALUE_DELIMITER = '=';
+ private static final char PATH_SEPARATOR = '/';
+
+ private StringBuilder urlStringBuilder = new StringBuilder();
+
+ private boolean parametersAdded = false;
+
+ public UrlBuilder() {
+ }
+
+ public UrlBuilder(String baseUrl) {
+ urlStringBuilder.append(baseUrl);
+ }
+
+ public UrlBuilder(URL baseUrl) {
+ urlStringBuilder.append(baseUrl.toString());
+ }
+
+ /**
+ * adds a host to .
+ *
+ * @param host
+ * the host
+ *
+ * @return the url builder
+ */
+ public UrlBuilder host(String host) {
+ urlStringBuilder.append(HTTP_PROTOCOL_PREFIX);
+ urlStringBuilder.append(host);
+ return this;
+ }
+
+ /**
+ * Adds a port.
+ *
+ * @param port
+ * the port
+ *
+ * @return the url builder
+ */
+ public UrlBuilder port(Object port) {
+ urlStringBuilder.append(HOST_PROTOCOL_DELIMITER);
+ urlStringBuilder.append(port);
+ return this;
+ }
+
+ /**
+ * adds a path to the url.
+ *
+ * @param path
+ * the path
+ *
+ * @return the url builder
+ */
+ public UrlBuilder path(String path) {
+ urlStringBuilder.append(PATH_SEPARATOR);
+ urlStringBuilder.append(path);
+ return this;
+ }
+
+ public UrlBuilder path(Collection<String> paths) {
+ for (String path : paths) {
+ path(path);
+ }
+ return this;
+ }
+
+ public UrlBuilder parameter(String name, String value) {
+ if (value != null) {
+ appendParameterDelimiter();
+ urlStringBuilder.append(name).append(PARAMETER_NAME_VALUE_DELIMITER).append(urlEncode(value));
+ }
+ return this;
+ }
+
+ private void appendParameterDelimiter() {
+ if (!parametersAdded) {
+ urlStringBuilder.append(PARAMETER_URL_DELIMITER);
+ parametersAdded = true;
+ } else {
+ urlStringBuilder.append(PARAMETER_DELIMITER);
+ }
+ }
+
+ public UrlBuilder parameters(String... parameters) {
+ for (String parameter : parameters) {
+ parameter(parameter);
+ }
+ return this;
+ }
+
+ public UrlBuilder parameter(String parameter) {
+ appendParameterDelimiter();
+ urlStringBuilder.append(urlEncode(parameter));
+ return this;
+ }
+
+ private String urlEncode(String value) {
+ try {
+ return URLEncoder.encode(value, URL_ENCODING);
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public URL toUrl() throws MalformedURLException {
+ return new URL(urlStringBuilder.toString());
+ }
+
+ public String toString() {
+ return urlStringBuilder.toString();
+ }
+}
--
1.7.3.4