コード例 #1
0
ファイル: ProjectServiceImpl.java プロジェクト: Rawin2/guvnor
  @SuppressWarnings({"unchecked", "rawtypes"})
  @Override
  public void addRole(final Project project, final String role) {
    ConfigGroup thisProjectConfig = findProjectConfig(project.getRootPath());

    if (thisProjectConfig == null) {
      thisProjectConfig =
          configurationFactory.newConfigGroup(
              ConfigType.PROJECT,
              project.getRootPath().toURI(),
              "Project '" + project.getProjectName() + "' configuration");
      thisProjectConfig.addConfigItem(
          configurationFactory.newConfigItem("security:roles", new ArrayList<String>()));
      configurationService.addConfiguration(thisProjectConfig);
    }

    if (thisProjectConfig != null) {
      final ConfigItem<List> roles = thisProjectConfig.getConfigItem("security:roles");
      roles.getValue().add(role);

      configurationService.updateConfiguration(thisProjectConfig);

    } else {
      throw new IllegalArgumentException("Project " + project.getProjectName() + " not found");
    }
  }
コード例 #2
0
  @Override
  public OrganizationalUnit createOrganizationalUnit(final String name, final String owner) {
    final ConfigGroup groupConfig =
        configurationFactory.newConfigGroup(ConfigType.ORGANIZATIONAL_UNIT, name, "");
    groupConfig.addConfigItem(configurationFactory.newConfigItem("owner", owner));
    groupConfig.addConfigItem(
        configurationFactory.newConfigItem("repositories", new ArrayList<String>()));
    groupConfig.addConfigItem(
        configurationFactory.newConfigItem("security:roles", new ArrayList<String>()));
    configurationService.addConfiguration(groupConfig);

    final OrganizationalUnit newOrganizationalUnit =
        organizationalUnitFactory.newOrganizationalUnit(groupConfig);
    registeredOrganizationalUnits.put(newOrganizationalUnit.getName(), newOrganizationalUnit);

    newOrganizationalUnitEvent.fire(new NewOrganizationalUnitEvent(newOrganizationalUnit));

    return newOrganizationalUnit;
  }
コード例 #3
0
  @Override
  public void updateOrganizationalUnitOwner(final String name, final String owner) {
    final ConfigGroup thisGroupConfig = findGroupConfig(name);

    if (thisGroupConfig != null) {
      thisGroupConfig.setConfigItem(configurationFactory.newConfigItem("owner", owner));
      configurationService.updateConfiguration(thisGroupConfig);

      final OrganizationalUnit updatedOrganizationalUnit =
          organizationalUnitFactory.newOrganizationalUnit(thisGroupConfig);
      registeredOrganizationalUnits.put(
          updatedOrganizationalUnit.getName(), updatedOrganizationalUnit);
    } else {
      throw new IllegalArgumentException("OrganizationalUnit " + name + " not found");
    }
  }