mirror of https://github.com/apache/jclouds.git
Issue 280: started work converting to new error type in vcloud
This commit is contained in:
parent
7846b4e8b7
commit
3d5bfa7422
|
@ -0,0 +1,114 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jclouds.vcloud.domain;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import org.jclouds.vcloud.domain.internal.ErrorImpl;
|
||||
|
||||
import com.google.inject.ImplementedBy;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@ImplementedBy(ErrorImpl.class)
|
||||
public interface Error {
|
||||
public static enum MinorCode {
|
||||
/**
|
||||
* The request was made by a user who had insufficient rights to the object or operation.
|
||||
*/
|
||||
ACCESS_TO_RESOURCE_IS_FORBIDDEN,
|
||||
/**
|
||||
* The request could not be validated or contained invalid XML.
|
||||
*/
|
||||
BAD_REQUEST,
|
||||
/**
|
||||
* A conflict was detected between sections of an OVF descriptor.
|
||||
*/
|
||||
CONFLICT,
|
||||
/**
|
||||
* An attempt to instantiate a vAppTemplate or use a vAppTemplate or a Vm in a composition did
|
||||
* not include an AllEULAsAccepted element with a value of true.
|
||||
*/
|
||||
EULA_NOT_ACCEPTED,
|
||||
/**
|
||||
* Returned for any failure that cannot be matched to another minor error code.
|
||||
*/
|
||||
INTERNAL_SERVER_ERROR,
|
||||
/**
|
||||
* One or more references (href attribute values) supplied in the request could not be
|
||||
* resolved to an object.
|
||||
*/
|
||||
INVALID_REFERENCE,
|
||||
/**
|
||||
* The HTTP method (GET, PUT, POST, DELETE) is not allowed for the request.
|
||||
*/
|
||||
METHOD_NOT_ALLOWED,
|
||||
/**
|
||||
* One or more references (href attribute values) supplied in the request could not be
|
||||
* resolved to an object, or the Content‐type of the request was incorrect.
|
||||
*/
|
||||
RESOURCE_NOT_FOUND,
|
||||
/**
|
||||
* The request raised an exception that did not match any HTTP status code.
|
||||
*/
|
||||
UNKNOWN,
|
||||
/**
|
||||
* The wrong content type was specified for the request.
|
||||
*/
|
||||
UNSUPPORTED_MEDIA_TYPE;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return message describing the error
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return matches the HTTP status code
|
||||
*/
|
||||
int getMajorErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return error code specific to the failed operation or null if vcloud <0.9
|
||||
*/
|
||||
@Nullable
|
||||
String getMinorErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return optional additional information about the source of the error
|
||||
*/
|
||||
@Nullable
|
||||
String getVendorSpecificErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return stack trace of the error, if available. This attribute is returned only when a request
|
||||
* is made by the system administrator.
|
||||
*/
|
||||
String getStackTrace();
|
||||
}
|
|
@ -34,6 +34,11 @@ import com.google.inject.ImplementedBy;
|
|||
*/
|
||||
@ImplementedBy(TaskImpl.class)
|
||||
public interface Task extends ReferenceType {
|
||||
/**
|
||||
* The current status of the task.
|
||||
*/
|
||||
String getOperation();
|
||||
|
||||
/**
|
||||
* The current status of the task.
|
||||
*/
|
||||
|
@ -68,40 +73,4 @@ public interface Task extends ReferenceType {
|
|||
@Nullable
|
||||
Error getError();
|
||||
|
||||
@ImplementedBy(TaskImpl.ErrorImpl.class)
|
||||
static interface Error {
|
||||
/**
|
||||
*
|
||||
* @return message describing the error
|
||||
*/
|
||||
String getMessage();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return matches the HTTP status code
|
||||
*/
|
||||
int getMajorErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return error code specific to the failed operation or null if vcloud <0.9
|
||||
*/
|
||||
@Nullable
|
||||
String getMinorErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return optional additional information about the source of the error
|
||||
*/
|
||||
@Nullable
|
||||
String getVendorSpecificErrorCode();
|
||||
|
||||
/**
|
||||
*
|
||||
* @return stack trace of the error, if available. This attribute is returned only when a
|
||||
* request is made by the system administrator.
|
||||
*/
|
||||
String getStackTrace();
|
||||
}
|
||||
|
||||
}
|
|
@ -45,7 +45,7 @@ public enum TaskStatus {
|
|||
/**
|
||||
* not an official status, temporarily in.
|
||||
*/
|
||||
CANCELLED;
|
||||
CANCELLED, UNRECOGNIZED;
|
||||
public String value() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
@ -64,7 +64,11 @@ public enum TaskStatus {
|
|||
} else if ("COMPLETED".equals(status.toUpperCase())) {
|
||||
status = "SUCCESS";
|
||||
}
|
||||
return valueOf(checkNotNull(status, "status").toUpperCase());
|
||||
try {
|
||||
return valueOf(checkNotNull(status, "status").toUpperCase());
|
||||
} catch (IllegalArgumentException e) {
|
||||
return UNRECOGNIZED;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/**
|
||||
*
|
||||
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
|
||||
*
|
||||
* ====================================================================
|
||||
* Licensed 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.jclouds.vcloud.domain.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.vcloud.domain.Error;
|
||||
|
||||
import com.google.inject.internal.Nullable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*
|
||||
*/
|
||||
public class ErrorImpl implements Error {
|
||||
private final String message;
|
||||
private final int majorErrorCode;
|
||||
private final String minorErrorCode;
|
||||
@Nullable
|
||||
private final String vendorSpecificErrorCode;
|
||||
@Nullable
|
||||
private final String stackTrace;
|
||||
|
||||
public ErrorImpl(String message, int majorErrorCode, @Nullable String minorErrorCode,
|
||||
@Nullable String vendorSpecificErrorCode, @Nullable String stackTrace) {
|
||||
this.message = checkNotNull(message, "message");
|
||||
this.majorErrorCode = checkNotNull(majorErrorCode, "majorErrorCode");
|
||||
this.minorErrorCode = minorErrorCode; // check null after 0.8 is gone
|
||||
this.vendorSpecificErrorCode = vendorSpecificErrorCode;
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getMajorErrorCode() {
|
||||
return majorErrorCode;
|
||||
}
|
||||
|
||||
public String getMinorErrorCode() {
|
||||
return minorErrorCode;
|
||||
}
|
||||
|
||||
public String getVendorSpecificErrorCode() {
|
||||
return vendorSpecificErrorCode;
|
||||
}
|
||||
|
||||
public String getStackTrace() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + majorErrorCode;
|
||||
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
||||
result = prime * result + ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
|
||||
result = prime * result + ((stackTrace == null) ? 0 : stackTrace.hashCode());
|
||||
result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ErrorImpl other = (ErrorImpl) obj;
|
||||
if (majorErrorCode != other.majorErrorCode)
|
||||
return false;
|
||||
if (message == null) {
|
||||
if (other.message != null)
|
||||
return false;
|
||||
} else if (!message.equals(other.message))
|
||||
return false;
|
||||
if (minorErrorCode == null) {
|
||||
if (other.minorErrorCode != null)
|
||||
return false;
|
||||
} else if (!minorErrorCode.equals(other.minorErrorCode))
|
||||
return false;
|
||||
if (stackTrace == null) {
|
||||
if (other.stackTrace != null)
|
||||
return false;
|
||||
} else if (!stackTrace.equals(other.stackTrace))
|
||||
return false;
|
||||
if (vendorSpecificErrorCode == null) {
|
||||
if (other.vendorSpecificErrorCode != null)
|
||||
return false;
|
||||
} else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[majorErrorCode=" + majorErrorCode + ", message=" + message + ", minorErrorCode=" + minorErrorCode
|
||||
+ ", stackTrace=" + stackTrace + ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]";
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@ import java.net.URI;
|
|||
import java.util.Date;
|
||||
|
||||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.Error;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
|
@ -38,98 +39,7 @@ import com.google.inject.internal.Nullable;
|
|||
*/
|
||||
public class TaskImpl extends ReferenceTypeImpl implements Task {
|
||||
|
||||
public static class ErrorImpl implements Error {
|
||||
private final String message;
|
||||
private final int majorErrorCode;
|
||||
private final String minorErrorCode;
|
||||
@Nullable
|
||||
private final String vendorSpecificErrorCode;
|
||||
@Nullable
|
||||
private final String stackTrace;
|
||||
|
||||
public ErrorImpl(String message, int majorErrorCode, @Nullable String minorErrorCode,
|
||||
@Nullable String vendorSpecificErrorCode, @Nullable String stackTrace) {
|
||||
this.message = checkNotNull(message, "message");
|
||||
this.majorErrorCode = checkNotNull(majorErrorCode, "majorErrorCode");
|
||||
this.minorErrorCode = minorErrorCode; // check null after 0.8 is gone
|
||||
this.vendorSpecificErrorCode = vendorSpecificErrorCode;
|
||||
this.stackTrace = stackTrace;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public int getMajorErrorCode() {
|
||||
return majorErrorCode;
|
||||
}
|
||||
|
||||
public String getMinorErrorCode() {
|
||||
return minorErrorCode;
|
||||
}
|
||||
|
||||
public String getVendorSpecificErrorCode() {
|
||||
return vendorSpecificErrorCode;
|
||||
}
|
||||
|
||||
public String getStackTrace() {
|
||||
return stackTrace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + majorErrorCode;
|
||||
result = prime * result + ((message == null) ? 0 : message.hashCode());
|
||||
result = prime * result + ((minorErrorCode == null) ? 0 : minorErrorCode.hashCode());
|
||||
result = prime * result + ((stackTrace == null) ? 0 : stackTrace.hashCode());
|
||||
result = prime * result + ((vendorSpecificErrorCode == null) ? 0 : vendorSpecificErrorCode.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ErrorImpl other = (ErrorImpl) obj;
|
||||
if (majorErrorCode != other.majorErrorCode)
|
||||
return false;
|
||||
if (message == null) {
|
||||
if (other.message != null)
|
||||
return false;
|
||||
} else if (!message.equals(other.message))
|
||||
return false;
|
||||
if (minorErrorCode == null) {
|
||||
if (other.minorErrorCode != null)
|
||||
return false;
|
||||
} else if (!minorErrorCode.equals(other.minorErrorCode))
|
||||
return false;
|
||||
if (stackTrace == null) {
|
||||
if (other.stackTrace != null)
|
||||
return false;
|
||||
} else if (!stackTrace.equals(other.stackTrace))
|
||||
return false;
|
||||
if (vendorSpecificErrorCode == null) {
|
||||
if (other.vendorSpecificErrorCode != null)
|
||||
return false;
|
||||
} else if (!vendorSpecificErrorCode.equals(other.vendorSpecificErrorCode))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[majorErrorCode=" + majorErrorCode + ", message=" + message + ", minorErrorCode=" + minorErrorCode
|
||||
+ ", stackTrace=" + stackTrace + ", vendorSpecificErrorCode=" + vendorSpecificErrorCode + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final String operation;
|
||||
private final TaskStatus status;
|
||||
private final Date startTime;
|
||||
@Nullable
|
||||
|
@ -140,9 +50,10 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
|
|||
@Nullable
|
||||
private final Error error;
|
||||
|
||||
public TaskImpl(URI id, TaskStatus status, Date startTime, @Nullable Date endTime, @Nullable Date expiryTime,
|
||||
ReferenceType owner, Error error) {
|
||||
public TaskImpl(URI id, String operation, TaskStatus status, Date startTime, @Nullable Date endTime,
|
||||
@Nullable Date expiryTime, ReferenceType owner, Error error) {
|
||||
super(null, VCloudMediaType.TASK_XML, id);
|
||||
this.operation = operation;
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
|
@ -176,13 +87,31 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
|
|||
return error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskImpl [endTime=" + endTime + ", error=" + error + ", expiryTime=" + expiryTime + ", operation="
|
||||
+ operation + ", owner=" + owner + ", startTime=" + startTime + ", status=" + status + ", getHref()="
|
||||
+ getHref() + ", getName()=" + getName() + ", getType()=" + getType() + ", toString()="
|
||||
+ super.toString() + ", getClass()=" + getClass() + "]";
|
||||
}
|
||||
|
||||
public Date getExpiryTime() {
|
||||
return expiryTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((endTime == null) ? 0 : endTime.hashCode());
|
||||
result = prime * result + ((error == null) ? 0 : error.hashCode());
|
||||
result = prime * result + ((expiryTime == null) ? 0 : expiryTime.hashCode());
|
||||
result = prime * result + ((operation == null) ? 0 : operation.hashCode());
|
||||
result = prime * result + ((owner == null) ? 0 : owner.hashCode());
|
||||
result = prime * result + ((startTime == null) ? 0 : startTime.hashCode());
|
||||
result = prime * result + ((status == null) ? 0 : status.hashCode());
|
||||
|
@ -193,7 +122,7 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
|
|||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
if (!super.equals(obj))
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
|
@ -213,6 +142,11 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
|
|||
return false;
|
||||
} else if (!expiryTime.equals(other.expiryTime))
|
||||
return false;
|
||||
if (operation == null) {
|
||||
if (other.operation != null)
|
||||
return false;
|
||||
} else if (!operation.equals(other.operation))
|
||||
return false;
|
||||
if (owner == null) {
|
||||
if (other.owner != null)
|
||||
return false;
|
||||
|
@ -231,14 +165,4 @@ public class TaskImpl extends ReferenceTypeImpl implements Task {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TaskImpl [endTime=" + endTime + ", error=" + error + ", id=" + getName() + ", owner=" + owner
|
||||
+ ", startTime=" + startTime + ", status=" + status + "]";
|
||||
}
|
||||
|
||||
public Date getExpiryTime() {
|
||||
return expiryTime;
|
||||
}
|
||||
|
||||
}
|
|
@ -30,10 +30,10 @@ import javax.inject.Inject;
|
|||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.functions.ParseSax;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.vcloud.domain.Error;
|
||||
import org.jclouds.vcloud.domain.ReferenceType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
import org.jclouds.vcloud.domain.Task.Error;
|
||||
import org.jclouds.vcloud.domain.internal.TaskImpl;
|
||||
import org.jclouds.vcloud.util.Utils;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -44,7 +44,7 @@ import org.xml.sax.SAXException;
|
|||
*/
|
||||
public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
||||
protected final DateService dateService;
|
||||
|
||||
private String operation;
|
||||
private ReferenceType taskLink;
|
||||
private ReferenceType owner;
|
||||
private TaskStatus status;
|
||||
|
@ -53,6 +53,7 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
private Date expiryTime;
|
||||
private Task task;
|
||||
private Error error;
|
||||
private boolean inOwner;
|
||||
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
|
@ -69,10 +70,11 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
public void startElement(String uri, String localName, String qName, Attributes attrs) throws SAXException {
|
||||
Map<String, String> attributes = cleanseAttributes(attrs);
|
||||
if (qName.equalsIgnoreCase("Task")) {
|
||||
if (attributes.get("href") != null)// queued tasks may not have an
|
||||
if (attributes.get("href") != null && !inOwner)// queued tasks may not have an
|
||||
// href yet
|
||||
taskLink = Utils.newReferenceType(attributes);
|
||||
status = TaskStatus.fromValue(attributes.get("status"));
|
||||
operation = attributes.get("operation");
|
||||
if (attributes.containsKey("startTime"))
|
||||
startTime = parseDate(attributes.get("startTime"));
|
||||
if (attributes.containsKey("endTime"))
|
||||
|
@ -107,13 +109,16 @@ public class TaskHandler extends ParseSax.HandlerWithResult<Task> {
|
|||
@Override
|
||||
public void endElement(String uri, String localName, String qName) {
|
||||
if (qName.equalsIgnoreCase("Task")) {
|
||||
this.task = new TaskImpl(taskLink.getHref(), status, startTime, endTime, expiryTime, owner, error);
|
||||
this.task = new TaskImpl(taskLink.getHref(), operation, status, startTime, endTime, expiryTime, owner, error);
|
||||
operation = null;
|
||||
taskLink = null;
|
||||
status = null;
|
||||
startTime = null;
|
||||
endTime = null;
|
||||
owner = null;
|
||||
error = null;
|
||||
} else if (qName.equalsIgnoreCase("Owner")) {
|
||||
inOwner = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.jclouds.http.functions.BaseHandlerTest;
|
|||
import org.jclouds.vcloud.VCloudMediaType;
|
||||
import org.jclouds.vcloud.domain.Task;
|
||||
import org.jclouds.vcloud.domain.TaskStatus;
|
||||
import org.jclouds.vcloud.domain.internal.ErrorImpl;
|
||||
import org.jclouds.vcloud.domain.internal.ReferenceTypeImpl;
|
||||
import org.jclouds.vcloud.domain.internal.TaskImpl;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -56,8 +57,9 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI.create("https://vcenterprise.bluelock.com/api/v1.0/vApp/vapp-607806320"),
|
||||
TaskStatus.RUNNING, dateService.iso8601DateParse("2010-08-23T02:09:52.443-04:00"), dateService
|
||||
Task expects = new TaskImpl(URI.create("https://vcenterprise.bluelock.com/api/v1.0/task/3cc08ir8oczbze3n1a3"),
|
||||
"Creating Virtual Application vApp_acole_2(607806320)", TaskStatus.RUNNING, dateService
|
||||
.iso8601DateParse("2010-08-23T02:09:52.443-04:00"), dateService
|
||||
.iso8601DateParse("9999-12-31T23:59:59.999-05:00"), dateService
|
||||
.iso8601DateParse("2010-11-21T02:09:52.443-05:00"), new ReferenceTypeImpl("vApp_acole_2",
|
||||
VCloudMediaType.VAPP_XML, URI
|
||||
|
@ -74,7 +76,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
InputStream is = getClass().getResourceAsStream("/express/task.xml");
|
||||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||
Task expects = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"), null,
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
|
||||
.iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
|
||||
VCloudMediaType.VAPP_XML, URI
|
||||
|
@ -90,7 +92,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"),
|
||||
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/d188849-78"), null,
|
||||
TaskStatus.QUEUED, null, null, null, null, null);
|
||||
assertEquals(result, expects);
|
||||
|
||||
|
@ -101,7 +103,7 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"),
|
||||
Task expects = new TaskImpl(URI.create("https://vcloud.safesecureweb.com/api/v0.8/task/97806"), null,
|
||||
TaskStatus.SUCCESS, dateService.iso8601SecondsDateParse("2010-01-14T20:04:51Z"), dateService
|
||||
.iso8601SecondsDateParse("2010-01-14T20:05:02Z"), dateService
|
||||
.iso8601SecondsDateParse("2010-01-15T20:05:02Z"),
|
||||
|
@ -116,12 +118,12 @@ public class TaskHandlerTest extends BaseHandlerTest {
|
|||
|
||||
Task result = factory.create(injector.getInstance(TaskHandler.class)).parse(is);
|
||||
|
||||
Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), TaskStatus.ERROR, dateService
|
||||
.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService
|
||||
.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
|
||||
VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")), new TaskImpl.ErrorImpl(
|
||||
"Error processing job", 500, " Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00",
|
||||
null, null));
|
||||
Task expects = new TaskImpl(URI.create("http://10.150.4.49/api/v0.8/task/23"), null, TaskStatus.ERROR,
|
||||
dateService.iso8601SecondsDateParse("2009-12-07T19:05:02Z"), dateService
|
||||
.iso8601SecondsDateParse("2009-12-10T14:40:32Z"), null, new ReferenceTypeImpl("testapp1",
|
||||
VCloudMediaType.VAPP_XML, URI.create("http://10.150.4.49/api/v0.8/vapp/1")),
|
||||
new ErrorImpl("Error processing job", 500,
|
||||
" Error in runDailySummaries date used:2009-12-09 19:40:30.577326+00:00", null, null));
|
||||
assertEquals(result, expects);
|
||||
|
||||
}
|
||||
|
|
|
@ -61,12 +61,12 @@ public class TasksListHandlerTest extends BaseHandlerTest {
|
|||
assertEquals(result.getLocation(), URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/tasksList/1"));
|
||||
Task task1 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3300"),
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), dateService
|
||||
null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:30:19.587Z"), dateService
|
||||
.iso8601DateParse("2009-08-24T21:30:32.63Z"), null, new ReferenceTypeImpl("Server1",
|
||||
VCloudExpressMediaType.VAPP_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
|
||||
Task task2 = new TaskImpl(URI.create("https://services.vcloudexpress.terremark.com/api/v0.8/task/3299"),
|
||||
TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
|
||||
null, TaskStatus.SUCCESS, dateService.iso8601DateParse("2009-08-24T21:29:32.983Z"), dateService
|
||||
.iso8601DateParse("2009-08-24T21:29:44.65Z"), null, new ReferenceTypeImpl("Server1",
|
||||
VCloudExpressMediaType.VAPP_XML, URI
|
||||
.create("https://services.vcloudexpress.terremark.com/api/v0.8/vapp/4012")), null);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<VAppTemplate xmlns="http://www.vmware.com/vcloud/v1"
|
||||
xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1"
|
||||
ovfDescriptorUploaded="true" status="0" name="Ubuntu10.04_v2"
|
||||
type="application/vnd.vmware.vcloud.vAppTemplate+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://schemas.dmtf.org/ovf/envelope/1 http://schemas.dmtf.org/ovf/envelope/1/dsp8023_1.1.0.xsd http://www.vmware.com/vcloud/v1 http://vcenterprise.bluelock.com/api/v1.0/schema/master.xsd">
|
||||
<Link rel="up" type="application/vnd.vmware.vcloud.vdc+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vdc/105186609" />
|
||||
<Description />
|
||||
<Tasks>
|
||||
<Task status="running" startTime="2010-09-17T23:20:46.039-04:00"
|
||||
operation="Copying Virtual Application Template Ubuntu10.04_v2(699683881)"
|
||||
expiryTime="2010-12-16T23:20:46.039-05:00" endTime="9999-12-31T23:59:59.999-05:00"
|
||||
type="application/vnd.vmware.vcloud.task+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/task/q62gxhi32xgd9yrqvr">
|
||||
<Owner type="application/vnd.vmware.vcloud.vAppTemplate+xml"
|
||||
name="Ubuntu10.04_v2"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881" />
|
||||
</Task>
|
||||
</Tasks>
|
||||
<Children />
|
||||
<LeaseSettingsSection
|
||||
type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/leaseSettingsSection/"
|
||||
ovf:required="false">
|
||||
<ovf:Info>Lease settings section</ovf:Info>
|
||||
<Link rel="edit"
|
||||
type="application/vnd.vmware.vcloud.leaseSettingsSection+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/leaseSettingsSection/" />
|
||||
<StorageLeaseInSeconds>0</StorageLeaseInSeconds>
|
||||
</LeaseSettingsSection>
|
||||
<CustomizationSection
|
||||
type="application/vnd.vmware.vcloud.customizationSection+xml"
|
||||
href="https://vcenterprise.bluelock.com/api/v1.0/vAppTemplate/vappTemplate-699683881/customizationSection/"
|
||||
ovf:required="false">
|
||||
<ovf:Info>VApp template customization section</ovf:Info>
|
||||
<CustomizeOnInstantiate>true</CustomizeOnInstantiate>
|
||||
</CustomizationSection>
|
||||
</VAppTemplate>
|
|
@ -45,7 +45,7 @@ public class ParseTaskFromLocationHeader implements Function<HttpResponse, Task>
|
|||
if (location == null)
|
||||
location = from.getFirstHeaderOrNull("location");
|
||||
if (location != null) {
|
||||
return new TaskImpl(URI.create(location), TaskStatus.QUEUED, new Date(), null, null, null, null);
|
||||
return new TaskImpl(URI.create(location), null, TaskStatus.QUEUED, new Date(), null, null, null, null);
|
||||
} else {
|
||||
throw new HttpResponseException("no uri in headers or content", null, from);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue