use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InMemoryRequestHandler method indexSearch.
/**
* Attempts to use indexes to obtain a candidate list for the provided filter.
*
* @param filter The filter to be processed.
*
* @return The DNs of entries which may match the given filter, or
* {@code null} if the filter is not indexed.
*/
@Nullable()
private Set<DN> indexSearch(@NotNull final Filter filter) {
switch(filter.getFilterType()) {
case Filter.FILTER_TYPE_AND:
Filter[] comps = filter.getComponents();
if (comps.length == 0) {
return null;
} else if (comps.length == 1) {
return indexSearch(comps[0]);
} else {
Set<DN> candidateSet = null;
for (final Filter f : comps) {
final Set<DN> dnSet = indexSearch(f);
if (dnSet != null) {
if (candidateSet == null) {
candidateSet = new TreeSet<>(dnSet);
} else {
candidateSet.retainAll(dnSet);
}
}
}
return candidateSet;
}
case Filter.FILTER_TYPE_OR:
comps = filter.getComponents();
if (comps.length == 0) {
return Collections.emptySet();
} else if (comps.length == 1) {
return indexSearch(comps[0]);
} else {
Set<DN> candidateSet = null;
for (final Filter f : comps) {
final Set<DN> dnSet = indexSearch(f);
if (dnSet == null) {
return null;
}
if (candidateSet == null) {
candidateSet = new TreeSet<>(dnSet);
} else {
candidateSet.addAll(dnSet);
}
}
return candidateSet;
}
case Filter.FILTER_TYPE_EQUALITY:
final Schema schema = schemaRef.get();
if (schema == null) {
return null;
}
final AttributeTypeDefinition at = schema.getAttributeType(filter.getAttributeName());
if (at == null) {
return null;
}
final InMemoryDirectoryServerEqualityAttributeIndex i = equalityIndexes.get(at);
if (i == null) {
return null;
}
try {
return i.getMatchingEntries(filter.getRawAssertionValue());
} catch (final Exception e) {
Debug.debugException(e);
return null;
}
default:
return null;
}
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InMemoryRequestHandler method getMissingAttributeNames.
/**
* Retrieves a list containing all of the named attributes which do not exist
* in the target entry.
*
* @param dn The DN of the entry to examine.
* @param attributeNames The names of the attributes expected to be present
* in the target entry.
*
* @return A list containing the names of the attributes which were not
* present in the target entry, an empty list if all specified
* attributes were found in the entry, or {@code null} if the target
* entry does not exist.
*
* @throws LDAPException If a problem is encountered while trying to
* communicate with the directory server.
*/
@Nullable()
public List<String> getMissingAttributeNames(@NotNull final String dn, @NotNull final Collection<String> attributeNames) throws LDAPException {
synchronized (entryMap) {
final Entry e = getEntry(dn);
if (e == null) {
return null;
}
final Schema schema = schemaRef.get();
final List<String> missingAttrs = new ArrayList<>(attributeNames.size());
for (final String attr : attributeNames) {
final Filter f = Filter.createPresenceFilter(attr);
if (!f.matchesEntry(e, schema)) {
missingAttrs.add(attr);
}
}
return missingAttrs;
}
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InMemoryDirectoryServer method getListenAddress.
/**
* Retrieves the configured listen address for the specified listener, if
* defined.
*
* @param listenerName The name of the listener for which to retrieve the
* listen address. It may be {@code null} in order to
* obtain the listen address for the first active
* listener.
*
* @return The configured listen address for the specified listener, or
* {@code null} if there is no such listener or the listener does not
* have an explicitly-configured listen address.
*/
@Nullable()
public synchronized InetAddress getListenAddress(@Nullable final String listenerName) {
final String name;
if (listenerName == null) {
name = getFirstListenerName();
} else {
name = StaticUtils.toLowerCase(listenerName);
}
final LDAPListenerConfig listenerCfg = ldapListenerConfigs.get(name);
if (listenerCfg == null) {
return null;
} else {
return listenerCfg.getListenAddress();
}
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorRequestHandler method transformEntry.
/**
* {@inheritDoc}
*/
@Override()
@Nullable()
public ObjectPair<SearchResultEntryProtocolOp, Control[]> transformEntry(final int messageID, @NotNull final SearchResultEntryProtocolOp entry, @NotNull final Control[] controls) {
final InterceptedSearchOperation op = (InterceptedSearchOperation) activeOperations.get(messageID);
if (op == null) {
return new ObjectPair<>(entry, controls);
}
final InterceptedSearchEntry e = new InterceptedSearchEntry(op, entry, controls);
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSearchEntry(e);
if (e.getSearchEntry() == null) {
return null;
}
} catch (final Exception ex) {
Debug.debugException(ex);
return null;
}
}
return new ObjectPair<>(new SearchResultEntryProtocolOp(e.getSearchEntry()), e.getSearchEntry().getControls());
}
use of com.unboundid.util.Nullable in project ldapsdk by pingidentity.
the class InMemoryOperationInterceptorRequestHandler method transformReference.
/**
* {@inheritDoc}
*/
@Override()
@Nullable()
public ObjectPair<SearchResultReferenceProtocolOp, Control[]> transformReference(final int messageID, @NotNull final SearchResultReferenceProtocolOp reference, @NotNull final Control[] controls) {
final InterceptedSearchOperation op = (InterceptedSearchOperation) activeOperations.get(messageID);
if (op == null) {
return new ObjectPair<>(reference, controls);
}
final InterceptedSearchReference r = new InterceptedSearchReference(op, reference, controls);
for (final InMemoryOperationInterceptor i : interceptors) {
try {
i.processSearchReference(r);
if (r.getSearchReference() == null) {
return null;
}
} catch (final Exception ex) {
Debug.debugException(ex);
return null;
}
}
return new ObjectPair<>(new SearchResultReferenceProtocolOp(r.getSearchReference()), r.getSearchReference().getControls());
}
Aggregations