initial sketch of trackback-handling servlet

This commit is contained in:
Eric J. Bowersox 2004-12-30 23:01:07 +00:00
parent d0d8611d15
commit d9ec3210a5
6 changed files with 292 additions and 90 deletions

View File

@ -97,7 +97,7 @@
<servlet> <servlet>
<servlet-name>PostShortcut</servlet-name> <servlet-name>PostShortcut</servlet-name>
<description>Redirects the user to a comunity, conference, topic, or message.</description> <description>Redirects the user to a community, conference, topic, or message.</description>
<servlet-class>com.silverwrist.venice.ui.conf.PostShortcutServlet</servlet-class> <servlet-class>com.silverwrist.venice.ui.conf.PostShortcutServlet</servlet-class>
</servlet> </servlet>
@ -125,6 +125,12 @@
<servlet-class>com.silverwrist.venice.ui.rpc.XmlRpcServlet</servlet-class> <servlet-class>com.silverwrist.venice.ui.rpc.XmlRpcServlet</servlet-class>
</servlet> </servlet>
<servlet>
<servlet-name>Trackback</servlet-name>
<description>Handles trackback requests.</description>
<servlet-class>com.silverwrist.venice.ui.conf.TrackbackServlet</servlet-class>
</servlet>
<!-- Servlet mappings --> <!-- Servlet mappings -->
<servlet-mapping> <servlet-mapping>
@ -192,6 +198,11 @@
<url-pattern>/RPC2</url-pattern> <url-pattern>/RPC2</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping>
<servlet-name>Trackback</servlet-name>
<url-pattern>/trackback/*</url-pattern>
</servlet-mapping>
<!-- Global parameters for the HTTP session --> <!-- Global parameters for the HTTP session -->
<session-config> <session-config>
<session-timeout>60</session-timeout> <!-- 1 hour --> <session-timeout>60</session-timeout> <!-- 1 hour -->

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Community System. * The Original Code is the Venice Web Community System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */

View File

