use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class SchemaAwareEntryTest method createEntry.
/**
* Helper method which creates an entry with 4 attributes.
*/
private Entry createEntry() {
try {
Entry entry = new DefaultEntry(exampleDn);
Attribute attrOC = new DefaultAttribute("objectClass", "top", "person");
Attribute attrCN = new DefaultAttribute("cn", "test1", "test2");
Attribute attrSN = new DefaultAttribute("sn", "Test1", "Test2");
Attribute attrPWD = new DefaultAttribute("userPassword", BYTES1, BYTES2);
entry.put(attrOC, attrCN, attrSN, attrPWD);
return entry;
} catch (LdapException ne) {
// Do nothing
return null;
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class SearchRequestTest method testRequestWithAttributes1Attribute.
/**
* Test parsing of a request with an Attributes element with 1 Attribute element
* @throws NamingException
*/
@Test
public void testRequestWithAttributes1Attribute() throws LdapException {
Dsmlv2Parser parser = null;
try {
parser = newParser();
parser.setInput(SearchRequestTest.class.getResource("request_with_attributes_1_attribute.xml").openStream(), "UTF-8");
parser.parse();
} catch (Exception e) {
fail(e.getMessage());
}
SearchRequest searchRequest = (SearchRequest) parser.getBatchRequest().getCurrentRequest();
List<String> attributes = searchRequest.getAttributes();
assertEquals(1, attributes.size());
String attribute = attributes.get(0);
assertEquals("sn", attribute);
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadDitStructureRules.
private void loadDitStructureRules(Attribute ditStructureRules) throws LdapException {
if (ditStructureRules == null) {
return;
}
for (Value value : ditStructureRules) {
String desc = value.getValue();
try {
DitStructureRule ditStructureRule = DSR_DESCR_SCHEMA_PARSER.parseDITStructureRuleDescription(desc);
updateSchemas(ditStructureRule);
} catch (ParseException pe) {
throw new LdapException(pe);
}
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadObjectClasses.
private void loadObjectClasses(Attribute objectClasses) throws LdapException {
if (objectClasses == null) {
return;
}
for (Value value : objectClasses) {
String desc = value.getValue();
try {
ObjectClass objectClass = OC_DESCR_SCHEMA_PARSER.parseObjectClassDescription(desc);
updateSchemas(objectClass);
} catch (ParseException pe) {
throw new LdapException(pe);
}
}
}
use of org.apache.directory.api.ldap.model.exception.LdapException in project directory-ldap-api by apache.
the class DefaultSchemaLoader method loadNameForms.
private void loadNameForms(Attribute nameForms) throws LdapException {
if (nameForms == null) {
return;
}
for (Value value : nameForms) {
String desc = value.getValue();
try {
NameForm nameForm = NF_DESCR_SCHEMA_PARSER.parseNameFormDescription(desc);
updateSchemas(nameForm);
} catch (ParseException pe) {
throw new LdapException(pe);
}
}
}
Aggregations