private ReadRequest(ContentFormat format, LwM2mPath target) { super(target); if (target.isRoot()) throw new InvalidRequestException("Read request cannot target root path"); this.format = format; }
private DiscoverRequest(LwM2mPath target) { super(target); if (target.isRoot()) throw new InvalidRequestException("Discover request cannot target root path"); }
private ObserveRequest(ContentFormat format, LwM2mPath target, Map<String, String> context) { super(target); if (target.isRoot()) throw new InvalidRequestException("Observe request cannot target root path"); this.format = format; if (context == null || context.isEmpty()) this.context = Collections.emptyMap(); else this.context = Collections.unmodifiableMap(new HashMap<>(context)); }
private WriteAttributesRequest(LwM2mPath path, AttributeSet attributes) throws InvalidRequestException { super(path); if (path.isRoot()) throw new InvalidRequestException("WriteAttributes request cannot target root path"); if (attributes == null) throw new InvalidRequestException("attributes are mandatory for %s", path); this.attributes = attributes; }
private ExecuteRequest(LwM2mPath path, String parameters) { super(path); if (path.isRoot()) throw new InvalidRequestException("Execute request cannot target root path"); if (!path.isResource()) throw new InvalidRequestException("Invalid path %s : Only resource can be executed.", path); this.parameters = parameters; }
private DeleteRequest(LwM2mPath target) { super(target); if (target.isRoot()) throw new InvalidRequestException("Delete request cannot target root path"); if (!target.isObjectInstance()) throw new InvalidRequestException("Invalid path %s : Only object instances can be delete", target); }
/** * @param path the end of the new path * @return a new path which is the concatenation of this path and the given one in parameter. */ public LwM2mPath append(String path) { LwM2mPath pathToAdd = new LwM2mPath(path); if (isRoot()) { return pathToAdd; } else { return new LwM2mPath(this.toString() + pathToAdd.toString()); } }
/** * Create a Object Link referencing an object instance with the given path. */ public static ObjectLink fromPath(String path) { LwM2mPath lwM2mPath = new LwM2mPath(path); if (lwM2mPath.isRoot()) { return new ObjectLink(); // create null link } else if (lwM2mPath.isObjectInstance()) { return new ObjectLink(lwM2mPath.getObjectId(), lwM2mPath.getObjectInstanceId()); } else { throw new IllegalArgumentException("Invalid path: ObjectLink should reference an object instance"); } }
@Override public BootstrapDeleteResponse doDelete(BootstrapDeleteRequest request) { if (request.getPath().isRoot() || request.getPath().isObject()) { if (id == LwM2mId.SECURITY) {
private CreateRequest(ContentFormat format, LwM2mPath target, Integer instanceId, LwM2mResource[] resources) { super(target); // accept only object and object instance path if (target.isRoot()) throw new InvalidRequestException("Create request cannot target root path"); if (!target.isObject() && !target.isObjectInstance()) throw new InvalidRequestException( "Invalid path %s: Create request must not target an object or object instance", target); // validate instance id if (instanceId != null && instanceId == LwM2mObjectInstance.UNDEFINED) { instanceId = null; } if (target.isObjectInstance()) { if (instanceId == null) { instanceId = target.getObjectInstanceId(); } else { if (!instanceId.equals(target.getObjectInstanceId())) { throw new InvalidRequestException("Conflict between path instance id %s and node instance id %s", target, instanceId); } } } if (instanceId != null && instanceId < 0) throw new InvalidRequestException("Invalid instance id %s for path %s ", instanceId, target); // store attributes this.instanceId = instanceId; this.resources = Collections.unmodifiableList(Arrays.asList(resources)); this.contentFormat = format != null ? format : ContentFormat.TLV; // default to TLV }
public BootstrapWriteRequest(LwM2mPath target, LwM2mNode node, ContentFormat format) throws InvalidRequestException { super(target); if (target.isRoot()) throw new InvalidRequestException("BootstrapWrite request cannot target root path");
private WriteRequest(Mode mode, ContentFormat format, LwM2mPath target, LwM2mNode node) { super(target); if (target.isRoot()) throw new InvalidRequestException("Write request cannot target root path"); if (mode == null)