@Override public boolean isSuccess() { return getCode() == ResponseCode.CHANGED; }
public static BootstrapResponse internalServerError(String errorMessage) { return new BootstrapResponse(ResponseCode.INTERNAL_SERVER_ERROR, errorMessage); } }
if (response.isSuccess()) { exchange.respond(toCoapResponseCode(response.getCode())); } else { exchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage());
@Override public void visit(BootstrapRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new BootstrapResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString()); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CHANGED) { // handle success response: lwM2mresponse = BootstrapResponse.success(); } else { // handle unexpected response: handleUnexpectedResponseCode(request, coapResponse); } }
public BootstrapResponse bootstrap(Identity sender, BootstrapRequest request) { String endpoint = request.getEndpointName(); // Start session, checking the BS credentials final BootstrapSession session = this.sessionManager.begin(endpoint, sender); if (!session.isAuthorized()) { this.sessionManager.failed(session, UNAUTHORIZED, null); return BootstrapResponse.badRequest("Unauthorized"); } // Get the desired bootstrap config for the endpoint final BootstrapConfig cfg = store.getBootstrap(endpoint, sender); if (cfg == null) { LOG.debug("No bootstrap config for {}", endpoint); this.sessionManager.failed(session, NO_BOOTSTRAP_CONFIG, null); return BootstrapResponse.badRequest("no bootstrap config"); } // Start the bootstrap session e.execute(new Runnable() { @Override public void run() { sendDelete(session, cfg); } }); return BootstrapResponse.success(); }
} else if (response.isSuccess()) { LOG.info("Bootstrap started"); LOG.error("Bootstrap failed: {} {}.", response.getCode(), response.getErrorMessage()); if (observer != null) { observer.onBootstrapFailure(bootstrapServer, response.getCode(), response.getErrorMessage());
public static BootstrapResponse success() { return new BootstrapResponse(ResponseCode.CHANGED, null); }
public static BootstrapResponse badRequest(String errorMessage) { return new BootstrapResponse(ResponseCode.BAD_REQUEST, errorMessage); }