class UserRolesServiceImpl implements UserRolesService {

	@Override
	public String updateUserRole(final UpdateRoleDetailsRequest roleDetailsRequest, final String userId) throws PacManException {
		boolean isRoleNameExits = userRolesRepository.existsById(roleDetailsRequest.getRoleId());
		if (isRoleNameExits) {
			try {
				Date currentDate = new Date();
				UserRoles userRole = userRolesRepository.findById(roleDetailsRequest.getRoleId()).get();
				userRole.setModifiedDate(currentDate);
				userRole.setOwner(userId);
				userRole.setRoleDesc(roleDetailsRequest.getDescription());
				userRole.setRoleName(roleDetailsRequest.getRoleName());
				userRole.setWritePermission(roleDetailsRequest.getWritePermission());
				userRolesRepository.save(userRole);
				return USER_ROLE_UPDATION_SUCCESS;
			} catch (Exception exception) {
				log.error(UNEXPECTED_ERROR_OCCURRED, exception);
				throw new PacManException(UNEXPECTED_ERROR_OCCURRED);
			}
		} else {
			throw new PacManException(USER_ROLE_NOT_EXITS);
		}
	}

}