Check emptyness not size
This commit is contained in:
parent
f2464bbc00
commit
10ff5787f0
3 changed files with 5 additions and 4 deletions
|
@ -4,6 +4,7 @@ import de.captaingoldfish.scim.sdk.common.resources.Group;
|
||||||
import de.captaingoldfish.scim.sdk.common.resources.complex.Meta;
|
import de.captaingoldfish.scim.sdk.common.resources.complex.Meta;
|
||||||
import de.captaingoldfish.scim.sdk.common.resources.multicomplex.Member;
|
import de.captaingoldfish.scim.sdk.common.resources.multicomplex.Member;
|
||||||
import jakarta.persistence.NoResultException;
|
import jakarta.persistence.NoResultException;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.keycloak.models.GroupModel;
|
import org.keycloak.models.GroupModel;
|
||||||
|
@ -60,7 +61,7 @@ public class GroupAdapter extends Adapter<GroupModel, Group> {
|
||||||
setExternalId(group.getId().get());
|
setExternalId(group.getId().get());
|
||||||
setDisplayName(group.getDisplayName().get());
|
setDisplayName(group.getDisplayName().get());
|
||||||
List<Member> groupMembers = group.getMembers();
|
List<Member> groupMembers = group.getMembers();
|
||||||
if (groupMembers != null && groupMembers.size() > 0) {
|
if (CollectionUtils.isNotEmpty(groupMembers)) {
|
||||||
this.members = new HashSet<>();
|
this.members = new HashSet<>();
|
||||||
for (Member groupMember : groupMembers) {
|
for (Member groupMember : groupMembers) {
|
||||||
try {
|
try {
|
||||||
|
@ -80,7 +81,7 @@ public class GroupAdapter extends Adapter<GroupModel, Group> {
|
||||||
group.setId(externalId);
|
group.setId(externalId);
|
||||||
group.setExternalId(id);
|
group.setExternalId(id);
|
||||||
group.setDisplayName(displayName);
|
group.setDisplayName(displayName);
|
||||||
if (members.size() > 0) {
|
if (!members.isEmpty()) {
|
||||||
for (String member : members) {
|
for (String member : members) {
|
||||||
Member groupMember = new Member();
|
Member groupMember = new Member();
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -116,7 +116,7 @@ public class ScimClient {
|
||||||
if (adapter.skip)
|
if (adapter.skip)
|
||||||
return;
|
return;
|
||||||
// If mapping exist then it was created by import so skip.
|
// If mapping exist then it was created by import so skip.
|
||||||
if (adapter.query("findById", adapter.getId()).getResultList().size() != 0) {
|
if (!adapter.query("findById", adapter.getId()).getResultList().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Retry retry = registry.retry("create-" + adapter.getId());
|
Retry retry = registry.retry("create-" + adapter.getId());
|
||||||
|
|
|
@ -139,7 +139,7 @@ public class UserAdapter extends Adapter<UserModel, User> {
|
||||||
setUsername(user.getUserName().get());
|
setUsername(user.getUserName().get());
|
||||||
setDisplayName(user.getDisplayName().get());
|
setDisplayName(user.getDisplayName().get());
|
||||||
setActive(user.isActive().get());
|
setActive(user.isActive().get());
|
||||||
if (user.getEmails().size() > 0) {
|
if (!user.getEmails().isEmpty()) {
|
||||||
setEmail(user.getEmails().get(0).getValue().get());
|
setEmail(user.getEmails().get(0).getValue().get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue