use of com.axelor.auth.db.Permission in project axelor-open-suite by axelor.
the class AccessConfigImportServiceImpl method createObjectRoles.
private void createObjectRoles(Map<Integer, AccessConfig> accessMap, Row row) {
Iterator<Cell> cellIter = row.iterator();
String obj = cellIter.next().getStringCellValue();
while (cellIter.hasNext()) {
Cell cell = cellIter.next();
String value = cell.getStringCellValue();
if (Strings.isNullOrEmpty(value) || invalidValue(value)) {
continue;
}
AccessConfig config = accessMap.get(cell.getColumnIndex());
Permission permission = getPermission(obj, value.trim(), config);
addRole(config, permission);
}
}
use of com.axelor.auth.db.Permission in project axelor-open-suite by axelor.
the class PermissionAssistantService method updatePermission.
public void updatePermission(Role role, String objectName, MetaField field, String[] row) {
String[] objectNames = objectName.split("\\.");
String permName = getPermissionName(field, objectNames[objectNames.length - 1], role.getName());
Permission permission = permissionRepository.all().filter("self.name = ?1", permName).fetchOne();
boolean newPermission = false;
if (permission == null) {
newPermission = true;
permission = new Permission();
permission.setName(permName);
permission.setObject(objectName);
}
permission.setCanRead(row[0].equalsIgnoreCase("x"));
permission.setCanWrite(row[1].equalsIgnoreCase("x"));
permission.setCanCreate(row[2].equalsIgnoreCase("x"));
permission.setCanRemove(row[3].equalsIgnoreCase("x"));
permission.setCanExport(row[4].equalsIgnoreCase("x"));
permission.setCondition(row[5]);
permission.setConditionParams(row[6]);
if (newPermission) {
role.addPermission(permission);
}
}
Aggregations