@ -38,14 +38,14 @@ public interface RequestInput extends ServiceProvider
public static final String LEFT_MENU_SESSION_ATTR = "LeftMenu"; public static final String LEFT_MENU_SESSION_ATTR = "LeftMenu";
/** /**
* Returns a <CODE>String</CODE> containing the real path for a given virtual path. For example, * Returns a {@link java.lang.String String} containing the real path for a given virtual path. For example,
* the virtual path &quot;/index.html&quot; has a real path of whatever file on the server's filesystem * the virtual path &quot;/index.html&quot; has a real path of whatever file on the server's filesystem
* would be served by a request for &quot;/index.html&quot;.<P> * would be served by a request for &quot;/index.html&quot;.<p>
* This method returns <CODE>null</CODE> if the virtual path cannot be translated to a real path for * This method returns <code>null</code> if the virtual path cannot be translated to a real path for
* any reason. * any reason.
* *
* @param s A <CODE>String</CODE> specifying a virtual path. * @param s A <code>String</code> specifying a virtual path.
* @return A <CODE>String</CODE> specifying the real path, or <CODE>null</CODE> if the translation cannot * @return A <code>String</code> specifying the real path, or <code>null</code> if the translation cannot
* be performed. * be performed.
*/ */
public String mapPath(String s); public String mapPath(String s);
@ -55,8 +55,8 @@ public interface RequestInput extends ServiceProvider
* context under which Venice is installed. The context path always comes first in a request URI. The * context under which Venice is installed. The context path always comes first in a request URI. The
* path starts with a &quot;/&quot; character but does not end with a &quot;/&quot; character. * path starts with a &quot;/&quot; character but does not end with a &quot;/&quot; character.
* *
* @return A <CODE>String</CODE> specifying the portion of the request URI that indicates the context * @return A {@link java.lang.String String} specifying the portion of the request URI that indicates the
* of the request. * context of the request.
*/ */
public String getContextPath(); public String getContextPath();
@ -64,28 +64,28 @@ public interface RequestInput extends ServiceProvider
* Returns the part of this request's URI that calls the servlet. This includes either the servlet name * Returns the part of this request's URI that calls the servlet. This includes either the servlet name
* or a path to the servlet, but does not include any extra path information or a query string. * or a path to the servlet, but does not include any extra path information or a query string.
* *
* @return A <CODE>String</CODE> containing the name or path of the servlet being called, as specified * @return A {@link java.lang.String String} containing the name or path of the servlet being called, as
* in the request URI. * specified in the request URI.
*/ */
public String getServletPath(); public String getServletPath();
/** /**
* Returns any extra path information associated with the URI the client sent when it made this request. * Returns any extra path information associated with the URI the client sent when it made this request.
* The extra path information follows the servlet path but precedes the query string. This method * The extra path information follows the servlet path but precedes the query string. This method
* returns <CODE>null</CODE> if there was no extra path information. In Venice, the path information is * returns <code>null</code> if there was no extra path information. In Venice, the path information is
* used to specify parameters in certain servlets. * used to specify parameters in certain servlets.
* *
* @return A <CODE>String</CODE> specifying extra path information that comes after the servlet path * @return A {@link java.lang.String String} specifying extra path information that comes after the servlet path
* but before the query string in the request URI; or <CODE>null</CODE> if the URI does not * but before the query string in the request URI; or <code>null</code> if the URI does not
* have any extra path information. * have any extra path information.
*/ */
public String getPathInfo(); public String getPathInfo();
/** /**
* Returns the query string that is contained in the request URI after the path. This method returns * Returns the query string that is contained in the request URI after the path. This method returns
* <CODE>null</CODE> if the URI does not have a query string. * <code>null</code> if the URI does not have a query string.
* *
* @return A <CODE>String</CODE> containing the query string or <CODE>null</CODE> if the URI contains * @return A {@link java.lang.String String} containing the query string or <code>null</code> if the URI contains
* no query string. * no query string.
*/ */
public String getQueryString(); public String getQueryString();
@ -93,20 +93,20 @@ public interface RequestInput extends ServiceProvider
/** /**
* Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT. * Returns the name of the HTTP method with which this request was made, for example, GET, POST, or PUT.
* *
* @return A <CODE>String</CODE> specifying the name of the method with which this request was made. * @return A {@link java.lang.String String} specifying the name of the method with which this request was made.
*/ */
public String getVerb(); public String getVerb();
/** /**
* Returns the Internet Protocol (IP) address of the client that sent the request. * Returns the Internet Protocol (IP) address of the client that sent the request.
* *
* @return A <CODE>String</CODE> containing the IP address of the client that sent the request. * @return A {@link java.lang.String String} containing the IP address of the client that sent the request.
*/ */
public String getSourceAddress(); public String getSourceAddress();
/** /**
* Returns <CODE>true</CODE> if the request parameter with the specified name is defined, * Returns <code>true</code> if the request parameter with the specified name is defined,
* <CODE>false</CODE> if not. For standard Venice requests, parameters are contained in the * <code>false</code> if not. For standard Venice requests, parameters are contained in the
* query string or posted form data. * query string or posted form data.
* *
* @param name Parameter name to be checked. * @param name Parameter name to be checked.
@ -115,117 +115,120 @@ public interface RequestInput extends ServiceProvider
public boolean hasParameter(String name); public boolean hasParameter(String name);
/** /**
* Returns the value of a request parameter as a <CODE>String</CODE>, or <CODE>null</CODE> if the * Returns the value of a request parameter as a {@link java.lang.String String}, or <code>null</code> if the
* parameter does not exist. For standard Venice requests, parameters are contained in the query * parameter does not exist. For standard Venice requests, parameters are contained in the query
* string or posted form data.<P> * string or posted form data.<p>
* You should only use this method when you are sure the parameter has only one value. If the parameter * You should only use this method when you are sure the parameter has only one value. If the parameter
* might have more than one value, use {@link #getParameterValues(java.lang.String)}.<P> * might have more than one value, use {@link #getParameterValues(java.lang.String)}.<p>
* If you use this method with a multivalued parameter, the value returned is equal to the first value * If you use this method with a multivalued parameter, the value returned is equal to the first value
* in the array returned by <CODE>getParameterValues</CODE>. * in the array returned by <code>getParameterValues</code>.
* *
* @param name A <CODE>String</CODE> specifying the name of the parameter. * @param name A <code>String</code> specifying the name of the parameter.
* @return A <CODE>String</CODE> representing the single value of the parameter. * @return A <code>String</code> representing the single value of the parameter.
* @see #getParameterValues(java.lang.String) * @see #getParameterValues(java.lang.String)
*/ */
public String getParameter(String name); public String getParameter(String name);
/** /**
* Returns the value of a request parameter as a <CODE>int</CODE>, or a specified default value if * Returns the value of a request parameter as a <code>int</code>, or a specified default value if
* the parameter does not exist. For standard Venice requests, parameters are contained in the query * the parameter does not exist. For standard Venice requests, parameters are contained in the query
* string or posted form data.<P> * string or posted form data.<p>
* If you use this method with a multivalued parameter, the value returned is equal to the * If you use this method with a multivalued parameter, the value returned is equal to the
* <CODE>int</CODE> equivalent of the first value in the array returned by <CODE>getParameterValues</CODE>. * <code>int</code> equivalent of the first value in the array returned by
* {@link #getParameterValues(java.lang.String)}.
* *
* @param name A <CODE>String</CODE> specifying the name of the parameter. * @param name A {@link java.lang.String String} specifying the name of the parameter.
* @param default_value The default value to use for the parameter if the specified parameter does not exist. * @param default_value The default value to use for the parameter if the specified parameter does not exist.
* @return An <CODE>int</CODE> representing the single value of the parameter. * @return An <code>int</code> representing the single value of the parameter.
*/ */
public int getParameterInt(String name, int default_value); public int getParameterInt(String name, int default_value);
/** /**
* Returns the value of a request parameter as a <CODE>short</CODE>, or a specified default value if * Returns the value of a request parameter as a <code>short</code>, or a specified default value if
* the parameter does not exist. For standard Venice requests, parameters are contained in the query * the parameter does not exist. For standard Venice requests, parameters are contained in the query
* string or posted form data.<P> * string or posted form data.<p>
* If you use this method with a multivalued parameter, the value returned is equal to the * If you use this method with a multivalued parameter, the value returned is equal to the
* <CODE>short</CODE> equivalent of the first value in the array returned by <CODE>getParameterValues</CODE>. * <code>short</code> equivalent of the first value in the array returned by
* {@link #getParameterValues(java.lang.String)}.
* *
* @param name A <CODE>String</CODE> specifying the name of the parameter. * @param name A {@link java.lang.String String} specifying the name of the parameter.
* @param default_value The default value to use for the parameter if the specified parameter does not exist. * @param default_value The default value to use for the parameter if the specified parameter does not exist.
* @return A <CODE>short</CODE> representing the single value of the parameter. * @return A <code>short</code> representing the single value of the parameter.
*/ */
public short getParameterShort(String name, short default_value); public short getParameterShort(String name, short default_value);
/** /**
* Returns the value of a request parameter as a <CODE>long</CODE>, or a specified default value if * Returns the value of a request parameter as a <code>long</code>, or a specified default value if
* the parameter does not exist. For standard Venice requests, parameters are contained in the query * the parameter does not exist. For standard Venice requests, parameters are contained in the query
* string or posted form data.<P> * string or posted form data.<p>
* If you use this method with a multivalued parameter, the value returned is equal to the * If you use this method with a multivalued parameter, the value returned is equal to the
* <CODE>long</CODE> equivalent of the first value in the array returned by <CODE>getParameterValues</CODE>. * <code>long</code> equivalent of the first value in the array returned by
* {@link #getParameterValues(java.lang.String)}.
* *
* @param name A <CODE>String</CODE> specifying the name of the parameter. * @param name A {@link java.lang.String String} specifying the name of the parameter.
* @param default_value The default value to use for the parameter if the specified parameter does not exist. * @param default_value The default value to use for the parameter if the specified parameter does not exist.
* @return A <CODE>long</CODE> representing the single value of the parameter. * @return A <code>long</code> representing the single value of the parameter.
*/ */
public long getParameterLong(String name, long default_value); public long getParameterLong(String name, long default_value);
/** /**
* Returns an <CODE>Enumeration</CODE> of <CODE>String</CODE> objects containing the names of the * Returns an {@link java.util.Enumeration Enumeration} of {@link java.lang.String String} objects containing
* parameters contained in this request. If the request has no parameters, the method returns an empty * the names of the parameters contained in this request. If the request has no parameters, the method returns
* <CODE>Enumeration.</CODE> * an empty <code>Enumeration.</code>
* *
* @return An <CODE>Enumeration</CODE> of <CODE>String</CODE> objects, each <CODE>String</CODE> * @return An <code>Enumeration</code> of <code>String</code> objects, each <code>String</code>
* containing the name of a request parameter, or an empty <CODE>Enumeration</CODE> if the * containing the name of a request parameter, or an empty <code>Enumeration</code> if the
* request has no parameters. * request has no parameters.
*/ */
public Enumeration getParameterNames(); public Enumeration getParameterNames();
/** /**
* Returns an array of <CODE>String</CODE> objects containing all of the values the given request * Returns an array of {@link java.lang.String String} objects containing all of the values the given request
* parameter has, or <CODE>null</CODE> if the parameter does not exist.<P> * parameter has, or <code>null</code> if the parameter does not exist.<p>
* If the parameter has a single value, the array has a length of 1. * If the parameter has a single value, the array has a length of 1.
* *
* @param name A <CODE>String</CODE> containing the name of the parameter whose value is requested. * @param name A <code>String</code> containing the name of the parameter whose value is requested.
* @return An array of <CODE>String</CODE> objects containing the parameter's values. * @return An array of <code>String</code> objects containing the parameter's values.
* @see #getParameter(java.lang.String) * @see #getParameter(java.lang.String)
*/ */
public String[] getParameterValues(String name); public String[] getParameterValues(String name);
/** /**
* Returns <CODE>true</CODE> if the specified parameter is a file parameter, <CODE>false</CODE> if * Returns <code>true</code> if the specified parameter is a file parameter, <code>false</code> if
* not. If the parameter does not exist, the return value is <CODE>false</CODE>. * not. If the parameter does not exist, the return value is <code>false</code>.
* *
* @param name A <CODE>String</CODE> containing the name of the parameter to test. * @param name A {@link java.lang.String String} containing the name of the parameter to test.
* @return See above. * @return See above.
*/ */
public boolean isFileParam(String name); public boolean isFileParam(String name);
/** /**
* Returns the MIME type of the specified parameter. If the type cannot be determined, the return * Returns the MIME type of the specified parameter. If the type cannot be determined, the return
* value is <CODE>null</CODE>.<P> * value is <code>null</code>.<p>
* N.B.: For non-file parameters, or all parameters to a request that is not a file upload, the MIME * N.B.: For non-file parameters, or all parameters to a request that is not a file upload, the MIME
* type is &quot;text/plain&quot;. * type is &quot;text/plain&quot;.
* *
* @param name A <CODE>String</CODE> containing the name of the parameter to test. * @param name A {@link java.lang.String String} containing the name of the parameter to test.
* @return See above. * @return See above.
*/ */
public String getParameterType(String name); public String getParameterType(String name);
/** /**
* Returns the size in bytes of the specified parameter. If the size cannot be determined, the return * Returns the size in bytes of the specified parameter. If the size cannot be determined, the return
* value is -1.<P> * value is -1.<p>
* N.B.: For non-file parameters, or all parameters to a request that is not a file upload, the size * N.B.: For non-file parameters, or all parameters to a request that is not a file upload, the size
* is the number of bytes occupied by the parameter, expressed in UTF-8 encoding. * is the number of bytes occupied by the parameter, expressed in UTF-8 encoding.
* *
* @param name A <CODE>String</CODE> containing the name of the parameter to test. * @param name A {@link java.lang.String String} containing the name of the parameter to test.
* @return See above. * @return See above.
*/ */
public int getParameterSize(String name); public int getParameterSize(String name);
/** /**
* Returns an <CODE>InputStream</CODE> reading from the data of the named file parameter. If the * Returns an {@link java.io.InputStream InputStream} reading from the data of the named file parameter. If the
* named parameter does not exist or is not a file parameter, returns <CODE>null; * named parameter does not exist or is not a file parameter, returns <code>null;
* *
* @param name A <CODE>String</CODE> containing the name of the parameter whose value is requested. * @param name A {@link java.lang.String String} containing the name of the parameter whose value is requested.
* @return See above. * @return See above.
* @exception com.silverwrist.util.ServletMultipartException If there is a problem retrieving * @exception com.silverwrist.util.ServletMultipartException If there is a problem retrieving
* the parameter data stream. * the parameter data stream.
@ -233,20 +236,20 @@ public interface RequestInput extends ServiceProvider
public InputStream getParameterDataStream(String name) throws ServletMultipartException; public InputStream getParameterDataStream(String name) throws ServletMultipartException;
/** /**
* Returns <CODE>true</CODE> if the parameter set reflects the clicking of an image button with a * Returns <code>true</code> if the parameter set reflects the clicking of an image button with a
* specified name, <CODE>false</CODE> if not. * specified name, <code>false</code> if not.
* *
* @param name A <CODE>String</CODE> containing the name of the image button to test. * @param name A {@link java.lang.String String} containing the name of the image button to test.
* @return See above. * @return See above.
*/ */
public boolean isImageButtonClicked(String name); public boolean isImageButtonClicked(String name);
/** /**
* Returns the application-level attribute with the given name, or <CODE>null</CODE> if there is no * Returns the application-level attribute with the given name, or <code>null</code> if there is no
* attribute by that name. * attribute by that name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no * @return An {@link java.lang.Object Object} containing the value of the attribute, or <code>null</code> if no
* attribute exists matching the given name. * attribute exists matching the given name.
*/ */
public Object getAppAttribute(String name); public Object getAppAttribute(String name);
@ -254,18 +257,18 @@ public interface RequestInput extends ServiceProvider
/** /**
* Sets the application-level attribute with the given name. * Sets the application-level attribute with the given name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding * @param o The object to be bound as the value of that attribute, or <code>null</code> if the binding
* is to be removed. * is to be removed.
*/ */
public void setAppAttribute(String name, Object o); public void setAppAttribute(String name, Object o);
/** /**
* Returns the session-level attribute with the given name, or <CODE>null</CODE> if there is no * Returns the session-level attribute with the given name, or <code>null</code> if there is no
* attribute by that name. * attribute by that name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no * @return An {@link java.lang.Object Object} containing the value of the attribute, or <code>null</code> if no
* attribute exists matching the given name. * attribute exists matching the given name.
*/ */
public Object getSessionAttribute(String name); public Object getSessionAttribute(String name);
@ -273,18 +276,18 @@ public interface RequestInput extends ServiceProvider
/** /**
* Sets the session-level attribute with the given name. * Sets the session-level attribute with the given name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding * @param o The object to be bound as the value of that attribute, or <code>null</code> if the binding
* is to be removed. * is to be removed.
*/ */
public void setSessionAttribute(String name, Object o); public void setSessionAttribute(String name, Object o);
/** /**
* Returns the request-level attribute with the given name, or <CODE>null</CODE> if there is no * Returns the request-level attribute with the given name, or <code>null</code> if there is no
* attribute by that name. * attribute by that name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @return An <CODE>Object</CODE> containing the value of the attribute, or <CODE>null</CODE> if no * @return An {@link java.lang.Object Object} containing the value of the attribute, or <code>null</code> if no
* attribute exists matching the given name. * attribute exists matching the given name.
*/ */
public Object getRequestAttribute(String name); public Object getRequestAttribute(String name);
@ -292,8 +295,8 @@ public interface RequestInput extends ServiceProvider
/** /**
* Sets the request-level attribute with the given name. * Sets the request-level attribute with the given name.
* *
* @param name A <CODE>String</CODE> specifying the name of the attribute. * @param name A {@link java.lang.String String} specifying the name of the attribute.
* @param o The object to be bound as the value of that attribute, or <CODE>null</CODE> if the binding * @param o The object to be bound as the value of that attribute, or <code>null</code> if the binding
* is to be removed. * is to be removed.
*/ */
public void setRequestAttribute(String name, Object o); public void setRequestAttribute(String name, Object o);
@ -329,8 +332,8 @@ public interface RequestInput extends ServiceProvider
public void setLocation(String str); public void setLocation(String str);
/** /**
* Returns <CODE>true</CODE> if the &quot;Log In&quot; link is to be displayed on the outer frame, * Returns <code>true</code> if the &quot;Log In&quot; link is to be displayed on the outer frame,
* <CODE>false</CODE> if not. * <code>false</code> if not.
* *
* @return See above. * @return See above.
*/ */
@ -339,8 +342,8 @@ public interface RequestInput extends ServiceProvider
/** /**
* Sets whether or not the &quot;Log In&quot; link is to be displayed on the outer frame. * Sets whether or not the &quot;Log In&quot; link is to be displayed on the outer frame.
* *
* @param val <CODE>true</CODE> to display the &quot;Log In&quot; link on the outer frame, * @param val <code>true</code> to display the &quot;Log In&quot; link on the outer frame,
* <CODE>false</CODE> to omit it. * <code>false</code> to omit it.
*/ */
public void setDisplayLogin(boolean val); public void setDisplayLogin(boolean val);

