package mentata.ldaphttp.gospel; import mentata.ldaphttp.LDAPHttpObject; import mentata.ldaphttp.LDAPHttpVirtualAttribute; import mentata.ldaphttp.LDAPHttpException; import mentata.gateway.GatewayObject; import mentata.gateway.GatewayHRAttribute; import mentata.gateway.GatewayStringAttribute; import mentata.gateway.GatewayURLAttribute; import mentata.gateway.GatewayDateAttribute; import mentata.gateway.GatewayDnAttribute; import mentata.gateway.GatewayReverseNestAttribute; /** * A directory entry that represents a Jesus weblog passage. */ public class comment extends GatewayObject { /** * Instantiates an empty template for a Jesus weblog passage or comment. */ public comment() throws LDAPHttpException { // add the object class unique to these objects addObjectclasses(new String[] {"notion", "expression"}); // set default values for this object useServlets( new String[] {"retrieve", "create"} ); useFormats( new String[] {"html", "ldif"} ); setDirectoryLocation("ou=Comments, ou=Expressions, o=mentata.com", SUBTREE); setFilter("(businesscategory=jesus)"); setLabel("Jesus Blog Comment"); setSorting(new String[] {"dnqualifier"}, new boolean[] {false}); setStylesheet("/styles/gospel.css"); setFooter("http://localhost/includes/gospel_footer.htm"); // make this an incremental object setIncremental("CJBA", "c=CJBAcounter, ou=Anonymous, ou=Comments, ou=Expressions, o=mentata.com", "description"); // add the attributes for this object class addAttribute( new GatewayStringAttribute(), "uid", "UID", REQUIRED, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "cn", "Title", REQUIRED, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "description", "Taken", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "businesscategory", "", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "content", "", REQUIRED, SINGLEVALUE); addAttribute( new GatewayDateAttribute(), "dnqualifier", "Added", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayURLAttribute(), "link", "See", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayDnAttribute(getContextName(), "person"), "owner", "By", OPTIONAL, MULTIVALUE); addAttribute( new GatewayDnAttribute(getContextName(), "comment"), "parent", "In response to", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayHRAttribute(), "commenthr", "Comments", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayReverseNestAttribute(getContextName(), "comment", "parent", "child"), "child", "", OPTIONAL, MULTIVALUE); addAttribute( new CommentFormAttribute(), "commentform", "", OPTIONAL, SINGLEVALUE); // set basic attribute lists for this object class addAttributeList("identify", new String[] {"uid", "cn"} ); addAttributeList("hyperlink", getAttributeList("identify") ); // set attribute lists to support retrievability addAttributeList("retrieve_list", new String[] {"dnqualifier"} ); addAttributeList("retrieve_html", new String[] {"dnqualifier", "owner", "description", "parent", "content", "link", "commenthr", "child", "commentform"} ); addAttributeList("retrieve_ldif", new String[] {"uid", "cn", "businesscategory", "dnqualifier", "parent", "description", "link", "content"} ); // set attribute lists to support creatability addAttributeList("create_initialize", new String[] {"description", "cn", "businesscategory", "content", "link", "parent"} ); } /** * Infers and sets the timestamp and/or title. */ public void preCreate() throws LDAPHttpException { resetAttribute("dnqualifier", new String[] { getTimestamp() }); if (getAttribute("cn").getValues() == null) resetAttribute("cn", new String[] {"untitled"}); } /** * An attribute for presenting a form for adding new comments. */ public class CommentFormAttribute extends LDAPHttpVirtualAttribute { /** * Generates an HTML form for adding new comments. */ public String[] getHTMLValues() throws LDAPHttpException { // build a create form StringBuffer results_buffer = new StringBuffer(); results_buffer.append("
"); // return the form as a single value return new String[] { results_buffer.toString() }; } } }