use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
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 infiniteautomation.
the class DataPointDao method mapRecord.
@Override
public DataPointVO mapRecord(Record record) {
int id = record.get(table.id);
String xid = record.get(table.xid);
String name = record.get(table.name);
DataPointVO dp = (DataPointVO) SerializationHelper.readObjectInContextFromArray(record.get(table.data));
dp.setId(id);
dp.setXid(xid);
dp.setName(name);
dp.setDataSourceId(record.get(table.dataSourceId));
dp.setDeviceName(record.get(table.deviceName));
dp.setEnabled(charToBool(record.get(table.enabled)));
dp.setLoggingType(record.get(table.loggingType));
dp.setIntervalLoggingPeriodType(record.get(table.intervalLoggingPeriodType));
dp.setIntervalLoggingPeriod(record.get(table.intervalLoggingPeriod));
dp.setIntervalLoggingType(record.get(table.intervalLoggingType));
dp.setTolerance(record.get(table.tolerance));
dp.setPurgeOverride(charToBool(record.get(table.purgeOverride)));
dp.setPurgeType(record.get(table.purgeType));
dp.setPurgePeriod(record.get(table.purgePeriod));
dp.setDefaultCacheSize(record.get(table.defaultCacheSize));
dp.setDiscardExtremeValues(charToBool(record.get(table.discardExtremeValues)));
dp.setEngineeringUnits(record.get(table.engineeringUnits));
dp.setRollup(record.get(table.rollup));
// // read and discard dataTypeId
// record.get(table.xyz);
// // read and discard settable boolean
// record.get(table.xyz);
dp.setData(extractDataFromObject(record.get(table.jsonData)));
dp.setSeriesId(record.get(table.seriesId));
MangoPermission read = new MangoPermission(record.get(table.readPermissionId));
dp.supplyReadPermission(() -> read);
MangoPermission edit = new MangoPermission(record.get(table.editPermissionId));
dp.supplyEditPermission(() -> edit);
MangoPermission set = new MangoPermission(record.get(table.setPermissionId));
dp.supplySetPermission(() -> set);
// Data source information from join
dp.setDataSourceName(record.get(dataSources.name));
dp.setDataSourceXid(record.get(dataSources.xid));
dp.setDataSourceTypeName(record.get(dataSources.dataSourceType));
dp.ensureUnitsCorrect();
return dp;
}
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 PermissionService method get.
/**
* Get a permission from the cache, load from db if necessary
* @param id
* @return
* @throws NotFoundException if permission with this ID not found
*/
public MangoPermission get(Integer id) throws NotFoundException {
Objects.requireNonNull(id);
MangoPermission permission = permissionCache.computeIfAbsent(id, this::loadPermission);
if (permission == null) {
throw new NotFoundException();
} else {
return permission.withId(id);
}
}
use of com.infiniteautomation.mango.permission.MangoPermission in project ma-core-public by infiniteautomation.
the class DataPointService method getReadPermission.
/**
* Get the read permission for this data point
*/
public MangoPermission getReadPermission(int dataPointId) throws NotFoundException, PermissionException {
PermissionHolder user = Common.getUser();
Integer permissionId = dao.getReadPermissionId(dataPointId);
if (permissionId == null) {
throw new NotFoundException();
}
MangoPermission read = permissionService.get(permissionId);
permissionService.ensurePermission(user, read);
return read;
}
Aggregations