[jboss-svn-commits] JBL Code SVN: r30447 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags: cs-hfurl-1.1.1 and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Dec 3 04:49:08 EST 2009
Author: lkrzyzanek
Date: 2009-12-03 04:49:08 -0500 (Thu, 03 Dec 2009)
New Revision: 30447
Added:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/changes/changes.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/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.1/src/main/resources/plugin.xml
Removed:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/changes/changes.xml
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/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.1/src/main/resources/plugin.xml
Log:
Version 1.1.1
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1 (from rev 26624, 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.1
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
deploy.pom
Deleted: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/pom.xml 2009-05-19 19:05:13 UTC (rev 26624)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -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.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>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml (from rev 30446, 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.1/pom.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/pom.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -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.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.6</source>
+ <target>1.6</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.1/src/changes/changes.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/changes/changes.xml 2009-05-19 19:05:13 UTC (rev 26624)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/changes/changes.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -1,31 +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.1.0" date="2009-04-27" description="New feature release">
- <action type="add" dev="lkrzyzan" date="2009-04-27">
- <fixes issue="ORG-198" />
- <fixes issue="ORG-190" />
- </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>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/changes/changes.xml (from rev 30446, 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.1/src/changes/changes.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/changes/changes.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -0,0 +1,37 @@
+<?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.1" date="2009-12-03" description="Upgrade to Java 6">
+ <action type="fix" dev="lkrzyzan" date="2009-12-03">
+ <fixes issue="ORG-353" />
+ </action>
+ </release>
+
+ <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" />
+ <fixes issue="ORG-190" />
+ </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.1/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-05-19 19:05:13 UTC (rev 26624)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2009-12-03 09:49:08 UTC (rev 30447)
@@ -1,387 +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) {
- return getHFURLUnique(standardURL, false);
- }
-
- public String getHFURLUnique(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;
- }
-
-}
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java (from rev 30446, 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.1/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.1/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/DbHFURLManager.java 2009-12-03 09:49:08 UTC (rev 30447)
@@ -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 getHFURLUnique(standardURL, false);
+ }
+
+ public String getHFURLUnique(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.1/src/main/resources/plugin.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/trunk/src/main/resources/plugin.xml 2009-05-19 19:05:13 UTC (rev 26624)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/main/resources/plugin.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -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.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>
Copied: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/main/resources/plugin.xml (from rev 30446, 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.1/src/main/resources/plugin.xml (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/tags/cs-hfurl-1.1.1/src/main/resources/plugin.xml 2009-12-03 09:49:08 UTC (rev 30447)
@@ -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.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>
More information about the jboss-svn-commits
mailing list