fixed up a few HTML generation issues in tag classes and JSP templates;

added the authenticatePrivileged method; added SQL date parameter method
to the XML-RPC Request object
This commit is contained in:
Eric J. Bowersox
2004-07-19 08:18:19 +00:00
parent 156511e747
commit 681ec6a8a0
15 changed files with 401 additions and 258 deletions

View File

@@ -130,5 +130,7 @@ public interface UserContext extends SearchMode
public void setDateOfBirth(java.sql.Date date) throws DataException;
public void authenticatePrivileged(String username) throws AccessError, DataException;
} // end interface UserContext

View File

@@ -1667,6 +1667,95 @@ class UserContextImpl implements UserContext, ServiceProvider, PropertyProvider
} // end setDateOfBirth
public void authenticatePrivileged(String username) throws AccessError, DataException
{
if (isLoggedIn())
{ // already authenticated, can't authenticate again
logger.error("UserContext already authenticated (with uid " + uid + ")");
throw new InternalStateError("context already authenticated");
} // end if
if (logger.isDebugEnabled())
logger.debug("authenticatePrivileged(): authenticating user \"" + username + "\"...");
if (!(globalsite.isPrivilegedAddress(remote_addr)))
{ // not privileged - f**k off
logger.error("source address " + remote_addr + " is not privileged!");
throw new AccessError("Remote address is not privileged!");
} // end if
Connection conn = null;
PreparedStatement stmt = null;
AuditRecord ar = null;
try
{ // look for a user name matching this user record
conn = globalsite.getConnection(null);
stmt = conn.prepareStatement("SELECT * FROM users WHERE username = ?;");
stmt.setString(1,username);
ResultSet rs = stmt.executeQuery();
if (!(rs.next()))
{ // user not found
logger.error("...user not found");
ar = new AuditRecord(AuditRecord.LOGIN_FAIL,0,remote_addr,"Bad username: " + username);
throw new AccessError("The user account you have specified does not exist. Please try again.");
} // end if
int the_uid = rs.getInt("uid");
if (rs.getBoolean("is_anon"))
{ // can't log in as Anonymous Honyak
logger.error("...user is the Anonymous Honyak, can't explicitly login");
ar = new AuditRecord(AuditRecord.LOGIN_FAIL,the_uid,remote_addr,"Anonymous user");
throw new AccessError("This account cannot be explicitly logged into. Please try again.");
} // end if
if (logger.isDebugEnabled())
logger.debug("...authenticated");
// we're authenticated - load the user data into the context
loadUserData(rs);
rs.close();
// update the "last access" time in the database
stmt.close();
stmt = conn.prepareStatement("UPDATE users SET lastaccess = ? WHERE uid = ?;");
java.util.Date mydate = new java.util.Date();
SQLUtil.setFullDateTime(stmt,1,mydate);
stmt.setInt(2,uid);
stmt.executeUpdate();
// update the "last access" time in this object
last_access = mydate;
// an audit record indicating we logged in OK
ar = new AuditRecord(AuditRecord.LOGIN_OK,the_uid,remote_addr,"[privileged]");
if (logger.isDebugEnabled())
logger.debug("...context loaded, we're ready :-)");
} // end try
catch (SQLException e)
{ // database error - this is a DataException
logger.error("DB error reading user data: " + e.getMessage(),e);
throw new DataException("unable to access user data: " + e.getMessage(),e);
} // end catch
finally
{ // make sure the connection is released before we go
SQLUtil.shutdown(stmt);
AuditRecord.store(conn,ar);
SQLUtil.shutdown(conn);
} // end if
} // end authenticatePrivileged
/*--------------------------------------------------------------------------------
* Implementations from interface ServiceProvider
*--------------------------------------------------------------------------------

View File

@@ -9,9 +9,9 @@
*
* 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
* 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):
*/
@@ -117,17 +117,18 @@ public class GlobalSiteImpl implements GlobalSite
*--------------------------------------------------------------------------------
*/
private ServiceProvider engine_svc = null; // ServiceProvider for the VeniceEngine
private DataPool datapool = null; // the database pool
private Properties email_props = null; // email properties
private javax.mail.Session mailsession = null; // email session object
private StockMessages stock_messages = null; // stock messages holder
private HashMap html_checkers = new HashMap(); // HTML checkers
private SecurityMonitorEnvironment sm_env; // security monitor environment
private volatile boolean task_running = true; // running tasks flag
private Object task_semaphore = new Object(); // semaphore used for tasks
private LinkedList[] task_queues; // the task queues
private Thread[] task_threads; // the task threads
private ServiceProvider engine_svc = null; // ServiceProvider for the VeniceEngine
private Set m_privileged_addrs = Collections.EMPTY_SET; // privileged addresses
private DataPool datapool = null; // the database pool
private Properties email_props = null; // email properties
private javax.mail.Session mailsession = null; // email session object
private StockMessages stock_messages = null; // stock messages holder
private HashMap html_checkers = new HashMap(); // HTML checkers
private SecurityMonitorEnvironment sm_env; // security monitor environment
private volatile boolean task_running = true; // running tasks flag
private Object task_semaphore = new Object(); // semaphore used for tasks
private LinkedList[] task_queues; // the task queues
private Thread[] task_threads; // the task threads
/*--------------------------------------------------------------------------------
* Constructor
@@ -140,9 +141,25 @@ public class GlobalSiteImpl implements GlobalSite
this.engine_svc = engine_svc;
XMLLoader loader = XMLLoader.get();
// Get the <database/> section.
// Get the <engine/> section.
DOMElementHelper config_h = new DOMElementHelper(config);
Element sect = loader.configGetSubSection(config_h,"database");
DOMElementHelper sect_h = new DOMElementHelper(sect);
// Get the <privileged-addresses/> value.
String s = sect_h.getSubElementText("privileged-addresses");
if (!(StringUtil.isStringEmpty(s)))
{ // break it up by commas
String[] addrs = StringUtil.splitArray(s,",");
HashSet tmp = new HashSet();
for (int i=0; i<addrs.length; i++)
tmp.add(addrs[i].trim());
m_privileged_addrs = Collections.unmodifiableSet(tmp);
} // end if
// Get the <database/> section.
sect = loader.configGetSubSection(config_h,"database");
try
{ // allocate the data pool object
@@ -158,7 +175,7 @@ public class GlobalSiteImpl implements GlobalSite
// Get the <email/> section.
sect = loader.configGetSubSection(config_h,"email");
DOMElementHelper sect_h = new DOMElementHelper(sect);
sect_h = new DOMElementHelper(sect);
// initialize the email properties and get a mail session object
email_props = new Properties();
@@ -580,6 +597,12 @@ public class GlobalSiteImpl implements GlobalSite
*--------------------------------------------------------------------------------
*/
public boolean isPrivilegedAddress(String addr)
{
return m_privileged_addrs.contains(addr);
} // end isPrivilegedAddress
public Connection getConnection(String db_selector) throws SQLException
{
// db_selector is ignored for now

View File

@@ -9,9 +9,9 @@
*
* 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
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* Copyright (C) 2002-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -27,12 +27,14 @@ public interface GlobalSite extends ServiceProvider
public static final int TASK_PRIO_NORMAL = 3;
public static final int TASK_PRIO_MAX = 7;
public abstract Connection getConnection(String db_selector) throws SQLException;
public boolean isPrivilegedAddress(String addr);
public abstract String getStockMessage(String key);
public Connection getConnection(String db_selector) throws SQLException;
public abstract void queueTask(Runnable task, int priority);
public String getStockMessage(String key);
public abstract void queueTask(Runnable task);
public void queueTask(Runnable task, int priority);
public void queueTask(Runnable task);
} // end interface GlobalSite

