@Override public boolean isSuccess() { return getCode() == ResponseCode.CHANGED; }
public static BootstrapFinishResponse notAcceptable(String errorMessage) { return new BootstrapFinishResponse(ResponseCode.NOT_ACCEPTABLE, errorMessage); }
@Override public void onResponse(BootstrapFinishResponse response) { LOG.trace("Bootstrap Finished {} return code {}", session.getEndpoint(), response.getCode()); if (response.isSuccess()) { sessionManager.end(session); } else { sessionManager.failed(session, FINISHED_WITH_ERROR, finishBootstrapRequest); } } }, new ErrorCallback() {
Response coapResponse = new Response(toCoapResponseCode(sendableResponse.getResponse().getCode())); if (sendableResponse.getResponse().getCode().isError()) { coapResponse.setPayload(sendableResponse.getResponse().getErrorMessage()); coapResponse.getOptions().setContentFormat(MediaTypeRegistry.TEXT_PLAIN);
public synchronized SendableResponse<BootstrapFinishResponse> finished(ServerIdentity identity, BootstrapFinishRequest finishedRequest) { if (bootstrapping) { // only if the request is from the bootstrap server if (!isBootstrapServer(identity)) { return new SendableResponse<>(BootstrapFinishResponse.badRequest("not from a bootstrap server")); } // TODO delete bootstrap server (see 5.2.5.2 Bootstrap Delete) Runnable whenSent = new Runnable() { @Override public void run() { bootstrappingLatch.countDown(); } }; return new SendableResponse<>(BootstrapFinishResponse.success(), whenSent); } else { return new SendableResponse<>(BootstrapFinishResponse.badRequest("no pending bootstrap session")); } }
public static BootstrapFinishResponse internalServerError(String errorMessage) { return new BootstrapFinishResponse(ResponseCode.INTERNAL_SERVER_ERROR, errorMessage); } }
public static BootstrapFinishResponse success() { return new BootstrapFinishResponse(ResponseCode.CHANGED, null); }
public static BootstrapFinishResponse badRequest(String errorMessage) { return new BootstrapFinishResponse(ResponseCode.BAD_REQUEST, errorMessage); }
@Override public void visit(BootstrapFinishRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new BootstrapFinishResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString(), coapResponse); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CHANGED) { // handle success response: lwM2mresponse = new BootstrapFinishResponse(ResponseCode.CHANGED, null, coapResponse); } else { // handle unexpected response: handleUnexpectedResponseCode(registration.getEndpoint(), request, coapResponse); } }