Development Guide

Configure your IDE

You can work on LinID with a simple text editor, but it is recommended to use a Java IDE, for example Eclipse. The goal is to have a working environment set-up with your IDE.

You can at least expect that, when you are done with this part, you will be able:
  • to compile source from the IDE
  • to launch a Web server from the IDE and test and debug code your code
  • to see the Tapestry 5 live reloading feature in action (change your java class, save, and the IDE automatically compile the class, and T5 automatically take into account the class update: press reload page on your browser, see the changes)

You will need a maven plugin, a jetty laucher plugin. If you want to commit back code into the SVN repository, you will need an SVN plugin too.

There is also a quite good LDAP editor plugins.

In all case, the configuration happens in "Help -> Software update..." eclipse menu.

Maven 2 plugin

This plugin will allows you to have to maven dependencies automatically resolved in your IDE if the project use Maven 2.

In the "Software Update#Available Software", click on "add site" and add in the location: http://m2eclipse.sonatype.org/sites/m2e

Validate and choose in the new "Maven integration for Eclipse Site" site at least "Maven Embedder" and "Maven Integration for Eclipse".

Click on install, accept dependencies, follow the steps.

Run Jetty Run

This plugin allows you to run a Jetty Application server from Eclipse, and so to debug you webapp as easily as it was a plain Java program (Debug launch command).

Go to "Software Update#Available Software", click on "add site" and add in the location: http://run-jetty-run.googlecode.com/svn/trunk/updatesite

Validate and choose in the new jetty related site the "Run Jetty Run" feature.

Click on install, accept dependencies, follow the steps.

Subversive for SVN

This plugin allows you to commit, update, manage svn repository, etc.

Go to "Software Update#Available Software", click on "add site" and add in the location: http://www.polarion.org/projects/subversive/download/eclipse/2.0/update-site/

Validate and choose in the new Subversive Connectors site at least "Subversive SVN Connectors" and "SVNKit 1.2.*".

Click on install, accept dependencies, follow the steps.

Apache DS studio

This plugin allows you to manage LDAP connection and LDAP content.

Go to "Software Update#Available Software", click on "add site" and add in the location: http://directory.apache.org/studio/update/1.x

Validate and choose in the apache DS studio entry the LDAP browser plugin.

Click on install, accept dependencies, follow the steps.

Other plugins

Eclipse is a kind of huge thing. You will need a lots of things to have it usable in some way for web dev (html and colloration, this kind of things).

You can also install those plugins:

Add LinID maven repository

To get LinID artifacts, these repositories should be enabled in pom.xml:

        <repository>
            <id>Linagora</id>
            <url>http://repo.linpki.org/nexus/content/repositories/public/</url>
        </repository>

        <repository>
            <id>Linagora-releases</id>
            <url>http://repo.linpki.org/nexus/content/repositories/releases</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>

        <repository>
            <id>Linagora-snapshot</id>
            <url>http://repo.linpki.org/nexus/content/repositories/snapshots</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>

Add LinID maven dependency

To use LinID components in your application, add this dependency in pom.xml:

    <!-- LinID -->
        <dependency>
            <groupId>org.linid.dm</groupId>
            <artifactId>wui</artifactId>
            <version>0.8</version>
            <type>jar</type>
            <optional>false</optional>
        </dependency>

Set the version to the last LinID stable version!

If you migrate from the old InterLDAP artefacts, follow the migration procedure.

Extended schema

Presentation

The extended schema is a collection of XML files that describe LDAP objects and override some of technical LDAP schema configuration. With this you can configure:
  • Labels and description
  • Mono or multivalued
  • Value choosen in a list
  • Default value at creation
  • Visibility in creation/display/modify screens
  • Mandatory

Extended schema generation

You can find a script in the LinID DM core script directory: https://redmine.linid.org/projects/directory-manager/repository/entry/core/trunk/scripts/eschemaGenerator.pl

You can use this script to grab the schema of your LDAP directory and generate all extended schema files:

./eschemaGenerator.pl -s ldap://localhost:3389

You need Perl, Perl-LDAP and XML::Simple to run this script.

Create your own display and edit blocks

