@Override public boolean isSuccess() { return getCode() == ResponseCode.CHANGED; }
public static UpdateResponse internalServerError(String errorMessage) { return new UpdateResponse(ResponseCode.INTERNAL_SERVER_ERROR, errorMessage); } }
} else if (response.getCode() == ResponseCode.CHANGED) { LOG.error("Registration update failed: {} {}.", response.getCode(), response.getErrorMessage()); if (observer != null) { observer.onUpdateFailure(server, response.getCode(), response.getErrorMessage());
@Override public void visit(UpdateRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new UpdateResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString()); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CHANGED) { // handle success response: lwM2mresponse = UpdateResponse.success(); } else { // handle unexpected response: handleUnexpectedResponseCode(request, coapResponse); } }
return new SendableResponse<>(UpdateResponse.notFound()); return new SendableResponse<>(UpdateResponse.badRequest("forbidden")); if (updatedRegistration == null) { LOG.debug("Invalid update: registration {} not found", registration.getId()); return new SendableResponse<>(UpdateResponse.notFound()); } else { LOG.debug("Updated registration {} by {}", updatedRegistration, update); }; }; return new SendableResponse<>(UpdateResponse.success(), whenSent);
if (updateResponse.getCode().isError()) { exchange.respond(toCoapResponseCode(updateResponse.getCode()), updateResponse.getErrorMessage()); } else { exchange.respond(toCoapResponseCode(updateResponse.getCode()));
public static UpdateResponse badRequest(String errorMessage) { return new UpdateResponse(ResponseCode.BAD_REQUEST, errorMessage); }
public static UpdateResponse success() { return new UpdateResponse(ResponseCode.CHANGED, null); }
public static UpdateResponse notFound() { return new UpdateResponse(ResponseCode.NOT_FOUND, null); }