[jboss-svn-commits] JBL Code SVN: r25629 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main: web and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Mar 13 07:32:35 EDT 2009


Author: lkrzyzanek
Date: 2009-03-13 07:32:35 -0400 (Fri, 13 Mar 2009)
New Revision: 25629

Added:
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/DuplicateDocument.java
Modified:
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/NavigationAction.java
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/web/navigation.ftl
Log:
added communities hiearchy for document navigation

Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/DuplicateDocument.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/DuplicateDocument.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/DuplicateDocument.java	2009-03-13 11:32:35 UTC (rev 25629)
@@ -0,0 +1,99 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2009  Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.labs.clearspace.plugin.hfurl.struts;
+
+import java.util.List;
+
+import org.apache.commons.lang.builder.EqualsBuilder;
+import org.apache.commons.lang.builder.HashCodeBuilder;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import com.jivesoftware.community.Community;
+
+/**
+ * Value object of duplicate document
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class DuplicateDocument {
+
+  private String documentID;
+
+  private String subject;
+
+  private List<Community> communities;
+
+  /**
+   * Get Document ID
+   * 
+   * @return
+   * @see com.jivesoftware.community.Document#getDocumentID()
+   */
+  public String getDocumentID() {
+    return documentID;
+  }
+
+  public void setDocumentID(String documentID) {
+    this.documentID = documentID;
+  }
+
+  /**
+   * Get document subject
+   * 
+   * @return
+   */
+  public String getSubject() {
+    return subject;
+  }
+
+  public void setSubject(String subject) {
+    this.subject = subject;
+  }
+
+  public void setCommunities(List<Community> communities) {
+    this.communities = communities;
+  }
+
+  public List<Community> getCommunities() {
+    return communities;
+  }
+
+  public int hashCode() {
+    return new HashCodeBuilder(1618983549, -1070315631).append(this.documentID)
+        .toHashCode();
+  }
+
+  public boolean equals(Object object) {
+    if (!(object instanceof DuplicateDocument)) {
+      return false;
+    }
+    DuplicateDocument rhs = (DuplicateDocument) object;
+    return new EqualsBuilder().append(this.documentID, rhs.documentID)
+        .isEquals();
+  }
+
+  public String toString() {
+    return new ToStringBuilder(this).append("docId", this.documentID).append(
+        "subject", this.subject).toString();
+  }
+
+}


Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/DuplicateDocument.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/NavigationAction.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/NavigationAction.java	2009-03-13 10:28:13 UTC (rev 25628)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/NavigationAction.java	2009-03-13 11:32:35 UTC (rev 25629)
@@ -28,13 +28,14 @@
 import org.apache.log4j.Logger;
 import org.jboss.labs.clearspace.plugin.hfurl.struts.mapping.HFURLMapping;
 
+import com.jivesoftware.base.UnauthorizedException;
 import com.jivesoftware.community.Community;
 import com.jivesoftware.community.CommunityManager;
 import com.jivesoftware.community.CommunityNotFoundException;
 import com.jivesoftware.community.Document;
-import com.jivesoftware.community.DocumentAlreadyExistsException;
 import com.jivesoftware.community.DocumentManager;
 import com.jivesoftware.community.DocumentObjectNotFoundException;
+import com.jivesoftware.community.JiveIterator;
 import com.jivesoftware.community.action.JiveActionSupport;
 
 /**
@@ -47,7 +48,7 @@
 
   List<String> docIds;
 
-  List<Document> documents = new ArrayList<Document>();
+  List<DuplicateDocument> documents = new ArrayList<DuplicateDocument>();
 
   protected DocumentManager documentManager;
 
@@ -61,14 +62,13 @@
       try {
         Document doc = documentManager.getDocument(docId);
 
-        String wholeTitle = doc.getSubject();
+        DuplicateDocument dupDoc = new DuplicateDocument();
+        dupDoc.setDocumentID(doc.getDocumentID());
+        dupDoc.setSubject(doc.getSubject());
 
-        Community currentCommunity = communityManager.getCommunity(doc
-            .getContainerID());
+        dupDoc.setCommunities(getCommunities(doc));
 
-        wholeTitle = currentCommunity.getDisplayName() + ">" + wholeTitle;
-
-        documents.add(doc);
+        documents.add(dupDoc);
       } catch (DocumentObjectNotFoundException e) {
         log.error("Document not found for HF URL", e);
         // TODO Probably we can remove record from HF URL Map
@@ -76,13 +76,30 @@
 
       }
       // TODO Catch and handle UnauthorizedException
-
     }
     log.debug(documents);
 
     return SUCCESS;
   }
 
+  protected List<Community> getCommunities(Document doc)
+      throws CommunityNotFoundException, UnauthorizedException {
+    Community community = communityManager.getCommunity(doc.getContainerID());
+
+    List<Community> communities = new ArrayList<Community>();
+
+    if (community != null
+        && community.getID() != communityManager.getRootCommunity().getID()) {
+      Community currentCommunity = community;
+      communities.add(0, currentCommunity);
+      for (int i = communityManager.getCommunityDepth(community); i > 0; i--) {
+        currentCommunity = currentCommunity.getParentContainer();
+        communities.add(0, currentCommunity);
+      }
+    }
+    return communities;
+  }
+
   public List<String> getDocIds() {
     return docIds;
   }
@@ -91,11 +108,11 @@
     this.docIds = docIds;
   }
 
-  public List<Document> getDocuments() {
+  public List<DuplicateDocument> getDocuments() {
     return documents;
   }
 
-  public void setDocuments(List<Document> documents) {
+  public void setDocuments(List<DuplicateDocument> documents) {
     this.documents = documents;
   }
 

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/web/navigation.ftl
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/web/navigation.ftl	2009-03-13 10:28:13 UTC (rev 25628)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/web/navigation.ftl	2009-03-13 11:32:35 UTC (rev 25629)
@@ -11,9 +11,14 @@
     <ul>
     <#list documents as doc>
       <li>
-        <a href="<@s.url value='/docs/${doc.documentID}' includeParams='none'/>">${doc.jiveContainer.name} - ${doc.subject}</a>
+        <a href="<@s.url value='/docs/${doc.documentID}' includeParams='none' />">
+        <#list doc.communities as comm>
+          ${comm.name} &gt;
+        </#list>
+        ${doc.subject}
+        </a>
       </li>
     </#list>
     </ul>
 </body>
-</html>
\ No newline at end of file
+</html>




More information about the jboss-svn-commits mailing list