org.guvnor.structure.repositories.Repository.getGroups()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(107)

本文整理了Java中org.guvnor.structure.repositories.Repository.getGroups方法的一些代码示例,展示了Repository.getGroups的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Repository.getGroups方法的具体详情如下:
包路径:org.guvnor.structure.repositories.Repository
类名称:Repository
方法名:getGroups

Repository.getGroups介绍

暂无

代码示例

代码示例来源:origin: org.kie/kie-config-cli

@Override
public String execute(CliContext context) {
  StringBuffer result = new StringBuffer();
  WeldContainer container = context.getContainer();
  RepositoryService repositoryService = container.instance().select(RepositoryService.class).get();
  Collection<Repository> repositories = repositoryService.getRepositories();
  result.append("Currently available repositories: \n");
  for (Repository config : repositories) {
    result.append("\tRepository " + config.getAlias() + "\n");
    result.append("\t scheme: " + config.getScheme() + "\n");
    result.append("\t uri: " + config.getUri() + "\n");
    result.append("\t environment: " + printEnvironment(config.getEnvironment()) + "\n");
    result.append("\t groups: " + config.getGroups() + "\n");
  }
  return result.toString();
}

代码示例来源:origin: org.kie/kie-config-cli

@Override
public String execute( CliContext context ) {
  StringBuffer result = new StringBuffer();
  WeldContainer container = context.getContainer();
  OrganizationalUnitService organizationalUnitService = container.instance().select( OrganizationalUnitService.class ).get();
  Collection<OrganizationalUnit> groups = organizationalUnitService.getOrganizationalUnits();
  result.append( "Currently available Organizational Units: \n" );
  for ( OrganizationalUnit config : groups ) {
    result.append( "\tOrganizational Unit " + config.getName() + "\n" );
    result.append( "\towner: " + config.getOwner() + "\n" );
    result.append( "\tgroups: " + config.getGroups() + "\n" );
    result.append( "\trepositories: \n" );
    for ( Repository repository : config.getRepositories() ) {
      result.append( "\t\tRepository " + repository.getAlias() + "\n" );
      result.append( "\t\t\t scheme: " + repository.getScheme() + "\n" );
      result.append( "\t\t\t uri: " + repository.getUri() + "\n" );
      result.append( "\t\t\t environment: " + printEnvironment(repository.getEnvironment()) + "\n" );
      result.append( "\t\t\t repository groups: " + repository.getGroups() + "\n" );
    }
  }
  return result.toString();
}

代码示例来源:origin: org.kie/kie-config-cli

@Override
public String execute( CliContext context ) {
  StringBuffer result = new StringBuffer();
  WeldContainer container = context.getContainer();
  RepositoryService repositoryService = container.instance().select( RepositoryService.class ).get();
  InputReader input = context.getInput();
  System.out.print( ">>Repository alias:" );
  String alias = input.nextLine();
  Repository repo = repositoryService.getRepository( alias );
  if ( repo == null ) {
    return "No repository " + alias + " was found";
  }
  if ( repo.getGroups() == null || repo.getGroups().isEmpty() ) {
    return "No groups defined for repository " + alias;
  }
  System.out.print( ">>Security groups (comma separated list):" );
  String groupsIn = input.nextLine();
  if ( groupsIn.trim().length() > 0 ) {
    String[] groups = groupsIn.split( "," );
    for ( String group : groups ) {
      repositoryService.removeGroup( repo, group );
      result.append( "Group " + group + " removed successfully from repository " + repo.getAlias() + "\n" );
    }
  }
  container.getBeanManager().fireEvent(new SystemRepositoryChangedEvent(), new AnnotationLiteral<OrgUnit>() {});
  return result.toString();
}

代码示例来源:origin: org.kie/kie-config-cli

@Override
public String execute(CliContext context) {
  StringBuffer result = new StringBuffer();
  WeldContainer container = context.getContainer();
  RepositoryService repositoryService = container.instance().select(RepositoryService.class).get();
  InputReader input = context.getInput();
  System.out.print(">>Repository alias:");
  String alias = input.nextLine();
  
  Repository repo = repositoryService.getRepository(alias);
  if (repo == null) {
    return "No repository " + alias + " was found";
  }
  System.out.print(">>Security groups (comma separated list):");
  String groupsIn = input.nextLine();
  if (groupsIn.trim().length() > 0) {
    
    String[] groups = groupsIn.split(",");
    for (String group : groups) {
      if (repo.getGroups().contains(group)) {
        continue;
      }
      repositoryService.addGroup(repo, group);
      result.append("Group " + group + " added successfully to repository " + repo.getAlias() + "\n");
    }
  }
  container.getBeanManager().fireEvent(new SystemRepositoryChangedEvent(), new AnnotationLiteral<OrgUnit>() {});
  return result.toString();
}

