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;
}
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;
}
Aggregations