@Override public void visit(BootstrapWriteRequest request) { coapRequest = Request.newPut(); coapRequest.setConfirmable(true); ContentFormat format = request.getContentFormat(); coapRequest.getOptions().setContentFormat(format.getCode()); coapRequest.setPayload(encoder.encode(request.getNode(), format, request.getPath(), model)); setTarget(coapRequest, request.getPath()); }
final LwM2mNode securityInstance = convertToSecurityInstance(key, securityConfig); final BootstrapWriteRequest writeBootstrapRequest = new BootstrapWriteRequest(path, securityInstance, session.getContentFormat()); send(session, writeBootstrapRequest, new ResponseCallback<BootstrapWriteResponse>() {
if (getPath().isResource()) { if (!(node instanceof LwM2mResource)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, node.getClass().getSimpleName()); } else if (getPath().isObjectInstance()) { if (!(node instanceof LwM2mObjectInstance)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, node.getClass().getSimpleName()); } else if (getPath().isObject()) { if (!(node instanceof LwM2mObject)) { throw new InvalidRequestException("path '%s' and node type '%s' do not match", target, if (!getPath().isResource()) { throw new InvalidRequestException( "Invalid format for path %s: %s format must be used only for single resources", target, format);
@Override protected BootstrapWriteResponse doWrite(ServerIdentity identity, BootstrapWriteRequest request) { LwM2mPath path = request.getPath(); for (LwM2mObjectInstance instanceNode : ((LwM2mObject) request.getNode()).getInstances().values()) { LwM2mInstanceEnabler instanceEnabler = instances.get(instanceNode.getId()); if (instanceEnabler == null) { LwM2mObjectInstance instanceNode = (LwM2mObjectInstance) request.getNode(); LwM2mInstanceEnabler instanceEnabler = instances.get(path.getObjectInstanceId()); if (instanceEnabler == null) { doCreate(new CreateRequest(path.getObjectId(), instanceNode)); } else { doWrite(identity, new WriteRequest(Mode.REPLACE, request.getContentFormat(), path.getObjectId(), path.getObjectInstanceId(), instanceNode.getResources().values())); LwM2mResource resource = (LwM2mResource) request.getNode(); LwM2mInstanceEnabler instanceEnabler = instances.get(path.getObjectInstanceId()); if (instanceEnabler == null) {
final LwM2mNode serverInstance = convertToServerInstance(key, serverConfig); final BootstrapWriteRequest writeServerRequest = new BootstrapWriteRequest(path, serverInstance, session.getContentFormat()); send(session, writeServerRequest, new ResponseCallback<BootstrapWriteResponse>() {
if (identity.isLwm2mBootstrapServer()) { BootstrapWriteResponse response = nodeEnabler.write(identity, new BootstrapWriteRequest(path, lwM2mNode, contentFormat)); if (response.getCode().isError()) { coapExchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage());