mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-05 22:39:52 -06:00
Add description field to OrganizationEntity
Closes #29356 Signed-off-by: Stefan Guilhen <sguilhen@redhat.com>
This commit is contained in:
committed by
Pedro Igor
parent
11a35e708e
commit
aa945d5636
@@ -29,6 +29,7 @@ public class OrganizationRepresentation {
|
||||
private String id;
|
||||
private String name;
|
||||
private boolean enabled = true;
|
||||
private String description;
|
||||
private Map<String, List<String>> attributes;
|
||||
private Set<OrganizationDomainRepresentation> domains;
|
||||
|
||||
@@ -56,6 +57,14 @@ public class OrganizationRepresentation {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getAttributes() {
|
||||
return attributes;
|
||||
}
|
||||
|
||||
@@ -54,6 +54,9 @@ public class OrganizationEntity {
|
||||
@Column(name = "ENABLED")
|
||||
private boolean enabled;
|
||||
|
||||
@Column(name = "DESCRIPTION")
|
||||
private String description;
|
||||
|
||||
@Column(name = "REALM_ID")
|
||||
private String realmId;
|
||||
|
||||
@@ -83,6 +86,14 @@ public class OrganizationEntity {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getRealmId() {
|
||||
return realmId;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,16 @@ public final class OrganizationAdapter implements OrganizationModel, JpaModel<Or
|
||||
entity.setEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return entity.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDescription(String description) {
|
||||
entity.setDescription(description);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAttributes(Map<String, List<String>> attributes) {
|
||||
if (attributes == null) {
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
<column name="NAME" type="VARCHAR(255)">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
<column name="DESCRIPTION" type="VARCHAR(4000)"/>
|
||||
</createTable>
|
||||
<addUniqueConstraint tableName="ORG" columnNames="REALM_ID, NAME" constraintName="UK_ORG_NAME"/>
|
||||
<addUniqueConstraint tableName="ORG" columnNames="GROUP_ID" constraintName="UK_ORG_GROUP"/>
|
||||
|
||||
@@ -38,6 +38,10 @@ public interface OrganizationModel {
|
||||
|
||||
void setEnabled(boolean enabled);
|
||||
|
||||
String getDescription();
|
||||
|
||||
void setDescription(String description);
|
||||
|
||||
Map<String, List<String>> getAttributes();
|
||||
|
||||
void setAttributes(Map<String, List<String>> attributes);
|
||||
|
||||
@@ -174,6 +174,7 @@ public class OrganizationResource {
|
||||
rep.setId(model.getId());
|
||||
rep.setName(model.getName());
|
||||
rep.setEnabled(model.isEnabled());
|
||||
rep.setDescription(model.getDescription());
|
||||
rep.setAttributes(model.getAttributes());
|
||||
model.getDomains().filter(Objects::nonNull).map(this::toRepresentation)
|
||||
.forEach(rep::addDomain);
|
||||
@@ -195,6 +196,7 @@ public class OrganizationResource {
|
||||
|
||||
model.setName(rep.getName());
|
||||
model.setEnabled(rep.isEnabled());
|
||||
model.setDescription(rep.getDescription());
|
||||
model.setAttributes(rep.getAttributes());
|
||||
model.setDomains(Optional.ofNullable(rep.getDomains()).orElse(Set.of()).stream()
|
||||
.filter(Objects::nonNull)
|
||||
|
||||
@@ -24,6 +24,7 @@ import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
import static org.hamcrest.Matchers.nullValue;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
@@ -56,6 +57,7 @@ public class OrganizationTest extends AbstractOrganizationTest {
|
||||
assertEquals(organizationName, expected.getName());
|
||||
expected.setName("acme");
|
||||
expected.setEnabled(false);
|
||||
expected.setDescription("ACME Corporation Organization");
|
||||
|
||||
OrganizationResource organization = testRealm().organizations().get(expected.getId());
|
||||
|
||||
@@ -68,6 +70,8 @@ public class OrganizationTest extends AbstractOrganizationTest {
|
||||
assertEquals(expected.getName(), existing.getName());
|
||||
assertEquals(1, existing.getDomains().size());
|
||||
assertThat(existing.isEnabled(), is(false));
|
||||
assertThat(existing.getDescription(), notNullValue());
|
||||
assertThat(expected.getDescription(), is(equalTo(existing.getDescription())));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user