Search in sources :

Example 6 with StringUtils.strip

use of org.apache.commons.lang3.StringUtils.strip in project syncope by apache.

the class SearchCondVisitor method complex.

private <E extends Enum<?>> SearchCond complex(final String operator, final String left, final String right, final List<SCIMComplexConf<E>> items) {
    if (left.endsWith(".type")) {
        Optional<SCIMComplexConf<E>> item = items.stream().filter(object -> object.getType().name().equals(StringUtils.strip(right, "\""))).findFirst();
        if (item.isPresent()) {
            AttributeCond attributeCond = new AttributeCond();
            attributeCond.setSchema(item.get().getValue());
            attributeCond.setType(AttributeCond.Type.ISNOTNULL);
            return SearchCond.getLeafCond(attributeCond);
        }
    } else if (!conf.getUserConf().getEmails().isEmpty() && (MULTIVALUE.contains(left) || left.endsWith(".value"))) {
        List<SearchCond> orConds = new ArrayList<>();
        items.forEach(item -> {
            AttributeCond cond = new AttributeCond();
            cond.setSchema(item.getValue());
            cond.setExpression(StringUtils.strip(right, "\""));
            orConds.add(setOperator(cond, operator));
        });
        if (!orConds.isEmpty()) {
            return SearchCond.getOrCond(orConds);
        }
    }
    return null;
}
Also used : Arrays(java.util.Arrays) SCIMUserConf(org.apache.syncope.common.lib.scim.SCIMUserConf) SearchCond(org.apache.syncope.core.persistence.api.dao.search.SearchCond) SCIMUserAddressConf(org.apache.syncope.common.lib.scim.SCIMUserAddressConf) StringUtils(org.apache.commons.lang3.StringUtils) ArrayList(java.util.ArrayList) List(java.util.List) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) Resource(org.apache.syncope.ext.scimv2.api.type.Resource) SCIMComplexConf(org.apache.syncope.common.lib.scim.SCIMComplexConf) SCIMConf(org.apache.syncope.common.lib.scim.SCIMConf) Map(java.util.Map) Optional(java.util.Optional) AnyCond(org.apache.syncope.core.persistence.api.dao.search.AnyCond) AttributeCond(org.apache.syncope.core.persistence.api.dao.search.AttributeCond) SCIMComplexConf(org.apache.syncope.common.lib.scim.SCIMComplexConf) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)3 StringUtils (org.apache.commons.lang3.StringUtils)3 StopWatch (org.apache.commons.lang3.time.StopWatch)3 Arrays (java.util.Arrays)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 SCIMComplexConf (org.apache.syncope.common.lib.scim.SCIMComplexConf)2 SCIMConf (org.apache.syncope.common.lib.scim.SCIMConf)2 SCIMUserAddressConf (org.apache.syncope.common.lib.scim.SCIMUserAddressConf)2 SCIMUserConf (org.apache.syncope.common.lib.scim.SCIMUserConf)2 AnyCond (org.apache.syncope.core.persistence.api.dao.search.AnyCond)2 AttributeCond (org.apache.syncope.core.persistence.api.dao.search.AttributeCond)2 SearchCond (org.apache.syncope.core.persistence.api.dao.search.SearchCond)2 Resource (org.apache.syncope.ext.scimv2.api.type.Resource)2 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1