From 1c245749f7adc07712b801727c9841a698ba43b2 Mon Sep 17 00:00:00 2001 From: "Eric J. Bowersox" Date: Tue, 20 Jul 2004 07:31:00 +0000 Subject: [PATCH] improved the XML-RPC library support and added a document describing all the current XML-RPC functions --- doc/xmlrpc-functions-reference.sxw | Bin 0 -> 6901 bytes .../venice/ui/rpc/XmlRpcLibrary.java | 110 ++++++++++++++++++ .../venice/ui/rpc/XmlRpcRequest.java | 75 +++++++++++- .../venice/ui/script/ScriptManager.java | 88 +++++++------- 4 files changed, 228 insertions(+), 45 deletions(-) create mode 100644 doc/xmlrpc-functions-reference.sxw create mode 100644 src/com/silverwrist/venice/ui/rpc/XmlRpcLibrary.java diff --git a/doc/xmlrpc-functions-reference.sxw b/doc/xmlrpc-functions-reference.sxw new file mode 100644 index 0000000000000000000000000000000000000000..cfab457586f8b710f9383ad7c4f4a56c18192a96 GIT binary patch literal 6901 zcma)B1z40#*QNzTT1voW2?1eQx|XH8yTJvPWf53n=~%i{6r_=m6eW}pB@HALlypI9 zBm_hn>3`vU@r~>IzU!a8=D8;B`^=g1%(HXmjDa>G5k1~%nv&Q8PnQTwv*XIAnG~1Z zk?wGGpeG#W>FI`agrSir4ZB0_3!CCXEy~{;5W|hTrKTuH=aFK*K%I zr=$O{{_62nilue3Y--8j*~JmFfjZ=UUC1I2h(|$BW9+p6NwA`Js;&u8oa=ID%aZKM zkB=X=HRrGKbsGt2*A%gm$TI43Zpeon>Zj%wU0p4r9;e~pLv(&zz0s){9XM9z7PJz= zj#T(T-nryC^EAb(YKm&%*Yz>Cgym8MFp1DMd`Iwb`D8! z`8Lyo+)A&ts9^k@`ObHHv{0I1axBqHOkROk%UpVUcj4s4XQ`b@cjC~Msmg)8)@qU% zNXR`ZNU*L@4RqY-ps-sJtHphci z1=bcd7e_nP6}{r2qU1>3zIT~iyn?wI9q z8(mkQ+r)X~teZ$1D_-Zy=td=N0-H_RYauSYR3Jy2*0P`&WUjWJ#JM`H#J$}qi#NVbW z8J~qFwO|~0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&HTHuPZ#Q6X`AuCEL#I@Vv7$c N_nx$ICjmUX{{xT-!A1Z8 literal 0 HcmV?d00001 diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcLibrary.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcLibrary.java new file mode 100644 index 0000000..aeaccd7 --- /dev/null +++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcLibrary.java @@ -0,0 +1,110 @@ +/* + * 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) 2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. + * + * Contributor(s): + */ +package com.silverwrist.venice.ui.rpc; + +import java.util.*; +import com.silverwrist.util.*; + +public class XmlRpcLibrary +{ + /*-------------------------------------------------------------------------------- + * Static data members + *-------------------------------------------------------------------------------- + */ + + private static XmlRpcLibrary s_self = null; + + /*-------------------------------------------------------------------------------- + * Constructor + *-------------------------------------------------------------------------------- + */ + + private XmlRpcLibrary() + { // no external access + } // end constructor + + /*-------------------------------------------------------------------------------- + * External operations + *-------------------------------------------------------------------------------- + */ + + public final void setIfNotNull(Map struct, String name, Object value) + { + if (value!=null) + struct.put(name,value); + + } // end setIfNotNull + + public final int structMemberAsInt(Map struct, String name) throws XmlRpcFault + { + Object foo = struct.get(name); + if (foo instanceof Integer) + return ((Integer)foo).intValue(); + else if (foo instanceof Boolean) + return ((Boolean)foo).booleanValue() ? 1 : 0; + else + throw new XmlRpcFault(10000,"type mismatch in structure member \"" + name + "\""); + + } // end structMemberAsInt + + public final String structMemberAsString(Map struct, String name) throws XmlRpcFault + { + Object foo = struct.get(name); + if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map)) + throw new XmlRpcFault(10000,"type mismatch in structure member \"" + name + "\""); + return foo.toString(); + + } // end structMemberAsString + + public final boolean structMemberAsBoolean(Map struct, String name) throws XmlRpcFault + { + Object foo = struct.get(name); + if (foo instanceof Boolean) + return ((Boolean)foo).booleanValue(); + else if (foo instanceof Integer) + return (((Integer)foo).intValue()!=0); + else if (foo instanceof String) + return !StringUtil.isStringEmpty((String)foo); + else + throw new XmlRpcFault(10000,"type mismatch in structure member \"" + name + "\""); + + } // end structMemberAsBoolean + + public final java.util.Date structMemberAsDate(Map struct, String name) throws XmlRpcFault + { + Object foo = struct.get(name); + if (!(foo instanceof java.util.Date)) + throw new XmlRpcFault(10000,"type mismatch in structure member \"" + name + "\""); + return (java.util.Date)foo; + + } // end structMemberAsDate + + /*-------------------------------------------------------------------------------- + * External static operations + *-------------------------------------------------------------------------------- + */ + + public static final XmlRpcLibrary get() + { + if (s_self==null) + s_self = new XmlRpcLibrary(); + return s_self; + + } // end get + +} // end class XmlRpcLibrary diff --git a/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java b/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java index 2a8c241..4d6d8de 100644 --- a/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java +++ b/src/com/silverwrist/venice/ui/rpc/XmlRpcRequest.java @@ -441,6 +441,44 @@ public class XmlRpcRequest } // end getParamType + public final boolean isParamCompatible(int ndx, String type) + { + Object foo = m_method_params.get(ndx); + if (type.equals("int")) + return ((foo instanceof Boolean) || (foo instanceof Integer)); + if (type.equals("boolean")) + return ((foo instanceof Boolean) || (foo instanceof Integer) || (foo instanceof String)); + if (type.equals("string")) + return ( (foo instanceof Boolean) || (foo instanceof Integer) || (foo instanceof Double) + || (foo instanceof String) || (foo instanceof java.util.Date)); + if (type.equals("double")) + return ((foo instanceof Boolean) || (foo instanceof Integer) || (foo instanceof Double)); + if (type.equals("dateTime")) + return (foo instanceof java.util.Date); + if (type.equals("base64")) + return (foo instanceof byte[]); + if (type.equals("struct")) + return (foo instanceof Map); + if (type.equals("array")) + return (foo instanceof List); + return false; + + } // end isParamCompatible + + public final boolean getParamBoolean(int ndx) throws XmlRpcFault + { + Object foo = m_method_params.get(ndx); + if (foo instanceof Boolean) + return ((Boolean)foo).booleanValue(); + else if (foo instanceof Integer) + return (((Integer)foo).intValue()!=0); + else if (foo instanceof String) + return !StringUtil.isStringEmpty((String)foo); + else + throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); + + } // end getParamBoolean + public final int getParamInt(int ndx) throws XmlRpcFault { Object foo = m_method_params.get(ndx); @@ -496,10 +534,42 @@ public class XmlRpcRequest } // end getParamSQLDate + public final Map getParamStruct(int ndx) throws XmlRpcFault + { + Object foo = m_method_params.get(ndx); + if (foo instanceof Map) + return (Map)foo; + throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); + + } // end getParamStruct + + public final List getParamArray(int ndx) throws XmlRpcFault + { + Object foo = m_method_params.get(ndx); + if (foo instanceof List) + return (List)foo; + throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); + + } // end getParamArray + + public final AdminUserContext getParamUser(int ndx, AdminOperations adm) throws XmlRpcFault, DataException + { + Object foo = m_method_params.get(ndx); + if ( (foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean) + || (foo instanceof java.util.Date)) + throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); + if (foo instanceof Number) + return adm.getUserContext(((Number)foo).intValue()); + else + return adm.getUserContext(foo.toString().trim()); + + } // end getParamUser + public final CommunityContext getParamCommunity(int ndx) throws XmlRpcFault, DataException { Object foo = m_method_params.get(ndx); - if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean)) + if ( (foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean) + || (foo instanceof java.util.Date)) throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); if (foo instanceof Integer) return m_req.getUser().getCommunityContext(((Integer)foo).intValue()); @@ -512,7 +582,8 @@ public class XmlRpcRequest throws XmlRpcFault, DataException, AccessError { Object foo = m_method_params.get(ndx); - if ((foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean)) + if ( (foo instanceof byte[]) || (foo instanceof List) || (foo instanceof Map) || (foo instanceof Boolean) + || (foo instanceof java.util.Date)) throw new XmlRpcFault(XmlRpcFault.INVALID_PARAMS,"parameter type mismatch"); if (foo instanceof Integer) return comm.getConferenceContext(((Integer)foo).intValue()); diff --git a/src/com/silverwrist/venice/ui/script/ScriptManager.java b/src/com/silverwrist/venice/ui/script/ScriptManager.java index 084c9d2..95f315f 100644 --- a/src/com/silverwrist/venice/ui/script/ScriptManager.java +++ b/src/com/silverwrist/venice/ui/script/ScriptManager.java @@ -9,7 +9,7 @@ * * The Original Code is the Venice Web Communities System. * - * The Initial Developer of the Original Code is Eric J. Bowersox , + * 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-2004 Eric J. Bowersox/Silverwrist Design Studios. All Rights Reserved. * @@ -25,6 +25,7 @@ import org.apache.log4j.*; import com.silverwrist.util.*; import com.silverwrist.venice.ui.*; import com.silverwrist.venice.ui.helpers.ThrowableContent; +import com.silverwrist.venice.ui.rpc.XmlRpcLibrary; public class ScriptManager { @@ -52,9 +53,9 @@ public class ScriptManager public void output(Object o) { - if (return_stack.size()>0) + if (m_return_stack.size()>0) { // set the return value - ScriptReturn sro = (ScriptReturn)(return_stack.getFirst()); + ScriptReturn sro = (ScriptReturn)(m_return_stack.getFirst()); sro.set(o); } // end if @@ -72,30 +73,30 @@ public class ScriptManager { public void fatal(Object message) { - if (logger_stack.size()>0) - ((Logger)(logger_stack.getFirst())).fatal(message); + if (m_logger_stack.size()>0) + ((Logger)(m_logger_stack.getFirst())).fatal(message); } // end fatal public void error(Object message) { - if (logger_stack.size()>0) - ((Logger)(logger_stack.getFirst())).error(message); + if (m_logger_stack.size()>0) + ((Logger)(m_logger_stack.getFirst())).error(message); } // end error public void warn(Object message) { - if (logger_stack.size()>0) - ((Logger)(logger_stack.getFirst())).warn(message); + if (m_logger_stack.size()>0) + ((Logger)(m_logger_stack.getFirst())).warn(message); } // end warn public void info(Object message) { - if (logger_stack.size()>0) + if (m_logger_stack.size()>0) { // check to make sure info is enabled first - Logger l = (Logger)(logger_stack.getFirst()); + Logger l = (Logger)(m_logger_stack.getFirst()); if (l.isInfoEnabled()) l.info(message); @@ -105,9 +106,9 @@ public class ScriptManager public void debug(Object message) { - if (logger_stack.size()>0) + if (m_logger_stack.size()>0) { // check to make sure debug is enabled first - Logger l = (Logger)(logger_stack.getFirst()); + Logger l = (Logger)(m_logger_stack.getFirst()); if (l.isDebugEnabled()) l.debug(message); @@ -132,10 +133,10 @@ public class ScriptManager *-------------------------------------------------------------------------------- */ - private BSFManager mgr; // Bean Scripting Framework manager - private LinkedList registered_names; // stack of lists of registered names - private LinkedList logger_stack; // stack of loggers for nested evaluation - private LinkedList return_stack; // stack of return values + private BSFManager m_bsf; // Bean Scripting Framework manager + private LinkedList m_registered_names; // stack of lists of registered names + private LinkedList m_logger_stack; // stack of loggers for nested evaluation + private LinkedList m_return_stack; // stack of return values /*-------------------------------------------------------------------------------- * Constructor @@ -154,14 +155,14 @@ public class ScriptManager logger.debug("creating new ScriptManager"); // initialize the BSFManager - mgr = new BSFManager(); - mgr.setTempDir(temp_dir); + m_bsf = new BSFManager(); + m_bsf.setTempDir(temp_dir); if (BSFManager.isLanguageRegistered("javascript")) { // we need to so some fixing up to make Rhino work try { // ensure the engine is loaded, and do our fixup routine - mgr.loadScriptingEngine("javascript"); + m_bsf.loadScriptingEngine("javascript"); fixupRhino(); } // end if @@ -173,8 +174,9 @@ public class ScriptManager try { // declare beans used by the scripting engines - mgr.declareBean("vlib",new MyScriptLibrary(),MyScriptLibrary.class); - mgr.declareBean("logger",new ScriptLogger(),ScriptLogger.class); + m_bsf.declareBean("vlib",new MyScriptLibrary(),MyScriptLibrary.class); + m_bsf.declareBean("logger",new ScriptLogger(),ScriptLogger.class); + m_bsf.declareBean("rpclib",XmlRpcLibrary.get(),XmlRpcLibrary.class); } // end try catch (BSFException e) @@ -185,10 +187,10 @@ public class ScriptManager } // end catch // initialize the rest of the object - registered_names = new LinkedList(); - registered_names.addFirst(new HashSet()); - logger_stack = new LinkedList(); - return_stack = new LinkedList(); + m_registered_names = new LinkedList(); + m_registered_names.addFirst(new HashSet()); + m_logger_stack = new LinkedList(); + m_return_stack = new LinkedList(); } // end constructor @@ -320,9 +322,9 @@ public class ScriptManager public void shutdown() { - mgr.terminate(); - registered_names.clear(); - logger_stack.clear(); + m_bsf.terminate(); + m_registered_names.clear(); + m_logger_stack.clear(); } // end shutdown @@ -337,7 +339,7 @@ public class ScriptManager try { // look up the scripting language for this file - lang = mgr.getLangFromFilename(filename); + lang = m_bsf.getLangFromFilename(filename); code = IOUtil.loadText(file); if (logger.isDebugEnabled()) logger.debug("Code language is " + lang + ", loaded " + code.length() + " characters"); @@ -355,13 +357,13 @@ public class ScriptManager } // end catch if (logger_name!=null) // push a new logger onto the stack - logger_stack.addFirst(Logger.getLogger(logger_name)); + m_logger_stack.addFirst(Logger.getLogger(logger_name)); if (sro!=null) - return_stack.addFirst(sro); + m_return_stack.addFirst(sro); try { // execute the script! - mgr.exec(lang,filename,1,1,code); + m_bsf.exec(lang,filename,1,1,code); } // end try catch (BSFException e) @@ -372,9 +374,9 @@ public class ScriptManager finally { // pop the logger stack if necessary if (logger_name!=null) - logger_stack.removeFirst(); + m_logger_stack.removeFirst(); if (sro!=null) - return_stack.removeFirst(); + m_return_stack.removeFirst(); } // end finally @@ -386,32 +388,32 @@ public class ScriptManager public void register(String name, Object obj) { - mgr.registerBean(name,obj); - HashSet tbl = (HashSet)(registered_names.getFirst()); + m_bsf.registerBean(name,obj); + HashSet tbl = (HashSet)(m_registered_names.getFirst()); tbl.add(name); } // end register public void pushContext() { - registered_names.addFirst(new HashSet()); + m_registered_names.addFirst(new HashSet()); } // end pushContext public void popContext() { - HashSet tbl = (HashSet)(registered_names.removeFirst()); + HashSet tbl = (HashSet)(m_registered_names.removeFirst()); Iterator it = tbl.iterator(); while (it.hasNext()) - mgr.unregisterBean((String)(it.next())); - if (registered_names.isEmpty()) - registered_names.addFirst(new HashSet()); + m_bsf.unregisterBean((String)(it.next())); + if (m_registered_names.isEmpty()) + m_registered_names.addFirst(new HashSet()); } // end popContext public Object lookupObject(String name) { - return mgr.lookupBean(name); + return m_bsf.lookupBean(name); } // end lookupObject