Fix creation of domains when creating the organization
Closes #29005 Signed-off-by: vramik <vramik@redhat.com>
This commit is contained in:
parent
6d6131cade
commit
a8ceada973
3 changed files with 3 additions and 12 deletions
|
@ -78,7 +78,7 @@ public class JpaOrganizationProvider implements OrganizationProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public OrganizationModel create(String name, Set<String> domains) {
|
public OrganizationModel create(String name) {
|
||||||
if (StringUtil.isBlank(name)) {
|
if (StringUtil.isBlank(name)) {
|
||||||
throw new ModelValidationException("Name can not be null");
|
throw new ModelValidationException("Name can not be null");
|
||||||
}
|
}
|
||||||
|
@ -98,8 +98,6 @@ public class JpaOrganizationProvider implements OrganizationProvider {
|
||||||
adapter.setEnabled(true);
|
adapter.setEnabled(true);
|
||||||
|
|
||||||
em.persist(adapter.getEntity());
|
em.persist(adapter.getEntity());
|
||||||
|
|
||||||
adapter.setDomains(domains.stream().map(OrganizationDomainModel::new).collect(Collectors.toSet()));
|
|
||||||
} finally {
|
} finally {
|
||||||
session.removeAttribute(OrganizationModel.class.getName());
|
session.removeAttribute(OrganizationModel.class.getName());
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
package org.keycloak.organization;
|
package org.keycloak.organization;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import org.keycloak.models.IdentityProviderModel;
|
import org.keycloak.models.IdentityProviderModel;
|
||||||
import org.keycloak.models.ModelDuplicateException;
|
import org.keycloak.models.ModelDuplicateException;
|
||||||
|
@ -35,11 +34,10 @@ public interface OrganizationProvider extends Provider {
|
||||||
* Creates a new organization with given {@code name} to the realm.
|
* Creates a new organization with given {@code name} to the realm.
|
||||||
* The internal ID of the organization will be created automatically.
|
* The internal ID of the organization will be created automatically.
|
||||||
* @param name String name of the organization.
|
* @param name String name of the organization.
|
||||||
* @param domains the domains
|
|
||||||
* @throws ModelDuplicateException If there is already an organization with the given name
|
* @throws ModelDuplicateException If there is already an organization with the given name
|
||||||
* @return Model of the created organization.
|
* @return Model of the created organization.
|
||||||
*/
|
*/
|
||||||
OrganizationModel create(String name, Set<String> domains);
|
OrganizationModel create(String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link OrganizationModel} by its {@code id};
|
* Returns a {@link OrganizationModel} by its {@code id};
|
||||||
|
|
|
@ -93,13 +93,8 @@ public class OrganizationsResource {
|
||||||
throw ErrorResponse.error("Organization cannot be null.", Response.Status.BAD_REQUEST);
|
throw ErrorResponse.error("Organization cannot be null.", Response.Status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> domains = ofNullable(organization.getDomains()).orElse(Set.of()).stream()
|
|
||||||
.map(OrganizationDomainRepresentation::getName)
|
|
||||||
.filter(StringUtil::isNotBlank)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OrganizationModel model = provider.create(organization.getName(), domains);
|
OrganizationModel model = provider.create(organization.getName());
|
||||||
|
|
||||||
Organizations.toModel(organization, model);
|
Organizations.toModel(organization, model);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue