use of jetbrains.buildServer.groups.SUserGroup in project teamcity-rest by JetBrains.
the class GroupRequest method addRoleSimple.
@POST
@Path("/{groupLocator}/roles/{roleId}/{scope}")
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Add a role with the specific scope to the matching user group.", nickname = "addRoleAtScopeToGroup")
public RoleAssignment addRoleSimple(@PathParam("groupLocator") String groupLocator, @PathParam("roleId") String roleId, @PathParam("scope") String scopeValue) {
SUserGroup group = myUserGroupFinder.getGroup(groupLocator);
group.addRole(RoleAssignment.getScope(scopeValue, myBeanContext.getServiceLocator()), RoleAssignment.getRoleById(roleId, myBeanContext.getServiceLocator()));
return new RoleAssignment(DataProvider.getGroupRoleEntry(group, roleId, scopeValue, myBeanContext), group, myBeanContext);
}
use of jetbrains.buildServer.groups.SUserGroup in project teamcity-rest by JetBrains.
the class GroupRequest method setParentGroups.
@PUT
@Path("/{groupLocator}/parent-groups")
@Consumes({ "application/xml", "application/json" })
@Produces({ "application/xml", "application/json" })
@ApiOperation(value = "Update parent groups of the matching user group.", nickname = "setGroupParentGroups")
public Groups setParentGroups(@PathParam("groupLocator") String groupLocator, Groups parents, @QueryParam("fields") String fields) {
SUserGroup group = myUserGroupFinder.getGroup(groupLocator);
if (parents == null) {
throw new BadRequestException("No payload received while list of groups expected");
}
Group.setGroupParents(group, new LinkedHashSet<>(parents.getFromPosted(myBeanContext.getServiceLocator())), true, myBeanContext.getServiceLocator());
return new Groups(group.getParentGroups(), new Fields(fields), myBeanContext);
}
use of jetbrains.buildServer.groups.SUserGroup in project teamcity-rest by JetBrains.
the class UserGroupFinder method getGroup.
@NotNull
public SUserGroup getGroup(final String groupLocator) {
if (StringUtil.isEmpty(groupLocator)) {
throw new BadRequestException("Empty group locator is not supported.");
}
final Locator locator = new Locator(groupLocator);
if (locator.isSingleValue()) {
// no dimensions found, assume it's group key
SUserGroup group = myUserGroupManager.findUserGroupByKey(groupLocator);
if (group == null) {
throw new NotFoundException("No group can be found by key '" + groupLocator + "'.");
}
return group;
}
String groupKey = locator.getSingleDimensionValue(KEY);
if (groupKey != null) {
SUserGroup group = myUserGroupManager.findUserGroupByKey(groupKey);
if (group == null) {
throw new NotFoundException("No group can be found by key '" + groupKey + "'.");
}
return group;
}
String groupName = locator.getSingleDimensionValue(NAME);
if (groupName != null) {
SUserGroup group = myUserGroupManager.findUserGroupByName(groupName);
if (group == null) {
throw new NotFoundException("No group can be found by name '" + groupName + "'.");
}
return group;
}
throw new NotFoundException("Group locator '" + groupLocator + "' is not supported.");
}
Aggregations