Skip to content

Commit a9419ab

Browse files
committed
Cleaned up the documentation in edu.umass.cs.gnscommon.ReponseCode
1 parent 8a93340 commit a9419ab

1 file changed

Lines changed: 38 additions & 46 deletions

File tree

src/edu/umass/cs/gnscommon/ResponseCode.java

Lines changed: 38 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
/**
2828
* This class describes the error and exception codes for GNS packets that get
29-
* sent back to the server and the client.
29+
* sent between the server and the clients.
3030
*
3131
* These codes are used by the GNS to communicate via response packets why a
3232
* value could not be returned from the server(s) to the client.
@@ -43,92 +43,84 @@ public enum ResponseCode implements Serializable {
4343
* For other response codes the return value only contains
4444
* additional information to describe the error or exception.
4545
*/
46-
/**
47-
* A positive acknowledgment. This indicates that the
48-
* return value contains the result of the command or in
49-
* the case of commands that don't return a value that the
50-
* command was executed without error.
51-
* For other response codes the return value only contains
52-
* additional information to describe the error or exception.
53-
*/
54-
NO_ERROR(200, GNSProtocol.OK_RESPONSE.toString(), TYPE.NORMAL),
46+
NO_ERROR(200, GNSProtocol.OK_RESPONSE.toString(), ResponseCodeType.NORMAL),
5547
/**
5648
* Unspecified error. This should be used replaced with more specific errors
5749
* in most cases and used sparingly, if at all because it doesn't convey
5850
* enough information.
5951
*/
60-
UNSPECIFIED_ERROR(1, GNSProtocol.UNSPECIFIED_ERROR.toString(), TYPE.ERROR),
52+
UNSPECIFIED_ERROR(1, GNSProtocol.UNSPECIFIED_ERROR.toString(), ResponseCodeType.ERROR),
6153
/**
62-
* Field in a record was not found.
54+
* A field in a record was not found.
6355
*/
64-
FIELD_NOT_FOUND_ERROR(2, GNSProtocol.FIELD_NOT_FOUND.toString(), TYPE.ERROR),
56+
FIELD_NOT_FOUND_ERROR(2, GNSProtocol.FIELD_NOT_FOUND.toString(), ResponseCodeType.ERROR),
6557
// The following three are access or signature errors
6658
/**
6759
* Bad signature. A signature error.
6860
* This will happen when the message in a command packet fails signature verification.
6961
* See {@link edu.umass.cs.gnsserver.gnsapp.clientSupport.NSAuthentication#signatureAndACLCheck}
7062
*/
71-
SIGNATURE_ERROR(5, GNSProtocol.BAD_SIGNATURE.toString(), TYPE.ERROR),
63+
SIGNATURE_ERROR(5, GNSProtocol.BAD_SIGNATURE.toString(), ResponseCodeType.ERROR),
7264
/**
7365
* Stale signature or key. An access or signature error.
7466
* This will happen when a command packet arrives that is too old.
7567
*
7668
* See {@link edu.umass.cs.gnsserver.gnsapp.clientSupport.NSAuthentication#signatureAndACLCheck}
7769
*/
78-
STALE_COMMAND_VALUE(6, GNSProtocol.STALE_COMMMAND.toString(), TYPE.ERROR),
70+
STALE_COMMAND_VALUE(6, GNSProtocol.STALE_COMMMAND.toString(), ResponseCodeType.ERROR),
7971
/**
8072
* Access denied. An access error.
8173
* This will happen when a command packet arrives that tries to access a field
8274
* for which it does not have the correct access control.
8375
*
8476
* See {@link edu.umass.cs.gnsserver.gnsapp.clientSupport.NSAuthentication#signatureAndACLCheck}
8577
*/
86-
ACCESS_ERROR(7, GNSProtocol.ACCESS_DENIED.toString(), TYPE.ERROR),
78+
ACCESS_ERROR(7, GNSProtocol.ACCESS_DENIED.toString(), ResponseCodeType.ERROR),
8779
/**
8880
* Non-existent GNSProtocol.GUID.toString().
8981
* This will happen when a command packet arrives that tries to access a guid
9082
* that does not exist.
9183
*/
92-
BAD_GUID_ERROR(8, GNSProtocol.BAD_GUID.toString(), TYPE.ERROR),
84+
BAD_GUID_ERROR(8, GNSProtocol.BAD_GUID.toString(), ResponseCodeType.ERROR),
9385
/**
9486
* Non-existent accessor GNSProtocol.GUID.toString().
9587
* This will happen when a command packet arrives that is trying to access
9688
* a field using an accessor guid that does not exist.
9789
*/
98-
BAD_ACCESSOR_ERROR(9, GNSProtocol.BAD_ACCESSOR_GUID.toString(), TYPE.ERROR),
90+
BAD_ACCESSOR_ERROR(9, GNSProtocol.BAD_ACCESSOR_GUID.toString(), ResponseCodeType.ERROR),
9991
/**
10092
* An error during account GNSProtocol.GUID.toString() verification.
10193
* This will happen if the verification code is incorrect.
10294
*/
103-
VERIFICATION_ERROR(10, GNSProtocol.VERIFICATION_ERROR.toString(), TYPE.ERROR),
95+
VERIFICATION_ERROR(10, GNSProtocol.VERIFICATION_ERROR.toString(), ResponseCodeType.ERROR),
10496
/**
10597
* Account guid does not exist.
10698
*
10799
*/
108-
BAD_ACCOUNT_ERROR(11, GNSProtocol.BAD_ACCOUNT.toString(), TYPE.ERROR),
100+
BAD_ACCOUNT_ERROR(11, GNSProtocol.BAD_ACCOUNT.toString(), ResponseCodeType.ERROR),
109101
/**
110102
* The operation does not exist or does not except the arguments given.
111103
*/
112104
OPERATION_NOT_SUPPORTED(404, GNSProtocol.OPERATION_NOT_SUPPORTED.toString(),
113-
TYPE.ERROR),
105+
ResponseCodeType.ERROR),
114106
/* Errors above, exceptions below. The distinction is that the former is
115107
* more serious and irrecoverable for that operation, but the latter may
116108
* sometimes happen in the otherwise normal course of events. */
117109
/**
118110
* Account has already been verified.
119111
*/
120-
ALREADY_VERIFIED_EXCEPTION(12, GNSProtocol.ALREADY_VERIFIED_EXCEPTION.toString(), TYPE.EXCEPTION),
112+
ALREADY_VERIFIED_EXCEPTION(12, GNSProtocol.ALREADY_VERIFIED_EXCEPTION.toString(), ResponseCodeType.EXCEPTION),
121113
/**
122114
* Duplicate GNSProtocol.GUID.toString() or HRN.
123115
*/
124116
DUPLICATE_ID_EXCEPTION(14,
125117
ClientReconfigurationPacket.ResponseCodes.DUPLICATE_ERROR
126-
.toString(), TYPE.EXCEPTION),
118+
.toString(), ResponseCodeType.EXCEPTION),
127119
/**
128120
* Duplicate field in a record.
129121
*/
130122
DUPLICATE_FIELD_EXCEPTION(15, GNSProtocol.DUPLICATE_FIELD.toString(),
131-
TYPE.EXCEPTION),
123+
ResponseCodeType.EXCEPTION),
132124
/**
133125
* The name for which a RequestActiveReplicas was sent was found to not
134126
* exist at a reconfigurator. This can happen simply because a laggard
@@ -146,7 +138,7 @@ public enum ResponseCode implements Serializable {
146138
*/
147139
NONEXISTENT_NAME_EXCEPTION(16,
148140
ClientReconfigurationPacket.ResponseCodes.NONEXISTENT_NAME_ERROR
149-
.toString(), TYPE.EXCEPTION),
141+
.toString(), ResponseCodeType.EXCEPTION),
150142
/**
151143
* When an application request is received by an active replica where no
152144
* replica for the name exists. This does not necessarily mean that the name
@@ -157,65 +149,65 @@ public enum ResponseCode implements Serializable {
157149
*/
158150
ACTIVE_REPLICA_EXCEPTION(17,
159151
ClientReconfigurationPacket.ResponseCodes.ACTIVE_REPLICA_EXCEPTION
160-
.toString(), TYPE.EXCEPTION),
152+
.toString(), ResponseCodeType.EXCEPTION),
161153
/**
162154
* The alias does not exist.
163155
*/
164-
BAD_ALIAS_EXCEPTION(18, GNSProtocol.BAD_ALIAS.toString(), TYPE.EXCEPTION),
156+
BAD_ALIAS_EXCEPTION(18, GNSProtocol.BAD_ALIAS.toString(), ResponseCodeType.EXCEPTION),
165157
/**
166158
* The ACL type does not exist.
167159
*/
168-
BAD_ACL_TYPE_ERROR(19, GNSProtocol.BAD_ACL_TYPE.toString(), TYPE.ERROR),
160+
BAD_ACL_TYPE_ERROR(19, GNSProtocol.BAD_ACL_TYPE.toString(), ResponseCodeType.ERROR),
169161
/**
170162
* The field does not exist.
171163
*/
172-
FIELD_NOT_FOUND_EXCEPTION(20, GNSProtocol.FIELD_NOT_FOUND.toString(), TYPE.EXCEPTION),
164+
FIELD_NOT_FOUND_EXCEPTION(20, GNSProtocol.FIELD_NOT_FOUND.toString(), ResponseCodeType.EXCEPTION),
173165
/**
174166
* The guid is a duplicate of an already existing guid.
175167
*/
176-
DUPLICATE_GUID_EXCEPTION(21, GNSProtocol.DUPLICATE_GUID.toString(), TYPE.EXCEPTION),
168+
DUPLICATE_GUID_EXCEPTION(21, GNSProtocol.DUPLICATE_GUID.toString(), ResponseCodeType.EXCEPTION),
177169
/**
178170
* The HRN already exists.
179171
*/
180-
DUPLICATE_NAME_EXCEPTION(22, GNSProtocol.DUPLICATE_NAME.toString(), TYPE.EXCEPTION),
172+
DUPLICATE_NAME_EXCEPTION(22, GNSProtocol.DUPLICATE_NAME.toString(), ResponseCodeType.EXCEPTION),
181173
/**
182174
* A JSON parsing error occurred.
183175
*/
184-
JSON_PARSE_ERROR(23, GNSProtocol.JSON_PARSE_ERROR.toString(), TYPE.ERROR),
176+
JSON_PARSE_ERROR(23, GNSProtocol.JSON_PARSE_ERROR.toString(), ResponseCodeType.ERROR),
185177
/**
186178
* The max alias limit was exceeded.
187179
*/
188-
TOO_MANY_ALIASES_EXCEPTION(24, GNSProtocol.TOO_MANY_ALIASES.toString(), TYPE.EXCEPTION),
180+
TOO_MANY_ALIASES_EXCEPTION(24, GNSProtocol.TOO_MANY_ALIASES.toString(), ResponseCodeType.EXCEPTION),
189181
/**
190182
* The max guid limit was exceeded.
191183
*/
192-
TOO_MANY_GUIDS_EXCEPTION(25, GNSProtocol.TOO_MANY_GUIDS.toString(), TYPE.EXCEPTION),
184+
TOO_MANY_GUIDS_EXCEPTION(25, GNSProtocol.TOO_MANY_GUIDS.toString(), ResponseCodeType.EXCEPTION),
193185
/**
194186
* There was an error while updating a record.
195187
*/
196-
UPDATE_ERROR(26, GNSProtocol.UPDATE_ERROR.toString(), TYPE.ERROR),
188+
UPDATE_ERROR(26, GNSProtocol.UPDATE_ERROR.toString(), ResponseCodeType.ERROR),
197189
/**
198190
* Something went wrong while we were reading from or writing to the database.
199191
*/
200-
DATABASE_OPERATION_ERROR(27, GNSProtocol.DATABASE_OPERATION_ERROR.toString(), TYPE.ERROR),
192+
DATABASE_OPERATION_ERROR(27, GNSProtocol.DATABASE_OPERATION_ERROR.toString(), ResponseCodeType.ERROR),
201193
/**
202194
* An error occurred during the processing of a command query.
203195
*/
204-
QUERY_PROCESSING_ERROR(405, GNSProtocol.QUERY_PROCESSING_ERROR.toString(), TYPE.ERROR),
196+
QUERY_PROCESSING_ERROR(405, GNSProtocol.QUERY_PROCESSING_ERROR.toString(), ResponseCodeType.ERROR),
205197
/**
206198
* A timeout occurred.
207199
*/
208-
TIMEOUT(408, GNSProtocol.TIMEOUT.toString(), TYPE.EXCEPTION),
200+
TIMEOUT(408, GNSProtocol.TIMEOUT.toString(), ResponseCodeType.EXCEPTION),
209201
/**
210202
* A remote query failed on the server side.
211203
*/
212-
REMOTE_QUERY_EXCEPTION(410, GNSProtocol.REMOTE_QUERY_EXCEPTION.toString(), TYPE.EXCEPTION),
204+
REMOTE_QUERY_EXCEPTION(410, GNSProtocol.REMOTE_QUERY_EXCEPTION.toString(), ResponseCodeType.EXCEPTION),
213205
/**
214206
* An internal request, possibly an active request, failed probably because the TTL expired
215207
* or it was attempting to cause a cycle.
216208
*/
217209
INTERNAL_REQUEST_EXCEPTION(411, GNSProtocol.INTERNAL_REQUEST_EXCEPTION
218-
.toString(), TYPE.EXCEPTION),;
210+
.toString(), ResponseCodeType.EXCEPTION),;
219211

