| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.vcloud.domain; |
| 20 | |
| 21 | import static com.google.common.base.Preconditions.checkNotNull; |
| 22 | |
| 23 | import org.jclouds.javax.annotation.Nullable; |
| 24 | |
| 25 | import org.jclouds.vcloud.domain.internal.ErrorImpl; |
| 26 | |
| 27 | import com.google.inject.ImplementedBy; |
| 28 | |
| 29 | /** |
| 30 | * |
| 31 | * |
| 32 | * @author Adrian Cole |
| 33 | */ |
| 34 | @ImplementedBy(ErrorImpl.class) |
| 35 | public interface VCloudError { |
| 36 | public static enum MinorCode { |
| 37 | /** |
| 38 | * The request was made by a user who had insufficient rights to the object or operation. |
| 39 | */ |
| 40 | ACCESS_TO_RESOURCE_IS_FORBIDDEN, |
| 41 | /** |
| 42 | * The request could not be validated or contained invalid XML. |
| 43 | */ |
| 44 | BAD_REQUEST, |
| 45 | /** |
| 46 | * A conflict was detected between sections of an OVF descriptor. |
| 47 | */ |
| 48 | CONFLICT, |
| 49 | /** |
| 50 | * The entity is busy |
| 51 | */ |
| 52 | BUSY_ENTITY, |
| 53 | /** |
| 54 | * An attempt to instantiate a vAppTemplate or use a vAppTemplate or a Vm in a composition did |
| 55 | * not include an AllEULAsAccepted element with a value of true. |
| 56 | */ |
| 57 | EULA_NOT_ACCEPTED, |
| 58 | /** |
| 59 | * Returned for any failure that cannot be matched to another minor error code. |
| 60 | */ |
| 61 | INTERNAL_SERVER_ERROR, |
| 62 | /** |
| 63 | * One or more references (href attribute values) supplied in the request could not be |
| 64 | * resolved to an object. |
| 65 | */ |
| 66 | INVALID_REFERENCE, |
| 67 | /** |
| 68 | * The HTTP method (GET, PUT, POST, DELETE) is not allowed for the request. |
| 69 | */ |
| 70 | METHOD_NOT_ALLOWED, |
| 71 | /** |
| 72 | * One or more references (href attribute values) supplied in the request could not be |
| 73 | * resolved to an object, or the Content?type of the request was incorrect. |
| 74 | */ |
| 75 | RESOURCE_NOT_FOUND, |
| 76 | /** |
| 77 | * The request raised an exception that did not match any HTTP status code. |
| 78 | */ |
| 79 | UNKNOWN, |
| 80 | /** |
| 81 | * The wrong content type was specified for the request. |
| 82 | */ |
| 83 | UNSUPPORTED_MEDIA_TYPE, UNRECOGNIZED; |
| 84 | |
| 85 | public static MinorCode fromValue(String minorCode) { |
| 86 | try { |
| 87 | return valueOf(checkNotNull(minorCode, "minorCode")); |
| 88 | } catch (IllegalArgumentException e) { |
| 89 | return UNRECOGNIZED; |
| 90 | } |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | /** |
| 95 | * |
| 96 | * @return message describing the error |
| 97 | */ |
| 98 | String getMessage(); |
| 99 | |
| 100 | /** |
| 101 | * |
| 102 | * @return matches the HTTP status code |
| 103 | */ |
| 104 | int getMajorErrorCode(); |
| 105 | |
| 106 | /** |
| 107 | * |
| 108 | * @return error code specific to the failed operation or null if vcloud <0.9 |
| 109 | */ |
| 110 | @Nullable |
| 111 | MinorCode getMinorErrorCode(); |
| 112 | |
| 113 | /** |
| 114 | * |
| 115 | * @return optional additional information about the source of the error |
| 116 | */ |
| 117 | @Nullable |
| 118 | String getVendorSpecificErrorCode(); |
| 119 | |
| 120 | /** |
| 121 | * |
| 122 | * @return stack trace of the error, if available. This attribute is returned only when a request |
| 123 | * is made by the system administrator. |
| 124 | */ |
| 125 | String getStackTrace(); |
| 126 | } |