use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class DataPointServiceTest method testSetRolesCannotBeNull.
@Test
@ExpectValidationException("setPermission")
public void testSetRolesCannotBeNull() {
DataPointVO vo = newVO(editUser);
setReadPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
setEditPermission(MangoPermission.requireAnyRole(roleService.getUserRole()), vo);
vo.setSetPermission(null);
service.insert(vo);
runAs.runAs(readUser, () -> {
DataPointVO fromDb = service.get(vo.getId());
assertVoEqual(vo, fromDb);
fromDb.setName("read user edited me");
fromDb.setSetPermission(new MangoPermission());
service.update(fromDb.getXid(), fromDb);
});
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class DataPointServiceTest method addRoleToCreatePermission.
void addRoleToCreatePermission(Role role, DataPointVO vo) {
DataSourceVO ds = dataSourceService.get(vo.getDataSourceId());
Set<Set<Role>> roles = new HashSet<>(ds.getEditPermission().getRoles());
Set<Role> createRole = new HashSet<>();
createRole.add(role);
roles.add(createRole);
ds.setEditPermission(new MangoPermission(roles));
dataSourceService.update(ds.getXid(), ds);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class EmailEventHandlerServiceTest method addRoleToCreatePermission.
void addRoleToCreatePermission(Role vo) {
PermissionDefinition def = ModuleRegistry.getPermissionDefinition(EventHandlerCreatePermission.PERMISSION);
Set<Set<Role>> roleSet = def.getPermission().getRoles();
Set<Set<Role>> newRoles = new HashSet<>();
newRoles.add(Collections.singleton(vo));
for (Set<Role> roles : roleSet) {
newRoles.add(new HashSet<>(roles));
}
Common.getBean(SystemPermissionService.class).update(new MangoPermission(newRoles), def);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class MangoPermissionConverter method jsonWrite.
@Override
public JsonValue jsonWrite(JsonTypeWriter writer, Object value) throws JsonException {
MangoPermission permission = (MangoPermission) value;
JsonArray outerRolesArray = new JsonArray();
for (Set<Role> roleSet : permission.getRoles()) {
JsonArray roles = new JsonArray();
for (Role role : roleSet) {
roles.add(role.getXid());
}
outerRolesArray.add(roles);
}
return outerRolesArray;
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class UserDao method savePreRelationalData.
@Override
public void savePreRelationalData(User existing, User vo) {
super.savePreRelationalData(existing, vo);
MangoPermission readPermission = permissionService.findOrCreate(vo.getReadPermission());
vo.setReadPermission(readPermission);
MangoPermission editPermission = permissionService.findOrCreate(vo.getEditPermission());
vo.setEditPermission(editPermission);
}
Aggregations