use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException 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.LdapNoSuchAttributeException 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.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class DefaultObjectClassRegistry method descendants.
/**
* {@inheritDoc}
*/
@SuppressWarnings("unchecked")
@Override
public Iterator<ObjectClass> descendants(String ancestorId) throws LdapException {
try {
String oid = getOidByName(ancestorId);
Set<ObjectClass> descendants = oidToDescendants.get(oid);
if (descendants == null) {
return Collections.EMPTY_SET.iterator();
}
return descendants.iterator();
} catch (LdapException ne) {
throw new LdapNoSuchAttributeException(ne.getMessage(), ne);
}
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-ldap-api by apache.
the class WrappedPartialResultException method wrap.
/**
* Wraps a LDAP exception into a NaingException
*
* @param t The original exception
* @throws NamingException The wrapping JNDI exception
*/
public static void wrap(Throwable t) throws NamingException {
if (t instanceof NamingException) {
throw (NamingException) t;
}
NamingException ne;
if ((t instanceof LdapAffectMultipleDsaException) || (t instanceof LdapAliasDereferencingException) || (t instanceof LdapLoopDetectedException) || (t instanceof LdapAliasException) || (t instanceof LdapOperationErrorException) || (t instanceof LdapOtherException)) {
ne = new NamingException(t.getLocalizedMessage());
} else if (t instanceof LdapAttributeInUseException) {
ne = new AttributeInUseException(t.getLocalizedMessage());
} else if (t instanceof LdapAuthenticationException) {
ne = new AuthenticationException(t.getLocalizedMessage());
} else if (t instanceof LdapAuthenticationNotSupportedException) {
ne = new AuthenticationNotSupportedException(t.getLocalizedMessage());
} else if (t instanceof LdapContextNotEmptyException) {
ne = new ContextNotEmptyException(t.getLocalizedMessage());
} else if (t instanceof LdapEntryAlreadyExistsException) {
ne = new NameAlreadyBoundException(t.getLocalizedMessage());
} else if (t instanceof LdapInvalidAttributeTypeException) {
ne = new InvalidAttributeIdentifierException(t.getLocalizedMessage());
} else if (t instanceof LdapInvalidAttributeValueException) {
ne = new InvalidAttributeValueException(t.getLocalizedMessage());
} else if (t instanceof LdapInvalidDnException) {
ne = new InvalidNameException(t.getLocalizedMessage());
} else if (t instanceof LdapInvalidSearchFilterException) {
ne = new InvalidSearchFilterException(t.getLocalizedMessage());
} else if (t instanceof LdapNoPermissionException) {
ne = new NoPermissionException(t.getLocalizedMessage());
} else if (t instanceof LdapNoSuchAttributeException) {
ne = new NoSuchAttributeException(t.getLocalizedMessage());
} else if (t instanceof LdapNoSuchObjectException) {
ne = new NameNotFoundException(t.getLocalizedMessage());
} else if (t instanceof LdapProtocolErrorException) {
ne = new CommunicationException(t.getLocalizedMessage());
} else if (t instanceof LdapReferralException) {
ne = new WrappedReferralException((LdapReferralException) t);
} else if (t instanceof LdapPartialResultException) {
ne = new WrappedPartialResultException((LdapPartialResultException) t);
} else if (t instanceof LdapSchemaViolationException) {
ne = new SchemaViolationException(t.getLocalizedMessage());
} else if (t instanceof LdapServiceUnavailableException) {
ne = new ServiceUnavailableException(t.getLocalizedMessage());
} else if (t instanceof LdapTimeLimitExceededException) {
ne = new TimeLimitExceededException(t.getLocalizedMessage());
} else if (t instanceof LdapUnwillingToPerformException) {
ne = new OperationNotSupportedException(t.getLocalizedMessage());
} else {
ne = new NamingException(t.getLocalizedMessage());
}
ne.setRootCause(t);
throw ne;
}
use of org.apache.directory.api.ldap.model.exception.LdapNoSuchAttributeException in project directory-fortress-core by apache.
the class PermDAO method revoke.
/**
* @param pOp
* @param role
* @throws org.apache.directory.fortress.core.UpdateException
*
* @throws org.apache.directory.fortress.core.FinderException
*/
void revoke(Permission pOp, Role role) throws UpdateException, FinderException {
LdapConnection ld = null;
String dn = getDn(pOp, pOp.getContextId());
try {
List<Modification> mods = new ArrayList<Modification>();
mods.add(new DefaultModification(ModificationOperation.REMOVE_ATTRIBUTE, ROLES, role.getName()));
ld = getAdminConnection();
modify(ld, dn, mods, pOp);
} catch (LdapNoSuchAttributeException e) {
String warning = "revoke perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] name [" + role.getName() + "] assignment does not exist.";
throw new FinderException(GlobalErrIds.PERM_ROLE_NOT_EXIST, warning);
} catch (LdapException e) {
String error = "revoke perm object [" + pOp.getObjName() + "] operation [" + pOp.getOpName() + "] name [" + role.getName() + "] caught LdapException=" + e.getMessage();
throw new UpdateException(GlobalErrIds.PERM_REVOKE_FAILED, error, e);
} finally {
closeAdminConnection(ld);
}
}
Aggregations