[jboss-svn-commits] JBL Code SVN: r34776 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk: src/changes and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Aug 18 10:22:17 EDT 2010
Author: lkrzyzanek
Date: 2010-08-18 10:22:16 -0400 (Wed, 18 Aug 2010)
New Revision: 34776
Removed:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/cache-config.xml
Modified:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/plugin.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/spring.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
Log:
Upgraded to work with SBS 4.5.x
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml 2010-08-18 14:22:16 UTC (rev 34776)
@@ -7,7 +7,7 @@
<artifactId>human-friendly-urls</artifactId>
<name>SBS plugin: Human friendly URLs</name>
<description>Plugin offers human friendly URLs in SBS</description>
- <version>2.0.1-SNAPSHOT</version>
+ <version>2.1.0</version>
<parent>
<groupId>org.jboss.labs</groupId>
@@ -170,13 +170,5 @@
<scope>test</scope>
</dependency>
</dependencies>
- <!--
- This is where you set the Jive SBS version your plugin is compiled
- against.
- -->
- <properties>
- <sbs.version>4.0.3</sbs.version>
- </properties>
-
</project>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml 2010-08-18 14:22:16 UTC (rev 34776)
@@ -9,6 +9,9 @@
</properties>
<body>
+ <release version="2.1.0" date="2010-08-18" description="Upgrade to work with SBS 4.5.x">
+ </release>
+
<release version="2.0.0" date="2010-02-23" description="Upgrade to work with SBS 4.x">
</release>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2010-08-18 14:22:16 UTC (rev 34776)
@@ -22,10 +22,8 @@
package org.jboss.labs.clearspace.plugin.hfurl;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Map.Entry;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
@@ -34,9 +32,9 @@
import org.springframework.dao.EmptyResultDataAccessException;
import com.jivesoftware.base.event.v2.EventListener;
+import com.jivesoftware.cache.Cache;
import com.jivesoftware.community.Document;
import com.jivesoftware.community.JiveGlobals;
-import com.jivesoftware.community.cache.Cache;
import com.jivesoftware.community.event.DocumentEvent;
import com.jivesoftware.community.event.listener.BaseDocumentEventListener;
@@ -46,18 +44,24 @@
* @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
*
*/
-public class DbHFURLManager extends BaseDocumentEventListener implements
- HFURLManager, EventListener<DocumentEvent> {
+public class DbHFURLManager extends BaseDocumentEventListener implements HFURLManager, EventListener<DocumentEvent> {
private static final Logger log = LogManager.getLogger(DbHFURLManager.class);
/**
* A cache for HF URL titles.<br>
* Key is DocumentID<br>
- * Value is HF URL Title
+ * Value is HF Title
*/
- private Cache<String, String> hfURLCache;
+ private Cache<String, String> hfURLIDsCache;
+ /**
+ * A cache for HF URL titles.<br>
+ * Key is HF Title<br>
+ * Value is list of Document ids separated by comma.
+ */
+ private Cache<String, ArrayList<String>> hfURLTitlesCache;
+
private HFURLDAO hfURLDAO;
private String hfULRPrefix;
@@ -73,8 +77,7 @@
}
public void setHFLinksEnabled(boolean enabled) {
- JiveGlobals.setJiveProperty(HFURLPlugin.HFURL_ENABLED_KEY, Boolean
- .toString(enabled));
+ JiveGlobals.setJiveProperty(HFURLPlugin.HFURL_ENABLED_KEY, Boolean.toString(enabled));
}
@@ -87,8 +90,7 @@
// Remove accents
// Java 6
- hfURLTitle = java.text.Normalizer.normalize(hfURLTitle,
- java.text.Normalizer.Form.NFD);
+ hfURLTitle = java.text.Normalizer.normalize(hfURLTitle, java.text.Normalizer.Form.NFD);
// Java 5
// hfURLTitle = sun.text.Normalizer.normalize(hfURLTitle,
@@ -109,27 +111,23 @@
public void updateIndex() {
hfURLDAO.updateIndex();
- hfURLCache.clear();
+ hfURLIDsCache.clear();
+ hfURLTitlesCache.clear();
}
- public String getHfURLTitle(String documentID)
- throws EmptyResultDataAccessException {
- String hfURLTitle = hfURLCache.get(documentID);
+ public String getHfURLTitle(String documentID) {
+ String hfURLTitle = hfURLIDsCache.get(documentID);
if (hfURLTitle == null) {
- HFURLBean bean = hfURLDAO.getByDocumentId(documentID);
- hfURLTitle = bean.getHfTitle();
-
- // Don't put this object to cache by simple cache.put ... because it's not
- // sure if there are some other objects with same hf title in DB.
- // We must ensure that in cache will be always all records of duplicate HF
- // URL docs, then mapping from HF URL to ID from cache will be consistent.
-
try {
- List<HFURLBean> beans = hfURLDAO.getByHfURLTitle(hfURLTitle);
- for (HFURLBean dbbean : beans) {
- hfURLCache.put(dbbean.getDocumentID(), hfURLTitle);
- }
+ HFURLBean hfURLBean = hfURLDAO.getByDocumentId(documentID);
+
+ hfURLTitle = hfURLBean.getHfTitle();
+ hfURLIDsCache.put(hfURLBean.getDocumentID(), hfURLTitle);
+
+ // refresh item in Titles' cache.
+ hfURLTitlesCache.remove(hfURLTitle);
+ getDocumentID(hfURLTitle);
} catch (EmptyResultDataAccessException e) {
// nothing founded - should not occur
}
@@ -150,39 +148,30 @@
try {
// fixed bug ORG-174 and ORG-175 for deleting and restoring the article -
// for these actions are standard URL returned.
- if (standardURL != null && standardURL.contains(docIdURLPrefix + "/")
- && !standardURL.contains("/delete")
+ if (standardURL != null && standardURL.contains(docIdURLPrefix + "/") && !standardURL.contains("/delete")
&& !standardURL.contains("/restore")) {
final String documentId = getDocumentId(standardURL);
final String hfTitle = getHfURLTitle(documentId);
+ if (hfTitle == null) {
+ return standardURL;
+ }
if (onlyUniqueHFURL) {
- Iterator<String> hfUrls = hfURLCache.values().iterator();
- int occurances = 0;
- while (hfUrls.hasNext()) {
- if (hfUrls.next().equals(hfTitle)) {
- occurances++;
- if (occurances >= 2) {
- return standardURL;
- }
- }
+ List<String> docIds = getDocumentID(hfTitle);
+ if (docIds.size() > 1) {
+ return standardURL;
}
}
- hfURL = standardURL.replaceFirst(docIdURLPrefix + "/" + documentId,
- getHfULRPrefix() + "/" + hfTitle);
+ hfURL = standardURL.replaceFirst(docIdURLPrefix + "/" + documentId, getHfULRPrefix() + "/" + hfTitle);
if (log.isDebugEnabled()) {
- log.debug("Founded title: " + hfTitle + ", for documentID: "
- + documentId);
+ log.debug("Founded title: " + hfTitle + ", for documentID: " + documentId);
log.debug("Transformed URL: " + hfURL);
}
}
- } catch (EmptyResultDataAccessException e) {
- log.debug("HF URL not defined. Returning original URL");
} catch (Exception e) {
- log.error("Error occur while changing URL to Human friendly URL."
- + " Returning original URL", e);
+ log.error("Error occur while changing URL to Human friendly URL." + " Returning original URL", e);
// something wrong - catch it and use original URL
}
return hfURL;
@@ -191,8 +180,7 @@
/**
* Get Document ID from URL
*
- * @param url
- * URL in standard CS format i.e. /docs/DOC-1234
+ * @param url URL in standard CS format i.e. /docs/DOC-1234
* @return document ID i.e. DOC-1234
*/
protected String getDocumentId(String url) {
@@ -211,8 +199,7 @@
url = url.replace(".pdf", "");
}
- final int docIDStart = url.indexOf(docIdURLPrefix + "/")
- + docIdURLPrefix.length() + 1;
+ final int docIDStart = url.indexOf(docIdURLPrefix + "/") + docIdURLPrefix.length() + 1;
int docIDEnd = url.indexOf("/", docIDStart);
if (docIDEnd == -1) {
docIDEnd = url.length();
@@ -222,28 +209,21 @@
}
public List<String> getDocumentID(String hfURLTitle) {
- List<String> docIds = new ArrayList<String>();
- if (hfURLCache.containsValue(hfURLTitle)) {
- Iterator<Entry<String, String>> it = hfURLCache.entrySet().iterator();
- while (it.hasNext()) {
- Entry<String, String> pairs = it.next();
+ ArrayList<String> docIds = hfURLTitlesCache.get(hfURLTitle);
- if (hfURLTitle.equals(pairs.getValue())) {
- docIds.add(pairs.getKey());
- }
- }
- } else {
+ if (docIds == null) {
+ docIds = new ArrayList<String>();
try {
List<HFURLBean> beans = hfURLDAO.getByHfURLTitle(hfURLTitle);
for (HFURLBean dbbean : beans) {
docIds.add(dbbean.getDocumentID());
- hfURLCache.put(dbbean.getDocumentID(), hfURLTitle);
}
+ hfURLTitlesCache.put(hfURLTitle, docIds);
+
} catch (EmptyResultDataAccessException e) {
- // nothing founded
+ // nothing founded - should not occur
}
}
-
return docIds;
}
@@ -281,11 +261,17 @@
}
public void documentDeleted(DocumentEvent event) {
+ String documentID = getDocumentID(event);
if (log.isDebugEnabled()) {
- log.debug("documentDeleted: " + getDocumentID(event));
+ log.debug("documentDeleted: " + documentID);
}
- hfURLDAO.deleteHFURL(getDocumentID(event));
- hfURLCache.remove(getDocumentID(event));
+ String title = getHfURLTitle(documentID);
+ if (title != null) {
+ hfURLTitlesCache.remove(title);
+ }
+ hfURLIDsCache.remove(documentID);
+
+ hfURLDAO.deleteHFURL(documentID);
}
public void documentModified(DocumentEvent event) {
@@ -307,15 +293,17 @@
try {
bean = hfURLDAO.getByDocumentId(doc.getDocumentID());
} catch (EmptyResultDataAccessException e) {
- log.warn("HFURL: "
- + "Document's title changed but title is not in HF URL index. "
+ log.warn("HFURL: " + "Document's title changed but title is not in HF URL index. "
+ "Going to create new entry.");
bean = new HFURLBean(doc.getDocumentID(), hfURLTitle);
}
bean.setHfTitle(hfURLTitle);
hfURLDAO.updateHFURL(bean);
- hfURLCache.put(doc.getDocumentID(), hfURLTitle);
+ hfURLIDsCache.put(doc.getDocumentID(), hfURLTitle);
+ // title is changed and we dont' know the
+ // previous one. Let's update title's cache.
+ hfURLTitlesCache.clear();
}
// Here is one special case of changing title - when user restore version
@@ -346,10 +334,6 @@
this.hfURLDAO = hfURLDAO;
}
- public void setHfURLCache(Cache<String, String> hfURLCache) {
- this.hfURLCache = hfURLCache;
- }
-
public void setHfULRPrefix(String hfULRPrefix) {
this.hfULRPrefix = hfULRPrefix;
}
@@ -362,4 +346,12 @@
this.docIdURLPrefix = docIdURLPrefix;
}
+ public void setHfURLIDsCache(Cache<String, String> hfURLIDsCache) {
+ this.hfURLIDsCache = hfURLIDsCache;
+ }
+
+ public void setHfURLTitlesCache(Cache<String, ArrayList<String>> hfURLTitlesCache) {
+ this.hfURLTitlesCache = hfURLTitlesCache;
+ }
+
}
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java 2010-08-18 14:22:16 UTC (rev 34776)
@@ -23,8 +23,6 @@
import java.util.List;
-import org.springframework.dao.EmptyResultDataAccessException;
-
/**
* Manager for handling with Human friendly URLs.
*
@@ -42,8 +40,7 @@
/**
* Set if HF links are enabled or disabled
*
- * @param enabled
- * true if HF links are enabled, false if disabled
+ * @param enabled true if HF links are enabled, false if disabled
*/
public void setHFLinksEnabled(boolean enabled);
@@ -62,8 +59,7 @@
/**
* Get document ID.
*
- * @param hfURLTitle
- * HF URL title.
+ * @param hfURLTitle HF URL title.
* @return set of ID of document i.e. DOC-1234 or empty set if no document is
* founded
* @see #createHFURLTitle(String)
@@ -85,11 +81,9 @@
* For urls that contain "/delete" or "/restore" then standard URL is
* returned.
*
- * @param standardURL
- * i.e. /docs/DOC-1234
- * @param onlyUniqueHFURL
- * if true then HF URL is returned only when there is no duplicate HF
- * URLs
+ * @param standardURL i.e. /docs/DOC-1234
+ * @param onlyUniqueHFURL if true then HF URL is returned only when there is
+ * no duplicate HF URLs
* @return i.e. /wiki/humanFriendlyURL
*/
public String getHFURLUnique(String standardURL, boolean onlyUniqueHFURL);
@@ -97,14 +91,10 @@
/**
* Get HF URL Title for document ID
*
- * @param documentID
- * i.e. DOC-1234
- * @return
- * @throws EmptyResultDataAccessException
- * if hf url title not found for given documentID
+ * @param documentID i.e. DOC-1234
+ * @return HF URL Title or null.
*/
- public String getHfURLTitle(String documentID)
- throws EmptyResultDataAccessException;
+ public String getHfURLTitle(String documentID);
/**
* Prefix for HF URLs
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/cache-config.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/cache-config.xml 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/cache-config.xml 2010-08-18 14:22:16 UTC (rev 34776)
@@ -1,20 +0,0 @@
-<cache-config>
- <cache-mapping>
- <cache-name>Human friendly URLs index</cache-name>
- <scheme-name>default-near</scheme-name>
- <init-params>
- <init-param>
- <param-name>back-size-high</param-name>
- <param-value>131072</param-value>
- </init-param>
- <init-param>
- <param-name>back-expiry</param-name>
- <param-value>6h</param-value>
- </init-param>
- <init-param>
- <param-name>back-size-low</param-name>
- <param-value>117965</param-value>
- </init-param>
- </init-params>
- </cache-mapping>
-</cache-config>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/plugin.xml 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/plugin.xml 2010-08-18 14:22:16 UTC (rev 34776)
@@ -3,8 +3,8 @@
<name>human-friendly-urls</name>
<description>Plugin offers human friendly URLs for documents based on their title</description>
<author>JBoss Community</author>
- <version>2.0.0</version>
- <minServerVersion>4.0.0</minServerVersion>
+ <version>2.1.0</version>
+ <minServerVersion>4.5.3</minServerVersion>
<!-- Plugin class -->
<class>org.jboss.labs.clearspace.plugin.hfurl.HFURLPlugin</class>
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/spring.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/spring.xml 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/plugin/spring.xml 2010-08-18 14:22:16 UTC (rev 34776)
@@ -20,12 +20,17 @@
<property name="hfURLManager" ref="hfURLManager" />
</bean>
- <bean id="hfURLCache" parent="cacheBean" depends-on="cacheFactoryManager">
- <constructor-arg value="Human friendly URLs index" />
+ <bean id="hfURLIDsCache" parent="cacheBean" depends-on="cacheFactoryManager">
+ <constructor-arg value="Human friendly URLs index (Document IDs)" />
</bean>
+ <bean id="hfURLTitlesCache" parent="cacheBean" depends-on="cacheFactoryManager">
+ <constructor-arg value="Human friendly URLs index (HF Titles)" />
+ </bean>
+
<bean id="hfURLManager" class="org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager">
- <property name="hfURLCache" ref="hfURLCache" />
+ <property name="hfURLIDsCache" ref="hfURLIDsCache" />
+ <property name="hfURLTitlesCache" ref="hfURLTitlesCache"/>
<property name="hfURLDAO" ref="hfURLDAO" />
<property name="documentManager" ref="documentManager" />
<property name="hfULRPrefix" value="/wiki" />
Modified: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java 2010-08-18 14:15:38 UTC (rev 34775)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java 2010-08-18 14:22:16 UTC (rev 34776)
@@ -23,6 +23,8 @@
import static org.junit.Assert.assertEquals;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
@@ -32,8 +34,7 @@
import org.springframework.dao.EmptyResultDataAccessException;
import com.jivesoftware.base.database.dao.DAOException;
-import com.jivesoftware.community.cache.Cache;
-import com.jivesoftware.community.cache.CoherenceCache;
+import com.jivesoftware.community.cache.CacheBean;
/**
* Test of DbHFURLManager
@@ -45,25 +46,20 @@
private DbHFURLManager hfURLManager;
- private Cache<String, String> hfURLCache;
-
- @SuppressWarnings("unchecked")
@Before
public void setupHFURLManager() {
hfURLManager = new DummyHFURLManager();
hfURLManager.setDocIdURLPrefix("/docs");
hfURLManager.setHfULRPrefix("/wiki");
- hfURLCache = new CoherenceCache();
+ CacheBean<String, String> hfURLIDsCache = new CacheBean<String, String>("hfURLIDsCache");
+ hfURLIDsCache.init();
+ CacheBean<String, ArrayList<String>> hfURLTitlesCache = new CacheBean<String, ArrayList<String>>("hfURLTitlesCache");
+ hfURLTitlesCache.init();
- hfURLCache.put("DOC-1234", "documentwithfriendlyurl");
- hfURLCache.put("DOC-2345", "documentwithfriendlyurl2");
+ hfURLManager.setHfURLIDsCache(hfURLIDsCache);
+ hfURLManager.setHfURLTitlesCache(hfURLTitlesCache);
- hfURLCache.put("DOC-3456", "duplicatehfurl");
- hfURLCache.put("DOC-5678", "duplicatehfurl");
-
- hfURLManager.setHfURLCache(hfURLCache);
-
hfURLManager.setHfURLDAO(new DummyHFURLDAO());
}
@@ -76,11 +72,22 @@
class DummyHFURLDAO implements HFURLDAO {
+ HashMap<String, String> data = new HashMap<String, String>();
+
+ public DummyHFURLDAO() {
+
+ data.put("DOC-1234", "documentwithfriendlyurl");
+ data.put("DOC-2345", "documentwithfriendlyurl2");
+
+ data.put("DOC-3456", "duplicatehfurl");
+ data.put("DOC-5678", "duplicatehfurl");
+ }
+
public void updateIndex() {
}
public long getIndexedURLsCount() {
- return 0;
+ return data.size();
}
public HFURLBean createHFURL(HFURLBean bean) throws DAOException {
@@ -93,17 +100,28 @@
public void deleteHFURL(String documentId) throws DAOException {
}
- public HFURLBean getByDocumentId(String documentId)
- throws EmptyResultDataAccessException {
- return null;
+ public HFURLBean getByDocumentId(String documentId) throws EmptyResultDataAccessException {
+ HFURLBean title = new HFURLBean();
+ title.setHfTitle(data.get(documentId));
+ title.setDocumentID(data.get(documentId));
+ return title;
}
- public List<HFURLBean> getByHfURLTitle(String hfURLTitle)
- throws EmptyResultDataAccessException {
+ public List<HFURLBean> getByHfURLTitle(String hfURLTitle) throws EmptyResultDataAccessException {
if ("not-existing".equals(hfURLTitle)) {
throw new EmptyResultDataAccessException("non existing document", 1);
}
- return null;
+ List<HFURLBean> titles = new ArrayList<HFURLBean>();
+ for (String key : data.keySet()) {
+ String value = data.get(key);
+ if (value.equals(hfURLTitle)) {
+ HFURLBean title = new HFURLBean();
+ title.setHfTitle(hfURLTitle);
+ title.setDocumentID(key);
+ titles.add(title);
+ }
+ }
+ return titles;
}
public HFURLBean updateHFURL(HFURLBean bean) throws DAOException {
@@ -118,22 +136,15 @@
*/
@Test
public void testCreateHFURLTitle() {
- assertEquals("documentwithfriendlyurl", DbHFURLManager
- .createHFURLTitle("document with friendly url"));
- assertEquals("morethanonespace", DbHFURLManager
- .createHFURLTitle("more than one space"));
- assertEquals("UPPERCASEDOCUMENTTITLE", DbHFURLManager
- .createHFURLTitle("UPPER CASE DOCUMENT TITLE"));
+ assertEquals("documentwithfriendlyurl", DbHFURLManager.createHFURLTitle("document with friendly url"));
+ assertEquals("morethanonespace", DbHFURLManager.createHFURLTitle("more than one space"));
+ assertEquals("UPPERCASEDOCUMENTTITLE", DbHFURLManager.createHFURLTitle("UPPER CASE DOCUMENT TITLE"));
+ assertEquals("specialcharacters",
+ DbHFURLManager.createHFURLTitle("special characters :!@#$%^&*()\"\"\u00a7()[]?><~\u00b1_+`"));
+ assertEquals("titlewith-hyphen", DbHFURLManager.createHFURLTitle("title with - hyphen"));
+ assertEquals("titlewithnumbers0123456789", DbHFURLManager.createHFURLTitle("title with numbers 0123456789"));
assertEquals(
- "specialcharacters",
- DbHFURLManager
- .createHFURLTitle("special characters :!@#$%^&*()\"\"\u00a7()[]?><~\u00b1_+`"));
- assertEquals("titlewith-hyphen", DbHFURLManager
- .createHFURLTitle("title with - hyphen"));
- assertEquals("titlewithnumbers0123456789", DbHFURLManager
- .createHFURLTitle("title with numbers 0123456789"));
- assertEquals(
"NationalcharactersescrzyaiedtnESCRZYAIEDTN",
DbHFURLManager
.createHFURLTitle("National characters: \u011b\u0161\u010d\u0159\u017e\u00fd\u00e1\u00ed\u00e9\u010f\u0165\u0148\u011a\u0160\u010c\u0158\u017d\u00dd\u00c1\u00cd\u00c9\u010e\u0164\u0147"));
@@ -145,55 +156,39 @@
*/
@Test
public void testGetDocumentID() {
- assertEquals("DOC-1234", hfURLManager.getDocumentID(
- "documentwithfriendlyurl").get(0));
- assertEquals("DOC-2345", hfURLManager.getDocumentID(
- "documentwithfriendlyurl2").get(0));
+ assertEquals("DOC-1234", hfURLManager.getDocumentID("documentwithfriendlyurl").get(0));
+ assertEquals("DOC-2345", hfURLManager.getDocumentID("documentwithfriendlyurl2").get(0));
assertEquals(0, hfURLManager.getDocumentID("not-existing").size());
}
@Test
public void testGetHFURL() {
- assertEquals("/wiki/documentwithfriendlyurl", hfURLManager
- .getHFURL("/docs/DOC-1234"));
- assertEquals("/wiki/documentwithfriendlyurl.pdf", hfURLManager
- .getHFURL("/docs/DOC-1234.pdf"));
- assertEquals("/wiki/documentwithfriendlyurl/edit", hfURLManager
- .getHFURL("/docs/DOC-1234/edit"));
- assertEquals("/wiki/documentwithfriendlyurl?decorator=print", hfURLManager
- .getHFURL("/docs/DOC-1234?decorator=print"));
+ assertEquals("/wiki/documentwithfriendlyurl", hfURLManager.getHFURL("/docs/DOC-1234"));
+ assertEquals("/wiki/documentwithfriendlyurl.pdf", hfURLManager.getHFURL("/docs/DOC-1234.pdf"));
+ assertEquals("/wiki/documentwithfriendlyurl/edit", hfURLManager.getHFURL("/docs/DOC-1234/edit"));
+ assertEquals("/wiki/documentwithfriendlyurl?decorator=print",
+ hfURLManager.getHFURL("/docs/DOC-1234?decorator=print"));
- assertEquals("/docs/DOC-1234/delete", hfURLManager
- .getHFURL("/docs/DOC-1234/delete"));
- assertEquals("/docs/DOC-1234/restore", hfURLManager
- .getHFURL("/docs/DOC-1234/restore"));
+ assertEquals("/docs/DOC-1234/delete", hfURLManager.getHFURL("/docs/DOC-1234/delete"));
+ assertEquals("/docs/DOC-1234/restore", hfURLManager.getHFURL("/docs/DOC-1234/restore"));
- assertEquals("/docs/DOC-3456", hfURLManager
- .getHFURLUnique("/docs/DOC-3456", true));
+ assertEquals("/docs/DOC-3456", hfURLManager.getHFURLUnique("/docs/DOC-3456", true));
}
@Test
public void testGetDocumentId() {
- assertEquals("DOC-1234", hfURLManager
- .getDocumentId("/community/docs/DOC-1234"));
- assertEquals("DOC-1234", hfURLManager
- .getDocumentId("/community/docs/DOC-1234.pdf"));
- assertEquals("DOC-10350", hfURLManager
- .getDocumentId("/community/docs/DOC-10350"));
- assertEquals("DOC-1234", hfURLManager
- .getDocumentId("/community/docs/DOC-1234/edit"));
+ assertEquals("DOC-1234", hfURLManager.getDocumentId("/community/docs/DOC-1234"));
+ assertEquals("DOC-1234", hfURLManager.getDocumentId("/community/docs/DOC-1234.pdf"));
+ assertEquals("DOC-10350", hfURLManager.getDocumentId("/community/docs/DOC-10350"));
+ assertEquals("DOC-1234", hfURLManager.getDocumentId("/community/docs/DOC-1234/edit"));
- assertEquals("DOC-1234", hfURLManager
- .getDocumentId("/community/docs/DOC-1234?decorator=print"));
- assertEquals("DOC-1234", hfURLManager
- .getDocumentId("/community/docs/DOC-1234/edit?decorator=print"));
+ assertEquals("DOC-1234", hfURLManager.getDocumentId("/community/docs/DOC-1234?decorator=print"));
+ assertEquals("DOC-1234", hfURLManager.getDocumentId("/community/docs/DOC-1234/edit?decorator=print"));
- assertEquals(
- "DOC-1234",
- hfURLManager
- .getDocumentId("/community/docs/DOC-1234;jsessionid=4666CC84E4D942F30DA3A5C3142D1DA4"));
+ assertEquals("DOC-1234",
+ hfURLManager.getDocumentId("/community/docs/DOC-1234;jsessionid=4666CC84E4D942F30DA3A5C3142D1DA4"));
}
More information about the jboss-svn-commits
mailing list