diff --git a/Maintenance Events/src/com/infiniteautomation/mango/spring/service/maintenanceEvents/MaintenanceEventsService.java b/Maintenance Events/src/com/infiniteautomation/mango/spring/service/maintenanceEvents/MaintenanceEventsService.java index ea35cdd4e..c3c5dfd30 100644 --- a/Maintenance Events/src/com/infiniteautomation/mango/spring/service/maintenanceEvents/MaintenanceEventsService.java +++ b/Maintenance Events/src/com/infiniteautomation/mango/spring/service/maintenanceEvents/MaintenanceEventsService.java @@ -249,7 +249,7 @@ public void row(DataPointVO point, int index) { DataSourceVO newDs = dataSourceDao.get(k); return newDs; }); - if(!permissionService.hasDataSourcePermission(user, source)) + if(!permissionService.hasDataSourceEditPermission(user, source)) hasPermission.setFalse(); } }else { @@ -257,7 +257,7 @@ public void row(DataPointVO point, int index) { DataSourceVO newDs = dataSourceDao.get(k); return newDs; }); - if(!permissionService.hasDataSourcePermission(user, source)) + if(!permissionService.hasDataSourceEditPermission(user, source)) hasPermission.setFalse(); } } @@ -289,7 +289,7 @@ public void row(DataSourceVO source, int index) { //short circuit the logic if we already failed return; }else { - if(!permissionService.hasDataSourcePermission(user, source)) + if(!permissionService.hasDataSourceEditPermission(user, source)) hasPermission.setFalse(); } } diff --git a/Maintenance Events/src/com/serotonin/m2m2/maintenanceEvents/MaintenanceEventType.java b/Maintenance Events/src/com/serotonin/m2m2/maintenanceEvents/MaintenanceEventType.java index 636d42df5..a87bc03c0 100644 --- a/Maintenance Events/src/com/serotonin/m2m2/maintenanceEvents/MaintenanceEventType.java +++ b/Maintenance Events/src/com/serotonin/m2m2/maintenanceEvents/MaintenanceEventType.java @@ -112,7 +112,7 @@ public boolean hasPermission(PermissionHolder user, PermissionService service) { return false; else { for(int dsId : vo.getDataSources()) - if(!service.hasDataSourcePermission(user, dsId)) + if(!service.hasDataSourceEditPermission(user, dsId)) return false; for(int dpId : vo.getDataPoints()) { diff --git a/Mango API/src/com/infiniteautomation/mango/rest/v2/DataPointTagsRestController.java b/Mango API/src/com/infiniteautomation/mango/rest/v2/DataPointTagsRestController.java index ff168c5c9..625ade676 100644 --- a/Mango API/src/com/infiniteautomation/mango/rest/v2/DataPointTagsRestController.java +++ b/Mango API/src/com/infiniteautomation/mango/rest/v2/DataPointTagsRestController.java @@ -263,7 +263,7 @@ public Map setTagsForDataPoint( DataPointVO dataPoint = dataPointService.get(xid); PermissionHolder user = Common.getUser(); - permissionService.ensureDataSourcePermission(user, dataPoint.getDataSourceId()); + permissionService.ensureDataSourceEditPermission(user, dataPoint.getDataSourceId()); dataPoint.setTags(tags); dataPointTagsDao.saveDataPointTags(dataPoint); @@ -285,7 +285,7 @@ public Map mergeTagsForDataPoint( return dataPointTagsDao.doInTransaction(txStatus -> { DataPointVO dataPoint = dataPointService.get(xid); PermissionHolder user = Common.getUser(); - permissionService.ensureDataSourcePermission(user, dataPoint.getDataSourceId()); + permissionService.ensureDataSourceEditPermission(user, dataPoint.getDataSourceId()); Map existingTags = dataPointTagsDao.getTagsForDataPointId(dataPoint.getId()); diff --git a/Mango API/src/com/infiniteautomation/mango/rest/v2/EventTypesRestController.java b/Mango API/src/com/infiniteautomation/mango/rest/v2/EventTypesRestController.java index 94095092a..96cee2b14 100644 --- a/Mango API/src/com/infiniteautomation/mango/rest/v2/EventTypesRestController.java +++ b/Mango API/src/com/infiniteautomation/mango/rest/v2/EventTypesRestController.java @@ -316,7 +316,7 @@ private List> getEventTypesForSubtype(String typeName, S throw new BadRequestException(); for(DataSourceVO vo : dataSourceDao.getAll()) { - if(permissionService.hasDataSourcePermission(user, vo)) { + if(permissionService.hasDataSourceEditPermission(user, vo)) { AbstractDataSourceModel dsModel = modelMapper.map(vo, AbstractDataSourceModel.class, user); DataSourceEventTypeModel model = new DataSourceEventTypeModel(new DataSourceEventType(vo.getId(), 0), dsModel); types.add(new EventTypeVOModel, String>(model, new TranslatableMessage("event.eventsFor", vo.getName()), false, true, true)); @@ -420,7 +420,7 @@ private List> getEventTypesForSubtypeAndReferenceId1(Str if(ds == null) throw new NotFoundException(); - permissionService.ensureDataSourcePermission(user, ds); + permissionService.ensureDataSourceEditPermission(user, ds); AbstractDataSourceModel dsModel = modelMapper.map(ds, AbstractDataSourceModel.class, user); for(EventTypeVO type : ds.getEventTypes()) { DataSourceEventType eventType = (DataSourceEventType)type.getEventType(); diff --git a/Mango API/src/com/infiniteautomation/mango/rest/v2/PointValueRestController.java b/Mango API/src/com/infiniteautomation/mango/rest/v2/PointValueRestController.java index 11bc005a5..825c31434 100644 --- a/Mango API/src/com/infiniteautomation/mango/rest/v2/PointValueRestController.java +++ b/Mango API/src/com/infiniteautomation/mango/rest/v2/PointValueRestController.java @@ -1195,7 +1195,7 @@ private ResponseEntity extends Ab private List eventAlarmLevels; private PurgeSettings purgeSettings; private Set editPermission; + private Set readPermission; public AbstractDataSourceModel() { @@ -102,6 +103,10 @@ public void fromVO(T vo) { for(Role role : vo.getEditRoles()) { this.editPermission.add(role.getXid()); } + this.readPermission = new HashSet<>(); + for(Role role : vo.getReadRoles()) { + this.readPermission.add(role.getXid()); + } } @Override @@ -118,6 +123,7 @@ public T toVO() { purgeSettings.toVO(vo); PermissionService service = Common.getBean(PermissionService.class); vo.setEditRoles(service.explodeLegacyPermissionGroupsToRoles(editPermission)); + vo.setReadRoles(service.explodeLegacyPermissionGroupsToRoles(readPermission)); return vo; } @@ -201,4 +207,12 @@ public void setEditPermission(Set editPermission) { this.editPermission = editPermission; } + public Set getReadPermission() { + return readPermission; + } + + public void setReadPermission(Set readPermission) { + this.readPermission = readPermission; + } + } diff --git a/Mango API/src/com/infiniteautomation/mango/rest/v2/websocket/DataPointWebSocketHandler.java b/Mango API/src/com/infiniteautomation/mango/rest/v2/websocket/DataPointWebSocketHandler.java index d5f0bc684..4c75af147 100644 --- a/Mango API/src/com/infiniteautomation/mango/rest/v2/websocket/DataPointWebSocketHandler.java +++ b/Mango API/src/com/infiniteautomation/mango/rest/v2/websocket/DataPointWebSocketHandler.java @@ -37,7 +37,7 @@ public DataPointWebSocketHandler(RestModelMapper mapper, PermissionService permi @Override protected boolean hasPermission(PermissionHolder user, DataPointVO vo) { - return user.hasAdminRole() || permissionService.hasDataSourcePermission(user, vo.getDataSourceId()); + return user.hasAdminRole() || permissionService.hasDataSourceEditPermission(user, vo.getDataSourceId()); } @Override