| | |
| | |
|
| | | private static final String EMAILADDRESS = "emailAddress";
|
| | |
|
| | | private static final String ORGANIZATIONALUNIT = "organizationalUnit";
|
| | | |
| | | private static final String ORGANIZATION = "organization";
|
| | | |
| | | private static final String LOCALITY = "locality";
|
| | | |
| | | private static final String STATEPROVINCE = "stateProvince";
|
| | | |
| | | private static final String COUNTRYCODE = "countryCode";
|
| | | |
| | | private static final String COOKIE = "cookie";
|
| | |
|
| | | private static final String REPOSITORY = "repository";
|
| | |
| | | if (!StringUtils.isEmpty(model.emailAddress)) {
|
| | | config.setString(USER, model.username, EMAILADDRESS, model.emailAddress);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.organizationalUnit)) {
|
| | | config.setString(USER, model.username, ORGANIZATIONALUNIT, model.organizationalUnit);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.organization)) {
|
| | | config.setString(USER, model.username, ORGANIZATION, model.organization);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.locality)) {
|
| | | config.setString(USER, model.username, LOCALITY, model.locality);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.stateProvince)) {
|
| | | config.setString(USER, model.username, STATEPROVINCE, model.stateProvince);
|
| | | }
|
| | | if (!StringUtils.isEmpty(model.countryCode)) {
|
| | | config.setString(USER, model.username, COUNTRYCODE, model.countryCode);
|
| | | }
|
| | |
|
| | | // user roles
|
| | | List<String> roles = new ArrayList<String>();
|
| | |
| | | }
|
| | | config.setStringList(USER, model.username, ROLE, roles);
|
| | |
|
| | | // repository memberships
|
| | | if (model.permissions == null) {
|
| | | // null check on "final" repositories because JSON-sourced UserModel
|
| | | // can have a null repositories object
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | config.setStringList(USER, model.username, REPOSITORY, new ArrayList<String>(
|
| | | model.repositories));
|
| | | }
|
| | | } else {
|
| | | // discrete repository permissions
|
| | | // discrete repository permissions
|
| | | if (model.permissions != null && !model.canAdmin) {
|
| | | List<String> permissions = new ArrayList<String>();
|
| | | for (Map.Entry<String, AccessPermission> entry : model.permissions.entrySet()) {
|
| | | if (entry.getValue().exceeds(AccessPermission.NONE)) {
|
| | |
| | | }
|
| | | config.setStringList(TEAM, model.name, ROLE, roles);
|
| | |
|
| | | if (model.permissions == null) {
|
| | | // null check on "final" repositories because JSON-sourced TeamModel
|
| | | // can have a null repositories object
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | config.setStringList(TEAM, model.name, REPOSITORY, new ArrayList<String>(
|
| | | model.repositories));
|
| | | }
|
| | | } else {
|
| | | // discrete repository permissions
|
| | | List<String> permissions = new ArrayList<String>();
|
| | | for (Map.Entry<String, AccessPermission> entry : model.permissions.entrySet()) {
|
| | | if (entry.getValue().exceeds(AccessPermission.NONE)) {
|
| | | // code:repository (e.g. RW+:~james/myrepo.git
|
| | | permissions.add(entry.getValue().asRole(entry.getKey()));
|
| | | if (!model.canAdmin) {
|
| | | // write team permission for non-admin teams
|
| | | if (model.permissions == null) {
|
| | | // null check on "final" repositories because JSON-sourced TeamModel
|
| | | // can have a null repositories object
|
| | | if (!ArrayUtils.isEmpty(model.repositories)) {
|
| | | config.setStringList(TEAM, model.name, REPOSITORY, new ArrayList<String>(
|
| | | model.repositories));
|
| | | }
|
| | | } else {
|
| | | // discrete repository permissions
|
| | | List<String> permissions = new ArrayList<String>();
|
| | | for (Map.Entry<String, AccessPermission> entry : model.permissions.entrySet()) {
|
| | | if (entry.getValue().exceeds(AccessPermission.NONE)) {
|
| | | // code:repository (e.g. RW+:~james/myrepo.git
|
| | | permissions.add(entry.getValue().asRole(entry.getKey()));
|
| | | }
|
| | | }
|
| | | config.setStringList(TEAM, model.name, REPOSITORY, permissions);
|
| | | }
|
| | | config.setStringList(TEAM, model.name, REPOSITORY, permissions);
|
| | | }
|
| | |
|
| | | // null check on "final" users because JSON-sourced TeamModel
|
| | |
| | | user.password = config.getString(USER, username, PASSWORD);
|
| | | user.displayName = config.getString(USER, username, DISPLAYNAME);
|
| | | user.emailAddress = config.getString(USER, username, EMAILADDRESS);
|
| | | user.organizationalUnit = config.getString(USER, username, ORGANIZATIONALUNIT);
|
| | | user.organization = config.getString(USER, username, ORGANIZATION);
|
| | | user.locality = config.getString(USER, username, LOCALITY);
|
| | | user.stateProvince = config.getString(USER, username, STATEPROVINCE);
|
| | | user.countryCode = config.getString(USER, username, COUNTRYCODE);
|
| | | user.cookie = config.getString(USER, username, COOKIE);
|
| | | if (StringUtils.isEmpty(user.cookie) && !StringUtils.isEmpty(user.password)) {
|
| | | user.cookie = StringUtils.getSHA1(user.username + user.password);
|
| | |
| | | user.excludeFromFederation = roles.contains(Constants.NOT_FEDERATED_ROLE);
|
| | |
|
| | | // repository memberships
|
| | | Set<String> repositories = new HashSet<String>(Arrays.asList(config
|
| | | .getStringList(USER, username, REPOSITORY)));
|
| | | for (String repository : repositories) {
|
| | | user.addRepositoryPermission(repository);
|
| | | if (!user.canAdmin) {
|
| | | // non-admin, read permissions
|
| | | Set<String> repositories = new HashSet<String>(Arrays.asList(config
|
| | | .getStringList(USER, username, REPOSITORY)));
|
| | | for (String repository : repositories) {
|
| | | user.addRepositoryPermission(repository);
|
| | | }
|
| | | }
|
| | |
|
| | | // update cache
|
| | |
| | | team.canFork = roles.contains(Constants.FORK_ROLE);
|
| | | team.canCreate = roles.contains(Constants.CREATE_ROLE);
|
| | |
|
| | | team.addRepositoryPermissions(Arrays.asList(config.getStringList(TEAM, teamname,
|
| | | REPOSITORY)));
|
| | | if (!team.canAdmin) {
|
| | | // non-admin team, read permissions
|
| | | team.addRepositoryPermissions(Arrays.asList(config.getStringList(TEAM, teamname,
|
| | | REPOSITORY)));
|
| | | }
|
| | | team.addUsers(Arrays.asList(config.getStringList(TEAM, teamname, USER)));
|
| | | team.addMailingLists(Arrays.asList(config.getStringList(TEAM, teamname,
|
| | | MAILINGLIST)));
|