use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultDitStructureRuleRegistry method getSchemaName.
/**
* {@inheritDoc}
*/
@Override
public String getSchemaName(int ruleId) throws LdapException {
DitStructureRule ditStructureRule = byRuleId.get(ruleId);
if (ditStructureRule != null) {
return ditStructureRule.getSchemaName();
}
String msg = I18n.err(I18n.ERR_13729_RULE_ID_NOT_FOUND, ruleId);
LOG.warn(msg);
throw new LdapException(msg);
}
use of org.apache.directory.api.ldap.model.exception.LdapException 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.LdapException in project directory-ldap-api by apache.
the class DefaultSchemaObjectRegistry method getSchemaName.
/**
* {@inheritDoc}
*/
@Override
public String getSchemaName(String oid) throws LdapException {
if (!Oid.isOid(oid)) {
String msg = I18n.err(I18n.ERR_13733_ARG_NOT_NUMERIC_OID);
LOG.warn(msg);
throw new LdapException(msg);
}
SchemaObject schemaObject = byName.get(oid);
if (schemaObject != null) {
return schemaObject.getSchemaName();
}
String msg = I18n.err(I18n.ERR_13734_OID_NOT_FOUND, oid);
LOG.warn(msg);
throw new LdapException(msg);
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DnComparator method compare.
/**
* {@inheritDoc}
*/
@Override
public int compare(Object obj0, Object obj1) {
if ((obj0 instanceof String) && (obj1 instanceof String)) {
return compare((String) obj0, (String) obj1);
}
Dn dn0 = null;
Dn dn1 = null;
try {
dn0 = getDn(obj0);
dn1 = getDn(obj1);
} catch (LdapException e) {
// -- what do we do here ?
return -1;
}
int dn0Size = dn0.getRdns().size();
int dn1Size = dn1.getRdns().size();
// when both DNs are equal checking isAncestorOf() returns true
if (dn0.equals(dn1)) {
return 0;
} else if (dn0Size > dn1Size) {
return -1;
} else if (dn1Size > dn0Size) {
return 1;
}
for (int i = dn0Size - 1; i >= 0; i--) {
int comp = dn0.getRdn(i).compareTo(dn1.getRdn(i));
if (comp != 0) {
return comp;
}
}
return 0;
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class AddAttributeType method action.
/**
* {@inheritDoc}
*/
public void action(LdapMessageContainer<SearchResultEntryDecorator> container) throws DecoderException {
SearchResultEntryDecorator searchResultEntry = container.getMessage();
TLV tlv = container.getCurrentTLV();
// Store the type
if (tlv.getLength() == 0) {
// The type can't be null
String msg = I18n.err(I18n.ERR_04081);
LOG.error(msg);
throw new DecoderException(msg);
} else {
try {
searchResultEntry.addAttribute(tlv.getValue().getData());
} catch (LdapException ine) {
String type = Strings.utf8ToString(tlv.getValue().getData());
// This is for the client side. We will never decode LdapResult on the server
String msg = "The Attribute type " + type + "is invalid : " + ine.getMessage();
LOG.error("{} : {}", msg, ine.getMessage());
throw new DecoderException(msg, ine);
}
}
if (IS_DEBUG) {
String type = Strings.utf8ToString(tlv.getValue().getData());
LOG.debug("Attribute type : {}", type);
}
}
Aggregations