class GitCredentialServiceImpl implements GitCredentialService {

	@Override
	public void updateGitCredentials(UserInfo userInfo, ExploratoryGitCredsDTO formDTO) {
		log.debug("Updating GIT creds for user {} to {}", userInfo.getName(), formDTO);
		try {
			gitCredsDAO.updateGitCreds(userInfo.getName(), formDTO);
			final String failedNotebooks = exploratoryDAO.fetchRunningExploratoryFields(userInfo.getName())
					.stream()
					.filter(ui -> !updateNotebookGitCredentials(userInfo, formDTO, ui))
					.map(UserInstanceDTO::getExploratoryName)
					.collect(Collectors.joining(","));
			if (StringUtils.isNotEmpty(failedNotebooks)) {
				throw new DlabException("Requests for notebooks failed: " + failedNotebooks);
			}
		} catch (Exception t) {
			log.error("Cannot update the GIT creds for user {}", userInfo.getName(), t);
			throw new DlabException("Cannot update the GIT credentials: " + t.getLocalizedMessage(), t);
		}
	}

}