
Java Build Instructions:

1) Update the build.properties file to reference the correct BEA Home for ALDSP 3.2 (defaults to C:\bea)
2) setup Ant environment - call <WEBLOGIC_HOME>/server/bin/setWLSEnv
3) execute 'ant dist' to build the Java Spring LDAP classes
4) Test by executing 'ant test-app' - The environment is setup for use with the Apache Directory Server 1.5.1 (http://directory.apache.org).

The sample code will work with any LDAP server that has a DN with a list of inetOrgPerson instances. You can update the LDAP connection information in the src/com/example/ldap/springldap.xml file.

ALDSP instructions:

To create a Java Physical Data Service, follow these steps from a Dataspace Project within the ALDSP Studio:

1) Import the following jars into the DSP-INF/lib directory of the Dataspace Project
   a) all jars in the lib directory of the Java project (these are the Spring LDAP 1.2.1 and its dependencies)
   b) the ldap_java.jar file from the dist directory created as part of the ant dist step above
2) Right click on the folder you want to create the Java Physical Data Service in and select 'New | Physical Data Service'
3) In the 'Create Physical Data Service' wizard:
   a) set the 'Data source type:' to 'Java Function'
   b) set the 'Class name:' to 'com.example.ldap.DspLdapWrapper' - when you select Browse..., expand the ldap_java folder (the folder names map to the JAR file names) and navigate to ldap_java/com/example/ldap/DspLdapWrapper
   c) Next
   d) In the 'Select Java Function' step, select all of the functions except 'main(Ljava.lang.String)'
   e) highlight 'updatePerson(...)' on the list list, and then select the Check Box under 'With Change Summary' (scroll to the far right in the 'Properties for updatePerson' grid
   f) Next
   g) In the 'Review New/Updated Data Service Operation(s)' step, update the setting to match the following:

   Operation       |   Kind   |   Primary

   updatePerson       Update       Unchecked
   deletePerson       Delete       Checked
   createPerson       Create       Checked
   getPersonByUserId  Read         (Grayed out)
   getAllPersons      Read         (Grayed out)

   h) Next
   i) Enter a 'Data service name:' (e.g. 'LdapDsp')
   j) Finish

Now we need to update the source of the generated Data Service to correct a bug in ALDSP 3.2 New Physical Data Service Wizard

1) Open the newly created Java Data Service
2) Select the Source tab
3) Update the declaration for the updatePerson to match the following (make sure the namespace prefixes match your source)

  declare procedure f1:updatePerson($x1 as changed-element(t1:inetOrgPerson)*) as empty() external;

In my case the wizard has the wrong updatePerson parameter of type - t1:ldapKey.

Note: If you did not select the 'With Change Summary' field as part of the 'Create Physical Data Service' wizard, you'd see the parameter of type element(...)*. It needs to be of type changed-element(...)* to work correctly as update methods take the new (as of ALDSP 3.0) changed-element type that provides access to old and new values. 

4) You can update the updatePerson to be the Primary method which means that Logical Data Services that depend on it will automatically pick up this method for Update Maps. To change either select updatePerson in the Overview tab and change the Primary property to true OR update the updatePerson method pragma to isPrimary="true"

You can now perform full CRUD (Create, Read, Update and Delete) operations against an LDAP server. You can also create new Logical Data Services that can combine this LDSP Physical Data Service with any other Data Service (RDBMS, Web Service, etc.)
