mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
fix: wrong briefRepresentation behavior on Organization
Signed-off-by: Olivier Boudet <o.boudet@gmail.com>
This commit is contained in:
parent
310afe820e
commit
e507eb6175
@ -255,7 +255,7 @@ public class ExportUtils {
|
||||
if (Profile.isFeatureEnabled(Feature.ORGANIZATION) && !options.isPartial()) {
|
||||
OrganizationProvider orgProvider = session.getProvider(OrganizationProvider.class);
|
||||
orgProvider.getAllStream().map(model -> {
|
||||
OrganizationRepresentation org = ModelToRepresentation.toRepresentation(model);
|
||||
OrganizationRepresentation org = ModelToRepresentation.toRepresentation(model, false);
|
||||
|
||||
orgProvider.getMembersStream(model, (Map<String, String>) null, null, null, null)
|
||||
.forEach(user -> {
|
||||
|
||||
@ -1317,15 +1317,10 @@ public class ModelToRepresentation {
|
||||
}
|
||||
|
||||
public static OrganizationRepresentation toRepresentation(OrganizationModel model) {
|
||||
OrganizationRepresentation rep = toBriefRepresentation(model,false);
|
||||
if (rep == null) {
|
||||
return null;
|
||||
}
|
||||
rep.setAttributes(model.getAttributes());
|
||||
return rep;
|
||||
return toRepresentation(model, true);
|
||||
}
|
||||
|
||||
public static OrganizationRepresentation toBriefRepresentation(OrganizationModel model, Boolean briefRepresentation) {
|
||||
public static OrganizationRepresentation toRepresentation(OrganizationModel model, boolean briefRepresentation) {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
@ -1333,7 +1328,7 @@ public class ModelToRepresentation {
|
||||
rep.setId(model.getId());
|
||||
rep.setName(model.getName());
|
||||
rep.setAlias(model.getAlias());
|
||||
if (briefRepresentation) {
|
||||
if (!briefRepresentation) {
|
||||
rep.setAttributes(model.getAttributes());
|
||||
}
|
||||
rep.setEnabled(model.isEnabled());
|
||||
|
||||
@ -73,7 +73,7 @@ public class OrganizationResource {
|
||||
@APIResponse(responseCode = "200", description = "", content = @Content(schema = @Schema(implementation = OrganizationRepresentation.class)))
|
||||
})
|
||||
public OrganizationRepresentation get() {
|
||||
return ModelToRepresentation.toRepresentation(organization);
|
||||
return ModelToRepresentation.toRepresentation(organization, false);
|
||||
}
|
||||
|
||||
@DELETE
|
||||
|
||||
@ -149,7 +149,7 @@ public class OrganizationsResource {
|
||||
@Parameter(description = "Boolean which defines whether the param 'search' must match exactly or not") @QueryParam("exact") Boolean exact,
|
||||
@Parameter(description = "The position of the first result to be processed (pagination offset)") @QueryParam("first") @DefaultValue("0") Integer first,
|
||||
@Parameter(description = "The maximum number of results to be returned - defaults to 10") @QueryParam("max") @DefaultValue("10") Integer max,
|
||||
@Parameter(description = "if true, return the full representation. Otherwise, only the basic fields are returned.") @QueryParam("briefRepresentation") @DefaultValue("false") boolean briefRepresentation
|
||||
@Parameter(description = "if false, return the full representation. Otherwise, only the basic fields are returned.") @QueryParam("briefRepresentation") @DefaultValue("true") boolean briefRepresentation
|
||||
) {
|
||||
auth.realm().requireManageRealm();
|
||||
Organizations.checkEnabled(provider);
|
||||
@ -157,9 +157,9 @@ public class OrganizationsResource {
|
||||
// check if are searching orgs by attribute.
|
||||
if (StringUtil.isNotBlank(searchQuery)) {
|
||||
Map<String, String> attributes = SearchQueryUtils.getFields(searchQuery);
|
||||
return provider.getAllStream(attributes, first, max).map(model -> ModelToRepresentation.toBriefRepresentation(model, briefRepresentation));
|
||||
return provider.getAllStream(attributes, first, max).map(model -> ModelToRepresentation.toRepresentation(model, briefRepresentation));
|
||||
} else {
|
||||
return provider.getAllStream(search, exact, first, max).map(model -> ModelToRepresentation.toBriefRepresentation(model, briefRepresentation));
|
||||
return provider.getAllStream(search, exact, first, max).map(model -> ModelToRepresentation.toRepresentation(model, briefRepresentation));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -161,7 +161,7 @@ public class OrganizationTest extends AbstractOrganizationTest {
|
||||
orgRep.singleAttribute("foo", "bar");
|
||||
orgRep.singleAttribute("bar", "foo");
|
||||
testRealm().organizations().get(orgRep.getId()).update(orgRep).close();
|
||||
existing = testRealm().organizations().search("gtbank.net", true, 0, 10, true);
|
||||
existing = testRealm().organizations().search("gtbank.net", true, 0, 10, false);
|
||||
assertThat(existing, hasSize(1));
|
||||
orgRep = existing.get(0);
|
||||
assertThat(orgRep.getAttributes(), notNullValue());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user