View File

@ -9,15 +9,15 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
package com.silverwrist.venice.ui.conf; package com.silverwrist.venice.ui.conf;
import org.apache.log4j.*; import org.apache.log4j.Logger;
import com.silverwrist.venice.core.*; import com.silverwrist.venice.core.*;
import com.silverwrist.venice.db.PostLinkDecoder; import com.silverwrist.venice.db.PostLinkDecoder;
import com.silverwrist.venice.except.*; import com.silverwrist.venice.except.*;
@ -32,7 +32,7 @@ public class PostShortcutServlet extends BaseServlet implements LinkTypes
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private static Category logger = Category.getInstance(PostShortcutServlet.class); private static Logger logger = Logger.getLogger(PostShortcutServlet.class);
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Internal operations * Internal operations

View File

@ -0,0 +1,188 @@
/*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
*
* Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
* WARRANTY OF ANY KIND, either express or implied. See the License for the specific
* language governing rights and limitations under the License.
*
* The Original Code is the Venice Web Communities System.
*
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
package com.silverwrist.venice.ui.conf;
import org.apache.log4j.Logger;
import com.silverwrist.venice.core.*;
import com.silverwrist.venice.db.PostLinkDecoder;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.helpers.*;
import com.silverwrist.venice.ui.servlet.BaseServlet;
public class TrackbackServlet extends BaseServlet
{
/*--------------------------------------------------------------------------------
* Static data members
*--------------------------------------------------------------------------------
*/
private static Logger logger = Logger.getLogger(TrackbackServlet.class);
private static final int INVALID = 0;
private static final int COMMUNITY = 1;
private static final int CONFERENCE = 2;
private static final int TOPIC = 3;
private static final int POST = 4;
private static final int POST_RANGE = 5;
private static final int POST_OE_RANGE = 6;
/*--------------------------------------------------------------------------------
* Internal operations
*--------------------------------------------------------------------------------
*/
private static final int classifyPostLink(RequestInput req, PostLinkDecoder pld)
{
String s = pld.getCommunity();
if (s==null)
return INVALID; // we must have the community or we're not valid
CommunityContext comm = null;
try
{ // get the community context we're looking for
comm = req.getUser().getCommunityContext(s);
req.setRequestAttribute("current.community",comm);
} // end try
catch (DataException e)
{ // can't find the community - we're screwed
logger.error("unable to decode community \"" + s + "\"",e);
return INVALID;
} // end catch
s = pld.getConference();
if (s==null)
return COMMUNITY; // community link only
ConferenceContext conf = null;
try
{ // get the conference context
conf = comm.getConferenceContext(s);
req.setRequestAttribute("current.conference",comm);
} // end try
catch (DataException e)
{ // can't find the conference - we're screwed
logger.error("unable to decode conference \"" + s + "\"",e);
return INVALID;
} // end catch
catch (AccessError ae)
{ // we can't get to the conference...
logger.error("AccessError getting conference \"" + s + "\"",ae);
return INVALID;
} // end catch
short tn = pld.getTopic();
if (tn==-1)
return CONFERENCE; // only a conference locator
TopicContext topic = null;
try
{ // get the resulting topic number
topic = conf.getTopic(tn);
req.setRequestAttribute("current.topic",comm);
} // end try
catch (DataException e)
{ // we can't find the topic - we're screwed
logger.error("unable to decode topic \"" + tn + "\"",e);
return INVALID;
} // end catch
catch (AccessError ae)
{ // we can't get to the topic...
logger.error("AccessError getting topic \"" + tn + "\"",ae);
return INVALID;
} // end catch
int fp = pld.getFirstPost();
if (fp==-1)
return TOPIC; // just referencing the topic
int lp = pld.getLastPost();
if (fp==lp)
return POST; // single post
if (lp==-1)
return POST_OE_RANGE; // open-ended range of posts
return POST_RANGE; // normal range of posts
} // end classifyPostLink
/*--------------------------------------------------------------------------------
* Implementations from class BaseServlet
*--------------------------------------------------------------------------------
*/
public Object process(RequestInput req)
{
String raw_link = req.getPathInfo().substring(1);
PostLinkDecoder decoder;
if (logger.isDebugEnabled())
logger.debug("decoding post link: " + raw_link);
try
{ // attempt to decode the path link information
decoder = new PostLinkDecoder(raw_link);
} // end try
catch (ValidationException e)
{ // the post link decoder failed
logger.error("Post link decode failed!",e);
return new HTTPError(400,"Invalid post link \"" + raw_link + "\": " + e.getMessage());
} // end catch
// classify the post link and decode as much of it as we can
int what = classifyPostLink(req,decoder);
if (what==INVALID)
return new HTTPError(400,"Invalid post link \"" + raw_link + "\"");
// at this point, trackback may only be applied to single posts, not ranges or anything higher
if (what!=POST)
return new HTTPError(400,"Trackback only applies to single posts");
TopicMessageContext msg = null;
try
{ // get the message involved
TopicContext topic = (TopicContext)(req.getRequestAttribute("current.topic"));
msg = topic.getMessage(decoder.getFirstPost());
} // end try
catch (DataException e)
{ // the post was not found
return new HTTPError(404,"Post not found: \"" + raw_link + "\"");
} // end catch
catch (AccessError e)
{ // could not access the post
return new HTTPError(403,"Post not accessible: \"" + raw_link + "\"");
} // end catch
// TODO: POST = add trackback
// GET = get list of trackbacks, may be with either ?__mode=rss (default) or ?__mode=view
return null;
} // end process
} // end class TrackbackServlet

View File

@ -9,9 +9,9 @@
* *
* The Original Code is the Venice Web Communities System. * The Original Code is the Venice Web Communities System.
* *
* The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>, * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@ricochet.com>,
* for Silverwrist Design Studios. Portions created by Eric J. Bowersox are * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
* Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* *
* Contributor(s): * Contributor(s):
*/ */
@ -29,7 +29,7 @@ public class HTTPError extends ThrowableContent implements ContentExecute
*-------------------------------------------------------------------------------- *--------------------------------------------------------------------------------
*/ */
private int code; private final int code;
/*-------------------------------------------------------------------------------- /*--------------------------------------------------------------------------------
* Constructors * Constructors