use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class LdapSyntaxHelper method addToRegistries.
/**
* Inject the LdapSyntax into the registries, updating the references to
* other SchemaObject
*
* @param ldapSyntax The LdapSyntax to add to the Registries
* @param errors The errors we got while adding the LdapSyntax to the Registries
* @param registries The Registries
* @throws LdapException If the addition failed
*/
public static void addToRegistries(LdapSyntax ldapSyntax, List<Throwable> errors, Registries registries) throws LdapException {
if (registries != null) {
try {
ldapSyntax.unlock();
SyntaxChecker syntaxChecker = null;
try {
// Gets the associated SyntaxChecker
syntaxChecker = registries.getSyntaxCheckerRegistry().lookup(ldapSyntax.getOid());
} catch (LdapException ne) {
// No SyntaxChecker ? Associate the Syntax to a catch all SyntaxChecker
syntaxChecker = OctetStringSyntaxChecker.builder().setOid(ldapSyntax.getOid()).build();
}
// S -> SC
if (syntaxChecker != null) {
registries.addReference(ldapSyntax, syntaxChecker);
ldapSyntax.setSyntaxChecker(syntaxChecker);
}
} finally {
ldapSyntax.lock();
}
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class MatchingRuleHelper method addToRegistries.
/**
* Inject the MatchingRule into the Registries, updating the references to
* other SchemaObject
*
* @param matchingRule The MatchingRule to add to the Registries
* @param errors The errors we got while adding the MatchingRule to the registries
* @param registries The Registries
* @throws LdapException If the addition failed
*/
@SuppressWarnings("rawtypes")
public static void addToRegistries(MutableMatchingRule matchingRule, List<Throwable> errors, Registries registries) throws LdapException {
if (registries != null) {
try {
matchingRule.unlock();
LdapComparator<?> ldapComparator = null;
Normalizer normalizer = null;
LdapSyntax ldapSyntax = null;
try {
// Gets the associated Comparator
ldapComparator = registries.getComparatorRegistry().lookup(matchingRule.getOid());
} catch (LdapException ne) {
// Default to a catch all comparator
ldapComparator = new ComparableComparator(matchingRule.getOid());
}
try {
// Gets the associated Normalizer
normalizer = registries.getNormalizerRegistry().lookup(matchingRule.getOid());
} catch (LdapException ne) {
// Default to the NoOp normalizer
normalizer = new NoOpNormalizer(matchingRule.getOid());
}
try {
// Get the associated LdapSyntax
ldapSyntax = registries.getLdapSyntaxRegistry().lookup(matchingRule.getSyntaxOid());
} catch (LdapException ne) {
// The Syntax is a mandatory element, it must exist.
String msg = I18n.err(I18n.ERR_13765_MR_MUST_REFER_EXISTING_SYNTAX);
LdapSchemaException ldapSchemaException = new LdapSchemaException(LdapSchemaExceptionCodes.MR_NONEXISTENT_SYNTAX, msg, ne);
ldapSchemaException.setSourceObject(matchingRule);
ldapSchemaException.setRelatedId(matchingRule.getSyntaxOid());
errors.add(ldapSchemaException);
LOG.info(msg);
}
/**
* Add the MR references (using and usedBy) :
* MR -> C
* MR -> N
* MR -> S
*/
if (ldapComparator != null) {
registries.addReference(matchingRule, ldapComparator);
matchingRule.setLdapComparator(ldapComparator);
}
if (normalizer != null) {
registries.addReference(matchingRule, normalizer);
matchingRule.setNormalizer(normalizer);
}
if (ldapSyntax != null) {
registries.addReference(matchingRule, ldapSyntax);
matchingRule.setSyntax(ldapSyntax);
}
} finally {
matchingRule.lock();
}
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultAttributeTypeRegistry method hasDescendants.
/**
* {@inheritDoc}
*/
@Override
public boolean hasDescendants(String ancestorId) throws LdapException {
try {
String oid = getOidByName(ancestorId);
Set<AttributeType> descendants = oidToDescendantSet.get(oid);
return (descendants != null) && !descendants.isEmpty();
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultAttributeTypeRegistry method unregister.
/**
* {@inheritDoc}
*/
@Override
public AttributeType unregister(String numericOid) throws LdapException {
try {
AttributeType removed = super.unregister(numericOid);
removeMappingFor(removed);
// Deleting an AT which might be used as a superior means we have
// to recursively update the descendant map. We also have to remove
// the at.oid -> descendant relation
oidToDescendantSet.remove(numericOid);
// Now recurse if needed
unregisterDescendants(removed, removed.getSuperior());
return removed;
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultDitStructureRuleRegistry method lookup.
/**
* {@inheritDoc}
*/
@Override
public DitStructureRule lookup(int ruleId) throws LdapException {
DitStructureRule ditStructureRule = byRuleId.get(ruleId);
if (ditStructureRule == null) {
String msg = I18n.err(I18n.ERR_13731_DIT_STRUCTURE_RULE_DOES_NOT_EXIST, ruleId);
LOG.debug(msg);
throw new LdapException(msg);
}
if (DEBUG) {
LOG.debug("Found {} with ruleId: {}", ditStructureRule, ruleId);
}
return ditStructureRule;
}
Aggregations