[jboss-svn-commits] JBL Code SVN: r30073 - in labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src: main/resources and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Nov 9 10:38:57 EST 2009


Author: lkrzyzanek
Date: 2009-11-09 10:38:57 -0500 (Mon, 09 Nov 2009)
New Revision: 30073

Modified:
   labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
   labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
   labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java
Log:
Added splitting out suffix from community names.

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java	2009-11-09 14:37:35 UTC (rev 30072)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManager.java	2009-11-09 15:38:57 UTC (rev 30073)
@@ -161,6 +161,12 @@
 
   private List<TextConverter> converters;
 
+  /**
+   * Suffix which should be stripped out from Community name<br>
+   * If null then nothing is strepped out.
+   */
+  private String stripOutSuffix = null;
+
   public int createForumMappingFromCategories() {
     Set<Map.Entry<Long, Long>> entries = getCategoryMappings().entrySet();
     int count = 0;
@@ -762,25 +768,25 @@
       elementList.addAll(JAXPUtils.selectAllNodes(document, "a"));
       elementList.addAll(JAXPUtils.selectAllNodes(document, "body"));
       // Following lines are commented because messages are not Wiki articles.
-//      for (org.w3c.dom.Element element : elementList) {
-//        NodeList childNodes = element.getChildNodes();
-//        for (int i = 0; i < childNodes.getLength(); i++) {
-//          Node node = childNodes.item(i);
-//          if (node.getNodeType() == Node.TEXT_NODE) {
-//            String content = node.getTextContent();
-//            if (content != null) {
-//              if (StringUtils.containsAnyOf(content, "!", "[", "*", "~", "+")) {
-//                WikiLexer lexer = new WikiLexer(content);
-//                Element body = lexer.parse();
-//                String bodyText = HtmlRenderUtils.toString(body);
-//                Document bodyDoc = JAXPUtils.toXmlDocument(bodyText);
-//                JAXPUtils.replace(node, bodyDoc.getDocumentElement()
-//                    .getChildNodes());
-//              }
-//            }
-//          }
-//        }
-//      }
+      // for (org.w3c.dom.Element element : elementList) {
+      // NodeList childNodes = element.getChildNodes();
+      // for (int i = 0; i < childNodes.getLength(); i++) {
+      // Node node = childNodes.item(i);
+      // if (node.getNodeType() == Node.TEXT_NODE) {
+      // String content = node.getTextContent();
+      // if (content != null) {
+      // if (StringUtils.containsAnyOf(content, "!", "[", "*", "~", "+")) {
+      // WikiLexer lexer = new WikiLexer(content);
+      // Element body = lexer.parse();
+      // String bodyText = HtmlRenderUtils.toString(body);
+      // Document bodyDoc = JAXPUtils.toXmlDocument(bodyText);
+      // JAXPUtils.replace(node, bodyDoc.getDocumentElement()
+      // .getChildNodes());
+      // }
+      // }
+      // }
+      // }
+      // }
       return document;
     } catch (Exception e) {
       log.error("Cannot parse text body. "
@@ -981,15 +987,16 @@
    */
   private Community createCommunity(Community parentCommunity,
       CommunityDefBean communityDef) {
-    log.info("Create community: " + communityDef.getName());
+    String communityName = stripOutSuffix(communityDef.getName());
+    log.info("Create community: " + communityName);
 
     Community community;
     if (parentCommunity == null) {
-      community = communityManager.createCommunity(communityDef.getName(),
-          communityDef.getDisplayName(), communityDef.getDescription());
+      community = communityManager.createCommunity(communityName, communityDef
+          .getDisplayName(), communityDef.getDescription());
     } else {
       community = communityManager.createCommunity(parentCommunity,
-          communityDef.getName(), communityDef.getDisplayName(), communityDef
+          communityName, communityDef.getDisplayName(), communityDef
               .getDescription());
     }
 
@@ -1000,6 +1007,13 @@
     return community;
   }
 
+  protected String stripOutSuffix(String name) {
+    if (stripOutSuffix != null && name.endsWith(stripOutSuffix)) {
+      name = name.substring(0, name.length() - stripOutSuffix.length());
+    }
+    return name;
+  }
+
   protected Set<CommunityDefBean> loadCommunityLayout(Properties layoutDef) {
     Set<CommunityDefBean> communities = new LinkedHashSet<CommunityDefBean>();
     final String rootPrefix = "community.";
@@ -1204,4 +1218,12 @@
     this.pollManager = pollManager;
   }
 
+  public void setStripOutSuffix(String stripOutSuffix) {
+    this.stripOutSuffix = stripOutSuffix;
+  }
+
+  public String getStripOutSuffix() {
+    return stripOutSuffix;
+  }
+
 }

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml	2009-11-09 14:37:35 UTC (rev 30072)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/main/resources/spring.xml	2009-11-09 15:38:57 UTC (rev 30073)
@@ -32,6 +32,7 @@
     <!-- JBoss.org Clearspace lives as root application in community.jboss.org -->
     <property name="appContext" value="" />    
     <property name="defaultTopicTimeStr" value="2002-01-01" />
+    <property name="stripOutSuffix" value=" Users" />
 
     <property name="topicMappings" ref="topicMappings" />
     <property name="postMappings" ref="postMappings" />

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java	2009-11-09 14:37:35 UTC (rev 30072)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-nfm/trunk/src/test/java/org/jboss/labs/clearspace/plugin/nfm/DbNukesForumsManagerTest.java	2009-11-09 15:38:57 UTC (rev 30073)
@@ -69,6 +69,16 @@
     dbNukesForumsManager.setNukesForumsDAO(new DummyNukesForumsDAO());
   }
 
+  @Test
+  public void testStripOutSuffix() {
+    DbNukesForumsManager nukesForumsManager = new DbNukesForumsManager();
+    nukesForumsManager.setStripOutSuffix(" Users");
+    
+    assertEquals("JBoss Portal", nukesForumsManager.stripOutSuffix("JBoss Portal Users"));
+    assertEquals("JBoss Portal", nukesForumsManager.stripOutSuffix("JBoss Portal"));
+    assertEquals("JBoss Users forum", nukesForumsManager.stripOutSuffix("JBoss Users forum"));
+  }
+  
   /**
    * Test method for
    * {@link org.jboss.labs.clearspace.plugin.nfm.DbNukesForumsManager#getCSForumsURL(java.lang.String, java.lang.String, java.lang.Long, java.lang.Long, java.lang.Long, java.lang.Long)}



More information about the jboss-svn-commits mailing list