Search in sources :

Example 1 with RepositoryInfo

use of org.guvnor.structure.organizationalunit.config.RepositoryInfo in project kie-wb-common by kiegroup.

the class ConfigGroupToSpaceInfoConverter method toRepositoryInfo.

private RepositoryInfo toRepositoryInfo(ConfigGroup configGroup) {
    final Map<String, Object> envMap = extractEnvMap(configGroup);
    RepositoryUtils.cleanUpCredentialsFromEnvMap(envMap);
    return new RepositoryInfo(configGroup.getName(), false, new RepositoryConfiguration(envMap));
}
Also used : RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) RepositoryConfiguration(org.guvnor.structure.organizationalunit.config.RepositoryConfiguration)

Example 2 with RepositoryInfo

use of org.guvnor.structure.organizationalunit.config.RepositoryInfo in project kie-wb-common by kiegroup.

the class ConfigGroupsMigrationServiceTest method checkSpaceRepo.

private void checkSpaceRepo(String repoName, SpaceInfo info) {
    RepositoryInfo spaceRepo = info.getRepositories().stream().filter(repo -> repo.getName().equals(repoName)).findAny().orElse(null);
    Assertions.assertThat(spaceRepo).isNotNull().hasFieldOrPropertyWithValue("name", repoName).hasFieldOrPropertyWithValue("deleted", DELETED);
    assertEquals(SPACE_NAME, spaceRepo.getSpace());
    assertEquals(SpacesAPI.Scheme.GIT.toString(), spaceRepo.getScheme());
    assertEquals(REPO_AVOID_INDEX, spaceRepo.isAvoidIndex());
    Assertions.assertThat(spaceRepo.getContributors()).hasSize(CONTRIBUTORS);
    Assertions.assertThat(spaceRepo.getContributors().iterator().next()).hasFieldOrPropertyWithValue("username", CONTRIBUTOR).hasFieldOrPropertyWithValue("type", ContributorType.OWNER);
    Assertions.assertThat(info.getSecurityGroups()).isEmpty();
}
Also used : RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo)

Example 3 with RepositoryInfo

use of org.guvnor.structure.organizationalunit.config.RepositoryInfo in project kie-wb-common by kiegroup.

the class ProjectImportServiceImpl method resolveGitRepository.

@Override
protected Repository resolveGitRepository(ExampleRepository repository) {
    try {
        String url = repository.getUrl();
        final String alias = getRepositoryAlias(url) + "_" + LocalTime.now().toString();
        Credentials credentials = repository.getCredentials();
        String username = null;
        String password = null;
        if (credentials != null) {
            username = credentials.getUsername();
            password = credentials.getPassword();
        }
        final Map<String, Object> env = this.buildGitEnv(url, username, password, true);
        final RepositoryInfo repositoryConfig = createConfigGroup(alias, env);
        Repository repo = repositoryFactory.newRepository(repositoryConfig);
        clonedRepositories.add(repo);
        return repo;
    } catch (final Exception e) {
        logger.error("Error during create repository", e);
        throw new RuntimeException(e);
    }
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) Credentials(org.kie.workbench.common.screens.examples.model.Credentials)

Example 4 with RepositoryInfo

use of org.guvnor.structure.organizationalunit.config.RepositoryInfo in project kie-wb-common by kiegroup.

the class BaseProjectImportService method createConfigGroup.

protected RepositoryInfo createConfigGroup(String alias, Map<String, Object> env) {
    RepositoryConfiguration configuration = new RepositoryConfiguration(env);
    configuration.add(EnvironmentParameters.AVOID_INDEX, true);
    configuration.add(EnvironmentParameters.SPACE, this.getDefaultSpace());
    RepositoryInfo repositoryConfig = new RepositoryInfo(alias, false, configuration);
    return repositoryConfig;
}
Also used : RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) RepositoryConfiguration(org.guvnor.structure.organizationalunit.config.RepositoryConfiguration)

Example 5 with RepositoryInfo

use of org.guvnor.structure.organizationalunit.config.RepositoryInfo in project kie-wb-common by kiegroup.

the class ExamplesServiceImpl method cloneRepository.

private Repository cloneRepository(final String repositoryURL, final String userName, final String password) {
    try {
        final String alias = getRepositoryAlias(repositoryURL);
        final Map<String, Object> env = this.buildGitEnv(repositoryURL, userName, password, false);
        final RepositoryInfo repositoryConfig = this.createConfigGroup(alias, env);
        Repository repository = repositoryFactory.newRepository(repositoryConfig);
        this.ouService.addRepository(this.ouService.getOrganizationalUnit(this.playgroundSpaceName), repository);
        return repository;
    } catch (final Exception e) {
        logger.error("Error during create repository", e);
        throw new RuntimeException(e);
    }
}
Also used : ExampleRepository(org.kie.workbench.common.screens.examples.model.ExampleRepository) Repository(org.guvnor.structure.repositories.Repository) RepositoryInfo(org.guvnor.structure.organizationalunit.config.RepositoryInfo) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException)

Aggregations

RepositoryInfo (org.guvnor.structure.organizationalunit.config.RepositoryInfo)5 RepositoryConfiguration (org.guvnor.structure.organizationalunit.config.RepositoryConfiguration)2 Repository (org.guvnor.structure.repositories.Repository)2 ExampleRepository (org.kie.workbench.common.screens.examples.model.ExampleRepository)2 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 Credentials (org.kie.workbench.common.screens.examples.model.Credentials)1