KEYCLOAK-12670 inconsistent param name full to briefRepresentation

This commit is contained in:
Axel Messinese 2020-01-14 14:25:59 +01:00 committed by Hynek Mlnařík
parent 8d49409de1
commit 72aff51fca
4 changed files with 10 additions and 10 deletions

View file

@ -73,7 +73,7 @@ public interface GroupsResource {
* @param search max number of occurrences * @param search max number of occurrences
* @param first index of the first element * @param first index of the first element
* @param max max number of occurrences * @param max max number of occurrences
* @param fullRepresentation if true, return groups with their attributes * @param briefRepresentation if false, return groups with their attributes
* @return A list containing the slice of all groups. * @return A list containing the slice of all groups.
*/ */
@GET @GET
@ -83,7 +83,7 @@ public interface GroupsResource {
List<GroupRepresentation> groups(@QueryParam("search") String search, List<GroupRepresentation> groups(@QueryParam("search") String search,
@QueryParam("first") Integer first, @QueryParam("first") Integer first,
@QueryParam("max") Integer max, @QueryParam("max") Integer max,
@QueryParam("full") @DefaultValue("false") boolean fullRepresentation); @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation);
/** /**
* Counts all groups. * Counts all groups.
* @return A map containing key "count" with number of groups as value. * @return A map containing key "count" with number of groups as value.

View file

@ -75,17 +75,17 @@ public class GroupsResource {
public List<GroupRepresentation> getGroups(@QueryParam("search") String search, public List<GroupRepresentation> getGroups(@QueryParam("search") String search,
@QueryParam("first") Integer firstResult, @QueryParam("first") Integer firstResult,
@QueryParam("max") Integer maxResults, @QueryParam("max") Integer maxResults,
@QueryParam("full") @DefaultValue("false") boolean fullRepresentation) { @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation) {
auth.groups().requireList(); auth.groups().requireList();
List<GroupRepresentation> results; List<GroupRepresentation> results;
if (Objects.nonNull(search)) { if (Objects.nonNull(search)) {
results = ModelToRepresentation.searchForGroupByName(realm, fullRepresentation, search.trim(), firstResult, maxResults); results = ModelToRepresentation.searchForGroupByName(realm, !briefRepresentation, search.trim(), firstResult, maxResults);
} else if(Objects.nonNull(firstResult) && Objects.nonNull(maxResults)) { } else if(Objects.nonNull(firstResult) && Objects.nonNull(maxResults)) {
results = ModelToRepresentation.toGroupHierarchy(realm, fullRepresentation, firstResult, maxResults); results = ModelToRepresentation.toGroupHierarchy(realm, !briefRepresentation, firstResult, maxResults);
} else { } else {
results = ModelToRepresentation.toGroupHierarchy(realm, fullRepresentation); results = ModelToRepresentation.toGroupHierarchy(realm, !briefRepresentation);
} }
return results; return results;

View file

@ -419,7 +419,7 @@ public class RoleContainerResource extends RoleResource {
* @param roleName * @param roleName
* @param firstResult * @param firstResult
* @param maxResults * @param maxResults
* @param fullRepresentation if true, return a full representation of the GroupRepresentation objects * @param briefRepresentation if false, return a full representation of the GroupRepresentation objects
* @return * @return
*/ */
@Path("{role-name}/groups") @Path("{role-name}/groups")
@ -429,7 +429,7 @@ public class RoleContainerResource extends RoleResource {
public List<GroupRepresentation> getGroupsInRole(final @PathParam("role-name") String roleName, public List<GroupRepresentation> getGroupsInRole(final @PathParam("role-name") String roleName,
@QueryParam("first") Integer firstResult, @QueryParam("first") Integer firstResult,
@QueryParam("max") Integer maxResults, @QueryParam("max") Integer maxResults,
@QueryParam("full") @DefaultValue("false") boolean fullRepresentation) { @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation) {
auth.roles().requireView(roleContainer); auth.roles().requireView(roleContainer);
firstResult = firstResult != null ? firstResult : 0; firstResult = firstResult != null ? firstResult : 0;
@ -444,7 +444,7 @@ public class RoleContainerResource extends RoleResource {
List<GroupModel> groupsModel = session.realms().getGroupsByRole(realm, role, firstResult, maxResults); List<GroupModel> groupsModel = session.realms().getGroupsByRole(realm, role, firstResult, maxResults);
return groupsModel.stream() return groupsModel.stream()
.map(g -> ModelToRepresentation.toRepresentation(g, fullRepresentation)) .map(g -> ModelToRepresentation.toRepresentation(g, !briefRepresentation))
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }

View file

@ -690,7 +690,7 @@ public class GroupTest extends AbstractGroupTest {
group.setAttributes(attributes); group.setAttributes(attributes);
group = createGroup(realm, group); group = createGroup(realm, group);
List<GroupRepresentation> groups = groupsResource.groups("groupWithAttribute", 0, 20, true); List<GroupRepresentation> groups = groupsResource.groups("groupWithAttribute", 0, 20, false);
assertFalse(groups.isEmpty()); assertFalse(groups.isEmpty());
assertTrue(groups.get(0).getAttributes().containsKey("attribute1")); assertTrue(groups.get(0).getAttributes().containsKey("attribute1"));