Search in sources :

Example 1 with EqualsFilter

use of org.identityconnectors.framework.common.objects.filter.EqualsFilter in project syncope by apache.

the class PullUtils method match.

public Optional<String> match(final AnyType anyType, final String name, final ExternalResource resource, final Connector connector) {
    Optional<? extends Provision> provision = resource.getProvision(anyType);
    if (!provision.isPresent()) {
        return Optional.empty();
    }
    Optional<String> result = Optional.empty();
    AnyUtils anyUtils = anyUtilsFactory.getInstance(anyType.getKind());
    final List<ConnectorObject> found = new ArrayList<>();
    connector.search(provision.get().getObjectClass(), new EqualsFilter(new Name(name)), obj -> found.add(obj), MappingUtils.buildOperationOptions(MappingUtils.getPullItems(provision.get().getMapping().getItems()).iterator()));
    if (found.isEmpty()) {
        LOG.debug("No {} found on {} with __NAME__ {}", provision.get().getObjectClass(), resource, name);
    } else {
        if (found.size() > 1) {
            LOG.warn("More than one {} found on {} with __NAME__ {} - taking first only", provision.get().getObjectClass(), resource, name);
        }
        ConnectorObject connObj = found.iterator().next();
        try {
            List<String> anyKeys = match(connObj, provision.get(), anyUtils);
            if (anyKeys.isEmpty()) {
                LOG.debug("No matching {} found for {}, aborting", anyUtils.getAnyTypeKind(), connObj);
            } else {
                if (anyKeys.size() > 1) {
                    LOG.warn("More than one {} found {} - taking first only", anyUtils.getAnyTypeKind(), anyKeys);
                }
                result = Optional.ofNullable(anyKeys.iterator().next());
            }
        } catch (IllegalArgumentException e) {
            LOG.warn(e.getMessage());
        }
    }
    return result;
}
Also used : ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) ArrayList(java.util.ArrayList) EqualsFilter(org.identityconnectors.framework.common.objects.filter.EqualsFilter) AnyUtils(org.apache.syncope.core.persistence.api.entity.AnyUtils) IntAttrName(org.apache.syncope.core.provisioning.api.IntAttrName) Name(org.identityconnectors.framework.common.objects.Name)

Example 2 with EqualsFilter

use of org.identityconnectors.framework.common.objects.filter.EqualsFilter in project CzechIdMng by bcvsolutions.

the class ConnIdIcConvertUtil method convertIcFilter.

