diff --git a/etc/ui-config.xml b/etc/ui-config.xml
index 68b943b..5d0d738 100644
--- a/etc/ui-config.xml
+++ b/etc/ui-config.xml
@@ -276,19 +276,58 @@
+
+ 60
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/rpcscripts/conf/conference.js b/rpcscripts/conf/conference.js
new file mode 100644
index 0000000..997af46
--- /dev/null
+++ b/rpcscripts/conf/conference.js
@@ -0,0 +1,59 @@
+// 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 .
+//
+// 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 ,
+// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+//
+// Contributor(s):
+
+// Implements the conferencing topic API
+
+importPackage(java.util);
+importPackage(Packages.com.silverwrist.venice.core);
+importPackage(Packages.com.silverwrist.venice.ui.rpc);
+
+rinput = bsf.lookupBean("request");
+xreq = bsf.lookupBean("xmlrpc");
+env = bsf.lookupBean("environment");
+call_name = env.get("call");
+
+// All methods have at least three parameters: session, community, conference.
+if (xreq.paramCount<3)
+{ // not enough parameters
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ vlib.done();
+
+} // end if
+
+comm = xreq.getParamCommunity(1);
+conf = xreq.getParamConference(2,comm);
+
+if ("name"==call_name)
+{ // venice:conferencing.conference.name []
+ // Retrieves or sets the conference name.
+ if (xreq.paramCount==3)
+ vlib.output(conf.name);
+ else if (xreq.paramCount==4)
+ { // set the name
+ name = xreq.getParamString(3);
+ conf.name = name;
+ vlib.output(name); // output the new name on success
+
+ } // end else if
+ else // wrong parameter count
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+
+ vlib.done();
+
+} // end if
+
+// just in case there's a method name that wasn't listed
+vlib.output(new XmlRpcFault(XmlRpcFault.METHOD_NOT_FOUND,"invalid method name: " + xreq.method));
diff --git a/rpcscripts/conf/message.js b/rpcscripts/conf/message.js
new file mode 100644
index 0000000..617b4c3
--- /dev/null
+++ b/rpcscripts/conf/message.js
@@ -0,0 +1,60 @@
+// 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 .
+//
+// 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 ,
+// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+//
+// Contributor(s):
+
+// Implements the conferencing message API
+
+importPackage(java.util);
+importPackage(Packages.com.silverwrist.venice.core);
+importPackage(Packages.com.silverwrist.venice.ui.rpc);
+
+rinput = bsf.lookupBean("request");
+xreq = bsf.lookupBean("xmlrpc");
+env = bsf.lookupBean("environment");
+call_name = env.get("call");
+
+// All methods have at least five parameters: session, community, conference, topic, message.
+if (xreq.paramCount<5)
+{ // not enough parameters
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ vlib.done();
+
+} // end if
+
+comm = xreq.getParamCommunity(1);
+conf = xreq.getParamConference(2,comm);
+topic = xreq.getParamTopic(3,conf);
+msg = xreq.getParamPost(4,topic);
+
+if ("attach"==call_name)
+{ // venice:conferencing.message.attach
+ //
+ if (xreq.paramCount!=8)
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ else if ("base64"!=xreq.getParamType(7))
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"data parameter type mismatch"));
+ else
+ { // attach the data and return
+ msg.attachData(xreq.getParamString(5),xreq.getParamString(6),vlib.castByteArray(xreq.getParam(7)));
+ vlib.output(vlib.booleanObject(true));
+
+ } // end else
+
+ vlib.done();
+
+} // end if
+
+// just in case there's a method name that wasn't listed
+vlib.output(new XmlRpcFault(XmlRpcFault.METHOD_NOT_FOUND,"invalid method name: " + xreq.method));
diff --git a/rpcscripts/conf/topic.js b/rpcscripts/conf/topic.js
new file mode 100644
index 0000000..4cf792b
--- /dev/null
+++ b/rpcscripts/conf/topic.js
@@ -0,0 +1,57 @@
+// 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 .
+//
+// 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 ,
+// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+//
+// Contributor(s):
+
+// Implements the conferencing topic API
+
+importPackage(java.util);
+importPackage(Packages.com.silverwrist.venice.core);
+importPackage(Packages.com.silverwrist.venice.ui.rpc);
+
+rinput = bsf.lookupBean("request");
+xreq = bsf.lookupBean("xmlrpc");
+env = bsf.lookupBean("environment");
+call_name = env.get("call");
+
+// All methods have at least four parameters: session, community, conference, topic.
+if (xreq.paramCount<4)
+{ // not enough parameters
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ vlib.done();
+
+} // end if
+
+comm = xreq.getParamCommunity(1);
+conf = xreq.getParamConference(2,comm);
+topic = xreq.getParamTopic(3,conf);
+
+if ("postMessage"==call_name)
+{ // venice:conferencing.topic.postMessage
+ // Posts a message, returns the message number within the topic
+ if (xreq.paramCount!=6)
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ else
+ { // post the message
+ msg = topic.postNewMessage(0,xreq.getParamString(4),xreq.getParamString(5));
+ vlib.output(vlib.createInteger(msg.postNumber));
+
+ } // end else
+
+ vlib.done();
+
+} // end if
+
+// just in case there's a method name that wasn't listed
+vlib.output(new XmlRpcFault(XmlRpcFault.METHOD_NOT_FOUND,"invalid method name: " + xreq.method));
diff --git a/rpcscripts/session.js b/rpcscripts/session.js
new file mode 100644
index 0000000..efeda16
--- /dev/null
+++ b/rpcscripts/session.js
@@ -0,0 +1,66 @@
+// 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 .
+//
+// 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 ,
+// for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+// Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+//
+// Contributor(s):
+
+// Implements the session API
+
+importPackage(java.util);
+importPackage(Packages.com.silverwrist.venice.core);
+importPackage(Packages.com.silverwrist.venice.ui.rpc);
+
+rinput = bsf.lookupBean("request");
+xreq = bsf.lookupBean("xmlrpc");
+env = bsf.lookupBean("environment");
+call_name = env.get("call");
+//logger.debug("call selector = " + call_name);
+
+if ("destroy"==call_name)
+{ // venice:session.destroy - destroys a session
+ if (xreq.paramCount!=1)
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ else
+ { // end the session
+ rinput.endSession();
+ vlib.output(vlib.booleanObject(true));
+
+ } // end else
+
+ vlib.done();
+
+} // end if
+
+if ("login"==call_name)
+{ // venice:session.login - logs in the session
+ if (xreq.paramCount!=3)
+ vlib.output(new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter count mismatch"));
+ else
+ { // get the user name and password and log in
+ username = xreq.getParamString(1);
+ password = xreq.getParamString(2);
+
+ if (rinput.user.isLoggedIn())
+ vlib.output(new XmlRpcFault(XmlRpcFault.DEFAULT_ERROR,"user already logged in"));
+ else
+ rinput.user.authenticate(username,password);
+ vlib.output(vlib.booleanObject(true));
+
+ } // end else
+
+ vlib.done();
+
+} // end if
+
+// just in case there's a method name that wasn't listed
+vlib.output(new XmlRpcFault(XmlRpcFault.METHOD_NOT_FOUND,"invalid method name: " + xreq.method));
diff --git a/src/com/silverwrist/venice/core/TopicMessageContext.java b/src/com/silverwrist/venice/core/TopicMessageContext.java
index 70e6838..faf8a16 100644
--- a/src/com/silverwrist/venice/core/TopicMessageContext.java
+++ b/src/com/silverwrist/venice/core/TopicMessageContext.java
@@ -75,6 +75,8 @@ public interface TopicMessageContext
public abstract void attachData(String m_type, String file, int length, InputStream data)
throws AccessError, DataException;
+ public abstract void attachData(String m_type, String file, byte[] data) throws AccessError, DataException;
+
public abstract boolean canPublish();
public abstract void publish() throws DataException, AccessError;
diff --git a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java
index 447082d..e60b647 100644
--- a/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java
+++ b/src/com/silverwrist/venice/core/impl/TopicMessageUserContextImpl.java
@@ -923,6 +923,12 @@ class TopicMessageUserContextImpl implements TopicMessageContext
} // end attachData
+ public void attachData(String m_type, String file, byte[] data) throws AccessError, DataException
+ {
+ attachData(m_type,file,data.length,new ByteArrayInputStream(data));
+
+ } // end attachData
+
public boolean canPublish()
{
if (!(env.testPermission(EnvUser.PERM_PUBLISH_FP)))
diff --git a/src/com/silverwrist/venice/except/AccessError.java b/src/com/silverwrist/venice/except/AccessError.java
index 317c3c5..c061432 100644
--- a/src/com/silverwrist/venice/except/AccessError.java
+++ b/src/com/silverwrist/venice/except/AccessError.java
@@ -11,7 +11,7 @@
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -19,6 +19,18 @@ package com.silverwrist.venice.except;
public class AccessError extends VeniceException
{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final int FAULTCODE_BASE = 20000;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
public AccessError()
{
super();
@@ -43,4 +55,15 @@ public class AccessError extends VeniceException
} // end constructor
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceException
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getFaultCode()
+ {
+ return FAULTCODE_BASE;
+
+ } // end getFaultCode
+
} // end class AccessError
diff --git a/src/com/silverwrist/venice/except/DataException.java b/src/com/silverwrist/venice/except/DataException.java
index 46d5ae1..f7c5676 100644
--- a/src/com/silverwrist/venice/except/DataException.java
+++ b/src/com/silverwrist/venice/except/DataException.java
@@ -11,7 +11,7 @@
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -19,6 +19,18 @@ package com.silverwrist.venice.except;
public class DataException extends VeniceException
{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final int FAULTCODE_BASE = 10000;
+
+ /*--------------------------------------------------------------------------------
+ * Constructors
+ *--------------------------------------------------------------------------------
+ */
+
public DataException()
{
super();
@@ -43,4 +55,15 @@ public class DataException extends VeniceException
} // end constructor
+ /*--------------------------------------------------------------------------------
+ * Overrides from class VeniceException
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getFaultCode()
+ {
+ return FAULTCODE_BASE;
+
+ } // end getFaultCode
+
} // end class DataException
diff --git a/src/com/silverwrist/venice/except/SupplyFaultCode.java b/src/com/silverwrist/venice/except/SupplyFaultCode.java
new file mode 100644
index 0000000..b287205
--- /dev/null
+++ b/src/com/silverwrist/venice/except/SupplyFaultCode.java
@@ -0,0 +1,24 @@
+/*
+ * 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 .
+ *
+ * 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 ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.venice.except;
+
+public interface SupplyFaultCode
+{
+ public abstract int getFaultCode();
+
+} // end interface SupplyFaultCode
diff --git a/src/com/silverwrist/venice/except/VeniceException.java b/src/com/silverwrist/venice/except/VeniceException.java
index 9d5bdb2..3d96ec5 100644
--- a/src/com/silverwrist/venice/except/VeniceException.java
+++ b/src/com/silverwrist/venice/except/VeniceException.java
@@ -11,7 +11,7 @@
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -27,7 +27,7 @@ import java.io.PrintWriter;
* @author Eric J. Bowersox <erbo@silcom.com>
* @version X
*/
-public class VeniceException extends Exception
+public class VeniceException extends Exception implements SupplyFaultCode
{
/*--------------------------------------------------------------------------------
* Attributes
@@ -139,6 +139,17 @@ public class VeniceException extends Exception
} // end printStackTrace
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface SupplyFaultCode
+ *--------------------------------------------------------------------------------
+ */
+
+ public int getFaultCode()
+ {
+ return 0;
+
+ } // end getFaultCode
+
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
diff --git a/src/com/silverwrist/venice/ui/RequestInput.java b/src/com/silverwrist/venice/ui/RequestInput.java
index 5f12199..daa8c46 100644
--- a/src/com/silverwrist/venice/ui/RequestInput.java
+++ b/src/com/silverwrist/venice/ui/RequestInput.java
@@ -188,4 +188,8 @@ public interface RequestInput extends LinkTypes
public abstract void registerCleanup(AutoCleanup ac);
+ public abstract void pushSession(VeniceUISession sess);
+
+ public abstract void popSession();
+
} // end interface RequestInput
diff --git a/src/com/silverwrist/venice/ui/config/RootConfig.java b/src/com/silverwrist/venice/ui/config/RootConfig.java
index 1c6738a..a790b24 100644
--- a/src/com/silverwrist/venice/ui/config/RootConfig.java
+++ b/src/com/silverwrist/venice/ui/config/RootConfig.java
@@ -81,6 +81,7 @@ public class RootConfig implements LinkTypes, ColorSelectors
private ButtonHolder buttons; // the button definitions
private String[] content_hdr; // the content header parts
private Remapper remapper; // the URL remapper
+ private int rpc_timeout = 60; // RPC session timeout
private List xmlrpc_methods; // the list of XML-RPC methods
private StockMessages stock_messages; // the stock messages
private Map menus; // the menus
@@ -391,6 +392,18 @@ public class RootConfig implements LinkTypes, ColorSelectors
sect = loader.configGetSubSection(root_h,"rpc");
sect_h = new DOMElementHelper(sect);
+ // Get the figure.
+ if (sect_h.hasChildElement("session-timeout"))
+ { // get the timeout value
+ Integer xtmp = sect_h.getSubElementInt("session-timeout");
+ if (xtmp==null)
+ throw new ConfigException(" value is not an integer",sect);
+ rpc_timeout = xtmp.intValue();
+ if (rpc_timeout<=0)
+ throw new ConfigException(" value is invalid",sect);
+
+ } // end if
+
// Get the section.
sect1 = loader.configGetSubSection(sect_h,"xmlrpc-methods");
nl = sect1.getChildNodes();
@@ -773,6 +786,12 @@ public class RootConfig implements LinkTypes, ColorSelectors
} // end getDefaultServletAddress
+ public final int getRpcSessionTimeout()
+ {
+ return rpc_timeout;
+
+ } // end getRpcSessionTimeout
+
public final List getXmlRpcMethods()
{
return xmlrpc_methods;
diff --git a/src/com/silverwrist/venice/ui/rpc/RpcSessionBroker.java b/src/com/silverwrist/venice/ui/rpc/RpcSessionBroker.java
new file mode 100644
index 0000000..5ddbdfa
--- /dev/null
+++ b/src/com/silverwrist/venice/ui/rpc/RpcSessionBroker.java
@@ -0,0 +1,203 @@
+/*
+ * 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 .
+ *
+ * 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 ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.venice.ui.rpc;
+
+import java.util.*;
+import javax.servlet.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.except.*;
+import com.silverwrist.venice.ui.*;
+import com.silverwrist.venice.ui.config.RootConfig;
+import com.silverwrist.venice.ui.servlet.RequestImpl;
+
+class RpcSessionBroker
+{
+ /*--------------------------------------------------------------------------------
+ * Internal class for sweeping the sessions
+ *--------------------------------------------------------------------------------
+ */
+
+ class SessionSweeper extends TimerTask
+ {
+ private LinkedList workspace = new LinkedList();
+
+ SessionSweeper()
+ {
+ super();
+
+ } // end constructor
+
+ public void run()
+ {
+ synchronized (RpcSessionBroker.this)
+ { // seek and destroy all expired sessions
+ Iterator it = sessions.values().iterator();
+ while (it.hasNext())
+ { // find all the tasks that are due to be invalidated
+ RpcVeniceUISession s = (RpcVeniceUISession)(it.next());
+ if (s.canUnloadNow())
+ workspace.addLast(s);
+
+ } // end while
+
+ while (workspace.size()>0)
+ { // invalidate all sessions that have not been accessed recently
+ RpcVeniceUISession s = (RpcVeniceUISession)(workspace.removeFirst());
+ if (logger.isDebugEnabled())
+ logger.debug("session sweeper removing session with ID " + s.getID());
+ s.invalidate();
+
+ } // end while
+
+ } // end synchronized block
+
+ } // end run
+
+ } // end class SessionSweeper
+
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(RpcSessionBroker.class);
+
+ private static final String ATTRIBUTE = "ui.rpc.SessionBroker";
+
+ private static final long INTERVAL = 1000;
+
+ private static final String PREFIX = "rpcsess:";
+ private static final String ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";
+ private static final int ID_LENGTH = 40;
+
+ private static Random rng = new Random(); // random number generator
+
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private HashMap sessions = new HashMap(); // the actual sessions
+ private VeniceEngine engine; // the Venice engine
+ private int timeout_value; // the timeout value
+ private Timer timer = new Timer(true); // the interval timer used to schedule sweeps
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ private RpcSessionBroker(VeniceEngine engine, RootConfig root)
+ {
+ this.engine = engine;
+ this.timeout_value = root.getRpcSessionTimeout();
+ timer.scheduleAtFixedRate(new SessionSweeper(),INTERVAL,INTERVAL);
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Internal operations
+ *--------------------------------------------------------------------------------
+ */
+
+ private static final String generateID()
+ {
+ StringBuffer buf = new StringBuffer(PREFIX);
+ for (int i=0; i.
+ *
+ * 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 ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.venice.ui.rpc;
+
+import java.util.*;
+import com.silverwrist.venice.core.*;
+import com.silverwrist.venice.except.*;
+import com.silverwrist.venice.ui.*;
+
+class RpcVeniceUISession implements VeniceUISession
+{
+ /*--------------------------------------------------------------------------------
+ * Attributes
+ *--------------------------------------------------------------------------------
+ */
+
+ private RpcSessionBroker broker; // session broker
+ private long create_time; // session creation time
+ private long access_time; // session last access time
+ private String id; // the session ID
+ private String remote_addr; // the remote address
+ private int max_inactive; // the maximum inactive interval
+ private HashMap attrs = new HashMap(); // storage for attributes
+ private UserContext user; // user context in this session
+
+ /*--------------------------------------------------------------------------------
+ * Constructor
+ *--------------------------------------------------------------------------------
+ */
+
+ RpcVeniceUISession(String id, String remote_addr, RpcSessionBroker broker) throws DataException
+ {
+ this.broker = broker;
+ this.id = id;
+ this.remote_addr = remote_addr;
+ this.max_inactive = broker.getTimeout() * 60;
+ this.user = broker.getEngine().createUserContext(remote_addr);
+ this.create_time = this.access_time = System.currentTimeMillis();
+
+ } // end constructor
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface VeniceUISession
+ *--------------------------------------------------------------------------------
+ */
+
+ public long getCreationTime()
+ {
+ return create_time;
+
+ } // end getCreationTime
+
+ public String getID()
+ {
+ return id;
+
+ } // end getID
+
+ public long getLastAccessedTime()
+ {
+ return access_time;
+
+ } // end getLastAccessedTime
+
+ public synchronized void setMaxInactiveInterval(int interval)
+ {
+ max_inactive = interval;
+ touch();
+
+ } // end setMaxInactiveInterval
+
+ public int getMaxInactiveInterval()
+ {
+ return max_inactive;
+
+ } // end getMaxInactiveInterval
+
+ public Object getAttribute(String name)
+ {
+ return attrs.get(name);
+
+ } // end getAttribute
+
+ public Enumeration getAttributeNames()
+ {
+ return Collections.enumeration(attrs.keySet());
+
+ } // end getAttributeNames
+
+ public synchronized void setAttribute(String name, Object o)
+ {
+ attrs.put(name,o);
+ touch();
+
+ } // end setAttribute
+
+ public synchronized void removeAttribute(String name)
+ {
+ attrs.remove(name);
+ touch();
+
+ } // end removeAttribute
+
+ public synchronized void invalidate()
+ {
+ broker.detachSession(id);
+ broker = null;
+ attrs.clear();
+
+ } // end invalidate
+
+ public UserContext getUser()
+ {
+ return user;
+
+ } // end getUser
+
+ public synchronized void setUser(UserContext user)
+ {
+ this.user = user;
+ touch();
+
+ } // end setUser
+
+ public void preprocess(RequestInput ri)
+ { // do nothing
+ } // end preprocess
+
+ /*--------------------------------------------------------------------------------
+ * External operations
+ *--------------------------------------------------------------------------------
+ */
+
+ final synchronized boolean canUnloadNow()
+ {
+ return ((System.currentTimeMillis() - access_time) > ((long)1000 * max_inactive));
+
+ } // end canUnloadNow
+
+ final synchronized void touch()
+ {
+ access_time = System.currentTimeMillis();
+
+ } // end touch
+
+} // end class RpcVeniceUISession
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcCreateSession.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcCreateSession.java
new file mode 100644
index 0000000..0858a43
--- /dev/null
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcCreateSession.java
@@ -0,0 +1,50 @@
+/*
+ * 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 .
+ *
+ * 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 ,
+ * for Silverwrist Design Studios. Portions created by Eric J. Bowersox are
+ * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
+ *
+ * Contributor(s):
+ */
+package com.silverwrist.venice.ui.rpc;
+
+import java.util.*;
+import org.apache.log4j.*;
+import com.silverwrist.venice.ui.*;
+
+public class XmlRpcCreateSession implements XmlRpcDispatch
+{
+ /*--------------------------------------------------------------------------------
+ * Static data members
+ *--------------------------------------------------------------------------------
+ */
+
+ private static Category logger = Category.getInstance(XmlRpcCreateSession.class);
+
+ /*--------------------------------------------------------------------------------
+ * Implementations from interface XmlRpcDispatch
+ *--------------------------------------------------------------------------------
+ */
+
+ public Object dispatch(RequestInput req, XmlRpcRequest xreq, Map environment) throws Exception, XmlRpcFault
+ {
+ if (logger.isDebugEnabled())
+ logger.debug("Dispatching a Create Session call");
+ VeniceUISession session = RpcSessionBroker.get(req).createSession(req.getSourceAddress());
+ if (logger.isDebugEnabled())
+ logger.debug("Created new session with ID " + session.getID());
+ return session.getID();
+
+ } // end dispatch
+
+} // end class XmlRpcSession
+
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcFault.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcFault.java
index 2da3e61..00cd70a 100644
--- a/src/com/silverwrist/venice/ui/rpc/XmlRpcFault.java
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcFault.java
@@ -19,6 +19,7 @@ package com.silverwrist.venice.ui.rpc;
import java.io.IOException;
import com.silverwrist.util.StringUtil;
+import com.silverwrist.venice.except.SupplyFaultCode;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.ui.helpers.ThrowableContent;
@@ -67,6 +68,12 @@ public class XmlRpcFault extends ThrowableContent implements ContentExecute
public XmlRpcFault(Throwable t)
{
super(t);
+ if (t instanceof SupplyFaultCode)
+ { // retrieve the fault code
+ SupplyFaultCode sfc = (SupplyFaultCode)t;
+ fault_code = sfc.getFaultCode();
+
+ } // end if
} // end constructor
@@ -80,6 +87,12 @@ public class XmlRpcFault extends ThrowableContent implements ContentExecute
public XmlRpcFault(String msg, Throwable t)
{
super(msg,t);
+ if (t instanceof SupplyFaultCode)
+ { // retrieve the fault code
+ SupplyFaultCode sfc = (SupplyFaultCode)t;
+ fault_code = sfc.getFaultCode();
+
+ } // end if
} // end constructor
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcMethod.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcMethod.java
index d43def4..a9c5b2b 100644
--- a/src/com/silverwrist/venice/ui/rpc/XmlRpcMethod.java
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcMethod.java
@@ -49,6 +49,7 @@ public class XmlRpcMethod
private Class obj_class = null; // "class" handler for object
private String script_name = null; // script name to use as a handler
private Map raw_env; // "raw" environment
+ private int session_param = -1; // session parameter
/*--------------------------------------------------------------------------------
* Constructor
@@ -119,7 +120,15 @@ public class XmlRpcMethod
else // no handler - this is an error
throw new ConfigException("method \"" + method_name + "\" does not have a valid handler",cfg);
- NodeList nl = sub.getChildNodes();
+ if ((sub = cfg_h.getSubElement("session"))!=null)
+ { // find the session parameter index
+ session_param = loader.configGetAttributeInt(sub,"param");
+ if (session_param<0)
+ throw new ConfigException("invalid session parameter index",sub);
+
+ } // end if
+
+ NodeList nl = cfg.getChildNodes();
HashMap tmp_env = new HashMap();
for (int i=0; i=xreq.getParamCount())
+ { // too few parameters - bail out!
+ logger.error("session parameter is at index " + session_param + " but only " + xreq.getParamCount()
+ + " parameter(s) present");
+ throw new XmlRpcFault(XmlRpcFault.SERVER_ERROR,"invalid parameter index for session binding");
+
+ } // end if
+
+ String session_id = xreq.getParamString(session_param).trim();
+ if (logger.isDebugEnabled())
+ logger.debug("Passed session ID = " + session_id);
+ VeniceUISession vuis = RpcSessionBroker.get(req).getSession(session_id);
+ if (vuis==null)
+ { // the session cannot be acquired
+ logger.debug("Cannot get session for session ID " + session_id);
+ throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"session not found");
+
+ } // end if
+
+ req.pushSession(vuis); // push the session into the request
+
+ } // end bindSession
+
/*--------------------------------------------------------------------------------
* External operations
*--------------------------------------------------------------------------------
@@ -181,7 +222,20 @@ public class XmlRpcMethod
} // end if
- return disp.dispatch(req,xreq,env); // dispatch the call
+ if (session_param>=0)
+ bindSession(req,xreq);
+
+ try
+ { // dispatch the call
+ return disp.dispatch(req,xreq,env);
+
+ } // end try
+ finally
+ { // pop the session we pushed
+ if (session_param>=0)
+ req.popSession();
+
+ } // end finally
} // end if
@@ -193,19 +247,36 @@ public class XmlRpcMethod
logger.debug("EXECUTING " + full_name);
try
{ // execute the script!
+ if (session_param>=0)
+ bindSession(req,xreq);
+
ScriptManager smgr = req.getScriptManager();
smgr.pushContext();
smgr.register("xmlrpc",xreq);
smgr.register("environment",env);
- ScriptReturn sro = new ScriptReturn();
- smgr.exec(new File(full_name),logger_name,sro);
- smgr.popContext();
- return sro.get();
+ try
+ { // execute the script
+ ScriptReturn sro = new ScriptReturn();
+ smgr.exec(new File(full_name),logger_name,sro);
+ return sro.get();
+
+ } // end try
+ finally
+ { // make sure and pop the context before we return
+ smgr.popContext();
+ if (session_param>=0)
+ req.popSession();
+
+ } // end finally
} // end try
catch (ScriptingException se)
{ // script error! we are not amused...
- return new XmlRpcFault(XmlRpcFault.APPLICATION_ERROR,"scripting error: " + se.toString());
+ Throwable t = se.getException();
+ if (t instanceof SupplyFaultCode)
+ return new XmlRpcFault(t);
+ else
+ return new XmlRpcFault(XmlRpcFault.APPLICATION_ERROR,"scripting error: " + se.toString());
} // end catch
catch (ThrowableContent tc)
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcMulticall.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcMulticall.java
index f919df1..e6ed55d 100644
--- a/src/com/silverwrist/venice/ui/rpc/XmlRpcMulticall.java
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcMulticall.java
@@ -99,7 +99,7 @@ public class XmlRpcMulticall implements XmlRpcDispatch
while (it.hasNext())
{ // parse out a request and dispatch it
try
- { // parse the request
+ { // parse the request, execute it, and add its result to the return array
XmlRpcRequest sub_xreq = parseRequest(req,it.next());
Object sub_rc = XmlRpcServlet.dispatchMethodCall(req,sub_xreq);
if (sub_rc instanceof XmlRpcFault)
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java
index a6ce536..27b4284 100644
--- a/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java
@@ -24,6 +24,7 @@ import javax.mail.internet.*;
import org.apache.log4j.*;
import org.w3c.dom.*;
import com.silverwrist.util.*;
+import com.silverwrist.venice.core.*;
import com.silverwrist.venice.except.*;
import com.silverwrist.venice.ui.*;
import com.silverwrist.venice.util.XMLLoader;
@@ -59,8 +60,7 @@ public class XmlRpcRequest
throw new XmlRpcFault(XmlRpcFault.INVALID_REQUEST,"no XML call structure found");
try
- {
- // load the initial structure and method name
+ { // load the initial structure and method name
XMLLoader loader = XMLLoader.get();
Element root = loader.postGetRootElement(req_doc,"methodCall");
DOMElementHelper root_h = new DOMElementHelper(root);
@@ -475,4 +475,49 @@ public class XmlRpcRequest
} // end getParamString
+ public final CommunityContext getParamCommunity(int ndx) throws XmlRpcFault, DataException
+ {
+ Object foo = 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());
+ else
+ return 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);
+ 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 comm.getConferenceContext(((Integer)foo).intValue());
+ else
+ return comm.getConferenceContext(foo.toString().trim());
+
+ } // end getParamConference
+
+ public final TopicContext getParamTopic(int ndx, ConferenceContext conf)
+ throws XmlRpcFault, DataException, AccessError
+ {
+ Object foo = method_params.get(ndx);
+ if (!(foo instanceof Integer))
+ throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
+ return conf.getTopic(((Integer)foo).shortValue());
+
+ } // end getParamTopic
+
+ public final TopicMessageContext getParamPost(int ndx, TopicContext topic)
+ throws XmlRpcFault, DataException, AccessError
+ {
+ Object foo = method_params.get(ndx);
+ if (!(foo instanceof Integer))
+ throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch");
+ return topic.getMessage(((Integer)foo).intValue());
+
+ } // end getParamPost
+
} // end class XmlRpcRequest
diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcServlet.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcServlet.java
index b4926f1..6a63b26 100644
--- a/src/com/silverwrist/venice/ui/rpc/XmlRpcServlet.java
+++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcServlet.java
@@ -21,6 +21,7 @@ import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
+import org.apache.log4j.*;
import org.apache.regexp.*;
import com.silverwrist.util.*;
import com.silverwrist.venice.core.*;
@@ -76,6 +77,8 @@ public class XmlRpcServlet extends BaseServlet
*--------------------------------------------------------------------------------
*/
+ private static Category logger = Category.getInstance(XmlRpcServlet.class);
+
private static final String METHOD_LIST_ATTR = "ui.xmlrpc.MethodList";
public static final String OBJECT_CLASS_CACHE_ATTR = "ui.xmlrpc.class.ObjectCache";
@@ -91,6 +94,7 @@ public class XmlRpcServlet extends BaseServlet
List methods = root.getXmlRpcMethods();
RequestImpl.setAppAttribute(ctxt,METHOD_LIST_ATTR,methods);
RequestImpl.setAppAttribute(ctxt,OBJECT_CLASS_CACHE_ATTR,Collections.synchronizedMap(new HashMap()));
+ RpcSessionBroker.init(ctxt,engine,root);
} // end init
@@ -135,7 +139,10 @@ public class XmlRpcServlet extends BaseServlet
static Object dispatchMethodCall(RequestInput req, XmlRpcRequest xreq)
{
- // Prepare the parameters map
+ if (logger.isDebugEnabled())
+ logger.debug("XML-RPC Method Call: " + xreq.getMethod());
+
+ // Prepare the parameters map.
int i;
HashMap param_repl_map = new HashMap();
for (i=0; i,
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -31,6 +31,20 @@ public class ScriptLibrary
*--------------------------------------------------------------------------------
*/
+ public final Boolean booleanObject(boolean b)
+ {
+ return (b ? Boolean.TRUE : Boolean.FALSE);
+
+ } // end booleanObject
+
+ public final byte[] castByteArray(Object o)
+ {
+ if (o instanceof byte[])
+ return (byte[])o;
+ throw new ClassCastException("ScriptLibrary.castByteArray: invalid cast");
+
+ } // end castByteArray
+
public final ConferenceContext castConferenceContext(Object o)
{
if (o instanceof ConferenceContext)
diff --git a/src/com/silverwrist/venice/ui/script/ScriptManager.java b/src/com/silverwrist/venice/ui/script/ScriptManager.java
index 3c7fb3b..b3754b6 100644
--- a/src/com/silverwrist/venice/ui/script/ScriptManager.java
+++ b/src/com/silverwrist/venice/ui/script/ScriptManager.java
@@ -11,7 +11,7 @@
*
* The Initial Developer of the Original Code is Eric J. Bowersox ,
* 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-02 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved.
*
* Contributor(s):
*/
@@ -264,8 +264,12 @@ public class ScriptManager
{ // throw a ScriptingException
logger.error("Execution exception while running script",t);
if (t!=null)
+ { // throw THIS exception
+ logger.error("Exception type: " + t.getClass().getName());
throw new ScriptingException(source,lang,e.getMessage(),t);
- else
+
+ } // end if
+ else // throw the regular old name
throw new ScriptingException(source,lang,e.getMessage(),e);
} // end if
@@ -273,15 +277,20 @@ public class ScriptManager
{ // usually indicates a compiler error in the scripting engine
logger.error("Script compilation error",e);
if (t!=null)
- logger.error("Root cause:",t);
- throw new ScriptingException(source,lang,e.getMessage());
+ { // throw THIS exception
+ logger.error("Exception type: " + t.getClass().getName());
+ throw new ScriptingException(source,lang,e.getMessage(),t);
+
+ } // end if
+ else // throw the regular old name
+ throw new ScriptingException(source,lang,e.getMessage(),e);
} // end else if
else
{ // unknown exception type here!
logger.error("Unknown BSFException in script execution (reason " + e.getReason() + ")",e);
if (t!=null)
- logger.error("Root cause:",t);
+ logger.error("Root cause (type " + t.getClass().getName() + "):",t);
throw new ScriptingException("unexpected exception while executing " + source + " [" + lang + "]",e);
} // end else
diff --git a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java
index f937cf8..c35ceaf 100644
--- a/src/com/silverwrist/venice/ui/servlet/RequestImpl.java
+++ b/src/com/silverwrist/venice/ui/servlet/RequestImpl.java
@@ -583,6 +583,7 @@ public class RequestImpl implements RequestInput
private CommunityContext community = null; // the current community
private LinkedList auto_cleanup = null; // auto-cleanup callbacks
private Document request_doc = null; // request parsed as an XML document
+ private LinkedList session_stack = null; // session stack
/*--------------------------------------------------------------------------------
* Constructor
@@ -1555,6 +1556,22 @@ public class RequestImpl implements RequestInput
} // end registerCleanup
+ public void pushSession(VeniceUISession sess)
+ {
+ if (session_stack==null)
+ session_stack = new LinkedList();
+ session_stack.addFirst(session);
+ session = sess;
+
+ } // end pushSession
+
+ public void popSession()
+ {
+ if ((session_stack!=null) && (session_stack.size()>0))
+ session = (VeniceUISession)(session_stack.removeFirst());
+
+ } // end popSession
+
/*--------------------------------------------------------------------------------
* External static operations
*--------------------------------------------------------------------------------