class UserRolesServiceImpl implements UserRolesService {

	@Override
	public String createUserRole(final CreateRoleDetailsRequest roleDetailsRequest, final String userId) throws PacManException {
		boolean isRoleNameExits = userRolesRepository.existsByRoleNameIgnoreCase(roleDetailsRequest.getRoleName());
		if (!isRoleNameExits) {
			try {
				Date currentDate = new Date();
				UserRoles userRole = new UserRoles();
				userRole.setRoleId(UUID.randomUUID().toString());
				userRole.setClient("pacman2_api_client");
				userRole.setRoleDesc(roleDetailsRequest.getDescription());
				userRole.setCreatedDate(currentDate);
				userRole.setModifiedDate(currentDate);
				userRole.setOwner(userId);
				userRole.setRoleName(roleDetailsRequest.getRoleName());
				userRole.setWritePermission(roleDetailsRequest.getWritePermission());
				userRolesRepository.save(userRole);
				return USER_ROLE_CREATION_SUCCESS;
			} catch (Exception exception) {
				log.error(UNEXPECTED_ERROR_OCCURRED, exception);
				throw new PacManException(UNEXPECTED_ERROR_OCCURRED);
			}
		} else {
			throw new PacManException(USER_ROLE_ALREADY_EXITS);
		}
	}

}