public static CreateResponse internalServerError(String errorMessage) { return new CreateResponse(ResponseCode.INTERNAL_SERVER_ERROR, null, errorMessage); } }
public static CreateResponse notFound() { return new CreateResponse(ResponseCode.NOT_FOUND, null, null); }
public static CreateResponse unauthorized() { return new CreateResponse(ResponseCode.UNAUTHORIZED, null, null); }
public static CreateResponse success(String location) { return new CreateResponse(ResponseCode.CREATED, location, null); }
public static CreateResponse unsupportedContentFormat() { return new CreateResponse(ResponseCode.UNSUPPORTED_CONTENT_FORMAT, null, null); }
public static CreateResponse badRequest(String errorMessage) { return new CreateResponse(ResponseCode.BAD_REQUEST, null, errorMessage); }
public static CreateResponse methodNotAllowed() { return new CreateResponse(ResponseCode.METHOD_NOT_ALLOWED, null, null); }
return new CreateResponse();
@Override public void visit(CreateRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new CreateResponse(toLwM2mResponseCode(coapResponse.getCode()), null, coapResponse.getPayloadString(), coapResponse); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CREATED) { // handle success response: lwM2mresponse = new CreateResponse(ResponseCode.CREATED, coapResponse.getOptions().getLocationPathString(), null, coapResponse); } else { // handle unexpected response: handleUnexpectedResponseCode(registration.getEndpoint(), request, coapResponse); } }
@Override public void visit(final CreateRequest request) { switch (coapResponse.getCode()) { case CREATED: lwM2mresponse = new CreateResponse(fromCoapCode(coapResponse.getCode().value), coapResponse.getOptions() .getLocationPathString()); break; case BAD_REQUEST: case UNAUTHORIZED: case NOT_FOUND: case METHOD_NOT_ALLOWED: lwM2mresponse = new CreateResponse(fromCoapCode(coapResponse.getCode().value)); break; default: handleUnexpectedResponseCode(client.getEndpoint(), coapRequest, coapResponse); } }
case "create": { String location = o.getString("location", null); return new CreateResponse(code, location, errorMessage);
case "create": { String location = o.getString("location", null); return new CreateResponse(code, location, errorMessage);