[jboss-svn-commits] JBL Code SVN: r26275 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags: cs-hfurl-1.1.0 and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Apr 27 05:40:59 EDT 2009
Author: lkrzyzanek
Date: 2009-04-27 05:40:58 -0400 (Mon, 27 Apr 2009)
New Revision: 26275
Added:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/RedirectToHFURLAction.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java
Removed:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java
Log:
Release 1.1.0
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0 (from rev 25997, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk)
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
deploy.pom
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,132 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project xmlns="http://maven.apache.org/POM/4.0.0"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.jboss.labs.clearspace.plugin</groupId>
- <artifactId>human-friendly-urls</artifactId>
- <name>Clearspace plugin: Human friendly URLs</name>
- <description>Plugin offers human friendly URLs in Clearspace</description>
- <version>1.0.1</version>
-
- <parent>
- <groupId>org.jboss.labs</groupId>
- <artifactId>integration</artifactId>
- <version>1.0-SNAPSHOT</version>
- <relativePath>../../pom.xml</relativePath>
- </parent>
-
- <build>
- <plugins>
- <plugin>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
- <groupId>com.jivesoftware.maven</groupId>
- <artifactId>maven-clearspace-plugin-packager</artifactId>
- <executions>
- <execution>
- <goals>
- <goal>package-plugin</goal>
- </goals>
- <phase>package</phase>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <finalName>tmp-classes</finalName>
- </configuration>
- </plugin>
- <plugin>
- <artifactId>maven-antrun-plugin</artifactId>
- <version>1.1</version>
- <executions>
- <execution>
- <id>rename-exploded</id>
- <goals>
- <goal>run</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <tasks>
- <delete>
- <fileset dir="target" includes="tmp-classes*" />
- </delete>
- </tasks>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>4.4</version>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>com.jivesoftware</groupId>
- <artifactId>clearspace-all</artifactId>
- <version>2.5.0.rc</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <pluginRepositories>
- <pluginRepository>
- <id>jive.ext.central</id>
- <name>Jive Repository</name>
- <url>http://maven.jivesoftware.com/archiva/repository/jive.internal/</url>
- </pluginRepository>
- <pluginRepository>
- <id>jive.ext.snapshots</id>
- <name>Jive Snapshot Repository</name>
- <url>http://maven.jivesoftware.com/archiva/repository/jive.snapshots/</url>
- </pluginRepository>
- </pluginRepositories>
- <repositories>
- <repository>
- <id>jive.ext.central</id>
- <name>Jive Repository</name>
- <url>http://maven.jivesoftware.com/archiva/repository/jive.internal/</url>
- </repository>
- <repository>
- <id>jive.ext.snapshots</id>
- <name>Jive Snapshot Repository</name>
- <url>http://maven.jivesoftware.com/archiva/repository/jive.snapshots/</url>
- </repository>
- </repositories>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-changes-plugin</artifactId>
- <reportSets>
- <reportSet>
- <reports>
- <report>changes-report</report>
- </reports>
- </reportSet>
- </reportSets>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>cobertura-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </reporting>
-
-</project>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml (from rev 26216, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/pom.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss.labs.clearspace.plugin</groupId>
+ <artifactId>human-friendly-urls</artifactId>
+ <name>Clearspace plugin: Human friendly URLs</name>
+ <description>Plugin offers human friendly URLs in Clearspace</description>
+ <version>1.1.0</version>
+
+ <parent>
+ <groupId>org.jboss.labs</groupId>
+ <artifactId>integration</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>com.jivesoftware.maven</groupId>
+ <artifactId>maven-clearspace-plugin-packager</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>package-plugin</goal>
+ </goals>
+ <phase>package</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <finalName>tmp-classes</finalName>
+ </configuration>
+ </plugin>
+ <plugin>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>1.1</version>
+ <executions>
+ <execution>
+ <id>rename-exploded</id>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <tasks>
+ <delete>
+ <fileset dir="target" includes="tmp-classes*" />
+ </delete>
+ </tasks>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.4</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.jivesoftware</groupId>
+ <artifactId>clearspace-all</artifactId>
+ <version>2.5.0.rc</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jive.ext.central</id>
+ <name>Jive Repository</name>
+ <url>http://maven.jivesoftware.com/archiva/repository/jive.internal/</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>jive.ext.snapshots</id>
+ <name>Jive Snapshot Repository</name>
+ <url>http://maven.jivesoftware.com/archiva/repository/jive.snapshots/</url>
+ </pluginRepository>
+ </pluginRepositories>
+ <repositories>
+ <repository>
+ <id>jive.ext.central</id>
+ <name>Jive Repository</name>
+ <url>http://maven.jivesoftware.com/archiva/repository/jive.internal/</url>
+ </repository>
+ <repository>
+ <id>jive.ext.snapshots</id>
+ <name>Jive Snapshot Repository</name>
+ <url>http://maven.jivesoftware.com/archiva/repository/jive.snapshots/</url>
+ </repository>
+ </repositories>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>changes-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>cobertura-maven-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+</project>
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document xmlns="http://maven.apache.org/changes/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
-
- <properties>
- <title>Clearspace plugin: Human friendly URL</title>
- <author email="lkrzyzan at redhat.com">Libor Krzyzanek</author>
- </properties>
-
- <body>
-
- <release version="1.0.1" date="2009-??-??" description="Bug fix release">
- <action type="fix" dev="lkrzyzan" date="2009-04-08">
- <fixes issue="ORG-174" />
- <fixes issue="ORG-175"/>
- </action>
- </release>
-
- <release version="1.0.0" date="2009-04-01" description="Initial version" />
-
- </body>
-
-</document>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml (from rev 26274, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/changes/changes.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document xmlns="http://maven.apache.org/changes/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/changes/1.0.0 http://maven.apache.org/plugins/maven-changes-plugin/xsd/changes-1.0.0.xsd">
+
+ <properties>
+ <title>Clearspace plugin: Human friendly URL</title>
+ <author email="lkrzyzan at redhat.com">Libor Krzyzanek</author>
+ </properties>
+
+ <body>
+
+ <release version="1.1.0" date="2009-04-27" description="New feature release">
+ <action type="add" dev="lkrzyzan" date="2009-04-27">
+ <fixes issue="ORG-198" />
+ </action>
+ </release>
+
+ <release version="1.0.1" date="2009-04-10" description="Bug fix release">
+ <action type="fix" dev="lkrzyzan" date="2009-04-08">
+ <fixes issue="ORG-174" />
+ <fixes issue="ORG-175" />
+ </action>
+ </release>
+
+ <release version="1.0.0" date="2009-04-01" description="Initial version" />
+
+ </body>
+
+</document>
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/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 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,369 +0,0 @@
-/*
- * 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;
-
-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;
-import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
-import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLDAO;
-import org.springframework.dao.EmptyResultDataAccessException;
-
-import com.jivesoftware.community.Document;
-import com.jivesoftware.community.DocumentState;
-import com.jivesoftware.community.JiveGlobals;
-import com.jivesoftware.community.cache.Cache;
-import com.jivesoftware.community.event.DocumentEvent;
-import com.jivesoftware.community.event.DocumentListener;
-
-/**
- * DB Implementation of HF URL Manager
- *
- * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- *
- */
-public class DbHFURLManager implements HFURLManager, DocumentListener {
-
- 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
- */
- private Cache<String, String> hfURLCache;
-
- private HFURLDAO hfURLDAO;
-
- private String hfULRPrefix;
-
- private String docIdURLPrefix;
-
- public long getIndexedURLsCount() {
- return hfURLDAO.getIndexedURLsCount();
- }
-
- public boolean isHFLinksEnabled() {
- return JiveGlobals.getJiveBooleanProperty(HFURLPlugin.HFURL_ENABLED_KEY);
- }
-
- public void setHFLinksEnabled(boolean enabled) {
- JiveGlobals.setJiveProperty(HFURLPlugin.HFURL_ENABLED_KEY, Boolean
- .toString(enabled));
-
- }
-
- public static String createHFURLTitle(String documentTitle) {
- if (log.isDebugEnabled()) {
- log.debug("createHFURLTitle from doc title: " + documentTitle);
- }
- // remove white spaces
- String hfURLTitle = documentTitle.replaceAll("[\\s]+", "");
-
- // Remove accents
- // Java 6
- // hfURLTitle = java.text.Normalizer.normalize(hfURLTitle,
- // java.text.Normalizer.Form.NFD);
-
- // Java 5
- hfURLTitle = sun.text.Normalizer.normalize(hfURLTitle,
- sun.text.Normalizer.DECOMP, 0);
-
- // remove special characters
- hfURLTitle = hfURLTitle.replaceAll("[^a-zA-Z0-9-]+", "");
-
- // URL Encode - not needed because all special characters are removed
- // hfURLTitle = URLEncoder.encode(hfURLTitle, "UTF-8");
-
- if (log.isDebugEnabled()) {
- log.debug("created HF URL title " + hfURLTitle);
- }
-
- return hfURLTitle;
- }
-
- public void updateIndex() {
- hfURLDAO.updateIndex();
- hfURLCache.clear();
- }
-
- public String getHfURLTitle(String documentID)
- throws EmptyResultDataAccessException {
- String hfURLTitle = hfURLCache.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);
- }
- } catch (EmptyResultDataAccessException e) {
- // nothing founded - should not occur
- }
- }
- return hfURLTitle;
- }
-
- public String getHFURL(String standardURL) {
- if (!isHFLinksEnabled()) {
- return standardURL;
- }
-
- String hfURL = standardURL;
- 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")
- && !standardURL.contains("/restore")) {
-
- final String documentId = getDocumentId(standardURL);
- final String hfTitle = getHfURLTitle(documentId);
- hfURL = standardURL.replaceFirst(docIdURLPrefix + "/" + documentId,
- getHfULRPrefix() + "/" + hfTitle);
- if (log.isDebugEnabled()) {
- 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);
- // something wrong - catch it and use original URL
- }
- return hfURL;
- }
-
- /**
- * Get Document ID from URL
- *
- * @param url
- * URL in standard CS format i.e. /docs/DOC-1234
- * @return document ID i.e. DOC-1234
- */
- protected String getDocumentId(String url) {
- log.trace("Test of question mark");
- final int questionMark = url.indexOf('?');
- if (questionMark != -1) {
- url = url.substring(0, questionMark);
- }
- log.trace("Test of ;jsessionid");
- final int jsessionid = url.indexOf(";jsessionid");
- if (jsessionid != -1) {
- url = url.substring(0, jsessionid);
- }
- log.trace("Test of .pdf");
- if (url.endsWith(".pdf")) {
- url = url.replace(".pdf", "");
- }
-
- final int docIDStart = url.indexOf(docIdURLPrefix + "/")
- + docIdURLPrefix.length() + 1;
- int docIDEnd = url.indexOf("/", docIDStart);
- if (docIDEnd == -1) {
- docIDEnd = url.length();
- }
-
- return url.substring(docIDStart, docIDEnd);
- }
-
- 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();
-
- if (hfURLTitle.equals(pairs.getValue())) {
- docIds.add(pairs.getKey());
- }
- }
- } else {
- try {
- List<HFURLBean> beans = hfURLDAO.getByHfURLTitle(hfURLTitle);
- for (HFURLBean dbbean : beans) {
- docIds.add(dbbean.getDocumentID());
- hfURLCache.put(dbbean.getDocumentID(), hfURLTitle);
- }
- } catch (EmptyResultDataAccessException e) {
- // nothing founded
- }
- }
-
- return docIds;
- }
-
- // DOCUMENT LISTENER METHODS
-
- public void binaryBodyDownloaded(DocumentEvent event) {
- }
-
- public void documentAdded(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("documentAdded: " + event.getDocument().getDocumentID());
- }
- Document doc = event.getDocument();
- String hfURLTitle = createHFURLTitle(doc.getSubject());
- HFURLBean bean = new HFURLBean(doc.getDocumentID(), hfURLTitle);
- hfURLDAO.createHFURL(bean);
- }
-
- public void documentDeleted(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("documentDeleted: " + event.getDocument().getDocumentID());
- }
- // this notification is fired when administrator delete document.
- // it's not fired when user mark document as deleted.
- // This case is handled by document modified with document state = deleted
- }
-
- public void documentExpired(DocumentEvent event) {
- }
-
- public void documentExpireWarning(DocumentEvent event) {
- }
-
- public void documentModified(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("documentModified: " + event.getDocument().getDocumentID());
- log.debug("event params: " + event.getParams());
- log.debug("Document state: " + event.getDocument().getDocumentState());
- }
-
- Map<String, ? extends Object> params = event.getParams();
- Document doc = event.getDocument();
-
- // Title modify
- if ("titleModify".equals(params.get("Type"))) {
- log.debug("Title is modified - go to refresh HF URL Map");
-
- HFURLBean bean = hfURLDAO.getByDocumentId(doc.getDocumentID());
- String hfURLTitle = createHFURLTitle(doc.getSubject());
- bean.setHfTitle(hfURLTitle);
-
- hfURLDAO.updateHFURL(bean);
- hfURLCache.put(doc.getDocumentID(), hfURLTitle);
- }
-
- // User delete - it's not Administrator delete that fire documentDeleted
- // event
- if ("documentStateModify".equals(params.get("Type"))
- && doc.getDocumentState().equals(DocumentState.DELETED)) {
- log.debug("State of document changed to DELETED");
- hfURLDAO.deleteHFURL(event.getDocument().getDocumentID());
- hfURLCache.remove(event.getDocument().getDocumentID());
- }
-
- // Here is one special case of changing title - when user restore version
- // which has another title CS doesn't fire this event.
-
- // At now we don't care because changing title at all is not done very
- // frequently
- }
-
- public void documentMoved(DocumentEvent event) {
- }
-
- public void documentRated(DocumentEvent event) {
- }
-
- public void documentRelatedObjectAdded(DocumentEvent event) {
- }
-
- public void documentRelatedObjectDeleted(DocumentEvent event) {
- }
-
- public void documentUndeleted(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("documentUndeleted: " + event.getDocument().getDocumentID());
- }
- Document doc = event.getDocument();
-
- try {
- hfURLDAO.getByDocumentId(doc.getDocumentID());
- // document HF URL founded - should not happen but rather check it
- } catch (EmptyResultDataAccessException e) {
- // document HF ULR not founded. Create new one
- String hfURLTitle = createHFURLTitle(doc.getSubject());
- HFURLBean bean = new HFURLBean(doc.getDocumentID(), hfURLTitle);
- hfURLDAO.createHFURL(bean);
- }
- }
-
- public void documentViewed(DocumentEvent event) {
- }
-
- public void versionAdded(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("versionAdded: " + event.getDocument().getDocumentID());
- }
- }
-
- public void versionDeleting(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("versionDeleting: " + event.getDocument().getDocumentID());
- }
- }
-
- public void versionModified(DocumentEvent event) {
- if (log.isDebugEnabled()) {
- log.debug("versionModified: " + event.getDocument().getDocumentID());
- }
- }
-
- public void setHfURLDAO(HFURLDAO hfURLDAO) {
- this.hfURLDAO = hfURLDAO;
- }
-
- public void setHfURLCache(Cache<String, String> hfURLCache) {
- this.hfURLCache = hfURLCache;
- }
-
- public void setHfULRPrefix(String hfULRPrefix) {
- this.hfULRPrefix = hfULRPrefix;
- }
-
- public String getHfULRPrefix() {
- return hfULRPrefix;
- }
-
- public void setDocIdURLPrefix(String docIdURLPrefix) {
- this.docIdURLPrefix = docIdURLPrefix;
- }
-
-}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java (from rev 26217, 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/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,387 @@
+/*
+ * 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;
+
+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;
+import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
+import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLDAO;
+import org.springframework.dao.EmptyResultDataAccessException;
+
+import com.jivesoftware.community.Document;
+import com.jivesoftware.community.DocumentState;
+import com.jivesoftware.community.JiveGlobals;
+import com.jivesoftware.community.cache.Cache;
+import com.jivesoftware.community.event.DocumentEvent;
+import com.jivesoftware.community.event.DocumentListener;
+
+/**
+ * DB Implementation of HF URL Manager
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class DbHFURLManager implements HFURLManager, DocumentListener {
+
+ 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
+ */
+ private Cache<String, String> hfURLCache;
+
+ private HFURLDAO hfURLDAO;
+
+ private String hfULRPrefix;
+
+ private String docIdURLPrefix;
+
+ public long getIndexedURLsCount() {
+ return hfURLDAO.getIndexedURLsCount();
+ }
+
+ public boolean isHFLinksEnabled() {
+ return JiveGlobals.getJiveBooleanProperty(HFURLPlugin.HFURL_ENABLED_KEY);
+ }
+
+ public void setHFLinksEnabled(boolean enabled) {
+ JiveGlobals.setJiveProperty(HFURLPlugin.HFURL_ENABLED_KEY, Boolean
+ .toString(enabled));
+
+ }
+
+ public static String createHFURLTitle(String documentTitle) {
+ if (log.isDebugEnabled()) {
+ log.debug("createHFURLTitle from doc title: " + documentTitle);
+ }
+ // remove white spaces
+ String hfURLTitle = documentTitle.replaceAll("[\\s]+", "");
+
+ // Remove accents
+ // Java 6
+ // hfURLTitle = java.text.Normalizer.normalize(hfURLTitle,
+ // java.text.Normalizer.Form.NFD);
+
+ // Java 5
+ hfURLTitle = sun.text.Normalizer.normalize(hfURLTitle,
+ sun.text.Normalizer.DECOMP, 0);
+
+ // remove special characters
+ hfURLTitle = hfURLTitle.replaceAll("[^a-zA-Z0-9-]+", "");
+
+ // URL Encode - not needed because all special characters are removed
+ // hfURLTitle = URLEncoder.encode(hfURLTitle, "UTF-8");
+
+ if (log.isDebugEnabled()) {
+ log.debug("created HF URL title " + hfURLTitle);
+ }
+
+ return hfURLTitle;
+ }
+
+ public void updateIndex() {
+ hfURLDAO.updateIndex();
+ hfURLCache.clear();
+ }
+
+ public String getHfURLTitle(String documentID)
+ throws EmptyResultDataAccessException {
+ String hfURLTitle = hfURLCache.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);
+ }
+ } catch (EmptyResultDataAccessException e) {
+ // nothing founded - should not occur
+ }
+ }
+ return hfURLTitle;
+ }
+
+ public String getHFURL(String standardURL) {
+ return getHFURL(standardURL, false);
+ }
+
+ public String getHFURL(String standardURL, boolean onlyUniqueHFURL) {
+ if (!isHFLinksEnabled()) {
+ return standardURL;
+ }
+
+ String hfURL = standardURL;
+ 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")
+ && !standardURL.contains("/restore")) {
+
+ final String documentId = getDocumentId(standardURL);
+ final String hfTitle = getHfURLTitle(documentId);
+
+ 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;
+ }
+ }
+ }
+ }
+
+ hfURL = standardURL.replaceFirst(docIdURLPrefix + "/" + documentId,
+ getHfULRPrefix() + "/" + hfTitle);
+ if (log.isDebugEnabled()) {
+ 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);
+ // something wrong - catch it and use original URL
+ }
+ return hfURL;
+ }
+
+ /**
+ * Get Document ID from URL
+ *
+ * @param url
+ * URL in standard CS format i.e. /docs/DOC-1234
+ * @return document ID i.e. DOC-1234
+ */
+ protected String getDocumentId(String url) {
+ log.trace("Test of question mark");
+ final int questionMark = url.indexOf('?');
+ if (questionMark != -1) {
+ url = url.substring(0, questionMark);
+ }
+ log.trace("Test of ;jsessionid");
+ final int jsessionid = url.indexOf(";jsessionid");
+ if (jsessionid != -1) {
+ url = url.substring(0, jsessionid);
+ }
+ log.trace("Test of .pdf");
+ if (url.endsWith(".pdf")) {
+ url = url.replace(".pdf", "");
+ }
+
+ final int docIDStart = url.indexOf(docIdURLPrefix + "/")
+ + docIdURLPrefix.length() + 1;
+ int docIDEnd = url.indexOf("/", docIDStart);
+ if (docIDEnd == -1) {
+ docIDEnd = url.length();
+ }
+
+ return url.substring(docIDStart, docIDEnd);
+ }
+
+ 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();
+
+ if (hfURLTitle.equals(pairs.getValue())) {
+ docIds.add(pairs.getKey());
+ }
+ }
+ } else {
+ try {
+ List<HFURLBean> beans = hfURLDAO.getByHfURLTitle(hfURLTitle);
+ for (HFURLBean dbbean : beans) {
+ docIds.add(dbbean.getDocumentID());
+ hfURLCache.put(dbbean.getDocumentID(), hfURLTitle);
+ }
+ } catch (EmptyResultDataAccessException e) {
+ // nothing founded
+ }
+ }
+
+ return docIds;
+ }
+
+ // DOCUMENT LISTENER METHODS
+
+ public void binaryBodyDownloaded(DocumentEvent event) {
+ }
+
+ public void documentAdded(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("documentAdded: " + event.getDocument().getDocumentID());
+ }
+ Document doc = event.getDocument();
+ String hfURLTitle = createHFURLTitle(doc.getSubject());
+ HFURLBean bean = new HFURLBean(doc.getDocumentID(), hfURLTitle);
+ hfURLDAO.createHFURL(bean);
+ }
+
+ public void documentDeleted(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("documentDeleted: " + event.getDocument().getDocumentID());
+ }
+ // this notification is fired when administrator delete document.
+ // it's not fired when user mark document as deleted.
+ // This case is handled by document modified with document state = deleted
+ }
+
+ public void documentExpired(DocumentEvent event) {
+ }
+
+ public void documentExpireWarning(DocumentEvent event) {
+ }
+
+ public void documentModified(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("documentModified: " + event.getDocument().getDocumentID());
+ log.debug("event params: " + event.getParams());
+ log.debug("Document state: " + event.getDocument().getDocumentState());
+ }
+
+ Map<String, ? extends Object> params = event.getParams();
+ Document doc = event.getDocument();
+
+ // Title modify
+ if ("titleModify".equals(params.get("Type"))) {
+ log.debug("Title is modified - go to refresh HF URL Map");
+
+ HFURLBean bean = hfURLDAO.getByDocumentId(doc.getDocumentID());
+ String hfURLTitle = createHFURLTitle(doc.getSubject());
+ bean.setHfTitle(hfURLTitle);
+
+ hfURLDAO.updateHFURL(bean);
+ hfURLCache.put(doc.getDocumentID(), hfURLTitle);
+ }
+
+ // User delete - it's not Administrator delete that fire documentDeleted
+ // event
+ if ("documentStateModify".equals(params.get("Type"))
+ && doc.getDocumentState().equals(DocumentState.DELETED)) {
+ log.debug("State of document changed to DELETED");
+ hfURLDAO.deleteHFURL(event.getDocument().getDocumentID());
+ hfURLCache.remove(event.getDocument().getDocumentID());
+ }
+
+ // Here is one special case of changing title - when user restore version
+ // which has another title CS doesn't fire this event.
+
+ // At now we don't care because changing title at all is not done very
+ // frequently
+ }
+
+ public void documentMoved(DocumentEvent event) {
+ }
+
+ public void documentRated(DocumentEvent event) {
+ }
+
+ public void documentRelatedObjectAdded(DocumentEvent event) {
+ }
+
+ public void documentRelatedObjectDeleted(DocumentEvent event) {
+ }
+
+ public void documentUndeleted(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("documentUndeleted: " + event.getDocument().getDocumentID());
+ }
+ Document doc = event.getDocument();
+
+ try {
+ hfURLDAO.getByDocumentId(doc.getDocumentID());
+ // document HF URL founded - should not happen but rather check it
+ } catch (EmptyResultDataAccessException e) {
+ // document HF ULR not founded. Create new one
+ String hfURLTitle = createHFURLTitle(doc.getSubject());
+ HFURLBean bean = new HFURLBean(doc.getDocumentID(), hfURLTitle);
+ hfURLDAO.createHFURL(bean);
+ }
+ }
+
+ public void documentViewed(DocumentEvent event) {
+ }
+
+ public void versionAdded(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("versionAdded: " + event.getDocument().getDocumentID());
+ }
+ }
+
+ public void versionDeleting(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("versionDeleting: " + event.getDocument().getDocumentID());
+ }
+ }
+
+ public void versionModified(DocumentEvent event) {
+ if (log.isDebugEnabled()) {
+ log.debug("versionModified: " + event.getDocument().getDocumentID());
+ }
+ }
+
+ public void setHfURLDAO(HFURLDAO hfURLDAO) {
+ this.hfURLDAO = hfURLDAO;
+ }
+
+ public void setHfURLCache(Cache<String, String> hfURLCache) {
+ this.hfURLCache = hfURLCache;
+ }
+
+ public void setHfULRPrefix(String hfULRPrefix) {
+ this.hfULRPrefix = hfULRPrefix;
+ }
+
+ public String getHfULRPrefix() {
+ return hfULRPrefix;
+ }
+
+ public void setDocIdURLPrefix(String docIdURLPrefix) {
+ this.docIdURLPrefix = docIdURLPrefix;
+ }
+
+}
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/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 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,103 +0,0 @@
-/*
- * 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;
-
-import java.util.List;
-
-import org.springframework.dao.EmptyResultDataAccessException;
-
-/**
- * Manager for handling with Human friendly URLs.
- *
- * @author @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- */
-public interface HFURLManager {
-
- /**
- * Get status of Human friendly links
- *
- * @return true if HF links are enabled, otherwise false
- */
- public boolean isHFLinksEnabled();
-
- /**
- * Set if HF links are enabled or disabled
- *
- * @param enabled
- * true if HF links are enabled, false if disabled
- */
- public void setHFLinksEnabled(boolean enabled);
-
- /**
- * Get count of indexed URLs
- *
- * @return
- */
- public long getIndexedURLsCount();
-
- /**
- * Update index of HF URLs. Go through articles and add missing HF URLs
- */
- public void updateIndex();
-
- /**
- * Get document ID.
- *
- * @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)
- * @see com.jivesoftware.community.impl.dao.DocumentBean#getDocumentID()
- */
- public List<String> getDocumentID(String hfURLTitle);
-
- /**
- * Get human friendly URL from standard CS URL. If human friendly links are
- * note enabled then standardURL is returned.
- *
- * @param standardURL
- * i.e. /docs/DOC-1234
- * @return i.e. /wiki/humanFriendlyURL
- */
- public String getHFURL(String standardURL);
-
- /**
- * 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
- */
- public String getHfURLTitle(String documentID)
- throws EmptyResultDataAccessException;
-
- /**
- * Prefix for HF URLs
- *
- * @return prefix for HF URL i.e. /wiki
- */
- public String getHfULRPrefix();
-
-}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java (from rev 26217, 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/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/HFURLManager.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,116 @@
+/*
+ * 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;
+
+import java.util.List;
+
+import org.springframework.dao.EmptyResultDataAccessException;
+
+/**
+ * Manager for handling with Human friendly URLs.
+ *
+ * @author @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public interface HFURLManager {
+
+ /**
+ * Get status of Human friendly links
+ *
+ * @return true if HF links are enabled, otherwise false
+ */
+ public boolean isHFLinksEnabled();
+
+ /**
+ * Set if HF links are enabled or disabled
+ *
+ * @param enabled
+ * true if HF links are enabled, false if disabled
+ */
+ public void setHFLinksEnabled(boolean enabled);
+
+ /**
+ * Get count of indexed URLs
+ *
+ * @return
+ */
+ public long getIndexedURLsCount();
+
+ /**
+ * Update index of HF URLs. Go through articles and add missing HF URLs
+ */
+ public void updateIndex();
+
+ /**
+ * Get document ID.
+ *
+ * @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)
+ * @see com.jivesoftware.community.impl.dao.DocumentBean#getDocumentID()
+ */
+ public List<String> getDocumentID(String hfURLTitle);
+
+ /**
+ * Shortcut for getHFURL(standardURL, false)
+ *
+ * @see #getHFURL(String, boolean)
+ */
+ public String getHFURL(String standardURL);
+
+ /**
+ * Get human friendly URL from standard CS URL. If human friendly links are
+ * note enabled then standardURL is returned.
+ * <p>
+ * 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
+ * @return i.e. /wiki/humanFriendlyURL
+ */
+ public String getHFURL(String standardURL, boolean onlyUniqueHFURL);
+
+ /**
+ * 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
+ */
+ public String getHfURLTitle(String documentID)
+ throws EmptyResultDataAccessException;
+
+ /**
+ * Prefix for HF URLs
+ *
+ * @return prefix for HF URL i.e. /wiki
+ */
+ public String getHfULRPrefix();
+
+}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/RedirectToHFURLAction.java (from rev 26224, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/RedirectToHFURLAction.java)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/RedirectToHFURLAction.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/RedirectToHFURLAction.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,103 @@
+/*
+ * 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 org.jboss.labs.clearspace.plugin.hfurl.HFURLManager;
+
+import com.jivesoftware.community.action.JiveActionSupport;
+
+/**
+ * Action redirects to HF URL
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class RedirectToHFURLAction extends JiveActionSupport {
+
+ /**
+ * URL to redirect
+ */
+ private String url = null;
+
+ /**
+ * Parameters from URLs
+ */
+ private String params = null;
+
+ private HFURLManager hfURLManager;
+
+ public static final String URL_NOT_DEFINED = "urlNotDefined";
+
+ @Override
+ public String execute() {
+ if (url == null || url.trim().equals("")) {
+ url = "/";
+ return URL_NOT_DEFINED;
+ }
+
+ if (params != null && params.length() > 0) {
+ url = url + "?" + params;
+ }
+
+ String urlToRedirect = hfURLManager.getHFURL(url, true);
+
+ if (url.equals(urlToRedirect)) {
+ url = addParameter(urlToRedirect, "uniqueTitle=false");
+ return INPUT;
+ } else {
+ url = urlToRedirect;
+ return SUCCESS;
+ }
+ }
+
+ protected String addParameter(String url, String parameter) {
+ StringBuilder sb = new StringBuilder(url);
+ if (url.indexOf('?') == -1) {
+ sb.append('?');
+ } else {
+ sb.append('&');
+ }
+ sb.append(parameter);
+ return sb.toString();
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setHfURLManager(HFURLManager hfURLManager) {
+ this.hfURLManager = hfURLManager;
+ }
+
+ public void setParams(String params) {
+ this.params = params;
+ }
+
+ public String getParams() {
+ return params;
+ }
+
+}
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/resources/plugin.xml 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,50 +0,0 @@
-<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="http://www.jivesoftware.com/schemas/clearspace/2_0/plugin.xsd">
- <name>human-friendly-urls</name>
- <description>Plugin offers human friendly URLs for documents based on their title</description>
- <author>JBoss.org</author>
- <version>1.0.1</version>
- <minServerVersion>2.5.0</minServerVersion>
-
- <!-- Plugin class -->
- <class>org.jboss.labs.clearspace.plugin.hfurl.HFURLPlugin</class>
-
- <!-- URL Mapping for human friendly URLs -->
- <!--
- Defined during initialization of plugin instead of this declaration:
- <urlmapping prefix="/wiki"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.mapping.HFURLMapping"/>
-
- Prefix is defined in spring.xml in bean hfURLManager, property hfURLPrefix
- -->
-
- <!--
- Sitemesh tag doesn't work. Should be fixed in version 2.5.9.
- For earlier versions this definition must be put in clearspace war/WEB-INF/templates.xml:
- <decorator name="default" page="default/template.ftl">
- <pattern>/wiki*</pattern>
- </decorator>
- <sitemesh>
- <decorator name="doc-default" page="/template/decorator/default/template.ftl">
- <pattern>/wiki*</pattern>
- </decorator>
- </sitemesh>
- -->
-
- <databaseKey>humanFriendlyURL</databaseKey>
- <databaseVersion>1</databaseVersion>
-
- <components>
- <component id="admin-console">
- <tab id="system">
- <section id="section-system">
- <item id="system-hf-urls"
- name="plugin.hfurl.admin.hf-urls.name"
- url="human-friendly-urls-view.jspa"
- description="plugin.hfurl.admin.hf-urls.description"/>
- </section>
- </tab>
- </component>
- </components>
-
-</plugin>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml (from rev 26216, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/resources/plugin.xml)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/plugin.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,50 @@
+<plugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="http://www.jivesoftware.com/schemas/clearspace/2_0/plugin.xsd">
+ <name>human-friendly-urls</name>
+ <description>Plugin offers human friendly URLs for documents based on their title</description>
+ <author>JBoss.org</author>
+ <version>1.1.0</version>
+ <minServerVersion>2.5.0</minServerVersion>
+
+ <!-- Plugin class -->
+ <class>org.jboss.labs.clearspace.plugin.hfurl.HFURLPlugin</class>
+
+ <!-- URL Mapping for human friendly URLs -->
+ <!--
+ Defined during initialization of plugin instead of this declaration:
+ <urlmapping prefix="/wiki"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.mapping.HFURLMapping"/>
+
+ Prefix is defined in spring.xml in bean hfURLManager, property hfURLPrefix
+ -->
+
+ <!--
+ Sitemesh tag doesn't work. Should be fixed in version 2.5.9.
+ For earlier versions this definition must be put in clearspace war/WEB-INF/templates.xml:
+ <decorator name="default" page="default/template.ftl">
+ <pattern>/wiki*</pattern>
+ </decorator>
+ <sitemesh>
+ <decorator name="doc-default" page="/template/decorator/default/template.ftl">
+ <pattern>/wiki*</pattern>
+ </decorator>
+ </sitemesh>
+ -->
+
+ <databaseKey>humanFriendlyURL</databaseKey>
+ <databaseVersion>1</databaseVersion>
+
+ <components>
+ <component id="admin-console">
+ <tab id="system">
+ <section id="section-system">
+ <item id="system-hf-urls"
+ name="plugin.hfurl.admin.hf-urls.name"
+ url="human-friendly-urls-view.jspa"
+ description="plugin.hfurl.admin.hf-urls.description"/>
+ </section>
+ </tab>
+ </component>
+ </components>
+
+</plugin>
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/resources/struts.xml 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,69 +0,0 @@
-<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
- "http://struts.apache.org/dtds/struts-2.0.dtd">
-<struts>
- <package name="hfurl-actions" namespace="/hfurl" extends="community-actions">
-
- <!--
- wiki navigation - when there are more then one document relevant
- to HF URL then show this page
- -->
- <action name="wikiNavigation"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.NavigationAction">
- <result name="success" type="freemarker">
- /plugins/human-friendly-urls/navigation.ftl
- </result>
- </action>
-
- <action name="wikiNotFound"
- class="com.jivesoftware.community.action.JiveActionSupport">
- <result name="success" type="freemarker">
- /plugins/human-friendly-urls/notfound.ftl
- </result>
- </action>
-
- </package>
-
- <package name="hfurl-actions-admin" namespace="/admin"
- extends="community-admin-default">
-
- <action name="human-friendly-urls-view"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction" method="input">
- <result name="input" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- </action>
-
- <action name="human-friendly-urls-reindex"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction">
- <result name="input" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- <result name="success" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- </action>
-
- <action name="human-friendly-urls-enable"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction" method="enable">
- <result name="input" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- <result name="success" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- </action>
-
- <action name="human-friendly-urls-disable"
- class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction" method="disable">
- <result name="input" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- <result name="success" type="freemarker">
- /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
- </result>
- </action>
-
-
- </package>
-
-</struts>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml (from rev 26217, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/resources/struts.xml)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/main/resources/struts.xml 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,87 @@
+<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
+ "http://struts.apache.org/dtds/struts-2.0.dtd">
+<struts>
+ <package name="hfurl-actions" namespace="/hfurl" extends="community-actions">
+
+ <!--
+ wiki navigation - when there are more then one document relevant
+ to HF URL then show this page
+ -->
+ <action name="wikiNavigation"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.NavigationAction">
+ <result name="success" type="freemarker">
+ /plugins/human-friendly-urls/navigation.ftl
+ </result>
+ </action>
+
+ <action name="wikiNotFound"
+ class="com.jivesoftware.community.action.JiveActionSupport">
+ <result name="success" type="freemarker">
+ /plugins/human-friendly-urls/notfound.ftl
+ </result>
+ </action>
+
+ <action name="redirectToHFURL"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.RedirectToHFURLAction">
+ <result name="success" type="httpheader">
+ <param name="status">301</param>
+ <param name="headers.Location">${url}</param>
+ <param name="parse">true</param>
+ </result>
+ <result name="input" type="httpheader">
+ <param name="status">302</param>
+ <param name="headers.Location">${url}</param>
+ <param name="parse">true</param>
+ </result>
+ <result name="urlNotDefined" type="redirect">/</result>
+ </action>
+
+ </package>
+
+ <package name="hfurl-actions-admin" namespace="/admin"
+ extends="community-admin-default">
+
+ <action name="human-friendly-urls-view"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction"
+ method="input">
+ <result name="input" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ </action>
+
+ <action name="human-friendly-urls-reindex"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction">
+ <result name="input" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ <result name="success" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ </action>
+
+ <action name="human-friendly-urls-enable"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction"
+ method="enable">
+ <result name="input" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ <result name="success" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ </action>
+
+ <action name="human-friendly-urls-disable"
+ class="org.jboss.labs.clearspace.plugin.hfurl.struts.AdminHfURLAction"
+ method="disable">
+ <result name="input" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ <result name="success" type="freemarker">
+ /plugins/human-friendly-urls/admin/human-friendly-urls.ftl
+ </result>
+ </action>
+
+
+ </package>
+
+</struts>
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/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 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,193 +0,0 @@
-/*
- * 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;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.List;
-
-import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
-import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLDAO;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.dao.EmptyResultDataAccessException;
-
-import com.jivesoftware.base.database.dao.DAOException;
-import com.jivesoftware.community.cache.Cache;
-import com.jivesoftware.community.cache.CoherenceCache;
-
-/**
- * Test of DbHFURLManager
- *
- * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- *
- */
-public class DbHFURLManagerTest {
-
- 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();
-
- hfURLCache.put("DOC-1234", "documentwithfriendlyurl");
- hfURLCache.put("DOC-2345", "documentwithfriendlyurl2");
-
- hfURLManager.setHfURLCache(hfURLCache);
- hfURLManager.setHfURLDAO(new DummyHFURLDAO());
- }
-
- class DummyHFURLManager extends DbHFURLManager {
- @Override
- public boolean isHFLinksEnabled() {
- return true;
- }
- }
-
- class DummyHFURLDAO implements HFURLDAO {
-
- public void updateIndex() {
- }
-
- public long getIndexedURLsCount() {
- return 0;
- }
-
- public HFURLBean createHFURL(HFURLBean bean) throws DAOException {
- return null;
- }
-
- public void deleteHFURL(Long id) throws DAOException {
- }
-
- public void deleteHFURL(String documentId) throws DAOException {
- }
-
- public HFURLBean getByDocumentId(String documentId)
- throws EmptyResultDataAccessException {
- return null;
- }
-
- public List<HFURLBean> getByHfURLTitle(String hfURLTitle)
- throws EmptyResultDataAccessException {
- if ("not-existing".equals(hfURLTitle)) {
- throw new EmptyResultDataAccessException("non existing document", 1);
- }
- return null;
- }
-
- public HFURLBean updateHFURL(HFURLBean bean) throws DAOException {
- return null;
- }
-
- }
-
- /**
- * Test method for
- * {@link org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager#createHFURLTitle(java.lang.String)}
- */
- @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(
- "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"));
- }
-
- /**
- * Test method for
- * {@link org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager#getDocumentID(java.lang.String)}
- */
- @Test
- public void testGetDocumentID() {
- 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("/docs/DOC-1234/delete", hfURLManager
- .getHFURL("/docs/DOC-1234/delete"));
- assertEquals("/docs/DOC-1234/restore", hfURLManager
- .getHFURL("/docs/DOC-1234/restore"));
-
- }
-
- @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?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"));
-
- }
-
-}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java (from rev 26217, 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/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManagerTest.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,200 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.List;
+
+import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLBean;
+import org.jboss.labs.clearspace.plugin.hfurl.dao.HFURLDAO;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.dao.EmptyResultDataAccessException;
+
+import com.jivesoftware.base.database.dao.DAOException;
+import com.jivesoftware.community.cache.Cache;
+import com.jivesoftware.community.cache.CoherenceCache;
+
+/**
+ * Test of DbHFURLManager
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class DbHFURLManagerTest {
+
+ 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();
+
+ hfURLCache.put("DOC-1234", "documentwithfriendlyurl");
+ hfURLCache.put("DOC-2345", "documentwithfriendlyurl2");
+
+ hfURLCache.put("DOC-3456", "duplicatehfurl");
+ hfURLCache.put("DOC-5678", "duplicatehfurl");
+
+ hfURLManager.setHfURLCache(hfURLCache);
+
+ hfURLManager.setHfURLDAO(new DummyHFURLDAO());
+ }
+
+ class DummyHFURLManager extends DbHFURLManager {
+ @Override
+ public boolean isHFLinksEnabled() {
+ return true;
+ }
+ }
+
+ class DummyHFURLDAO implements HFURLDAO {
+
+ public void updateIndex() {
+ }
+
+ public long getIndexedURLsCount() {
+ return 0;
+ }
+
+ public HFURLBean createHFURL(HFURLBean bean) throws DAOException {
+ return null;
+ }
+
+ public void deleteHFURL(Long id) throws DAOException {
+ }
+
+ public void deleteHFURL(String documentId) throws DAOException {
+ }
+
+ public HFURLBean getByDocumentId(String documentId)
+ throws EmptyResultDataAccessException {
+ return null;
+ }
+
+ public List<HFURLBean> getByHfURLTitle(String hfURLTitle)
+ throws EmptyResultDataAccessException {
+ if ("not-existing".equals(hfURLTitle)) {
+ throw new EmptyResultDataAccessException("non existing document", 1);
+ }
+ return null;
+ }
+
+ public HFURLBean updateHFURL(HFURLBean bean) throws DAOException {
+ return null;
+ }
+
+ }
+
+ /**
+ * Test method for
+ * {@link org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager#createHFURLTitle(java.lang.String)}
+ */
+ @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(
+ "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"));
+ }
+
+ /**
+ * Test method for
+ * {@link org.jboss.labs.clearspace.plugin.hfurl.DbHFURLManager#getDocumentID(java.lang.String)}
+ */
+ @Test
+ public void testGetDocumentID() {
+ 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("/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
+ .getHFURL("/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?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"));
+
+ }
+
+}
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java 2009-04-10 15:14:38 UTC (rev 25997)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -1,152 +0,0 @@
-/*
- * 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.mapping;
-
-import static org.junit.Assert.assertEquals;
-
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import org.jboss.labs.clearspace.plugin.hfurl.HFURLManager;
-import org.junit.Before;
-import org.junit.Test;
-import org.springframework.dao.EmptyResultDataAccessException;
-
-/**
- * Tests of HFURLMapping
- *
- * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
- *
- */
-public class HFURLMappingTest {
-
- private HFURLMapping actionMapping;
-
- private final String DOC1 = "DOC-1234";
- private final String DOC2 = "DOC-2345";
-
- @Before
- public void setupHFURLMapping() {
- actionMapping = new HFURLMapping();
- actionMapping.setHfURLManager(new HFURLManager() {
- public String getHFURL(String standardURL) {
- return null;
- }
-
- public boolean isHFLinksEnabled() {
- return false;
- }
-
- public void setHFLinksEnabled(boolean enabled) {
- }
-
- public String getHfULRPrefix() {
- return null;
- }
-
- public String getHfURLTitle(String documentID)
- throws EmptyResultDataAccessException {
- return null;
- }
-
- public long getIndexedURLsCount() {
- return 0;
- }
-
- public void updateIndex() {
- }
-
- public List<String> getDocumentID(String hfURLTitle) {
- List<String> docIds = new LinkedList<String>();
- if (hfURLTitle.equals("nonExisting")) {
- } else if (hfURLTitle.equals("duplicate")) {
- docIds.add(DOC1);
- docIds.add(DOC2);
- } else {
- docIds.add(DOC1);
- }
- return docIds;
- }
-
- });
- }
-
- /**
- * Test method for
- * {@link org.jboss.labs.clearspace.plugin.hfurl.struts.mapping.HFURLMapping#convertHFURL2StandardURL(java.lang.String)}
- * .
- */
- @Test
- public void testConvertHFURL2StandardURL() {
- Map<String, String> params = new HashMap<String, String>();
-
- assertEquals("/docs/DOC-1234", actionMapping.convertHFURL2StandardURL(
- "/doc/JDKs", params));
- assertEquals("/docs/DOC-1234.pdf", actionMapping.convertHFURL2StandardURL(
- "/doc/JDKs.pdf", params));
-
- assertEquals("/docs/DOC-1234/collaborate", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/collaborate", params));
- assertEquals("/docs/DOC-1234/edit", actionMapping.convertHFURL2StandardURL(
- "/doc/JDKs/edit", params));
- assertEquals("/docs/DOC-1234/upload", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/upload", params));
- assertEquals("/docs/DOC-1234/diff", actionMapping.convertHFURL2StandardURL(
- "/doc/JDKs/diff", params));
- assertEquals("/docs/DOC-1234/restore", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/restore", params));
- assertEquals("/docs/DOC-1234/deleteVersion", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/deleteVersion", params));
- assertEquals("/docs/DOC-1234/authors", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/authors", params));
- assertEquals("/docs/DOC-1234/version", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/version", params));
- assertEquals("/docs/DOC-1234/version/5", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/version/5", params));
- assertEquals("/docs/DOC-1234/diff/", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/diff/", params));
- assertEquals("/docs/DOC-1234/delete", actionMapping
- .convertHFURL2StandardURL("/doc/JDKs/delete", params));
-
- assertEquals(HFURLMapping.DOC_NOT_FOUND, actionMapping
- .convertHFURL2StandardURL("/doc/nonExisting", params));
-
- Map<String, String> duplicateParams = new HashMap<String, String>();
- assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
- .convertHFURL2StandardURL("/doc/duplicate", duplicateParams));
- assertEquals(DOC1, duplicateParams.get("docIds[0]"));
- assertEquals(DOC2, duplicateParams.get("docIds[1]"));
-
- duplicateParams = new HashMap<String, String>();
- assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
- .convertHFURL2StandardURL("/doc/duplicate/edit", duplicateParams));
- assertEquals("edit", duplicateParams.get("urlSuffix"));
-
- duplicateParams = new HashMap<String, String>();
- assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
- .convertHFURL2StandardURL("/doc/duplicate/version/1", duplicateParams));
- assertEquals("version/1", duplicateParams.get("urlSuffix"));
- }
-
-}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java (from rev 26217, labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java)
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.0/src/test/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMappingTest.java 2009-04-27 09:40:58 UTC (rev 26275)
@@ -0,0 +1,156 @@
+/*
+ * 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.mapping;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
+import org.jboss.labs.clearspace.plugin.hfurl.HFURLManager;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.dao.EmptyResultDataAccessException;
+
+/**
+ * Tests of HFURLMapping
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class HFURLMappingTest {
+
+ private HFURLMapping actionMapping;
+
+ private final String DOC1 = "DOC-1234";
+ private final String DOC2 = "DOC-2345";
+
+ @Before
+ public void setupHFURLMapping() {
+ actionMapping = new HFURLMapping();
+ actionMapping.setHfURLManager(new HFURLManager() {
+ public String getHFURL(String standardURL) {
+ return null;
+ }
+
+ public String getHFURL(String standardURL, boolean onlyUniqueHFURL) {
+ return null;
+ }
+
+ public boolean isHFLinksEnabled() {
+ return false;
+ }
+
+ public void setHFLinksEnabled(boolean enabled) {
+ }
+
+ public String getHfULRPrefix() {
+ return null;
+ }
+
+ public String getHfURLTitle(String documentID)
+ throws EmptyResultDataAccessException {
+ return null;
+ }
+
+ public long getIndexedURLsCount() {
+ return 0;
+ }
+
+ public void updateIndex() {
+ }
+
+ public List<String> getDocumentID(String hfURLTitle) {
+ List<String> docIds = new LinkedList<String>();
+ if (hfURLTitle.equals("nonExisting")) {
+ } else if (hfURLTitle.equals("duplicate")) {
+ docIds.add(DOC1);
+ docIds.add(DOC2);
+ } else {
+ docIds.add(DOC1);
+ }
+ return docIds;
+ }
+
+ });
+ }
+
+ /**
+ * Test method for
+ * {@link org.jboss.labs.clearspace.plugin.hfurl.struts.mapping.HFURLMapping#convertHFURL2StandardURL(java.lang.String)}
+ * .
+ */
+ @Test
+ public void testConvertHFURL2StandardURL() {
+ Map<String, String> params = new HashMap<String, String>();
+
+ assertEquals("/docs/DOC-1234", actionMapping.convertHFURL2StandardURL(
+ "/doc/JDKs", params));
+ assertEquals("/docs/DOC-1234.pdf", actionMapping.convertHFURL2StandardURL(
+ "/doc/JDKs.pdf", params));
+
+ assertEquals("/docs/DOC-1234/collaborate", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/collaborate", params));
+ assertEquals("/docs/DOC-1234/edit", actionMapping.convertHFURL2StandardURL(
+ "/doc/JDKs/edit", params));
+ assertEquals("/docs/DOC-1234/upload", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/upload", params));
+ assertEquals("/docs/DOC-1234/diff", actionMapping.convertHFURL2StandardURL(
+ "/doc/JDKs/diff", params));
+ assertEquals("/docs/DOC-1234/restore", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/restore", params));
+ assertEquals("/docs/DOC-1234/deleteVersion", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/deleteVersion", params));
+ assertEquals("/docs/DOC-1234/authors", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/authors", params));
+ assertEquals("/docs/DOC-1234/version", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/version", params));
+ assertEquals("/docs/DOC-1234/version/5", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/version/5", params));
+ assertEquals("/docs/DOC-1234/diff/", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/diff/", params));
+ assertEquals("/docs/DOC-1234/delete", actionMapping
+ .convertHFURL2StandardURL("/doc/JDKs/delete", params));
+
+ assertEquals(HFURLMapping.DOC_NOT_FOUND, actionMapping
+ .convertHFURL2StandardURL("/doc/nonExisting", params));
+
+ Map<String, String> duplicateParams = new HashMap<String, String>();
+ assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
+ .convertHFURL2StandardURL("/doc/duplicate", duplicateParams));
+ assertEquals(DOC1, duplicateParams.get("docIds[0]"));
+ assertEquals(DOC2, duplicateParams.get("docIds[1]"));
+
+ duplicateParams = new HashMap<String, String>();
+ assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
+ .convertHFURL2StandardURL("/doc/duplicate/edit", duplicateParams));
+ assertEquals("edit", duplicateParams.get("urlSuffix"));
+
+ duplicateParams = new HashMap<String, String>();
+ assertEquals(HFURLMapping.DOC_MORE_THAN_ONE, actionMapping
+ .convertHFURL2StandardURL("/doc/duplicate/version/1", duplicateParams));
+ assertEquals("version/1", duplicateParams.get("urlSuffix"));
+ }
+
+}
More information about the jboss-svn-commits
mailing list