src/main/java/com/epam/reportportal/auth/integration/github/GitHubUserReplicator.java
@Transactional
	public ReportPortalUser replicateUser(UserResource userResource, GitHubClient gitHubClient) {
		String login = normalizeId(userResource.getLogin());
		User user = userRepository.findByLogin(login).map(u -> {
			if (UserType.GITHUB.equals(u.getUserType())) {
				updateUser(u, userResource, gitHubClient);
			} else {
				//if user with such login exists, but it's not GitHub user than throw an exception
				throw new UserSynchronizationException("User with login '" + u.getLogin() + "' already exists");
			}
			return u;
		}).orElseGet(() -> userRepository.save(createUser(userResource, gitHubClient)));

		return ReportPortalUser.userBuilder().fromUser(user);
	}
/**
	 * Replicates GitHub user to internal database (if does NOT exist). Updates if exist. Creates personal project for that user
	 *
	 * @param userResource GitHub user to be replicated
	 * @param gitHubClient Configured github client
	 * @return Internal User representation
	 */
Replicates GitHub user to internal database (if does NOT exist). Updates if exist. Creates personal project for that user
@param userResource GitHub user to be replicated
@param gitHubClient Configured github client
@return Internal User representation
Replicates GitHub user to internal database ( if does NOT exist ) . Updates if exist . Creates personal project for that user @param userResource GitHub user to be replicated @param gitHubClient Configured github client @return Internal User representation
@Transactional
	public ReportPortalUser replicateUser(UserResource userResource, GitHubClient gitHubClient) {
		String login = normalizeId(userResource.getLogin());
		User user = userRepository.findByLogin(login).map(u -> {
			if (UserType.GITHUB.equals(u.getUserType())) {
				updateUser(u, userResource, gitHubClient);
			} else {
				throw new UserSynchronizationException("User with login '" + u.getLogin() + "' already exists");
			}
			return u;
		}).orElseGet(() -> userRepository.save(createUser(userResource, gitHubClient)));
		return ReportPortalUser.userBuilder().fromUser(user);
	}
@ Transactional public ReportPortalUser replicateUser ( UserResource userResource , GitHubClient gitHubClient ) { String login = normalizeId ( userResource . getLogin ( ) ) ; User user = userRepository . findByLogin ( login ) . map ( u -> { if ( UserType . GITHUB . equals ( u . getUserType ( ) ) ) { updateUser ( u , userResource , gitHubClient ) ; } else { throw new UserSynchronizationException ( "User with login '" + u . getLogin ( ) + "' already exists" ) ; } return u ; } ) . orElseGet ( ( ) -> userRepository . save ( createUser ( userResource , gitHubClient ) ) ) ; return ReportPortalUser . userBuilder ( ) . fromUser ( user ) ; }
Replicates GitHub user to internal database (if does NOT exist).
Replicates GitHub user to internal database ( if does NOT exist ) .
//if user with such login exists, but it's not GitHub user than throw an exception