[{TableOfContents}]

!!!Introduction

For [ages|https://bugzilla.mozilla.org/show_bug.cgi?id=86405], some people have desired an LDAP client sufficient to use as an address book. 

Such an LDAP client must have the following features:

*Create, update and delete LDAP entries
**Edit attributes which are part of the distinguished name (DN)
**Create update and delete attributes

Starting from:

* [IBM Jersey Contacts Example|http://www.ibm.com/developerworks/web/library/wa-aj-tomcat/]

Need to continue using the DN=uid=random,uid=realuser,ou=People... trick as not sure how to describe "uniqueness" in LDAP without unique DNs.

The URIs for the contacts will be http://server:port/addressbook/contact/uid


!!Exiting LDAP CLients

* [Apache Directory Studio|http://directory.apache.org/studio/]: awesome tool, but overkill for an address book
* [Evolution|http://projects.gnome.org/evolution/]: great but only for Linux users
* [Apple Address Book.app]: read only
* [Thunderbird|http://www.mozilla.org/en-US/thunderbird/]: read only

!!!ldapservice

The ldapservice project provides a Java EE web application with a REST API for interacting with an LDAP server.

*Public SVN repository: [http://spacepirates.com/ro/ldapservice/]
*Committers SVN repository: [http://spacepirates.com/rw/ldapservice/]

!!!ldapclient

The ldapclient project provides and HTML5 application which is a GUI interacting with the ldapservice.

!!Dealing with Updating DN

*Edit DN: clone, change DN, remove original, insert clone with new DN

!!!Tools

* [Tomcat 7]
* [Spring Framework]
* [Spring LDAP|http://static.springsource.org/spring-ldap/site/reference/html/configuration.html]
* [Spring Security]
* [JAX-RS (Jersey)]

!!!Hints
* [Use Spring @Autowired with Jersey|http://stackoverflow.com/questions/7638357/autowired-does-not-work-spring-3]
* [Jersey @Produces both XML and JSON|http://stackoverflow.com/questions/2744972/beyond-the-produces-annotation-how-does-jersey-jax-rs-know-to-treat-a-pojo-a]

!!!Learning
Netbeans 7 has some handy code generation tools (e.g. constructors, toString, hashCode, etc.).

Netbeans 7 automatically detects Jersey web services and shows the RESTful Web Service node in the project tree.

Netbeans 7 detects copy and pasted class references and generates the necessary import statements.

Netbeans 7 autodeploy on change to Tomcat is working nicely, even detects changes to Spring context.xml.
!!!Status
Code has been committed. Here's is an XML output from the "addressbook" service:

[addressbook-xml.png]

And here's the mocked contact output in JSON:
{{{
{"contact":[
{
  "displayName":"Joe Lion","faxNumber":"","firstName":"Joe",
  "homePhone":"510 222 5555","htmlEmail":"false","lastName":"Lion",
  "mobileNumber":"510 333 6666","nickname":"JoeL","pagerNumber":"",
  "primaryEmail":"joelion@jungle.com","secondaryEmail":"",
  "uid":"1","workPhone":""
},
{
  "displayName":"Sam Snake","faxNumber":"","firstName":"Sam",
  "homePhone":"510 444 5555","htmlEmail":"false","lastName":"Snake",
  "mobileNumber":"510 555 6666","nickname":"SamS","pagerNumber":"",
  "primaryEmail":"samsnake@jungle.com","secondaryEmail":"",
  "uid":"2","workPhone":""
}
]}
}}}