Author: rob.stryker(a)jboss.com
Date: 2011-03-02 17:52:25 -0500 (Wed, 02 Mar 2011)
New Revision: 29453
Removed:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/API.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Action.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ActionAware.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/AddressList.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthClientException.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudNotFoundClientException.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpMethod.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusRange.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/IdAware.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Key.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Realm.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ResourceAction.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/StateAware.java
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/request/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/unmarshal/
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/utils/
Modified:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
Log:
JBIDE-7589 removing duplicate original client classes
Modified: trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/META-INF/MANIFEST.MF 2011-03-02
22:52:25 UTC (rev 29453)
@@ -7,14 +7,11 @@
Bundle-Vendor: Red Hat Inc.
Require-Bundle: org.jboss.tools.common;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.runtime,
- org.eclipse.equinox.security;bundle-version="[1.0.100,2.0.0)"
+ org.eclipse.equinox.security;bundle-version="[1.0.100,2.0.0)",
+ org.jboss.tools.deltacloud.client;bundle-version="0.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Export-Package:
org.jboss.tools.deltacloud.core;x-friends:="org.jboss.tools.deltacloud.ui,org.jboss.tools.deltacloud.test,org.jboss.tools.deltacloud.integration",
-
org.jboss.tools.deltacloud.core.client;x-friends:="org.jboss.tools.deltacloud.test,org.jboss.tools.deltacloud.ui",
-
org.jboss.tools.deltacloud.core.client.request;x-friends:="org.jboss.tools.deltacloud.test",
-
org.jboss.tools.deltacloud.core.client.unmarshal;x-friends:="org.jboss.tools.deltacloud.test",
- org.jboss.tools.deltacloud.core.client.utils,
org.jboss.tools.deltacloud.core.job,
org.jboss.tools.internal.deltacloud.core.observable;x-friends:="org.jboss.tools.deltacloud.ui"
Bundle-ClassPath: .,
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/API.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/API.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/API.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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() + "]";
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Action.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Action.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Action.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * 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.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());
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ActionAware.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ActionAware.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ActionAware.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-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 {
- return client.performAction(getAction(Action.START_NAME));
- }
-
- public boolean stop(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.STOP_NAME));
- }
-
- public boolean destroy(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.DESTROY_NAME));
- }
-
- public boolean reboot(DeltaCloudClient client) throws DeltaCloudClientException {
- return client.performAction(getAction(Action.REBOOT_NAME));
- }
-
- 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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/AddressList.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/AddressList.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/AddressList.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthClientException.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthClientException.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudAuthClientException.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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);
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClient.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-import java.util.List;
-
-import org.jboss.tools.deltacloud.core.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
- *
- * @see Action
- */
- public boolean performAction(Action<?> action) throws DeltaCloudClientException;
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientException.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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);
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudClientImpl.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.UnknownHostException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.jboss.tools.deltacloud.core.client.API.Driver;
-import org.jboss.tools.deltacloud.core.client.request.CreateInstanceRequest;
-import org.jboss.tools.deltacloud.core.client.request.CreateKeyRequest;
-import org.jboss.tools.deltacloud.core.client.request.DeltaCloudRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListHardwareProfileRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListHardwareProfilesRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListImageRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListImagesRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListInstanceRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListInstancesRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListKeyRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListKeysRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListRealmRequest;
-import org.jboss.tools.deltacloud.core.client.request.ListRealmsRequest;
-import org.jboss.tools.deltacloud.core.client.request.PerformActionRequest;
-import org.jboss.tools.deltacloud.core.client.request.TypeRequest;
-import org.jboss.tools.deltacloud.core.client.unmarshal.APIUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.HardwareProfileUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.HardwareProfilesUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.ImageUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.ImagesUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.InstanceUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.InstancesUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.KeyUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.KeysUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.RealmUnmarshaller;
-import org.jboss.tools.deltacloud.core.client.unmarshal.RealmsUnmarshaller;
-
-/**
- * @author Andre Dietisheim (based on prior implementation by Martyn Taylor)
- */
-public class DeltaCloudClientImpl implements DeltaCloudClient {
-
- private String baseUrl;
- private String username;
- private String password;
-
- public DeltaCloudClientImpl(String url) throws MalformedURLException,
- DeltaCloudClientException {
- this(url, null, null);
- }
-
- public DeltaCloudClientImpl(String url, String username, String password) throws
DeltaCloudClientException {
- this.baseUrl = url;
- this.username = username;
- this.password = password;
- }
-
- protected InputStream request(DeltaCloudRequest deltaCloudRequest)
- throws DeltaCloudClientException {
- DefaultHttpClient httpClient = new DefaultHttpClient();
- try {
- URL url = deltaCloudRequest.getUrl();
- addCredentials(url, httpClient, username, password);
- HttpUriRequest request = createRequest(deltaCloudRequest);
- HttpResponse httpResponse = httpClient.execute(request);
- throwOnHttpErrors(deltaCloudRequest.getUrl(), httpResponse);
- if (httpResponse.getEntity() == null) {
- return null;
- }
- return httpResponse.getEntity().getContent();
- } catch (DeltaCloudClientException e) {
- throw e;
- } catch (MalformedURLException e) {
- throw new DeltaCloudClientException(MessageFormat.format(
- "Could not connect to \"{0}\". The url is invalid.",
deltaCloudRequest.toString()), e);
- } catch (IOException e) {
- throw new DeltaCloudClientException(e);
- } catch (Exception e) {
- throw new DeltaCloudClientException(e);
- }
- }
-
- private void throwOnHttpErrors(URL requestUrl, HttpResponse httpResponse)
- throws DeltaCloudClientException {
- int statusCode = httpResponse.getStatusLine().getStatusCode();
- 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}\"",
- httpResponse.getStatusLine()
- .getReasonPhrase(), 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}\"",
- httpResponse.getStatusLine()
- .getReasonPhrase(), requestUrl));
- }
- }
-
- /**
- * Returns a request instance for the given request type and url.
- *
- * @param httpMethod
- * the request type to use
- * @param requestUrl
- * the requested url
- * @return the request instance
- * @throws MalformedURLException
- */
- protected HttpUriRequest createRequest(DeltaCloudRequest deltaCloudRequest)
- throws MalformedURLException {
- HttpUriRequest request = null;
- String url = deltaCloudRequest.getUrl().toString();
- HttpMethod httpMethod = deltaCloudRequest.getHttpMethod();
- switch (httpMethod) {
- case POST:
- request = new HttpPost(url);
- break;
- case DELETE:
- request = new HttpDelete(url);
- break;
- case GET:
- default:
- request = new HttpGet(url);
- }
- request.setHeader("Accept", "application/xml;q=1");
- return request;
- }
-
- /**
- * Adds the credentials to the given http client.
- *
- * @param httpClient
- * the http client
- * @return the default http client
- * @throws UnknownHostException
- */
- private DefaultHttpClient addCredentials(URL url,
- DefaultHttpClient httpClient, String username, String password)
- throws UnknownHostException {
- if (username != null && password != null) {
- httpClient.getCredentialsProvider().setCredentials(
- new AuthScope(url.getHost(), url.getPort()),
- new UsernamePasswordCredentials(username, password));
- }
- return httpClient;
- }
-
- 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 boolean performAction(Action<?> action) throws DeltaCloudClientException {
- if (action != null) {
- try {
- request(new PerformActionRequest(action.getUrl(), action.getMethod()));
- } catch (DeltaCloudClientException e) {
- throw e;
- } catch (Exception e) {
- throw new DeltaCloudClientException(e);
- }
- return true;
- }
- return false;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudNotFoundClientException.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudNotFoundClientException.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/DeltaCloudNotFoundClientException.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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);
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HardwareProfile.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.jboss.tools.deltacloud.core.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpMethod.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpMethod.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpMethod.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,15 +0,0 @@
-/*******************************************************************************
- * 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.client;
-
-public enum HttpMethod {
- GET, POST, PUT, DELETE, HEAD;
-}
\ No newline at end of file
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusCode.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * 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.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusRange.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusRange.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/HttpStatusRange.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * 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.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/IdAware.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/IdAware.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/IdAware.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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 + "]";
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Image.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Instance.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-import java.util.List;
-
-/**
- * @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
- 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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Key.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Key.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Key.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.client;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * @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
- public String toString() {
- return "Key [url=" + url + ", pem=" + pem + ",
fingerprint=" + fingerprint + ", state=" + state + ", actions="
- + getActions() + ", toString()=" + super.toString() + "]";
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Property.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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();
- }
- }
-
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Realm.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Realm.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/Realm.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 Red Hat Inc..
- * All rights reserved. This program and the accompanying materials
- * are 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 Incorporated - initial API and implementation
- *******************************************************************************/
-package org.jboss.tools.deltacloud.core.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;
- }
-}
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ResourceAction.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ResourceAction.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/ResourceAction.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * 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.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
Deleted:
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/StateAware.java
===================================================================
---
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/StateAware.java 2011-03-02
21:49:20 UTC (rev 29452)
+++
trunk/deltacloud/plugins/org.jboss.tools.deltacloud.core/src/org/jboss/tools/deltacloud/core/client/StateAware.java 2011-03-02
22:52:25 UTC (rev 29453)
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * 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.client;
-
-
-/**
- * @author André Dietisheim
- *
- * @param <OWNER>
- */
-public 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;
- }
-}