use of javax.naming.directory.Attributes in project directory-ldap-api by apache.
the class LdifUtilsTest method testConvertAttributesfromLdif.
/**
* Test a conversion of an attributes from a LDIF file
* @throws org.apache.directory.api.ldap.model.ldif.LdapLdifException
*/
@Test
public void testConvertAttributesfromLdif() throws LdapException, LdapLdifException {
Attributes attributes = new BasicAttributes(true);
Attribute oc = new BasicAttribute("objectclass");
oc.add("top");
oc.add("person");
oc.add("inetorgPerson");
attributes.put(oc);
attributes.put("cn", "Saarbrucken");
attributes.put("sn", "test");
String ldif = LdifUtils.convertToLdif(attributes, (Dn) null, 15);
Attributes result = LdifUtils.getJndiAttributesFromLdif(ldif);
assertEquals(attributes, result);
}
use of javax.naming.directory.Attributes in project directory-ldap-api by apache.
the class TriggerUtils method loadEntryTriggerSpecification.
/**
* Load the trigger specification entry
*
* @param ctx The context
* @param triggerSpec The trigger specification
* @throws NamingException If the operation failed
*/
public static void loadEntryTriggerSpecification(LdapContext ctx, String triggerSpec) throws NamingException {
Attributes changes = new BasicAttributes(SchemaConstants.ENTRY_TRIGGER_SPECIFICATION_AT, triggerSpec, true);
ctx.modifyAttributes("", DirContext.ADD_ATTRIBUTE, changes);
}
use of javax.naming.directory.Attributes in project directory-ldap-api by apache.
the class TriggerUtils method loadPrescriptiveTriggerSpecification.
/**
* Load an prescriptive trigger specification
*
* @param apCtx The administrative point context
* @param subentryCN The subentry CN
* @param triggerSpec The trigger specification
* @throws NamingException If the operation failed
*/
public static void loadPrescriptiveTriggerSpecification(LdapContext apCtx, String subentryCN, String triggerSpec) throws NamingException {
Attributes changes = new BasicAttributes(SchemaConstants.PRESCRIPTIVE_TRIGGER_SPECIFICATION_AT, triggerSpec, true);
apCtx.modifyAttributes("cn=" + subentryCN, DirContext.ADD_ATTRIBUTE, changes);
}
use of javax.naming.directory.Attributes in project directory-ldap-api by apache.
the class TriggerUtils method defineTriggerExecutionSpecificPoint.
/**
* Defines the Administration point and administrative role for the TriggerExecution specific point
* @param apCtx The administrative point context
* @throws NamingException If the operation failed
*/
public static void defineTriggerExecutionSpecificPoint(LdapContext apCtx) throws NamingException {
Attributes ap = apCtx.getAttributes("", new String[] { SchemaConstants.ADMINISTRATIVE_ROLE_AT });
Attribute administrativeRole = ap.get(SchemaConstants.ADMINISTRATIVE_ROLE_AT);
if (administrativeRole == null || !AttributeUtils.containsValueCaseIgnore(administrativeRole, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA)) {
Attributes changes = new BasicAttributes(SchemaConstants.ADMINISTRATIVE_ROLE_AT, SchemaConstants.TRIGGER_EXECUTION_SPECIFIC_AREA, true);
apCtx.modifyAttributes("", DirContext.ADD_ATTRIBUTE, changes);
}
}
use of javax.naming.directory.Attributes in project directory-ldap-api by apache.
the class JavaStoredProcUtils method loadStoredProcedureClass.
/**
* Loads a Java class's stream data as a subcontext of an LdapContext given.
*
* @param ctx
* The parent context of the Java class entry to be loaded.
* @param clazz
* Class to be loaded.
* @throws NamingException
* If an error occurs during creating the subcontext.
*/
public static void loadStoredProcedureClass(LdapContext ctx, Class<?> clazz) throws NamingException {
byte[] buf = getClassFileAsStream(clazz);
String fullClassName = clazz.getName();
Attributes attributes = new BasicAttributes(SchemaConstants.OBJECT_CLASS_AT, SchemaConstants.TOP_OC, true);
attributes.get(SchemaConstants.OBJECT_CLASS_AT).add("storedProcUnit");
attributes.get(SchemaConstants.OBJECT_CLASS_AT).add("javaStoredProcUnit");
attributes.put("storedProcLangId", "Java");
attributes.put("storedProcUnitName", fullClassName);
attributes.put("javaByteCode", buf);
ctx.createSubcontext("storedProcUnitName=" + fullClassName, attributes);
}
Aggregations