public static DeleteResponse internalServerError(String errorMessage) { return new DeleteResponse(ResponseCode.INTERNAL_SERVER_ERROR, errorMessage); } }
@Override public boolean isSuccess() { return getCode() == ResponseCode.DELETED; }
protected DeleteResponse doDelete(DeleteRequest request) { // This should be a not implemented error, but this is not defined in the spec. return DeleteResponse.internalServerError("not implemented"); }
@Override public void handleDELETE(CoapExchange coapExchange) { // Manage Delete Request String URI = coapExchange.getRequestOptions().getUriPathString(); ServerIdentity identity = extractServerIdentity(coapExchange, bootstrapHandler); if (identity.isLwm2mBootstrapServer()) { BootstrapDeleteResponse response = nodeEnabler.delete(identity, new BootstrapDeleteRequest(URI)); if (response.getCode().isError()) { coapExchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage()); } else { coapExchange.respond(toCoapResponseCode(response.getCode())); } } else { DeleteResponse response = nodeEnabler.delete(identity, new DeleteRequest(URI)); if (response.getCode().isError()) { coapExchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage()); } else { coapExchange.respond(toCoapResponseCode(response.getCode())); } } }
@Override public synchronized DeleteResponse delete(ServerIdentity identity, DeleteRequest request) { if (!identity.isSystem()) { // delete the security object is forbidden if (id == LwM2mId.SECURITY) { return DeleteResponse.notFound(); } if (id == LwM2mId.DEVICE) { return DeleteResponse.methodNotAllowed(); } } return doDelete(request); }
public static DeleteResponse unauthorized() { return new DeleteResponse(ResponseCode.UNAUTHORIZED, null); }
public static DeleteResponse success() { return new DeleteResponse(ResponseCode.DELETED, null); }
public static DeleteResponse badRequest(String errorMessage) { return new DeleteResponse(ResponseCode.BAD_REQUEST, errorMessage); }
public static DeleteResponse notFound() { return new DeleteResponse(ResponseCode.NOT_FOUND, null); }
public static DeleteResponse methodNotAllowed() { return new DeleteResponse(ResponseCode.METHOD_NOT_ALLOWED, null); }
@Override public void visit(DeleteRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new DeleteResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString(), coapResponse); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.DELETED) { // handle success response: lwM2mresponse = new DeleteResponse(ResponseCode.DELETED, null, coapResponse); } else { // handle unexpected response: handleUnexpectedResponseCode(registration.getEndpoint(), request, coapResponse); } }
return new DeleteResponse(code, errorMessage); case "discover": String objectLinks = o.getString("objectLinks", "");
return new DeleteResponse(code, errorMessage); case "discover": String objectLinks = o.getString("objectLinks", "");