use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class TemporaryNiogitService method importProjects.
public void importProjects(Path actualTarget) {
OrganizationalUnit ou = ouService.createOrganizationalUnit(OU_NAME, "org.migration", Collections.emptyList(), Collections.singletonList(new Contributor(OU_OWNER, ContributorType.OWNER)));
String repositoryURL = actualTarget.toUri().toString();
RepositoryEnvironmentConfigurations configurations = new RepositoryEnvironmentConfigurations();
Map<String, Object> configMap = configurations.getConfigurationMap();
configMap.put(EnvironmentParameters.AVOID_INDEX, Boolean.TRUE);
configMap.put("origin", repositoryURL);
Repository repo = repoService.createRepository(ou, GitRepository.SCHEME.toString(), TMP_REPO_ALIAS, configurations);
WorkspaceProject project = projectService.resolveProject(repo);
migrationService.migrate(project);
repoService.removeRepository(ou.getSpace(), TMP_REPO_ALIAS);
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class ConfigGroupToSpaceInfoConverter method extractContributors.
private Collection<Contributor> extractContributors(final ConfigGroup configGroup) {
final List<Contributor> contributors = new ArrayList<>();
boolean oldConfigGroup = false;
final String oldOwner = configGroup.getConfigItemValue(OWNER);
if (oldOwner != null) {
oldConfigGroup = true;
contributors.add(new Contributor(oldOwner, ContributorType.OWNER));
}
ConfigItem<List<String>> oldContributors = configGroup.getConfigItem(CONTRIBUTORS);
if (oldContributors != null) {
oldConfigGroup = true;
for (String userName : oldContributors.getValue()) {
if (!userName.equals(oldOwner)) {
contributors.add(new Contributor(userName, ContributorType.CONTRIBUTOR));
}
}
}
if (!oldConfigGroup) {
ConfigItem<List<Contributor>> newContributorsConfigItem = configGroup.getConfigItem(SPACE_CONTRIBUTORS);
contributors.addAll(newContributorsConfigItem.getValue());
}
return contributors;
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method createProjectTest.
@Test
public void createProjectTest() {
final List<Contributor> spaceContributors = new ArrayList<>();
spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
spaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
doReturn(spaceContributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
doReturn(Optional.empty()).when(archetypeService).getBaseKieTemplateRepository();
final POM pom = mock(POM.class);
libraryService.createProject(organizationalUnit, pom, DeploymentMode.VALIDATED);
verify(ouService, never()).updateOrganizationalUnit(anyString(), anyString(), anyList());
final List<Contributor> projectContributors = new ArrayList<>();
projectContributors.add(new Contributor("user1", ContributorType.OWNER));
projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
projectContributors.add(new Contributor("admin", ContributorType.OWNER));
verify(projectService).newProject(organizationalUnit, pom, DeploymentMode.VALIDATED, projectContributors, null, null);
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method createProjectFromTemplateTest.
@Test
public void createProjectFromTemplateTest() {
final List<Contributor> spaceContributors = new ArrayList<>();
spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
spaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
doReturn(spaceContributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
final String templateId = "my-template";
final Repository templateRepository = mock(Repository.class);
doReturn(templateRepository).when(archetypeService).getTemplateRepository(templateId);
final POM pom = mock(POM.class);
libraryService.createProject(organizationalUnit, pom, DeploymentMode.VALIDATED, templateId);
verify(ouService, never()).updateOrganizationalUnit(anyString(), anyString(), anyList());
final List<Contributor> projectContributors = new ArrayList<>();
projectContributors.add(new Contributor("user1", ContributorType.OWNER));
projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
projectContributors.add(new Contributor("admin", ContributorType.OWNER));
verify(projectService).newProject(organizationalUnit, pom, DeploymentMode.VALIDATED, projectContributors, templateRepository, null);
}
use of org.uberfire.security.Contributor in project kie-wb-common by kiegroup.
the class LibraryServiceImplTest method createProjectWithUserThatIsNotASpaceContributorTest.
@Test
public void createProjectWithUserThatIsNotASpaceContributorTest() {
final List<Contributor> spaceContributors = new ArrayList<>();
spaceContributors.add(new Contributor("user1", ContributorType.OWNER));
spaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
spaceContributors.add(new Contributor("user3", ContributorType.CONTRIBUTOR));
final OrganizationalUnit organizationalUnit = mock(OrganizationalUnit.class);
doReturn("ou").when(organizationalUnit).getName();
doReturn("org.ou").when(organizationalUnit).getDefaultGroupId();
doReturn(spaceContributors).when(organizationalUnit).getContributors();
doReturn(organizationalUnit).when(ouService).getOrganizationalUnit("ou");
doReturn(Optional.empty()).when(archetypeService).getBaseKieTemplateRepository();
final POM pom = mock(POM.class);
libraryService.createProject(organizationalUnit, pom, DeploymentMode.VALIDATED);
final List<Contributor> updatedSpaceContributors = new ArrayList<>();
updatedSpaceContributors.add(new Contributor("user1", ContributorType.OWNER));
updatedSpaceContributors.add(new Contributor("user2", ContributorType.ADMIN));
updatedSpaceContributors.add(new Contributor("user3", ContributorType.CONTRIBUTOR));
updatedSpaceContributors.add(new Contributor("admin", ContributorType.CONTRIBUTOR));
verify(ouService).updateOrganizationalUnit(anyString(), anyString(), eq(updatedSpaceContributors));
final List<Contributor> projectContributors = new ArrayList<>();
projectContributors.add(new Contributor("user1", ContributorType.OWNER));
projectContributors.add(new Contributor("user2", ContributorType.ADMIN));
projectContributors.add(new Contributor("user3", ContributorType.CONTRIBUTOR));
projectContributors.add(new Contributor("admin", ContributorType.OWNER));
verify(projectService).newProject(organizationalUnit, pom, DeploymentMode.VALIDATED, projectContributors, null, null);
}
Aggregations