use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by MangoAutomation.
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 MangoAutomation.
the class MangoPermissionConverter method jsonWrite.
@Override
public void jsonWrite(JsonWriter writer, Object value) throws IOException, 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);
}
writer.writeObject(outerRolesArray);
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by MangoAutomation.
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 MangoAutomation.
the class AbstractVOServiceWithPermissionsTest method removeRoleFromCreatePermission.
void removeRoleFromCreatePermission(Role vo) {
String permissionType = getCreatePermissionType();
if (permissionType != null) {
PermissionDefinition def = ModuleRegistry.getPermissionDefinition(getCreatePermissionType());
MangoPermission permission = def.getPermission();
Common.getBean(SystemPermissionService.class).update(new MangoPermission(permission.withoutRole(vo).getRoles()), def);
}
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by MangoAutomation.
the class SetPointEventHandlerServiceTest 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);
}
Aggregations