220212
// stash the codes in a lookup table
221213
private static final Map<Integer, ResponseCode> responseCodes = new HashMap<>();
@@ -245,13 +237,13 @@ public static ResponseCode getResponseCode(int codeValue) {
245237
//
246238
private final int codeValue;
247239
private final String protocolCode;
248-
private final TYPE type;
240+
private final ResponseCodeType type;
249241
private String message = null;
250242

251243
/**
252244
* The response code category.
253245
*/
254-
public static enum TYPE {
246+
public static enum ResponseCodeType {
255247
/**
256248
* No error or exceptional condition.
257249
*/
@@ -266,7 +258,7 @@ public static enum TYPE {
266258
ERROR;
267259
};
268260

269-
private ResponseCode(int codeValue, String protocolCode, TYPE type) {
261+
private ResponseCode(int codeValue, String protocolCode, ResponseCodeType type) {
270262
this.codeValue = codeValue;
271263
this.protocolCode = protocolCode;
272264
this.type = type;
@@ -316,7 +308,7 @@ public String getProtocolCode() {
316308
* @return true if this is an error
317309
*/
318310
public boolean isExceptionOrError() {
319-
return type == TYPE.ERROR || type == TYPE.EXCEPTION;
311+
return type == ResponseCodeType.ERROR || type == ResponseCodeType.EXCEPTION;
320312
}
321313

322314
/**
@@ -335,14 +327,14 @@ public boolean isOKResult() {
335327
* @return true if this is an error
336328
*/
337329
public boolean isError() {
338-
return type == TYPE.ERROR;
330+
return type == ResponseCodeType.ERROR;
339331
}
340332

341333
/**
342334
* @return True if this is an exception.
343335
*/
344336
public boolean isException() {
345-
return type == TYPE.EXCEPTION;
337+
return type == ResponseCodeType.EXCEPTION;
346338
}
347339

348340
private static String generateSwiftConstants() {

0 commit comments

Comments
 (0)