package mentata.ldaphttp.forum; // import necessary classes 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.GatewayTextAttribute; import mentata.gateway.GatewayDateAttribute; import mentata.gateway.GatewayDnAttribute; import mentata.gateway.GatewayReverseNestAttribute; /** * A directory entry that represents a comment. */ public class comment extends GatewayObject { // category for new entries private String buscat = "comment"; /** * Instantiates an empty template for a 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); setLabel("comment"); setSorting(new String[] {"dnqualifier"}, new boolean[] {false}); setStylesheet("/styles/mentata.css"); // make this an incremental object setIncremental("CMA", "c=CMAcounter, ou=Anonymous, ou=Comments, ou=Expressions, o=mentata.com", "description"); // add the attributes for this object class addAttribute( new GatewayStringAttribute(), "uid", "ID", REQUIRED, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "cn", "Title", REQUIRED, SINGLEVALUE); addAttribute( new GatewayStringAttribute(), "description", "Description", OPTIONAL, MULTIVALUE); addAttribute( new GatewayStringAttribute(), "businesscategory", "Type", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayTextAttribute(5), "content", "", REQUIRED, SINGLEVALUE); addAttribute( new GatewayDateAttribute(), "dnqualifier", "Submitted", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayURLAttribute(), "link", "See", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayDnAttribute(getContextName(), "person"), "owner", "By", OPTIONAL, MULTIVALUE); addAttribute( new GatewayDnAttribute(getContextName(), "comment"), "parent", "Response to", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayHRAttribute(), "commenthr", "Comments", OPTIONAL, SINGLEVALUE); addAttribute( new GatewayReverseNestAttribute(getContextName(), "comment", "parent", "child"), "child", "", OPTIONAL, MULTIVALUE); // 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[] {"description", "owner", "content", "link", "parent", "dnqualifier", "commenthr", "child"} ); addAttributeList("retrieve_ldif", new String[] {"uid", "cn", "businesscategory", "dnqualifier", "parent", "description", "link", "content"} ); // set attribute lists to support creatability addAttributeList("create_initialize", new String[] {"cn", "description", "businesscategory", "content", "dnqualifier", "link", "owner", "parent"} ); } /** * Infers and sets the attribute's identifier. */ public void preCreate() throws LDAPHttpException { if (getAttribute("cn").getValues() == null) resetAttribute("cn", new String[] {"untitled"}); if (getAttribute("dnqualifier").getValues() == null) resetAttribute("dnqualifier", new String[] { getTimestamp() }); if (getAttribute("businesscategory").getValues() == null) resetAttribute("businesscategory", new String[] { getCategory() }); } /** * Sets the business category for new entries. * * @param buscat the category name */ protected final void setCategory(String buscat) { this.buscat = buscat; setFilter("(businesscategory=" + buscat + ")"); } /** * Returns the business category for new entries. * * @return buscat the category name */ public final String getCategory() { return this.buscat; } }