public static Filter convertIcFilter(IcFilter filter) {
    if (filter == null) {
        return null;
    }
    if (filter instanceof IcAndFilter) {
        List<IcFilter> subFilters = (List<IcFilter>) ((IcAndFilter) filter).getFilters();
        LinkedList<Filter> subFiltersConnId = new LinkedList<>();
        if (!subFilters.isEmpty()) {
            subFilters.forEach(subFilter -> {
                subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
            });
        }
        return new AndFilter(subFiltersConnId);
    }
    if (filter instanceof IcOrFilter) {
        List<IcFilter> subFilters = (List<IcFilter>) ((IcOrFilter) filter).getFilters();
        LinkedList<Filter> subFiltersConnId = new LinkedList<>();
        if (!subFilters.isEmpty()) {
            subFilters.forEach(subFilter -> {
                subFiltersConnId.add(ConnIdIcConvertUtil.convertIcFilter(subFilter));
            });
        }
        return new OrFilter(subFiltersConnId);
    }
    if (filter instanceof IcNotFilter) {
        return new NotFilter(ConnIdIcConvertUtil.convertIcFilter(((IcNotFilter) filter).getFilter()));
    }
    if (filter instanceof IcAttributeFilter) {
        Attribute attr = ConnIdIcConvertUtil.convertIcAttribute(((IcAttributeFilter) filter).getAttribute());
        if (filter instanceof IcEqualsFilter) {
            return new EqualsFilter(attr);
        }
        if (filter instanceof IcContainsFilter) {
            return new ContainsFilter(attr);
        }
        if (filter instanceof IcEndsWithFilter) {
            return new EndsWithFilter(attr);
        }
        if (filter instanceof IcContainsAllValuesFilter) {
            return new ContainsAllValuesFilter(attr);
        }
        if (filter instanceof IcStartsWithFilter) {
            return new StartsWithFilter(attr);
        }
        if (filter instanceof IcGreaterThanFilter) {
            return new GreaterThanFilter(attr);
        }
        if (filter instanceof IcLessThanFilter) {
            return new LessThanFilter(attr);
        }
    }
    return null;
}
Also used : IcEnabledAttribute(eu.bcvsolutions.idm.ic.api.IcEnabledAttribute) IcPasswordAttribute(eu.bcvsolutions.idm.ic.api.IcPasswordAttribute) Attribute(org.identityconnectors.framework.common.objects.Attribute) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) IcLoginAttribute(eu.bcvsolutions.idm.ic.api.IcLoginAttribute) IcAttribute(eu.bcvsolutions.idm.ic.api.IcAttribute) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) ContainsFilter(org.identityconnectors.framework.common.objects.filter.ContainsFilter) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) EqualsFilter(org.identityconnectors.framework.common.objects.filter.EqualsFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) IcAttributeFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAttributeFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) OrFilter(org.identityconnectors.framework.common.objects.filter.OrFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) EndsWithFilter(org.identityconnectors.framework.common.objects.filter.EndsWithFilter) LinkedList(java.util.LinkedList) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) AndFilter(org.identityconnectors.framework.common.objects.filter.AndFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) LessThanFilter(org.identityconnectors.framework.common.objects.filter.LessThanFilter) IcContainsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) Filter(org.identityconnectors.framework.common.objects.filter.Filter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) ContainsAllValuesFilter(org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter) NotFilter(org.identityconnectors.framework.common.objects.filter.NotFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) IcAttributeFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAttributeFilter) EqualsFilter(org.identityconnectors.framework.common.objects.filter.EqualsFilter) EndsWithFilter(org.identityconnectors.framework.common.objects.filter.EndsWithFilter) StartsWithFilter(org.identityconnectors.framework.common.objects.filter.StartsWithFilter) IcLessThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter) IcEqualsFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter) LessThanFilter(org.identityconnectors.framework.common.objects.filter.LessThanFilter) IcOrFilter(eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter) IcAndFilter(eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) AndFilter(org.identityconnectors.framework.common.objects.filter.AndFilter) ContainsFilter(org.identityconnectors.framework.common.objects.filter.ContainsFilter) GreaterThanFilter(org.identityconnectors.framework.common.objects.filter.GreaterThanFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) OrFilter(org.identityconnectors.framework.common.objects.filter.OrFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) IcStartsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter) StartsWithFilter(org.identityconnectors.framework.common.objects.filter.StartsWithFilter) IcNotFilter(eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter) NotFilter(org.identityconnectors.framework.common.objects.filter.NotFilter) GreaterThanFilter(org.identityconnectors.framework.common.objects.filter.GreaterThanFilter) IcGreaterThanFilter(eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter) ContainsAllValuesFilter(org.identityconnectors.framework.common.objects.filter.ContainsAllValuesFilter) IcContainsAllValuesFilter(eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter) IcEndsWithFilter(eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter) IcFilter(eu.bcvsolutions.idm.ic.filter.api.IcFilter)

Aggregations

ArrayList (java.util.ArrayList)2 EqualsFilter (org.identityconnectors.framework.common.objects.filter.EqualsFilter)2 IcAttribute (eu.bcvsolutions.idm.ic.api.IcAttribute)1 IcEnabledAttribute (eu.bcvsolutions.idm.ic.api.IcEnabledAttribute)1 IcLoginAttribute (eu.bcvsolutions.idm.ic.api.IcLoginAttribute)1 IcPasswordAttribute (eu.bcvsolutions.idm.ic.api.IcPasswordAttribute)1 IcUidAttribute (eu.bcvsolutions.idm.ic.api.IcUidAttribute)1 IcFilter (eu.bcvsolutions.idm.ic.filter.api.IcFilter)1 IcAndFilter (eu.bcvsolutions.idm.ic.filter.impl.IcAndFilter)1 IcAttributeFilter (eu.bcvsolutions.idm.ic.filter.impl.IcAttributeFilter)1 IcContainsAllValuesFilter (eu.bcvsolutions.idm.ic.filter.impl.IcContainsAllValuesFilter)1 IcContainsFilter (eu.bcvsolutions.idm.ic.filter.impl.IcContainsFilter)1 IcEndsWithFilter (eu.bcvsolutions.idm.ic.filter.impl.IcEndsWithFilter)1 IcEqualsFilter (eu.bcvsolutions.idm.ic.filter.impl.IcEqualsFilter)1 IcGreaterThanFilter (eu.bcvsolutions.idm.ic.filter.impl.IcGreaterThanFilter)1 IcLessThanFilter (eu.bcvsolutions.idm.ic.filter.impl.IcLessThanFilter)1 IcNotFilter (eu.bcvsolutions.idm.ic.filter.impl.IcNotFilter)1 IcOrFilter (eu.bcvsolutions.idm.ic.filter.impl.IcOrFilter)1 IcStartsWithFilter (eu.bcvsolutions.idm.ic.filter.impl.IcStartsWithFilter)1 LinkedList (java.util.LinkedList)1