[jboss-svn-commits] JBL Code SVN: r25577 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main: java/org/jboss/labs/clearspace/plugin/hfurl/dao and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Mar 10 12:06:07 EDT 2009


Author: lkrzyzanek
Date: 2009-03-10 12:06:06 -0400 (Tue, 10 Mar 2009)
New Revision: 25577

Added:
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/DbHFURLDAOImpl.java
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLDAO.java
Modified:
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLPlugin.java
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/plugin.xml
   labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/spring.xml
Log:
added DAO and changed URL prefix to /document

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java	2009-03-10 16:05:25 UTC (rev 25576)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java	2009-03-10 16:06:06 UTC (rev 25577)
@@ -21,17 +21,13 @@
  */
 package org.jboss.labs.clearspace.plugin.hfurl;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLEncoder;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 
 import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
+import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLDAO;
 
-import com.jivesoftware.base.database.dao.DAOException;
-import com.jivesoftware.community.cache.Cache;
 import com.jivesoftware.community.event.DocumentEvent;
 import com.jivesoftware.community.event.DocumentListener;
 
@@ -49,6 +45,8 @@
    */
   private Map<String, String> hfURLCache;
 
+  private HFURLDAO hfURLDAO;
+
   public String createHFURLTitle(String documentTitle) {
     // remove white spaces
     String hfURLTitle = documentTitle.replaceAll("[\\s]+", "-");
@@ -89,18 +87,11 @@
         }
       }
     } else {
-      // try {
-      // bean = documentDAO.getByID(documentID);
-      // if (bean == null) {
-      // throw new DocumentObjectNotFoundException(JiveConstants.DOCUMENT, -1,
-      // "Document " + docID + " could not be loaded from the database.");
-      // }
-      // } catch (DAOException e) {
-      // throw new DocumentObjectNotFoundException(JiveConstants.DOCUMENT, -1,
-      // "", e);
-      // }
-
-      hfURLCache.put(documentID, hfURLTitle);
+      HFURLBean bean = hfURLDAO.getByHfURLTitle(hfURLTitle);
+      if (bean != null) {
+        documentID = bean.getDocumentID();
+        hfURLCache.put(documentID, hfURLTitle);
+      }
     }
 
     return documentID;
@@ -187,4 +178,8 @@
 
   }
 
+  public void setHfURLDAO(HFURLDAO hfURLDAO) {
+    this.hfURLDAO = hfURLDAO;
+  }
+
 }

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLPlugin.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLPlugin.java	2009-03-10 16:05:25 UTC (rev 25576)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLPlugin.java	2009-03-10 16:06:06 UTC (rev 25577)
@@ -54,7 +54,7 @@
   /**
    * HF URL Mapping prefix
    */
-  private final String URL_MAPPING_PREFIX = "/doc";
+  private final String URL_MAPPING_PREFIX = "/document";
 
   public void init() {
     log.debug("Init " + PLUGIN_NAME);

Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/DbHFURLDAOImpl.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/DbHFURLDAOImpl.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/DbHFURLDAOImpl.java	2009-03-10 16:06:06 UTC (rev 25577)
@@ -0,0 +1,62 @@
+/*
+ * 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.dao;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import org.springframework.jdbc.core.simple.ParameterizedRowMapper;
+
+import com.jivesoftware.base.database.dao.DAOException;
+import com.jivesoftware.base.database.dao.JiveJdbcDaoSupport;
+
+/**
+ * DB Implementation of HF URL DAO
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ * 
+ */
+public class DbHFURLDAOImpl extends JiveJdbcDaoSupport implements HFURLDAO {
+
+  private static final String SELECT_FIELDS = "SELECT id, hfTitle, documentID ";
+
+  private static final String LOAD_HFURL_BY_DOCUMENT_ID = SELECT_FIELDS
+      + " FROM humanFriendlyURLMap WHERE hfTitle=?";
+
+  private static final HfURLMapMapper mapper = new HfURLMapMapper();
+
+  public HFURLBean getByHfURLTitle(String hfURLTitle) throws DAOException {
+    return this.getSimpleJdbcTemplate().queryForObject(
+        LOAD_HFURL_BY_DOCUMENT_ID, mapper, hfURLTitle);
+  }
+
+  static final class HfURLMapMapper implements
+      ParameterizedRowMapper<HFURLBean> {
+    public HFURLBean mapRow(ResultSet rs, int rowNum) throws SQLException {
+      HFURLBean uct = new HFURLBean();
+      uct.setId(rs.getLong("id"));
+      uct.setHfTitle(rs.getString("hfTitle"));
+      uct.setDocumentID(rs.getString("documentID"));
+      return uct;
+    }
+  }
+}


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

Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLDAO.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLDAO.java	                        (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLDAO.java	2009-03-10 16:06:06 UTC (rev 25577)
@@ -0,0 +1,43 @@
+/*
+ * 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.dao;
+
+import com.jivesoftware.base.database.dao.DAOException;
+
+/**
+ * Human friendly DAO interface
+ * 
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ * 
+ */
+public interface HFURLDAO {
+
+  /**
+   * Get by HF URL Title
+   * 
+   * @param hfURLTitle
+   * @return HF URL Bean
+   * @throws DAOException
+   */
+  public HFURLBean getByHfURLTitle(String hfURLTitle) throws DAOException;
+
+}


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

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/plugin.xml	2009-03-10 16:05:25 UTC (rev 25576)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/plugin.xml	2009-03-10 16:06:06 UTC (rev 25577)
@@ -18,7 +18,7 @@
 
   <sitemesh>
     <decorator name="doc-default" page="/template/decorator/default/template.ftl">
-      <pattern>/doc*</pattern>
+      <pattern>/document*</pattern>
     </decorator>
   </sitemesh>
 

Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/spring.xml	2009-03-10 16:05:25 UTC (rev 25576)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/resources/spring.xml	2009-03-10 16:06:06 UTC (rev 25577)
@@ -24,9 +24,16 @@
   <bean id="hfURLManager" class="org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager">
     <property name="hfURLCache">
       <map>
-        <entry key="DOC-1000" value="hf-url-page" />
       </map>
     </property>
+    <property name="hfURLDAO" ref="hfURLDAO" />
   </bean>
 
+    <bean id="hfURLDAO" 
+        class="org.jboss.labs.clearspace.plugin.hfurl.dao.DbHFURLDAOImpl">
+        <property name="dataSource">
+            <util:property-path path="dataSourceFactory.dataSource" />
+        </property>
+    </bean>
+
 </beans>




More information about the jboss-svn-commits mailing list