public static WriteAttributesResponse internalServerError(String errorMessage) { return new WriteAttributesResponse(ResponseCode.INTERNAL_SERVER_ERROR, errorMessage); } }
@Override public boolean isSuccess() { return getCode() == ResponseCode.CHANGED; }
@Override public synchronized WriteAttributesResponse writeAttributes(ServerIdentity identity, WriteAttributesRequest request) { // TODO should be implemented here to be available for all object enabler // This should be a not implemented error, but this is not defined in the spec. return WriteAttributesResponse.internalServerError("not implemented"); }
WriteAttributesResponse response = nodeEnabler.writeAttributes(identity, new WriteAttributesRequest(URI, attributes)); if (response.getCode().isError()) { coapExchange.respond(toCoapResponseCode(response.getCode()), response.getErrorMessage()); } else { coapExchange.respond(toCoapResponseCode(response.getCode()));
public static WriteAttributesResponse success() { return new WriteAttributesResponse(ResponseCode.CHANGED, null); }
public static WriteAttributesResponse notFound() { return new WriteAttributesResponse(ResponseCode.NOT_FOUND, null); }
public static WriteAttributesResponse badRequest(String errorMessage) { return new WriteAttributesResponse(ResponseCode.BAD_REQUEST, errorMessage); }
public static WriteAttributesResponse unauthorized() { return new WriteAttributesResponse(ResponseCode.UNAUTHORIZED, null); }
public static WriteAttributesResponse methodNotAllowed() { return new WriteAttributesResponse(ResponseCode.METHOD_NOT_ALLOWED, null); }
@Override public void visit(WriteAttributesRequest request) { if (coapResponse.isError()) { // handle error response: lwM2mresponse = new WriteAttributesResponse(toLwM2mResponseCode(coapResponse.getCode()), coapResponse.getPayloadString(), coapResponse); } else if (coapResponse.getCode() == org.eclipse.californium.core.coap.CoAP.ResponseCode.CHANGED) { // handle success response: lwM2mresponse = new WriteAttributesResponse(ResponseCode.CHANGED, null, coapResponse); } else { // handle unexpected response: handleUnexpectedResponseCode(registration.getEndpoint(), request, coapResponse); } }
return new ExecuteResponse(code, errorMessage); case "writeAttributes": { return new WriteAttributesResponse(code, errorMessage);
return new ExecuteResponse(code, errorMessage); case "writeAttributes": { return new WriteAttributesResponse(code, errorMessage);