View Javadoc
1   /*
2    * Copyright 2001-2008 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   *
16   */
17  
18  package org.apache.juddi.v3.error;
19  
20  import org.apache.juddi.config.ResourceConfig;
21  import org.uddi.api_v3.DispositionReport;
22  import org.uddi.api_v3.Result;
23  import org.uddi.api_v3.ErrInfo;
24  
25  /**
26   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
27   */
28  public class UDDIErrorHelper {
29          /**
30           *  E_assertionNotFound: (30000) Signifies that a particular publisher assertion cannot be identified in a save or delete operation.
31           */
32  	public static final int E_ASSERTION_NOT_FOUND = 30000;
33          /**
34           *  E_authTokenExpired: (10110) Signifies that the authentication token information has timed out.
35           */
36  	public static final int E_AUTH_TOKEN_EXPIRED = 10110;
37          /**
38           *  E_authTokenRequired: (10120) Signifies that an authentication token is missing or is invalid for an API call that requires authentication.
39           */
40  	public static final int E_AUTH_TOKEN_REQUIRED = 10120;
41          /**
42           * E_accountLimitExceeded: (10160) Signifies that a save request exceeded the quantity limits for a given data type. Account limits are established based on the relationship between an individual publisher and an individual node. See your UDDI node’s policy for account limits for details. Other nodes in the registry MAY NOT place additional restrictions on publishing limits established by a custodial node.
43           */
44  	public static final int E_ACCOUNT_LIMIT_EXCEEDED = 10160;
45          /**
46           *  E_busy: (10400) Signifies that the request cannot be processed at the current time.
47           */
48  	public static final int E_BUSY = 10400;
49          /**
50           * NON UDDIv3 spec error
51           */
52  	public static final int E_CATEGORIZATION_NOT_ALLOWED = 20100;
53          /**
54           * E_fatalError: (10500) Signifies that a serious technical error has occurred while processing the request.
55           */
56  	public static final int E_FATAL_ERROR = 10500;
57          /**
58           *  E_invalidKeyPassed: (10210) Signifies that the uddiKey value passed did not match with any known key values.  The details on the invalid key SHOULD be included in the dispositionReport element.
59           */
60  	public static final int E_INVALID_KEY_PASSED = 10210;
61          /**
62           * E_invalidProjection: (20230) Signifies that an attempt was made to save a businessEntity containing a service projection where the serviceKey does not belong to the business designated by the businessKey. The serviceKey of at least one such businessService SHOULD be included in the dispositionReport.
63           */
64  	public static final int E_INVALID_PROJECTION = 20230;
65          /**
66           * NON UDDIv3 spec
67           */
68  	public static final int E_INVALID_CATEGORY = 20000;
69          /**
70           *   E_invalidCompletionStatus: (30100) Signifies that one of the assertion status values passed is unrecognized.  The completion status that caused the problem SHOULD be clearly indicated in the error text.
71           */
72  	public static final int E_INVALID_COMPLETION_STATUS = 30100;
73          
74  	public static final int E_INVALID_URL_PASSED = 10220;
75          /**
76           *  E_invalidValue: (20200) This error code has multiple uses.  This error code applies to the subscription APIs and the value set APIs. It can be used to indicate that a value that was passed in a keyValue attribute did not pass validation.  This applies to checked value sets that are referenced using keyedReferences. The error text SHOULD clearly indicate the key and value combination that failed validation. It can also be used to indicate that a chunkToken supplied is invalid. This applies in both subscription and value set APIs.  The error text SHOULD clearly indicate the reason for failure.
77           */
78  	public static final int E_INVALID_VALUE = 20200;
79          /**
80           *  E_invalidCombination: (40500) Signifies conflicting find qualifiers have been specified.  The find qualifiers that caused the problem SHOULD be clearly indicated in the error text.
81           */
82  	public static final int E_INVALID_COMBINATION = 40500;
83  	public static final int E_KEY_RETIRED = 10310;
84          /**
85           * E_keyUnavailable: (40100) Signifies that the proposed key is in a partition that has already been assigned to some other publisher.
86           */
87  	public static final int E_KEY_UNAVAILABLE = 40100;
88  	public static final int E_LANGUAGE_ERROR = 10060;
89          /**
90           *  E_messageTooLarge: (30110) Signifies that the message is too large.  The upper limit SHOULD be clearly indicated in the error text.
91           */
92  	public static final int E_MESSAGE_TOO_LARGE = 30110;
93  	public static final int E_NAME_TOO_LONG = 10020;
94  	public static final int E_OPERATOR_MISMATCH = 10130;
95  	public static final int E_PUBLISHER_CANCELLED = 30220;
96          /**
97           *  Signifies that a subscription cannot be renewed. The request has been denied due to either node or registry policy.
98           */
99  	public static final int E_REQUEST_DENIED = 30210;
100 	public static final int E_SECRET_UNKNOWN = 30230;
101 	public static final int E_SUCCESS = 0;
102 	public static final int E_TOO_MANY_OPTIONS = 10030;
103 	public static final int E_TRANSFER_ABORTED = 30200;
104         /**
105          * E_unrecognizedVersion: (10040) Signifies that the value of the namespace attribute is unsupported by the node being queried.
106          */
107 	public static final int E_UNRECOGNIZED_VERSION = 10040;
108         /**
109          * E_unknownUser: (10150) Signifies that the user ID and password pair passed in a get_authToken API is not known to the UDDI node or is not valid.
110          */
111 	public static final int E_UNKNOWN_USER = 10150;
112         /**
113          * E_unsupported: (10050) Signifies that the implementer does not support a feature or API.
114          */
115 	public static final int E_UNSUPPORTED = 10050;
116         /**
117          *  E_userMismatch: (10140) Signifies that an attempt was made to use the publishing API to change data that is controlled by another party.
118          */
119 	public static final int E_USER_MISMATCH = 10140;
120         /**
121          * E_valueNotAllowed: (20210) Signifies that a value did not pass validation because of contextual issues.  The value may be valid in some contexts, but not in the context used.  The error text MAY contain information about the contextual problem.
122          */
123 	public static final int E_VALUE_NOT_ALLOWED = 20210;
124         /**
125          * E_unvalidatable: (20220) Signifies that an attempt was made to reference a value set in a keyedReference whose tModel is categorized with the unvalidatable categorization.
126          */
127 	public static final int E_UNVALIDATABLE = 20220;
128 	public static final int E_REQUEST_TIMEOUT = 20240;
129         /**
130          * E_invalidTime: (40030) Signifies that the time period, the date/time, or the pair of date/time is invalid. The error structure signifies the condition that occurred and the error text clearly calls out the cause of the problem.
131          */
132 	public static final int E_INVALID_TIME = 40030;
133         /**
134          *  E_resultSetTooLarge: (40300) Signifies that the UDDI node deems that a result set from an inquiry is too large, and requests to obtain the results are not honored, even using subsets.  The inquiry that triggered this error should be refined and re-issued.
135          */
136 	public static final int E_RESULT_SET_TOO_LARGE = 40300;
137         /**
138          * E_tokenAlreadyExists: (40070) Signifies that one or more of the businessKey or tModelKey elements that identify entities to be transferred are not owned by the publisher identified by the authInfo element.  The error text SHOULD clearly indicate which entity keys caused the error.
139          */
140 	public static final int E_TOKEN_ALREADY_EXISTS = 40070;
141         /**
142          *  E_transferNotAllowed: (40600) Signifies that the transfer of one or more entities has been by either the custodial node or the target node because the transfer token has expired or an attempt was made to transfer an unauthorized entity.
143          */
144 	public static final int E_TRANSFER_NOT_ALLOWED = 40600;
145 
146 	public static final String lookupErrCode(int errno) {
147 		switch (errno) {
148 			case E_ACCOUNT_LIMIT_EXCEEDED     : return DispositionReport.E_ACCOUNT_LIMIT_EXCEEDED;
149 			case E_ASSERTION_NOT_FOUND        : return DispositionReport.E_ASSERTION_NOT_FOUND; 
150 			case E_AUTH_TOKEN_EXPIRED         : return DispositionReport.E_AUTH_TOKEN_EXPIRED;
151 			case E_AUTH_TOKEN_REQUIRED        : return DispositionReport.E_AUTH_TOKEN_REQUIRED;
152 			case E_BUSY                       : return DispositionReport.E_BUSY;
153 			case E_CATEGORIZATION_NOT_ALLOWED : return DispositionReport.E_CATEGORIZATION_NOT_ALLOWED;
154 			case E_FATAL_ERROR                : return DispositionReport.E_FATAL_ERROR;
155 			case E_INVALID_COMBINATION        : return DispositionReport.E_INVALID_COMBINATION;
156 			case E_INVALID_CATEGORY           : return DispositionReport.E_INVALID_CATEGORY;
157 			case E_INVALID_COMPLETION_STATUS  : return DispositionReport.E_INVALID_COMPLETION_STATUS;
158 			case E_INVALID_KEY_PASSED         : return DispositionReport.E_INVALID_KEY_PASSED;
159 			case E_KEY_UNAVAILABLE         	  : return DispositionReport.E_KEY_UNAVAILABLE;
160 			case E_INVALID_PROJECTION         : return DispositionReport.E_INVALID_PROJECTION;
161 			case E_INVALID_TIME               : return DispositionReport.E_INVALID_TIME;
162 			case E_INVALID_URL_PASSED         : return DispositionReport.E_INVALID_URL_PASSED;
163 			case E_INVALID_VALUE              : return DispositionReport.E_INVALID_VALUE;
164 			case E_KEY_RETIRED                : return DispositionReport.E_KEY_RETIRED;
165 			case E_LANGUAGE_ERROR             : return DispositionReport.E_LANGUAGE_ERROR;
166 			case E_MESSAGE_TOO_LARGE          : return DispositionReport.E_MESSAGE_TOO_LARGE;
167 			case E_NAME_TOO_LONG              : return DispositionReport.E_NAME_TOO_LONG;
168 			case E_OPERATOR_MISMATCH          : return DispositionReport.E_OPERATOR_MISMATCH;
169 			case E_PUBLISHER_CANCELLED        : return DispositionReport.E_PUBLISHER_CANCELLED;
170 			case E_REQUEST_DENIED             : return DispositionReport.E_REQUEST_DENIED;
171 			case E_REQUEST_TIMEOUT            : return DispositionReport.E_REQUEST_TIMEOUT;
172 			case E_RESULT_SET_TOO_LARGE       : return DispositionReport.E_RESULT_SET_TOO_LARGE;
173 			case E_SECRET_UNKNOWN             : return DispositionReport.E_SECRET_UNKNOWN;
174 			case E_SUCCESS                    : return DispositionReport.E_SUCCESS;
175 			case E_TOO_MANY_OPTIONS           : return DispositionReport.E_TOO_MANY_OPTIONS;
176 			case E_TRANSFER_ABORTED           : return DispositionReport.E_TRANSFER_ABORTED;
177 			case E_UNKNOWN_USER               : return DispositionReport.E_UNKNOWN_USER;
178 			case E_UNRECOGNIZED_VERSION       : return DispositionReport.E_UNRECOGNIZED_VERSION;
179 			case E_UNSUPPORTED                : return DispositionReport.E_UNSUPPORTED;
180 			case E_UNVALIDATABLE              : return DispositionReport.E_UNVALIDATABLE;
181 			case E_USER_MISMATCH              : return DispositionReport.E_USER_MISMATCH;
182 			case E_VALUE_NOT_ALLOWED          : return DispositionReport.E_VALUE_NOT_ALLOWED;
183 			case E_TOKEN_ALREADY_EXISTS       : return DispositionReport.E_TOKEN_ALREADY_EXISTS;
184 			case E_TRANSFER_NOT_ALLOWED       : return DispositionReport.E_TRANSFER_NOT_ALLOWED;
185 			default                           : return null;
186 		}
187 	}  
188 
189 	public static final String lookupErrText(int errno) {
190 		String errCode = lookupErrCode(errno);
191 		if (errCode == null)
192 			return null;
193 		return ResourceConfig.getGlobalMessage(errCode);
194 	}    
195 
196 	public static final DispositionReport buildDispositionReport(int errNo) {
197 		DispositionReport dr = new DispositionReport();
198 		Result res = new Result();
199 		res.setErrno(errNo);
200 		
201 		ErrInfo ei = new ErrInfo();
202 		ei.setErrCode(lookupErrCode(errNo));
203 		ei.setValue(lookupErrText(errNo));
204 		
205 		res.setErrInfo(ei);
206 		
207 		dr.getResult().add(res);
208 			  
209 		return dr;
210 	}
211 }