代码示例来源:origin: kiegroup/appformer

public void migrateRepositories(final AuthorizationPolicy policy) {

    final Collection<Repository> itemList = repositoryService.getAllRepositoriesFromAllUserSpaces();

    for (final Repository repository : itemList) {
      final Permission permission = permissionManager.createPermission(repository,
                                       RepositoryAction.READ,
                                       true);
      for (final String groupName : repository.getGroups()) {
        final Group group = getGroup(groupName);
        final PermissionCollection permissionCollection = policy.getPermissions(group);
        permissionCollection.add(permission);
      }
    }
  }
}

代码示例来源:origin: org.jbpm/jbpm-console-ng-business-domain-backend

public void createDeploymentDescriptor( @Observes NewProjectEvent newProjectEvent ) {
  KieProject project = (KieProject) newProjectEvent.getProject();
  URI projectRootURI = URI.create( project.getRootPath().toURI() );
  String repositoryAlias = projectRootURI.getHost();
  String metaInfPath = Paths.convert( project.getKModuleXMLPath() ).getParent().toUri().toString();
  String separator = Paths.convert( project.getRootPath() ).getFileSystem().getSeparator();
  String deploymentDescriptorPath = metaInfPath + separator + "kie-deployment-descriptor.xml";
  Path ddVFSPath = ioService.get( URI.create( deploymentDescriptorPath ) );
  if ( !ioService.exists( ddVFSPath ) ) {
    DeploymentDescriptor dd = new DeploymentDescriptorManager( "org.jbpm.domain" ).getDefaultDescriptor();
    Set<String> groups = new HashSet<String>( project.getGroups() );
    Repository repo = repositoryService.getRepository( repositoryAlias );
    if ( repo != null ) {
      groups.addAll( repo.getGroups() );
    }
    dd.getBuilder().setRequiredRoles( new ArrayList<String>( groups ) );
    String xmlDescriptor = dd.toXml();
    ioService.write( ddVFSPath, xmlDescriptor );
  }
}

代码示例来源:origin: org.uberfire/uberfire-services-backend

@Before
public void setUp() {
  permissionManager = new DefaultPermissionManager();
  authorizationPolicy = permissionManager.newAuthorizationPolicy().build();
  migrationTool = spy(new ACLMigrationTool(organizationalUnitService,
                       repositoryService,
                       permissionManager,
                       policyStorage));
  final Path repo1root = mock(Path.class);
  when(organizationalUnitService.getAllOrganizationalUnits()).thenReturn(Collections.singleton(orgUnit1));
  when(repositoryService.getAllRepositoriesFromAllUserSpaces()).thenReturn(Collections.singleton(repo1));
  when(orgUnit1.getIdentifier()).thenReturn("orgUnit1");
  when(orgUnit1.getResourceType()).thenReturn(OrganizationalUnit.RESOURCE_TYPE);
  when(orgUnit1.getGroups()).thenReturn(Collections.singleton("group1"));
  when(repo1.getIdentifier()).thenReturn("repo1");
  final Branch master = new Branch("master",
                repo1root);
  when(repo1.getBranch("master")).thenReturn(Optional.of(master));
  when(repo1.getDefaultBranch()).thenReturn(Optional.of(master));
  when(repo1.getResourceType()).thenReturn(Repository.RESOURCE_TYPE);
  final ArrayList<String> groupList = new ArrayList<>();
  groupList.add("group1");
  groupList.add("group2");
  when(repo1.getGroups()).thenReturn(groupList);
}

代码示例来源:origin: org.guvnor/guvnor-services-backend

public void migrateRepositories(AuthorizationPolicy policy) {
  Collection<Repository> itemList = repositoryService.getAllRepositories();
  for (Repository item : itemList) {
    Permission p = permissionManager.createPermission(item,
                             RepositoryAction.READ,
                             true);
    for (String groupName : item.getGroups()) {
      Group group = getGroup(groupName);
      PermissionCollection pc = policy.getPermissions(group);
      pc.add(p);
    }
    migrateProjects(policy,
            item);
  }
}

