Dashboard > Penrose 1.0 > ... > Embedding Penrose > Mapping API
Mapping API
Added by Endi S. Dewata, last edited by Endi S. Dewata on Jun 15, 2006  (view change)
Labels: 
(None)


Entry

Each entry in Penrose is represented by an EntryMapping object. The following code creates an entry:

EntryMapping entryMapping = new EntryMapping();
entryMapping.setDn("dc=Example,dc=com");

The above entry is static, meaning this particular EntryMapping will generate exactly one entry in Penrose tree.

To create a dynamic entry, use the "..." in the DN:

EntryMapping entryMapping = new EntryMapping();
entryMapping.setDn("uid=...,ou=Users,dc=Example,dc=com");

Object Class

The following code adds object classes into an entry:

entryMapping.addObjectClass("person");
entryMapping.addObjectClass("organizationalPerson");
entryMapping.addObjectClass("inetOrgPerson");

Attribute

The following code creates an attribute:

AttributeMapping attributeMapping = new AttributeMapping();
attributeMapping.setName("dc");

If this attribute is used in the RDN, you should mark it as follows:

attributeMapping.setRdn(true);

Each attribute has a value. There are 3 types of values:

  • constant
  • variable
  • expression

To set a constant value:

attributeMapping.setType(AttributeMapping.CONSTANT);
attributeMapping.setConstant("Example");

To set a variable:

attributeMapping.setType(AttributeMapping.VARIABLE);
attributeMapping.setVariable("users.firstName");

To set an expression:

Expression expression = new Expression();
expression.setScript("users.firstName+\" \"+users.lastName");

attributeMapping.setType(AttributeMapping.EXPRESSION);
attributeMapping.setExpression(expression);

See also Expressions.

Then add the attribute to the entry:

entryMapping.addAttributeMapping(attributeMapping);

Partition

When all of the components are complete, you can add the entry to a partition:

partition.addEntryMapping(entryMapping);

Site running on a free Atlassian Confluence Open Source Project License granted to Safehaus. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.4 Build:#809 Jun 12, 2007) - Bug/feature request - Contact Administrators