> DNU home > online course > Portal Overview page 42
Novell Portal Services Overview and Gadget Development
April 2003
DeveloperNet University Course
Reader Rating    from ratings rate this article
View an eBook Version of this course - LARGE FILE! Send this page to a friend

Solution-LDAPBrowse.java

Solution - LDAPBrowse.java

The changes required are as follows:

  1. Code fill:

/* -------------------------------------------------------
TODO(1): provide some constants (static final) for:
* the LDAP browse tag
* the LDAP object tag
* the LDAP attrbiute tag
--------------------------------------------------------------- */

Solution:


private static final String LDAPBROWSE_TAG = "LDAPBROWSE";
private static final String LDAP_OBJECT_TAG = "LDAP_OBJECT";
private static final String LDAP_ATTRIBUTE_TAG = "LDAP_ATTRIBUTE";

  1. Code fill:

/* ---------------------------------------------------------
TODO(2): initialize the following to the empty string ("")
* base
* parentDN
* currentDN
* selectedCN
--------------------------------------------------------------- */

Solution:


base = "";
parentDN = "";
currentDN = "";
selectedCN = "";

  1. Code fill:

/* ----------------------------------------------------
TODO(3): set CURRENT_DN and PARENT_DN properties on ldapBrowseAttrbiutes.
Hint: try the setProperty() method!
------------------------------------------------------------ */

Solution:


ldapBrowseAttributes.setProperty("CURRENT_DN", currentDN);
ldapBrowseAttributes.setProperty("PARENT_DN", parentDN);

  1. Code fill:

/* ------------------------------------------------------
TODO(4): write out the start tag for <LDAPBROWSE someAttrbiutes> ensuring
you specify the attributes (ldaoBrowseAttribtues) you created
above.
Hint: try the XmlUtil.writeStartTag() method
------------------------------------------------------------ */

Solution:


XmlUtil.writeStartTag(LDAPBROWSE_TAG, ldapBrowseAttributes, out);

  1. Code fill:

/* -------------------------------------------------------
TODO(5): write out the full tag for <LDAPOBJECT > which will contain the
current object in the loop.
-------------------------------------------------------------- */

Solution:


XmlUtil.writeTag(LDAP_OBJECT_TAG, dn2Cn((String)ldapResults.elementAt(i)), out);

  1. Code fill:

/* ----------------------------------------------------
TODO(6): write out the end tag for </LDAPBROWSE>
---------------------------------------------------------- */

Solution:


XmlUtil.writeEndTag(LDAPBROWSE_TAG, out);

  1. Code fill:

/* ------------------------------------------------------
TODO(7): get the following from the HttpServletRequest
* CURRENT_DN
* SELECTED_CN
Hint: use the getParameter() method.
------------------------------------------------------------- */

Solution:


String currentDN = req.getParameter( "CURRENT_DN" );
String selectedCN = req.getParameter( "SELECTED_CN" );

  1. Code fill:

/* --------------------------------------------------------
TODO(8): set CURRENT_DN and PARENT_DN properties on ldapBrowseAttrbiutes.
Hint: try the setProperty() method!
-------------------------------------------------------------- */

Solution:


ldapBrowseAttributes.setProperty("CURRENT_DN", currentDN);
ldapBrowseAttributes.setProperty("PARENT_DN", parentDN);

  1. Code fill:

/* ---------------------------------------------------------
TODO(9): write out the start tag for <LDAPBROWSE someAttrbiutes> ensuring
you specify the attributes (ldaoBrowseAttribtues) you created
above.
--------------------------------------------------------------- */

Solution:


XmlUtil.writeStartTag(LDAPBROWSE_TAG, ldapBrowseAttributes, out);

  1. Code fill:

/* ----------------------------------------------------------
TODO(10): write out the end tag for </LDAPBROWSE>
--------------------------------------------------------------- */

Solution:


XmlUtil.writeEndTag(LDAPBROWSE_TAG, out);

Previous Contents
download sample file