代码示例来源:origin: org.guvnor/guvnor-services-backend

@Before
public void setUp() {
  permissionManager = new DefaultPermissionManager();
  authorizationPolicy = permissionManager.newAuthorizationPolicy().build();
  migrationTool = spy(new ACLMigrationTool(organizationalUnitService,
                       repositoryService,
                       mock(Instance.class),
                       permissionManager,
                       policyStorage));
  when(migrationTool.getProjectService()).thenReturn(projectService);
  when(organizationalUnitService.getAllOrganizationalUnits()).thenReturn(Collections.singleton(orgUnit1));
  when(repositoryService.getAllRepositories()).thenReturn(Collections.singleton(repo1));
  when(projectService.getAllProjects(repo1,
                    "master")).thenReturn(Collections.singleton(project1));
  when(orgUnit1.getIdentifier()).thenReturn("orgUnit1");
  when(orgUnit1.getResourceType()).thenReturn(OrganizationalUnit.RESOURCE_TYPE);
  when(orgUnit1.getGroups()).thenReturn(Collections.singleton("group1"));
  when(repo1.getIdentifier()).thenReturn("repo1");
  when(repo1.getResourceType()).thenReturn(Repository.RESOURCE_TYPE);
  when(repo1.getGroups()).thenReturn(Collections.singleton("group1"));
  when(project1.getIdentifier()).thenReturn("project1");
  when(project1.getResourceType()).thenReturn(Project.RESOURCE_TYPE);
  when(project1.getGroups()).thenReturn(Collections.singleton("group2"));
}

代码示例来源:origin: kiegroup/appformer

@Before
public void setUp() {
  permissionManager = new DefaultPermissionManager();
  authorizationPolicy = permissionManager.newAuthorizationPolicy().build();
  migrationTool = spy(new ACLMigrationTool(organizationalUnitService,
                       repositoryService,
                       permissionManager,
                       policyStorage));
  final Path repo1root = mock(Path.class);
  when(organizationalUnitService.getAllOrganizationalUnits()).thenReturn(Collections.singleton(orgUnit1));
  when(repositoryService.getAllRepositoriesFromAllUserSpaces()).thenReturn(Collections.singleton(repo1));
  when(orgUnit1.getIdentifier()).thenReturn("orgUnit1");
  when(orgUnit1.getResourceType()).thenReturn(OrganizationalUnit.RESOURCE_TYPE);
  when(orgUnit1.getGroups()).thenReturn(Collections.singleton("group1"));
  when(repo1.getIdentifier()).thenReturn("repo1");
  final Branch master = new Branch("master",
                repo1root);
  when(repo1.getBranch("master")).thenReturn(Optional.of(master));
  when(repo1.getDefaultBranch()).thenReturn(Optional.of(master));
  when(repo1.getResourceType()).thenReturn(Repository.RESOURCE_TYPE);
  final ArrayList<String> groupList = new ArrayList<>();
  groupList.add("group1");
  groupList.add("group2");
  when(repo1.getGroups()).thenReturn(groupList);
}

代码示例来源:origin: org.guvnor/guvnor-structure-backend

@Override
public Repository newRepository(final ConfigGroup repoConfig) {
  checkNotNull("repoConfig",
         repoConfig);
  final ConfigItem<String> schemeConfigItem = repoConfig.getConfigItem(EnvironmentParameters.SCHEME);
  checkNotNull("schemeConfigItem",
         schemeConfigItem);
  //Find a Helper that can create a repository
  Repository repository = null;
  for (RepositoryFactoryHelper helper : helpers) {
    if (helper.accept(repoConfig)) {
      repository = helper.newRepository(repoConfig);
      break;
    }
  }
  //Check one was created
  if (repository == null) {
    throw new IllegalArgumentException("Unrecognized scheme '" + schemeConfigItem.getValue() + "'.");
  }
  //Copy in Security Roles required to access this resource
  ConfigItem<List<String>> groups = backward.compat(repoConfig).getConfigItem("security:groups");
  if (groups != null) {
    for (String group : groups.getValue()) {
      repository.getGroups().add(group);
    }
  }
  return repository;
}

代码示例来源:origin: kiegroup/appformer

if (groups != null) {
  for (String group : groups.getValue()) {
    repository.getGroups().add(group);

相关文章