use of com.epam.pipeline.entity.user.Role in project cloud-pipeline by epam.
the class RoleManager method update.
@Transactional(propagation = Propagation.REQUIRED)
public Role update(final Long roleId, final RoleVO roleVO) {
Role role = loadRole(roleId);
role.setName(getValidName(roleVO.getName()));
role.setUserDefault(roleVO.isUserDefault());
role.setDefaultStorageId(roleVO.getDefaultStorageId());
storageValidator.validate(role);
roleDao.updateRole(role);
return role;
}
use of com.epam.pipeline.entity.user.Role in project cloud-pipeline by epam.
the class UserDaoTest method testDefaultAdmin.
@Test
public void testDefaultAdmin() {
PipelineUser admin = userDao.loadUserByName(defaultAdmin);
Assert.assertNotNull(admin);
Assert.assertEquals(defaultAdmin, admin.getUserName());
Assert.assertTrue(admin.getId().equals(1L));
Assert.assertEquals(1, admin.getRoles().size());
Assert.assertTrue(isRolePresent(DefaultRoles.ROLE_ADMIN.getRole(), admin.getRoles()));
Collection<Role> allRoles = roleDao.loadAllRoles(false);
Assert.assertEquals(EXPECTED_DEFAULT_ROLES_NUMBER, allRoles.size());
Assert.assertTrue(isRolePresent(DefaultRoles.ROLE_ADMIN.getRole(), allRoles));
Assert.assertTrue(isRolePresent(DefaultRoles.ROLE_USER.getRole(), allRoles));
}
use of com.epam.pipeline.entity.user.Role in project cloud-pipeline by epam.
the class RoleContextualPreferenceHandlerTest method isValidShouldReturnTrueIfRoleExists.
@Test
public void isValidShouldReturnTrueIfRoleExists() {
final ContextualPreference preference = new ContextualPreference(NAME, VALUE, role1Resource);
when(roleDao.loadRole(eq(Long.valueOf(role1Resource.getResourceId())))).thenReturn(Optional.of(new Role()));
assertTrue(handler().isValid(preference));
}
use of com.epam.pipeline.entity.user.Role in project cloud-pipeline by epam.
the class RoleDao method createRole.
@Transactional(propagation = Propagation.MANDATORY)
public Role createRole(String name, boolean predefined, boolean userDefault, Long storageId) {
Role role = new Role();
role.setName(name);
role.setId(daoHelper.createId(roleSequence));
role.setUserDefault(userDefault);
role.setPredefined(predefined);
role.setDefaultStorageId(storageId);
getNamedParameterJdbcTemplate().update(createRoleQuery, RoleParameters.getParameters(role));
return role;
}
use of com.epam.pipeline.entity.user.Role in project cloud-pipeline by epam.
the class RoleManager method deleteRole.
@Transactional(propagation = Propagation.REQUIRED)
public Role deleteRole(Long id) {
Role role = loadRole(id);
Assert.isTrue(!role.isPredefined(), "Predefined system roles cannot be deleted");
permissionManager.deleteGrantedAuthority(role.getName());
roleDao.deleteRoleReferences(id);
roleDao.deleteRole(id);
return role;
}
Aggregations