Skip to content

Commit

Permalink
Add missing response code defined in the lwm2m specification
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernard31 committed Nov 10, 2017
1 parent 3cab54d commit b959764
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions leshan-core/src/main/java/org/eclipse/leshan/ResponseCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public class ResponseCode {
public final static int CHANGED_CODE = 204;
/** Content correctly delivered */
public final static int CONTENT_CODE = 205;
/** Access Right Permission Denied */
public final static int UNAUTHORIZED_CODE = 401;
/** Bad request format (missing parameters, bad encoding ...) */
public final static int BAD_REQUEST_CODE = 400;
/** Access Right Permission Denied */
public final static int UNAUTHORIZED_CODE = 401;
/** This method (GET/PUT/POST/DELETE) is not allowed on this resource */
public final static int METHOD_NOT_ALLOWED_CODE = 405;
/** The Endpoint Client Name registration in the LWM2M Server is not allowed */
Expand All @@ -45,6 +45,12 @@ public class ResponseCode {
public final static int NOT_FOUND_CODE = 404;
/** None of the preferred Content-Formats can be returned */
public final static int NOT_ACCEPTABLE_CODE = 406;
/** None of the preferred Content-Formats can be returned */
public final static int REQUEST_ENTITY_INCOMPLETE_CODE = 408;
/** Supported LwM2M Versions of the Server and the Client are not compatible */
public final static int PRECONDITION_FAILED_CODE = 412;
/** None of the preferred Content-Formats can be returned */
public final static int REQUEST_ENTITY_TOO_LARGE_CODE = 413;
/** The specified format is not supported */
public final static int UNSUPPORTED_CONTENT_FORMAT_CODE = 415;
/** generic response code for unexpected error */
Expand All @@ -55,19 +61,26 @@ public class ResponseCode {
public final static ResponseCode DELETED = new ResponseCode(DELETED_CODE, "DELETED");
public final static ResponseCode CHANGED = new ResponseCode(CHANGED_CODE, "CHANGED");
public final static ResponseCode CONTENT = new ResponseCode(CONTENT_CODE, "CONTENT");
public final static ResponseCode UNAUTHORIZED = new ResponseCode(UNAUTHORIZED_CODE, "UNAUTHORIZED");
public final static ResponseCode BAD_REQUEST = new ResponseCode(BAD_REQUEST_CODE, "BAD_REQUEST");
public final static ResponseCode UNAUTHORIZED = new ResponseCode(UNAUTHORIZED_CODE, "UNAUTHORIZED");
public final static ResponseCode METHOD_NOT_ALLOWED = new ResponseCode(METHOD_NOT_ALLOWED_CODE,
"METHOD_NOT_ALLOWED");
public final static ResponseCode FORBIDDEN = new ResponseCode(FORBIDDEN_CODE, "FORBIDDEN");
public final static ResponseCode NOT_FOUND = new ResponseCode(NOT_FOUND_CODE, "NOT_FOUND");
public final static ResponseCode NOT_ACCEPTABLE = new ResponseCode(NOT_ACCEPTABLE_CODE, "NOT_ACCEPTABLE");
public final static ResponseCode REQUEST_ENTITY_INCOMPLETE = new ResponseCode(REQUEST_ENTITY_INCOMPLETE_CODE,
"REQUEST_ENTITY_INCOMPLETE");
public final static ResponseCode PRECONDITION_FAILED = new ResponseCode(PRECONDITION_FAILED_CODE,
"PRECONDITION_FAILED");
public final static ResponseCode REQUEST_ENTITY_TOO_LARGE = new ResponseCode(REQUEST_ENTITY_TOO_LARGE_CODE,
"REQUEST_ENTITY_TOO_LARGE");
public final static ResponseCode UNSUPPORTED_CONTENT_FORMAT = new ResponseCode(UNSUPPORTED_CONTENT_FORMAT_CODE,
"UNSUPPORTED_CONTENT_FORMAT");
public final static ResponseCode INTERNAL_SERVER_ERROR = new ResponseCode(INTERNAL_SERVER_ERROR_CODE, "CREATED");

private static final ResponseCode knownResponseCode[] = new ResponseCode[] { CREATED, DELETED, CHANGED, CONTENT,
UNAUTHORIZED, BAD_REQUEST, METHOD_NOT_ALLOWED, FORBIDDEN, NOT_FOUND, NOT_ACCEPTABLE,
BAD_REQUEST, UNAUTHORIZED, METHOD_NOT_ALLOWED, FORBIDDEN, NOT_FOUND, NOT_ACCEPTABLE,
REQUEST_ENTITY_INCOMPLETE, PRECONDITION_FAILED, REQUEST_ENTITY_TOO_LARGE,
UNSUPPORTED_CONTENT_FORMAT, INTERNAL_SERVER_ERROR };

private int code;
Expand Down

0 comments on commit b959764

Please sign in to comment.