Author: adietish
Date: 2010-12-22 19:16:12 -0500 (Wed, 22 Dec 2010)
New Revision: 27700
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
Log:
[JBIDE-7763] added methods to DeltaCloud to get all keys and to create a key on the
server
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-22 22:05:46
UTC (rev 27699)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2010-12-23 00:16:12
UTC (rev 27700)
@@ -1,3 +1,12 @@
+2010-12-23 adietisheim <adietisheim@adietisheim-thinkpad>
+
+ * 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 <adietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
(DeltaCloudClientImpl):
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-22
22:05:46 UTC (rev 27699)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloud.java 2010-12-23
00:16:12 UTC (rev 27700)
@@ -26,6 +26,7 @@
import org.jboss.tools.deltacloud.core.client.Image;
import org.jboss.tools.deltacloud.core.client.Instance;
import org.jboss.tools.deltacloud.core.client.InternalDeltaCloudClient;
+import org.jboss.tools.deltacloud.core.client.Key;
import org.jboss.tools.deltacloud.core.client.Realm;
import org.jboss.tools.internal.deltacloud.core.observable.ObservablePojo;
@@ -407,6 +408,20 @@
return deltaCloudImage;
}
+ public DeltaCloudKey[] getKeys() throws DeltaCloudException {
+ List<DeltaCloudKey> keys = new ArrayList<DeltaCloudKey>();
+ try {
+ for (Key key : client.listKeys()) {
+ DeltaCloudKey deltaCloudKey = new DeltaCloudKey(key, this);
+ keys.add(deltaCloudKey);
+ }
+ return keys.toArray(new DeltaCloudKey[] {});
+ } catch (DeltaCloudClientException e) {
+ // TODO: internationalize strings
+ throw new DeltaCloudException(MessageFormat.format("Cloud not get keys from cloud
\"{0}\"", getName()), e);
+ }
+ }
+
public void createKey(String keyname, String keystoreLocation) throws
DeltaCloudException {
try {
client.createKey(keyname, keystoreLocation);
@@ -415,6 +430,17 @@
}
}
+ public DeltaCloudKey createKey(String id) throws DeltaCloudException {
+ try {
+ Key key = client.createKey(id);
+ return new DeltaCloudKey(key, this);
+ } catch (DeltaCloudClientException e) {
+ // TODO: internationalize strings
+ throw new DeltaCloudException(
+ MessageFormat.format("Could not create key \"{0}\" on cloud
\"{1}\"", id, getName()), e);
+ }
+ }
+
public void deleteKey(String keyname) throws DeltaCloudException {
try {
client.deleteKey(keyname);
Added:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java
(rev 0)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java 2010-12-23
00:16:12 UTC (rev 27700)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.deltacloud.core;
+
+import org.jboss.tools.deltacloud.core.client.Key;
+
+/**
+ * @author André Dietisheim
+ */
+public class DeltaCloudKey extends AbstractDeltaCloudElement {
+
+ private Key key;
+
+ public DeltaCloudKey(Key key, DeltaCloud cloud) {
+ super(cloud);
+ this.key = key;
+ }
+
+ @Override
+ public String getName() {
+ return key.getId();
+ }
+
+ @Override
+ public String getId() {
+ return key.getId();
+ }
+
+ public String getFingerprint() {
+ return key.getFingerprint();
+ }
+
+ public String getPem() {
+ return key.getPem();
+ }
+}
Property changes on:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudKey.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java 2010-12-22
22:05:46 UTC (rev 27699)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/job/AbstractCloudElementJob.java 2010-12-23
00:16:12 UTC (rev 27700)
@@ -19,7 +19,7 @@
public abstract class AbstractCloudElementJob extends AbstractCloudJob {
public static enum CLOUDELEMENT {
- IMAGES, INSTANCES, PROFILES, REALMS
+ IMAGES, INSTANCES, PROFILES, REALMS, KEYS
}
private CLOUDELEMENT cloudElement;