Author: adietish
Date: 2011-03-11 11:56:12 -0500 (Fri, 11 Mar 2011)
New Revision: 29709
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/ActionAware.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Instance.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Key.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/StateAware.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
Log:
[JBIDE-8565] refreshing instance and key after performing action
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/ChangeLog 2011-03-11
16:55:40 UTC (rev 29708)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/ChangeLog 2011-03-11
16:56:12 UTC (rev 29709)
@@ -1,3 +1,19 @@
+2011-03-11 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * 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 <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/core/DeltaCloudManager.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/ActionAware.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/ActionAware.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/ActionAware.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.core.client;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -43,21 +44,38 @@
}
public boolean start(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.START_NAME));
+ InputStream in = client.performAction(getAction(Action.START_NAME));
+ update(in);
+ return in != null;
}
public boolean stop(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.STOP_NAME));
+ InputStream in = client.performAction(getAction(Action.STOP_NAME));
+ update(in);
+ return in != null;
}
public boolean destroy(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.DESTROY_NAME));
+ InputStream in = client.performAction(getAction(Action.DESTROY_NAME));
+ return in != null;
}
public boolean reboot(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.REBOOT_NAME));
+ 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;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.core.client;
+import java.io.InputStream;
import java.util.List;
import org.jboss.tools.deltacloud.core.client.API.Driver;
@@ -154,8 +155,8 @@
*
* @param action the action to execute
* @return true, if successful
- *
+ * @throws DeltaCloudClientException the delta cloud client exception
* @see Action
*/
- public boolean performAction(Action<?> action) throws DeltaCloudClientException;
+ public InputStream performAction(Action<?> action) throws
DeltaCloudClientException;
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -87,7 +87,15 @@
if (httpResponse.getEntity() == null) {
return null;
}
- return httpResponse.getEntity().getContent();
+ InputStream in = httpResponse.getEntity().getContent();
+// StringWriter writer = new StringWriter();
+// int data = -1;
+//
+// while(((data = in.read()) != -1)) {
+// writer.write(data);
+// }
+// System.err.println(writer.toString());
+ return in;
} catch (DeltaCloudClientException e) {
throw e;
} catch (MalformedURLException e) {
@@ -332,17 +340,17 @@
return key;
}
- public boolean performAction(Action<?> action) throws DeltaCloudClientException {
+ public InputStream performAction(Action<?> action) throws
DeltaCloudClientException {
+ InputStream in = null;
if (action != null) {
try {
- request(new PerformActionRequest(action.getUrl(), action.getMethod()));
+ in = request(new PerformActionRequest(action.getUrl(), action.getMethod()));
} catch (DeltaCloudClientException e) {
throw e;
} catch (Exception e) {
throw new DeltaCloudClientException(e);
}
- return true;
}
- return false;
+ return in;
}
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Instance.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Instance.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Instance.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -10,8 +10,11 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.core.client;
+import java.io.InputStream;
import java.util.List;
+import org.jboss.tools.deltacloud.core.client.unmarshal.InstanceUnmarshaller;
+
/**
* @author Martyn Taylor
* @author Andre Dietisheim
@@ -134,6 +137,12 @@
}
@Override
+ protected void doUpdate(InputStream in) throws DeltaCloudClientException {
+ new InstanceUnmarshaller().unmarshall(in, this);
+ }
+
+
+ @Override
public String toString() {
String s = "";
s += "Instance:\t" + getId() + "\n";
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Key.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Key.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/Key.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -10,9 +10,12 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.core.client;
+import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
+import org.jboss.tools.deltacloud.core.client.unmarshal.KeyUnmarshaller;
+
/**
* @author Andre Dietisheim
*/
@@ -57,9 +60,13 @@
}
@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() + "]";
}
-
}
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/StateAware.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/StateAware.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.client/src/org/jboss/tools/deltacloud/core/client/StateAware.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -16,7 +16,7 @@
*
* @param <OWNER>
*/
-public class StateAware<OWNER> extends ActionAware<OWNER> {
+public abstract class StateAware<OWNER> extends ActionAware<OWNER> {
public static enum State {
RUNNING, STOPPED, PENDING, TERMINATED, BOGUS
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog
===================================================================
--- trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-03-11 16:55:40
UTC (rev 29708)
+++ trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/ChangeLog 2011-03-11 16:56:12
UTC (rev 29709)
@@ -1,3 +1,8 @@
+2011-03-11 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
+
+ * src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java (performAction):
+ [JBIDE-8565] refreshing instance and key after performing action
+
2011-03-09 André Dietisheim <André Dietisheim@adietisheim-thinkpad>
* src/org/jboss/tools/deltacloud/core/DeltaCloud.java
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java 2011-03-11
16:55:40 UTC (rev 29708)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/DeltaCloudInstance.java 2011-03-11
16:56:12 UTC (rev 29709)
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.jboss.tools.deltacloud.core;
+import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -39,7 +40,7 @@
BOGUS(Instance.State.BOGUS.name());
private String name;
-
+
private State(String name) {
this.name = name;
}
@@ -97,7 +98,7 @@
public String getKeyId() {
return instance.getKeyId();
}
-
+
public List<DeltaCloudResourceAction> getActions() {
List<DeltaCloudResourceAction> actions = new
ArrayList<DeltaCloudResourceAction>();
for (Action<Instance> action : instance.getActions()) {
@@ -145,7 +146,7 @@
public boolean isRunning() {
return instance.isRunning();
}
-
+
protected void setInstance(Instance instance) {
this.instance = instance;
}
@@ -165,7 +166,8 @@
if (instanceAction == null) {
return false;
}
- return client.performAction(instanceAction);
+ InputStream in = client.performAction(instanceAction);
+ return in != null;
}
@Override