View File

@@ -9,9 +9,9 @@
*
* 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
* 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):
*/
@@ -31,11 +31,11 @@ class ButtonHolder
*--------------------------------------------------------------------------------
*/
private int width;
private int height;
private Map id_to_caption;
private Map id_to_image;
private String tail_tag;
private int m_width;
private int m_height;
private Map m_id_to_caption;
private Map m_id_to_image;
private String m_tail_tag;
/*--------------------------------------------------------------------------------
* Constructor
@@ -47,9 +47,9 @@ class ButtonHolder
// get the initial header information
XMLLoader loader = XMLLoader.get();
loader.configVerifyNodeName(cfg,"buttons");
width = loader.configGetAttributeInt(cfg,"width");
height = loader.configGetAttributeInt(cfg,"height");
tail_tag = "\" WIDTH=" + width + " HEIGHT=" + height + " BORDER=0>";
m_width = loader.configGetAttributeInt(cfg,"width");
m_height = loader.configGetAttributeInt(cfg,"height");
m_tail_tag = "\" width=\"" + m_width + "\" height=\"" + m_height + "\" border=\"0\" />";
// load the individual button descriptors
HashMap tmp_caption = new HashMap();
@@ -78,30 +78,30 @@ class ButtonHolder
} // end for
if (tmp_caption.isEmpty())
id_to_caption = Collections.EMPTY_MAP;
m_id_to_caption = Collections.EMPTY_MAP;
else
id_to_caption = Collections.unmodifiableMap(tmp_caption);
m_id_to_caption = Collections.unmodifiableMap(tmp_caption);
if (tmp_image.isEmpty())
id_to_image = Collections.EMPTY_MAP;
m_id_to_image = Collections.EMPTY_MAP;
else
id_to_image = Collections.unmodifiableMap(tmp_image);
m_id_to_image = Collections.unmodifiableMap(tmp_image);
} // end constructor
final String getButtonVisual(String id)
{
// Look up the caption and image.
String img = (String)(id_to_image.get(id));
String img = (String)(m_id_to_image.get(id));
if (img==null)
return "";
String caption = (String)(id_to_caption.get(id));
String caption = (String)(m_id_to_caption.get(id));
// Build the returned tag.
StringBuffer buf = new StringBuffer("<IMG SRC=\"");
buf.append(img).append("\" ALT=\"");
StringBuffer buf = new StringBuffer("<img src=\"");
buf.append(img).append("\" alt=\"");
if (caption!=null) // add square brackets, like Links does around <INPUT TYPE=IMAGE>
buf.append("[ ").append(caption).append(" ]");
buf.append(tail_tag);
buf.append(m_tail_tag);
return buf.toString();
} // end getButtonVisual
@@ -109,17 +109,17 @@ class ButtonHolder
final String getButtonInput(String id)
{
// Look up the caption and image.
String img = (String)(id_to_image.get(id));
String img = (String)(m_id_to_image.get(id));
if (img==null)
return "";
String caption = (String)(id_to_caption.get(id));
String caption = (String)(m_id_to_caption.get(id));
// Build the returned tag.
StringBuffer buf = new StringBuffer("<INPUT TYPE=IMAGE SRC=\"");
buf.append(img).append("\" NAME=\"").append(id).append("\" ALT=\"");
StringBuffer buf = new StringBuffer("<input type=\"image\" src=\"");
buf.append(img).append("\" name=\"").append(id).append("\" alt=\"");
if (caption!=null)
buf.append(caption);
buf.append(tail_tag);
buf.append(m_tail_tag);
return buf.toString();
} // end getButtonInput

View File

@@ -9,9 +9,9 @@
*
* 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
* 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):
*/
@@ -30,8 +30,8 @@ public class UtilButtonTag extends VeniceTagSupport
*--------------------------------------------------------------------------------
*/
private String type = "img";
private String id = null;
private String m_type = "img";
private String m_id = null;
/*--------------------------------------------------------------------------------
* Overrides from class TagSupport
@@ -40,17 +40,17 @@ public class UtilButtonTag extends VeniceTagSupport
public int doStartTag() throws JspException
{
if (id==null)
if (m_id==null)
throw new JspTagException("<util:button/> ID not specified!");
if (!(type.equals("img") || type.equals("input")))
if (!(m_type.equals("img") || m_type.equals("input")))
throw new JspTagException("<util:button/> type not valid!");
String data;
HTMLRendering html = (HTMLRendering)(getRequestOutput().queryService(HTMLRendering.class));
if (type.equals("img"))
data = html.getButtonVisual(id);
if (m_type.equals("img"))
data = html.getButtonVisual(m_id);
else
data = html.getButtonInput(id);
data = html.getButtonInput(m_id);
try
{ // write out what we came here to accomplish
@@ -71,8 +71,8 @@ public class UtilButtonTag extends VeniceTagSupport
public void release()
{
super.release();
type = "img";
id = null;
m_type = "img";
m_id = null;
} // end release
@@ -83,13 +83,13 @@ public class UtilButtonTag extends VeniceTagSupport
public void setType(String s)
{
type = s.trim().toLowerCase();
m_type = s.trim().toLowerCase();
} // end setType
public void setId(String s)
{
id = s;
m_id = s;
} // end setId

View File

@@ -9,7 +9,7 @@
*
* 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
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
@@ -39,11 +39,11 @@ public class UtilLinkTag extends VeniceTagSupport
*--------------------------------------------------------------------------------
*/
private String href = null;
private String type = null;
private String cls = null;
private String target = null;
private String title = null;
private String m_href = null;
private String m_type = null;
private String m_class = null;
private String m_target = null;
private String m_title = null;
/*--------------------------------------------------------------------------------
* Overrides from class TagSupport
@@ -53,39 +53,39 @@ public class UtilLinkTag extends VeniceTagSupport
public int doStartTag() throws JspException
{
// Check the parameters!
if (href==null)
if (m_href==null)
throw new JspTagException("<util:link/> href not specified!");
if (type==null)
if (m_type==null)
throw new JspTagException("<util:link/> type not specified!");
RequestInput ri = getRequestInput();
HTMLRendering html = (HTMLRendering)(ri.queryService(HTMLRendering.class));
int ityp = html.convertLinkType(type);
int ityp = html.convertLinkType(m_type);
if (ityp==-1)
throw new JspTagException("<util:link/> invalid link type!");
try
{ // Do parameter replacement on the HREF string if necessary.
if (href.indexOf(LOCATION_PARAM)>=0)
href = StringUtil.replaceAllInstances(href,LOCATION_PARAM,URLEncoder.encode(ri.getLocation(),"UTF-8"));
if (m_href.indexOf(LOCATION_PARAM)>=0)
m_href = StringUtil.replaceAllInstances(m_href,LOCATION_PARAM,URLEncoder.encode(ri.getLocation(),"UTF-8"));
// write out what we came here to accomplish
JspWriter out = pageContext.getOut();
out.write("<A ");
if (cls!=null)
out.write("CLASS=\"" + cls + "\" ");
out.write("HREF=\"" + html.formatURL(href,ityp) + "\"");
if (title!=null)
out.write(" TITLE=\"" + title + "\"");
if (target!=null)
out.write(" TARGET=\"" + target + "\"");
out.write("<a ");
if (m_class!=null)
out.write("class=\"" + m_class + "\" ");
out.write("href=\"" + html.formatURL(m_href,ityp) + "\"");
if (m_title!=null)
out.write(" title=\"" + m_title + "\"");
if (m_target!=null)
out.write(" target=\"" + m_target + "\"");
out.write(">");
} // end try
catch (IOException e)
{ // convert the I/O error into something the servlet engine can deal with
throw new JspTagException("error writing <A> tag - " + e.getMessage());
throw new JspTagException("error writing <a> tag - " + e.getMessage());
} // end catch
@@ -98,12 +98,12 @@ public class UtilLinkTag extends VeniceTagSupport
try
{ // write out what we came here to accomplish
JspWriter out = pageContext.getOut();
out.write("</A>");
out.write("</a>");
} // end try
catch (IOException e)
{ // convert the I/O error into something the servlet engine can deal with
throw new JspTagException("error writing </A> tag - " + e.getMessage());
throw new JspTagException("error writing </a> tag - " + e.getMessage());
} // end catch
@@ -114,11 +114,11 @@ public class UtilLinkTag extends VeniceTagSupport
public void release()
{
super.release();
href = null;
type = null;
cls = null;
target = null;
title = null;
m_href = null;
m_type = null;
m_class = null;
m_target = null;
m_title = null;
} // end release
@@ -129,31 +129,31 @@ public class UtilLinkTag extends VeniceTagSupport
public void setHref(String s)
{
href = s;
m_href = s;
} // end setHref
public void setType(String s)
{
type = s;
m_type = s;
} // end setType
public void setAclass(String s)
{
cls = s;
m_class = s;
} // end setAclass
public void setTarget(String s)
{
target = s;
m_target = s;
} // end setTarget
public void setTitle(String s)
{
title = s;
m_title = s;
} // end setTitle

View File

@@ -9,9 +9,9 @@
*
* 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
* 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):
*/
@@ -38,13 +38,13 @@ public class UtilStdBulletTag extends VeniceTagSupport
{ // write out what we came here to accomplish
JspWriter out = pageContext.getOut();
// TODO: make this configurable
out.write("<IMG SRC=\"" + html.getImagePath("purple-ball.gif")
+ "\" ALT=\"*\" WIDTH=14 HEIGHT=14 BORDER=0>");
out.write("<img src=\"" + html.getImagePath("purple-ball.gif")
+ "\" alt=\"*\" width=\"14\" height=\"14\" border=\"0\" />");
} // end try
catch (IOException e)
{ // convert the I/O error into something the servlet engine can deal with
throw new JspTagException("error writing button - " + e.getMessage());
throw new JspTagException("error writing standard bullet - " + e.getMessage());
} // end catch

