/** * Require that a non-String field be non-null. * * @param field * @throws SiteWhereException */ protected static void requireNotNull(Object field) throws SiteWhereException { if (field == null) { throw new SiteWhereSystemException(ErrorCode.IncompleteData, ErrorLevel.ERROR); } }
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidTenantId, ErrorLevel.ERROR); } };
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidDeviceGroupToken, ErrorLevel.ERROR); } };
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidBatchOperationToken, ErrorLevel.ERROR); } };
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidDeviceSpecificationToken, ErrorLevel.ERROR); } };
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidScheduleToken, ErrorLevel.ERROR); } };
@Override public void throwInvalidKey() throws SiteWhereException { throw new SiteWhereSystemException(ErrorCode.InvalidScheduledJobToken, ErrorLevel.ERROR); } };
/** * Requires that a String field be a non null, non space-filled value. * * @param field * @throws SiteWhereException */ protected static void require(String field) throws SiteWhereException { if (StringUtils.isBlank(field)) { throw new SiteWhereSystemException(ErrorCode.IncompleteData, ErrorLevel.ERROR); } }
/** * Logic applied before deleting a device assignment. * * @param assignment * @throws SiteWhereException */ public static void deviceAssignmentDeleteLogic(IDeviceAssignment assignment) throws SiteWhereException { if (assignment.getReleasedDate() == null) { throw new SiteWhereSystemException(ErrorCode.CanNotDeleteActiveAssignment, ErrorLevel.ERROR); } }
@Override public boolean canInitialize() throws SiteWhereException { if (getLifecycleStatus() == LifecycleStatus.Started) { throw new SiteWhereSystemException(ErrorCode.TenantAlreadyStarted, ErrorLevel.ERROR); } return true; }
@Override public boolean canStart() throws SiteWhereException { if (getLifecycleStatus() == LifecycleStatus.Started) { throw new SiteWhereSystemException(ErrorCode.TenantAlreadyStarted, ErrorLevel.ERROR); } return true; }
@Override public boolean canStop() throws SiteWhereException { if (getLifecycleStatus() == LifecycleStatus.Stopped) { throw new SiteWhereSystemException(ErrorCode.TenantAlreadyStopped, ErrorLevel.ERROR); } return true; }
public List<? extends IAsset> search(String assetModuleId, String criteria) throws SiteWhereException { IAssetModule<?> match = getModule(assetModuleId); if (match != null) { List<? extends IAsset> results = match.search(criteria); Collections.sort(results); return results; } throw new SiteWhereSystemException(ErrorCode.InvalidAssetCategoryId, ErrorLevel.ERROR); }
@Override public byte[] getTenantConfiguration(UUID tenantId) throws SiteWhereException { T engine = getTenantEngineByTenantId(tenantId); if (engine == null) { throw new SiteWhereSystemException(ErrorCode.InvalidTenantId, ErrorLevel.ERROR); } return engine.getModuleConfiguration(); }
public IAsset getAssetById(String assetModuleId, String id) throws SiteWhereException { IAssetModule<?> match = getModule(assetModuleId); if (match != null) { return match.getAsset(id); } throw new SiteWhereSystemException(ErrorCode.InvalidAssetCategoryId, ErrorLevel.ERROR); }
@Override public void updateTenantConfiguration(UUID tenantId, byte[] content) throws SiteWhereException { T engine = getTenantEngineByTenantId(tenantId); if (engine == null) { throw new SiteWhereSystemException(ErrorCode.InvalidTenantId, ErrorLevel.ERROR); } engine.updateModuleConfiguration(content); }
@Override public ICustomerType deleteCustomerType(UUID id) throws SiteWhereException { Document existing = getCustomerTypeDocumentById(id); if (existing == null) { throw new SiteWhereSystemException(ErrorCode.InvalidCustomerTypeToken, ErrorLevel.ERROR); } MongoCollection<Document> types = getMongoClient().getCustomerTypesCollection(); MongoPersistence.delete(types, existing); return MongoCustomerType.fromDocument(existing); }
@Override public IArea deleteArea(UUID id) throws SiteWhereException { Document existing = getAreaDocumentById(id); if (existing == null) { throw new SiteWhereSystemException(ErrorCode.InvalidAreaToken, ErrorLevel.ERROR); } MongoCollection<Document> areas = getMongoClient().getAreasCollection(); MongoPersistence.delete(areas, existing); return MongoArea.fromDocument(existing); }
@Override public ICustomer deleteCustomer(UUID id) throws SiteWhereException { Document existing = getCustomerDocumentById(id); if (existing == null) { throw new SiteWhereSystemException(ErrorCode.InvalidCustomerToken, ErrorLevel.ERROR); } MongoCollection<Document> customers = getMongoClient().getCustomersCollection(); MongoPersistence.delete(customers, existing); return MongoCustomer.fromDocument(existing); }
@Override public IAreaType deleteAreaType(UUID id) throws SiteWhereException { Document existing = getAreaTypeDocumentById(id); if (existing == null) { throw new SiteWhereSystemException(ErrorCode.InvalidAreaTypeToken, ErrorLevel.ERROR); } MongoCollection<Document> types = getMongoClient().getAreaTypesCollection(); MongoPersistence.delete(types, existing); return MongoAreaType.fromDocument(existing); }