@Override public IDevice getDeviceByToken(String token) throws SiteWhereException { return getDelegate().getDeviceByToken(token); }
@Override public IBatchElement createBatchElement(UUID batchOperationId, IBatchElementCreateRequest request) throws SiteWhereException { MongoCollection<Document> elements = getMongoClient().getBatchOperationElementsCollection(); IBatchOperation operation = getBatchOperation(batchOperationId); IDevice device = getDeviceManagement().getDeviceByToken(request.getDeviceToken()); BatchElement element = BatchManagementPersistence.batchElementCreateLogic(operation, device); Document created = MongoBatchElement.toDocument(element); MongoPersistence.insert(elements, created, ErrorCode.DuplicateBatchElement); return element; }
IDevice device = null; try { device = getDeviceManagement().getDeviceByToken(payload.getDeviceToken()); } finally { deviceLookupTime.stop();
@Override public void getDeviceByToken(GGetDeviceByTokenRequest request, StreamObserver<GGetDeviceByTokenResponse> responseObserver) { try { GrpcUtils.handleServerMethodEntry(this, DeviceManagementGrpc.getGetDeviceByTokenMethod()); IDevice apiResult = getDeviceManagement().getDeviceByToken(request.getToken()); GGetDeviceByTokenResponse.Builder response = GGetDeviceByTokenResponse.newBuilder(); if (apiResult != null) { response.setDevice(DeviceModelConverter.asGrpcDevice(apiResult)); } responseObserver.onNext(response.build()); responseObserver.onCompleted(); } catch (Throwable e) { GrpcUtils.handleServerMethodException(DeviceManagementGrpc.getGetDeviceByTokenMethod(), e, responseObserver); } finally { GrpcUtils.handleServerMethodExit(DeviceManagementGrpc.getGetDeviceByTokenMethod()); } }
IDevice mapped = management.getDeviceByToken(match.getDeviceToken()); if (mapped != null) { DeviceCreateRequest nested = new DeviceCreateRequest();
/** * Get the current assignment or throw errors if it can not be resolved. * * @param deviceToken * @return * @throws SiteWhereException */ protected IDeviceAssignment getCurrentAssignment(String deviceToken) throws SiteWhereException { IDevice device = getDeviceManagement(getTenantEngine().getTenant()).getDeviceByToken(deviceToken); if (device == null) { throw new SiteWhereSystemException(ErrorCode.InvalidDeviceToken, ErrorLevel.ERROR); } if (device.getDeviceAssignmentId() == null) { throw new SiteWhereSystemException(ErrorCode.DeviceNotAssigned, ErrorLevel.ERROR); } return getDeviceManagement(getTenantEngine().getTenant()).getDeviceAssignment(device.getDeviceAssignmentId()); }
@Override public IDeviceContext<byte[]> buildContext(IMessageMetadata<byte[]> metadata) throws SiteWhereException { BinaryDeviceContext context = new BinaryDeviceContext(); IDeviceManagement devices = getDeviceManagement(getTenantEngine().getTenant()); context.setDevice(devices.getDeviceByToken(metadata.getDeviceToken())); if (context.getDevice() == null) { throw new SiteWhereException( "Unable to build device context. Device not found for token: " + metadata.getDeviceToken()); } context.setDeviceType(devices.getDeviceType(context.getDevice().getDeviceTypeId())); context.setPayload(metadata.getPayload()); return context; }
throw new SiteWhereSystemException(ErrorCode.InvalidDeviceId, ErrorLevel.ERROR); IDevice mapped = management.getDeviceByToken(request.getDeviceToken()); if (mapped == null) { throw new SiteWhereException("Device referenced by mapping does not exist.");
DeviceElementMapping cnvMapping = DeviceElementMapping.copy(mapping); if (isIncludeNested()) { IDevice device = getDeviceManagement().getDeviceByToken(mapping.getDeviceToken()); cnvMapping.setDevice(getNestedHelper().convert(device, assetManagement));
IDevice device = getDeviceManagement().getDeviceByToken(registration.getDeviceToken()); IDeviceCreateRequest request = registration.getDeviceRegistrationRequest(); if (device == null) {