Registration registration = server.getRegistrationService().getByEndpoint(clientEndpoint); if (registration != null) { DeleteRequest request = new DeleteRequest(target); DeleteResponse cResponse = server.send(registration, request, TIMEOUT); processDeviceResponse(req, resp, cResponse);
public synchronized BootstrapDeleteResponse delete(ServerIdentity identity, BootstrapDeleteRequest deleteRequest) { if (bootstrapping) { // Only if the request is from the bootstrap server if (!isBootstrapServer(identity)) { return BootstrapDeleteResponse.badRequest("not from a bootstrap server"); } // The spec say that delete on "/" should delete all the existing Object Instances - except LWM2M // Bootstrap Server Account, (see 5.2.5.2 Bootstrap Delete) // For now we only remove security and server object. // Delete all device management server LwM2mObjectEnabler serverObject = objects.get(SERVER); for (Integer instanceId : serverObject.getAvailableInstanceIds()) { serverObject.delete(identity, new DeleteRequest(SERVER, instanceId)); } // Delete all security instance (except bootstrap one) // TODO do not delete bootstrap server (see 5.2.5.2 Bootstrap Delete) LwM2mObjectEnabler securityObject = objects.get(SECURITY); for (Integer instanceId : securityObject.getAvailableInstanceIds()) { securityObject.delete(identity, new DeleteRequest(SECURITY, instanceId)); } return BootstrapDeleteResponse.success(); } else { return BootstrapDeleteResponse.badRequest("no pending bootstrap session"); } }
return new DeleteRequest(path); case "discover": return new DiscoverRequest(path);
return new DeleteRequest(path); case "discover": return new DiscoverRequest(path);
@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())); } } }