[jboss-svn-commits] JBL Code SVN: r25504 - in labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl: struts/mapping and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 5 11:22:19 EST 2009
Author: lkrzyzanek
Date: 2009-03-05 11:22:19 -0500 (Thu, 05 Mar 2009)
New Revision: 25504
Added:
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLBean.java
labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMapping.java
Log:
added
Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLBean.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLBean.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLBean.java 2009-03-05 16:22:19 UTC (rev 25504)
@@ -0,0 +1,142 @@
+/*
+ * JBoss.org http://jboss.org/
+ *
+ * Copyright (c) 2009 Red Hat Middleware, LLC. All rights reserved.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT A WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License, v.2.1 along with this distribution; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301, USA.
+ *
+ * Red Hat Author(s): Libor Krzyzanek
+ */
+package org.jboss.labs.clearspace.plugin.hfurl.dao;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import com.jivesoftware.community.cache.CacheSizes;
+import com.jivesoftware.community.cache.Cacheable;
+import com.tangosol.io.ExternalizableLite;
+import com.tangosol.util.ExternalizableHelper;
+
+/**
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ *
+ */
+public class HFURLBean implements Cacheable, ExternalizableLite {
+
+ /**
+ * Internal ID
+ */
+ private long id = -1;
+
+ /**
+ * HF Title
+ */
+ private String hfTitle;
+
+ /**
+ * Document ID
+ */
+ private String documentID;
+
+ public int getCachedSize() {
+ int size = 0;
+ size += CacheSizes.sizeOfObject(); // overhead of object
+ size += CacheSizes.sizeOfLong(); // id
+ size += CacheSizes.sizeOfString(hfTitle); // hfTitle
+ size += CacheSizes.sizeOfString(documentID); // documentID
+
+ return size;
+ }
+
+ public void readExternal(DataInput in) throws IOException {
+ this.id = ExternalizableHelper.readLong(in);
+ this.hfTitle = ExternalizableHelper.readSafeUTF(in);
+ this.documentID = ExternalizableHelper.readSafeUTF(in);
+ }
+
+ public void writeExternal(DataOutput out) throws IOException {
+ ExternalizableHelper.writeLong(out, id);
+ ExternalizableHelper.writeSafeUTF(out, hfTitle);
+ ExternalizableHelper.writeSafeUTF(out, documentID);
+ }
+
+ public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+
+ HFURLBean that = (HFURLBean) o;
+
+ if (id != that.id) {
+ return false;
+ }
+ if (hfTitle != null ? !hfTitle.equals(that.hfTitle) : that.hfTitle != null) {
+ return false;
+ }
+ if (documentID != null ? !documentID.equals(that.documentID)
+ : that.documentID != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = (int) (id ^ (id >>> 32));
+ result = 31 * result + (documentID != null ? documentID.hashCode() : 0);
+ result = 31 * result + (hfTitle != null ? hfTitle.hashCode() : 0);
+
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("DocumentBean");
+ sb.append("{id=").append(id);
+ sb.append(", hfTitle='").append(hfTitle);
+ sb.append(", documentID='").append(documentID);
+ sb.append('}');
+ return sb.toString();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public void setId(long id) {
+ this.id = id;
+ }
+
+ public String getHfTitle() {
+ return hfTitle;
+ }
+
+ public void setHfTitle(String hfTitle) {
+ this.hfTitle = hfTitle;
+ }
+
+ public String getDocumentID() {
+ return documentID;
+ }
+
+ public void setDocumentID(String documentID) {
+ this.documentID = documentID;
+ }
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/dao/HFURLBean.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMapping.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMapping.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMapping.java 2009-03-05 16:22:19 UTC (rev 25504)
@@ -0,0 +1,89 @@
+/*
+ * 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 org.apache.struts2.dispatcher.mapper.ActionMapping;
+import org.jboss.labs.clearspace.plugin.hfurl.HFURLManager;
+
+import com.jivesoftware.community.web.struts.mapping.DocURLMapping;
+
+/**
+ * Process document Human friendly URIs into standard CS doc url.<br>
+ * It extends {@link DocURLMapping} because it only construct standard DOC-XXXX
+ * URL and call standard mapping implementation.
+ *
+ * @author <a href="mailto:lkrzyzan at redhat.com">Libor Krzyzanek</a>
+ */
+public class HFURLMapping extends DocURLMapping {
+
+ private HFURLManager hfURLManager;
+
+ public void process(String uri, ActionMapping mapping) {
+ uri = convertHFURL2StandardURL(uri);
+ super.process(uri, mapping);
+ }
+
+ /**
+ * Converts HF URL to standard CS URL
+ * @param uri
+ * @return
+ */
+ protected String convertHFURL2StandardURL(String uri) {
+ String[] uriElements = uri.split("/");
+ if (uriElements.length > 2) {
+ // in this case try to switch from HF URL to standard CS URL
+ // document (documentID) is always the second element
+ String hfURLTitle;
+ if (uriElements[2].endsWith(".pdf")) {
+ hfURLTitle = uriElements[2].replace(".pdf", "");
+ } else {
+ hfURLTitle = uriElements[2];
+ }
+ // String documentID = hfURLManager.getDocumentID(hfURLTitle);
+ String documentID = "DOC-1000";
+
+ if (documentID == null) {
+ // document not found
+ } else {
+ final int hfURLTitleEndIndex = uri.indexOf(hfURLTitle) + hfURLTitle.length();
+ StringBuilder sb = new StringBuilder("/docs/");
+ sb.append(documentID);
+
+ if (hfURLTitleEndIndex < uri.length()) {
+ sb.append(uri.substring(hfURLTitleEndIndex, uri.length()));
+ }
+ uri = sb.toString();
+ }
+
+ }
+ return uri;
+ }
+
+ public void setHfURLManager(HFURLManager hfURLManager) {
+ this.hfURLManager = hfURLManager;
+ }
+
+ public HFURLManager getHfURLManager() {
+ return hfURLManager;
+ }
+
+}
Property changes on: labs/jbosslabs/labs-3.0-build/integration/cs-hfurl/src/main/java/org/jboss/labs/clearspace/plugin/hfurl/struts/mapping/HFURLMapping.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
More information about the jboss-svn-commits
mailing list