From: Wolfgang M. M. <wol...@us...> - 2004-03-30 17:08:12
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7528/src/org/exist/xmlrpc Modified Files: RpcServer.java RpcAPI.java RpcConnection.java Log Message: It is now possible to pass user declared variables via XMLRPC. Index: RpcServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcServer.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** RpcServer.java 8 Mar 2004 11:21:21 -0000 1.30 --- RpcServer.java 30 Mar 2004 16:56:31 -0000 1.31 *************** *** 107,115 **** } ! public int executeQuery(User user, String xpath) throws EXistException, PermissionDeniedException { RpcConnection con = pool.get(); try { ! return con.executeQuery(user, xpath); } catch (Exception e) { handleException(e); --- 107,115 ---- } ! public int executeQuery(User user, String xpath, Hashtable parameters) throws EXistException, PermissionDeniedException { RpcConnection con = pool.get(); try { ! return con.executeQuery(user, xpath, parameters); } catch (Exception e) { handleException(e); *************** *** 123,127 **** User user, byte[] xpath, ! String encoding) throws EXistException, PermissionDeniedException { String xpathString = null; --- 123,128 ---- User user, byte[] xpath, ! String encoding, ! Hashtable parameters) throws EXistException, PermissionDeniedException { String xpathString = null; *************** *** 136,145 **** LOG.debug("query: " + xpathString); ! return executeQuery(user, xpathString); } ! public int executeQuery(User user, byte[] xpath) throws EXistException, PermissionDeniedException { ! return executeQuery(user, xpath, null); } --- 137,146 ---- LOG.debug("query: " + xpathString); ! return executeQuery(user, xpathString, parameters); } ! public int executeQuery(User user, byte[] xpath, Hashtable parameters) throws EXistException, PermissionDeniedException { ! return executeQuery(user, xpath, null, parameters); } Index: RpcAPI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcAPI.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** RpcAPI.java 8 Mar 2004 11:21:21 -0000 1.24 --- RpcAPI.java 30 Mar 2004 16:56:32 -0000 1.25 *************** *** 40,43 **** --- 40,44 ---- public final static String SORT_EXPR = "sort-expr"; public final static String NAMESPACES = "namespaces"; + public final static String VARIABLES = "variables"; public final static String BASE_URI = "base-uri"; *************** *** 486,495 **** *@exception PermissionDeniedException Description of the Exception */ ! int executeQuery(User user, byte[] xpath, String encoding) throws EXistException, PermissionDeniedException; ! int executeQuery(User user, byte[] xpath) throws EXistException, PermissionDeniedException; ! int executeQuery(User user, String xpath) throws EXistException, PermissionDeniedException; /** --- 487,496 ---- *@exception PermissionDeniedException Description of the Exception */ ! int executeQuery(User user, byte[] xpath, String encoding, Hashtable parameters) throws EXistException, PermissionDeniedException; ! int executeQuery(User user, byte[] xpath, Hashtable parameters) throws EXistException, PermissionDeniedException; ! int executeQuery(User user, String xpath, Hashtable parameters) throws EXistException, PermissionDeniedException; /** Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** RpcConnection.java 25 Mar 2004 12:50:51 -0000 1.49 --- RpcConnection.java 30 Mar 2004 16:56:32 -0000 1.50 *************** *** 156,159 **** --- 156,168 ---- context.declareNamespaces(namespaces); } + // declare static variables + Hashtable variableDecls = (Hashtable)parameters.get(RpcAPI.VARIABLES); + if(variableDecls != null) { + for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + LOG.debug("declaring " + entry.getKey().toString() + " = " + entry.getValue()); + context.declareVariable((String) entry.getKey(), entry.getValue()); + } + } LOG.debug("compiling " + xquery); XQueryLexer lexer = new XQueryLexer(new StringReader(xquery)); *************** *** 206,209 **** --- 215,227 ---- context.declareNamespaces(namespaces); } + // declare static variables + Hashtable variableDecls = (Hashtable)parameters.get(RpcAPI.VARIABLES); + if(variableDecls != null) { + for (Iterator i = variableDecls.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + LOG.debug("declaring " + entry.getKey().toString() + " = " + entry.getValue()); + context.declareVariable((String) entry.getKey(), entry.getValue()); + } + } // set the current broker object when reusing a compiled query: context.setBroker(broker); *************** *** 216,220 **** } ! public int executeQuery(User user, String xpath) throws Exception { long startTime = System.currentTimeMillis(); LOG.debug("query: " + xpath); --- 234,238 ---- } ! public int executeQuery(User user, String xpath, Hashtable parameters) throws Exception { long startTime = System.currentTimeMillis(); LOG.debug("query: " + xpath); *************** *** 223,227 **** broker = brokerPool.get(user); Sequence resultValue = doQuery(user, broker, xpath, null, null, ! new Hashtable()); QueryResult qr = new QueryResult(resultValue, (System .currentTimeMillis() - startTime)); --- 241,245 ---- broker = brokerPool.get(user); Sequence resultValue = doQuery(user, broker, xpath, null, null, ! parameters); QueryResult qr = new QueryResult(resultValue, (System .currentTimeMillis() - startTime)); *************** *** 1674,1679 **** for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); ! properties.setProperty((String) entry.getKey(), (String) entry ! .getValue()); } return properties; --- 1692,1696 ---- for (Iterator i = parameters.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); ! properties.setProperty((String) entry.getKey(), entry.getValue().toString()); } return properties; |