View File

@@ -9,7 +9,7 @@
*
* 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
* Copyright (C) 2001-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
@@ -39,13 +39,13 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
*--------------------------------------------------------------------------------
*/
private String href = null;
private int type = -1;
private String cls = null;
private String target = null;
private String text = null;
private String title = null;
private boolean target_external = false;
private String m_href = null;
private int m_type = -1;
private String m_class = null;
private String m_target = null;
private String m_text = null;
private String m_title = null;
private boolean m_target_external = false;
/*--------------------------------------------------------------------------------
* Overrides from class BodyTagSupport
@@ -67,11 +67,11 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
public int doEndTag() throws JspException
{
// Do some shorts-checking on our stored data.
if (href==null)
if (m_href==null)
throw new JspTagException("<util:xlink/> does not have a <util:href/>!");
if (type<0)
if (m_type<0)
throw new JspTagException("<util:xlink/> does not have a <util:href/>!");
if (text==null)
if (m_text==null)
throw new JspTagException("<util:xlink/> does not have a <util:text/>!");
// Dig out the RequestInput and HTMLRendering service.
@@ -80,35 +80,35 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
try
{ // Do parameter replacement on the HREF string if necessary.
if (href.indexOf(LOCATION_PARAM)>=0)
href = StringUtil.replaceAllInstances(href,LOCATION_PARAM,URLEncoder.encode(ri.getLocation(),"UTF-8"));
if (m_href.indexOf(LOCATION_PARAM)>=0)
m_href = StringUtil.replaceAllInstances(m_href,LOCATION_PARAM,URLEncoder.encode(ri.getLocation(),"UTF-8"));
// write out what we came here to accomplish
JspWriter out = pageContext.getOut();
out.write("<A ");
if (cls!=null)
out.write("CLASS=\"" + cls + "\" ");
out.write("HREF=\"" + html.formatURL(href,type) + "\"");
if (title!=null)
out.write(" TITLE=\"" + title + "\"");
if (target!=null)
out.write(" TARGET=\"" + target + "\"");
out.write(">" + text + "</A>");
out.write("<a ");
if (m_class!=null)
out.write("class=\"" + m_class + "\" ");
out.write("href=\"" + html.formatURL(m_href,m_type) + "\"");
if (m_title!=null)
out.write(" title=\"" + m_title + "\"");
if (m_target!=null)
out.write(" target=\"" + m_target + "\"");
out.write(">" + m_text + "</a>");
} // end try
catch (IOException e)
{ // convert the I/O error into something the servlet engine can deal with
throw new JspTagException("error writing <A> tag - " + e.getMessage());
throw new JspTagException("error writing <a/> tag - " + e.getMessage());
} // end catch
href = null;
type = -1;
text = null;
title = null;
if (target_external)
target = null;
target_external = false;
m_href = null;
m_type = -1;
m_text = null;
m_title = null;
if (m_target_external)
m_target = null;
m_target_external = false;
return EVAL_PAGE;
} // end doEndTag
@@ -116,8 +116,8 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
public void release()
{
super.release();
cls = null;
target = null;
m_class = null;
m_target = null;
} // end release
@@ -128,13 +128,13 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
public void setAclass(String s)
{
cls = s;
m_class = s;
} // end setAclass
public void setTarget(String s)
{
target = s;
m_target = s;
} // end setTarget
@@ -145,29 +145,29 @@ public class UtilXLinkTag extends VeniceBodyTagSupport
final void setLink(String href, int type)
{
this.href = href;
this.type = type;
m_href = href;
m_type = type;
} // end setLink
final void setText(String text)
{
this.text = text;
m_text = text;
} // end setText
final void setTitle(String title)
{
this.title = title;
m_title = title;
} // end setTitle
final void setTarget2(String s)
{
if (target==null)
if (m_target==null)
{ // set target via external tag
target = s;
target_external = true;
m_target = s;
m_target_external = true;
} // end if

View File

@@ -9,9 +9,9 @@
*
* 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
* Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
* Copyright (C) 2002-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -36,18 +36,18 @@ public class XmlRpcRequest
*--------------------------------------------------------------------------------
*/
private static Category logger = Category.getInstance(XmlRpcRequest.class);
private static Logger logger = Logger.getLogger(XmlRpcRequest.class);
private static SimpleTimeZone utc = new SimpleTimeZone(0,"UTC");
private static SimpleTimeZone s_utc = new SimpleTimeZone(0,"UTC");
/*--------------------------------------------------------------------------------
* Attributes
*--------------------------------------------------------------------------------
*/
RequestInput req; // request input system
String method_name; // the method name
List method_params; // the method parameters
RequestInput m_req; // request input system
String m_method_name; // the method name
List m_method_params; // the method parameters
/*--------------------------------------------------------------------------------
* Constructors
@@ -64,7 +64,7 @@ public class XmlRpcRequest
XMLLoader loader = XMLLoader.get();
Element root = loader.postGetRootElement(req_doc,"methodCall");
DOMElementHelper root_h = new DOMElementHelper(root);
method_name = loader.postGetSubElementText(root_h,"methodName");
m_method_name = loader.postGetSubElementText(root_h,"methodName");
// parse the parameters
Element params = root_h.getSubElement("params");
@@ -91,11 +91,11 @@ public class XmlRpcRequest
// save the method parameters
if (tmp_method_params.isEmpty())
method_params = Collections.EMPTY_LIST;
m_method_params = Collections.EMPTY_LIST;
else
{ // make it read-only before
tmp_method_params.trimToSize();
method_params = Collections.unmodifiableList(tmp_method_params);
m_method_params = Collections.unmodifiableList(tmp_method_params);
} // end else
@@ -106,15 +106,15 @@ public class XmlRpcRequest
} // end catch
this.req = req; // save reference off
m_req = req; // save reference off
} // end constructor
XmlRpcRequest(RequestInput req, String method_name, List method_params)
{
this.req = req;
this.method_name = method_name;
this.method_params = method_params;
m_req = req;
m_method_name = method_name;
m_method_params = method_params;
} // end constructor
@@ -226,7 +226,7 @@ public class XmlRpcRequest
try
{ // use a GregorianCalendar to convert the fields into the appropriate format
GregorianCalendar cal = new GregorianCalendar(utc);
GregorianCalendar cal = new GregorianCalendar(s_utc);
cal.set(Calendar.YEAR,Integer.parseInt(dstr.substring(0,4)));
cal.set(Calendar.MONTH,Integer.parseInt(dstr.substring(4,6)) - 1 + Calendar.JANUARY);
cal.set(Calendar.DAY_OF_MONTH,Integer.parseInt(dstr.substring(6,8)));
@@ -396,31 +396,31 @@ public class XmlRpcRequest
public final String getMethod()
{
return method_name;
return m_method_name;
} // end getMethod
public final int getParamCount()
{
return method_params.size();
return m_method_params.size();
} // end getParamCount
public final List getParams()
{
return method_params;
return m_method_params;
} // end getParams
public final Object getParam(int ndx)
{
return method_params.get(ndx);
return m_method_params.get(ndx);
} // end getParam
public final String getParamType(int ndx)
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if (foo instanceof Integer)
return "int";
if (foo instanceof Boolean)
@@ -429,7 +429,7 @@ public class XmlRpcRequest
return "string";
if (foo instanceof Double)
return "double";
if (foo instanceof Date)
if (foo instanceof java.util.Date)
return "dateTime";
if (foo instanceof byte[])
return "base64";
@@ -443,7 +443,7 @@ public class XmlRpcRequest
public final int getParamInt(int ndx) throws XmlRpcFault
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if (foo instanceof Integer)
return ((Integer)foo).intValue();
else if (foo instanceof Boolean)
@@ -455,11 +455,11 @@ public class XmlRpcRequest
public final double getParamDouble(int ndx) throws XmlRpcFault
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if ((foo instanceof Integer) || (foo instanceof Double))
return ((Number)foo).doubleValue();
else if (foo instanceof Boolean)
return ((Boolean)foo).booleanValue() ? 1 : 0;
return ((Boolean)foo).booleanValue() ? 1.0 : 0.0;
else
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
@@ -467,7 +467,7 @@ public class XmlRpcRequest
public final String getParamString(int ndx) throws XmlRpcFault
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
@@ -475,22 +475,43 @@ public class XmlRpcRequest
} // end getParamString
public final java.sql.Date getParamSQLDate(int ndx) throws XmlRpcFault
{
Object foo = m_method_params.get(ndx);
if (!(foo instanceof java.util.Date))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
// need to crosswise convert this
Calendar cal_src = new GregorianCalendar(s_utc);
cal_src.setTime((java.util.Date)foo);
Calendar cal_dest = Calendar.getInstance();
cal_dest.set(Calendar.YEAR,cal_src.get(Calendar.YEAR));
cal_dest.set(Calendar.MONTH,cal_src.get(Calendar.MONTH));
cal_dest.set(Calendar.DAY_OF_MONTH,cal_src.get(Calendar.DAY_OF_MONTH));
cal_dest.set(Calendar.HOUR,0);
cal_dest.set(Calendar.MINUTE,0);
cal_dest.set(Calendar.SECOND,0);
cal_dest.set(Calendar.MILLISECOND,0);
return new java.sql.Date(cal_dest.getTimeInMillis());
} // end getParamSQLDate
public final CommunityContext getParamCommunity(int ndx) throws XmlRpcFault, DataException
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
if (foo instanceof Integer)
return req.getUser().getCommunityContext(((Integer)foo).intValue());
return m_req.getUser().getCommunityContext(((Integer)foo).intValue());
else
return req.getUser().getCommunityContext(foo.toString().trim());
return m_req.getUser().getCommunityContext(foo.toString().trim());
} // end getParamCommunity
public final ConferenceContext getParamConference(int ndx, CommunityContext comm)
throws XmlRpcFault, DataException, AccessError
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
if (foo instanceof Integer)
@@ -503,7 +524,7 @@ public class XmlRpcRequest
public final TopicContext getParamTopic(int ndx, ConferenceContext conf)
throws XmlRpcFault, DataException, AccessError
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if (!(foo instanceof Integer))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
return conf.getTopic(((Integer)foo).shortValue());
@@ -513,7 +534,7 @@ public class XmlRpcRequest
public final TopicMessageContext getParamPost(int ndx, TopicContext topic)
throws XmlRpcFault, DataException, AccessError
{
Object foo = method_params.get(ndx);
Object foo = m_method_params.get(ndx);
if (!(foo instanceof Integer))
throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
return topic.getMessage(((Integer)foo).intValue());