You should create new blocks when you need to add specific viewers or editors for particular LDAP attributes.

  1. Create your new block with blocks/MyBlock.tml and blocks/MyBlock.java. See for example source:wui/trunk/src/main/java/org/linid/dm/wui/t5lib/pages/edit/DateEditBlock.java and source:wui/trunk/src/main/resources/org/linid/dm/wui/t5lib/pages/edit/DateEditBlock.tml Note that blocks are always considered as pages. Your block should contain a reference such as
    <t:block t:id="idBlock">...</t:block>
  2. Contribute your block. In your [App]Module.java, add the following line in contributeBeanBlockSource:
    configuration.add(new BeanBlockContribution("myblock", "blocks/MyBlock", "idBlock", b_editable));
    where b_editable is true for an edit block and false for a view only block. Since Tapestry 5.2 you must now use:
    configuration.add(new DisplayBlockContribution("myblock", "blocks/MyBlock", "idBlock"));
    or:
    configuration.add(new EditBlockContribution("myblock", "blocks/MyBlock", "idBlock"));
    instead.
  3. Add the type in contributeLdapTypeAnalyzer:
    configuration.add("myType",String.class);
  4. Link the type and the block in contributeLdapEditorAnalyzer or contributeLdapViewerAnalyzer:
    configuration.add("myType", "myblock");
  5. Finally use the new type in your extended schema:
    <attributeDefinitions><entry><attributedefinition><type>myType</type>...

Now when an entry will be retrieved with an attribute corresponding to this attribute definition, the viewer or the editor will automatically use your customized block to display/edit the value(s).

Access control - Ldap Query Language

WARNING : When you try to use a function which has to compare DNs or try to compare DNs, you have to be carefull that the String object comparison is case sensitive.

Functions

  • This function is a ldapsearch with a SUBTREE research scope, it means the request will search in all the tree and recursively in subtrees from the baseDN provided. And it will search for all entries that matched the ldapfilter specified. It will return the DNs list of entries found.
    dnList = ldap.search (baseDN, ldapFilter)
  • This function is similar to the previous one (ldap.search) but with an ONELEVEL research scope. It means that only the entries just above the baseDN provided will be processed. It will return the DNs list of entries found.
    dnList = ldap.list (baseDN, ldapFilter)
  • This function is similar to the previous one (ldap.search) but with an OBJECT research scope. It means that only the entry DN specified by the baseDN will be read to return the DN of the entry if it exists or an empty list if not.
    attributesList = ldap.read (baseDN, ldapFilter)
  • This function take two ListDN and return the union of the two lists.
    dnList = ldap.or (ListDN, ListDN)
  • This function take two ListDN and return the list of DNs which are present in the two lists provided
    dnList = ldap.and (ListDN, ListDN)
  • This function take an entry DN and an Attribute to read this one in the entry specified by the DN
    attributeValue = ldap.attribute (DN, Attribute)
  • This function substracts the ListDN2 from the ListDN1 and return the substract dnList result
    dnList = ldap.retain (ListDN1, ListDN2)
  • This function return the dnList of parents from (specified DN + intLevel) to the directory root.
    dnList = ldap.sup (DN, intLevel)

    Example:
    For an ldap directory as :
    dc=org
       dc=linagora
          dc=linshare
             cn=test
          dc=linsign
          dc=linid
    

    ldap.sup(“cn=test,dc=linshare,dc=linagora,dc=org”, “1”)

    Will return:
    dc=linshare,dc=linagora,dc=org
    dc=linsign,dc=linagora,dc=org
    dc=linid,dc=linagora,dc=org
    

    ldap.sup(“cn=test,dc=linshare,dc=linagora,dc=org”, “2”)

    Will return:
    dc=linagora,dc=org
    

    Warning : if intLevel equals 0, it will return ALL the parents DN, including the DN specified in parameters!
  • This function is an ldap.sup(DN, 0) (see above), but with an ldapFilter apply to return only parents which matched it.
     dnList = ldap.fsup (DN, ldapFilter)

Parameterized value

  • Principal DN and RDN:
    • principalDN : Is the DN of the author of the action
    • principalRDN : Is the RDN of the author of the action
  • Target DN and RDN:
    • targetDN : Is the DN of the entry targeted by the action
    • targetRDN : Is the RDN of the entry targeted by the action

Debugging

You can debug Javascript with good old println:

java.lang.System.out.println("Hello debuggers!");

Eclipse_logo.png (36.7 KB) Clément OUDOT, 26/04/2011 15:02

Also available in: HTML TXT