You can subscribe to this list here.
| 2004 |
Jan
|
Feb
|
Mar
(57) |
Apr
(103) |
May
(164) |
Jun
(139) |
Jul
(173) |
Aug
(196) |
Sep
(221) |
Oct
(333) |
Nov
(214) |
Dec
(88) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2005 |
Jan
(163) |
Feb
(165) |
Mar
(98) |
Apr
(93) |
May
(199) |
Jun
(118) |
Jul
(200) |
Aug
(212) |
Sep
(185) |
Oct
(297) |
Nov
(437) |
Dec
(272) |
| 2006 |
Jan
(542) |
Feb
(329) |
Mar
(267) |
Apr
(332) |
May
(267) |
Jun
(130) |
Jul
(161) |
Aug
(348) |
Sep
(166) |
Oct
(305) |
Nov
(173) |
Dec
(173) |
| 2007 |
Jan
(199) |
Feb
(118) |
Mar
(133) |
Apr
(200) |
May
(208) |
Jun
(146) |
Jul
(198) |
Aug
(146) |
Sep
(187) |
Oct
(182) |
Nov
(181) |
Dec
(83) |
| 2008 |
Jan
(252) |
Feb
(124) |
Mar
(124) |
Apr
(101) |
May
(143) |
Jun
(122) |
Jul
(129) |
Aug
(60) |
Sep
(80) |
Oct
(89) |
Nov
(54) |
Dec
(112) |
| 2009 |
Jan
(88) |
Feb
(145) |
Mar
(105) |
Apr
(164) |
May
(123) |
Jun
(154) |
Jul
(374) |
Aug
(341) |
Sep
(219) |
Oct
(137) |
Nov
(373) |
Dec
(240) |
| 2010 |
Jan
(197) |
Feb
(270) |
Mar
(253) |
Apr
(150) |
May
(102) |
Jun
(51) |
Jul
(300) |
Aug
(512) |
Sep
(254) |
Oct
(258) |
Nov
(288) |
Dec
(143) |
| 2011 |
Jan
(238) |
Feb
(179) |
Mar
(253) |
Apr
(332) |
May
(248) |
Jun
(255) |
Jul
(216) |
Aug
(282) |
Sep
(146) |
Oct
(77) |
Nov
(86) |
Dec
(69) |
| 2012 |
Jan
(172) |
Feb
(234) |
Mar
(229) |
Apr
(101) |
May
(212) |
Jun
(267) |
Jul
(129) |
Aug
(210) |
Sep
(239) |
Oct
(271) |
Nov
(368) |
Dec
(220) |
| 2013 |
Jan
(179) |
Feb
(155) |
Mar
(59) |
Apr
(47) |
May
(99) |
Jun
(158) |
Jul
(185) |
Aug
(16) |
Sep
(16) |
Oct
(7) |
Nov
(20) |
Dec
(12) |
| 2014 |
Jan
(21) |
Feb
(17) |
Mar
(18) |
Apr
(13) |
May
(27) |
Jun
(15) |
Jul
(19) |
Aug
(22) |
Sep
(30) |
Oct
(16) |
Nov
(19) |
Dec
(16) |
| 2015 |
Jan
(14) |
Feb
(24) |
Mar
(33) |
Apr
(41) |
May
(14) |
Jun
(80) |
Jul
(53) |
Aug
(8) |
Sep
(7) |
Oct
(15) |
Nov
(13) |
Dec
(2) |
| 2016 |
Jan
(22) |
Feb
(12) |
Mar
(30) |
Apr
(6) |
May
(33) |
Jun
(16) |
Jul
(8) |
Aug
(20) |
Sep
(12) |
Oct
(18) |
Nov
(12) |
Dec
(11) |
| 2017 |
Jan
(24) |
Feb
(26) |
Mar
(47) |
Apr
(23) |
May
(19) |
Jun
(14) |
Jul
(28) |
Aug
(30) |
Sep
(17) |
Oct
|
Nov
|
Dec
|
| 2019 |
Jan
(1) |
Feb
(73) |
Mar
(90) |
Apr
(42) |
May
(116) |
Jun
(90) |
Jul
(127) |
Aug
(103) |
Sep
(56) |
Oct
(42) |
Nov
(95) |
Dec
(58) |
| 2020 |
Jan
(102) |
Feb
(31) |
Mar
(93) |
Apr
(60) |
May
(57) |
Jun
(45) |
Jul
(29) |
Aug
(32) |
Sep
(44) |
Oct
(86) |
Nov
(51) |
Dec
(71) |
| 2021 |
Jan
(44) |
Feb
(25) |
Mar
(78) |
Apr
(130) |
May
(64) |
Jun
(74) |
Jul
(21) |
Aug
(64) |
Sep
(40) |
Oct
(43) |
Nov
(21) |
Dec
(99) |
| 2022 |
Jan
(154) |
Feb
(64) |
Mar
(45) |
Apr
(95) |
May
(62) |
Jun
(48) |
Jul
(73) |
Aug
(37) |
Sep
(71) |
Oct
(27) |
Nov
(40) |
Dec
(65) |
| 2023 |
Jan
(89) |
Feb
(130) |
Mar
(124) |
Apr
(50) |
May
(93) |
Jun
(46) |
Jul
(45) |
Aug
(68) |
Sep
(62) |
Oct
(71) |
Nov
(108) |
Dec
(82) |
| 2024 |
Jan
(53) |
Feb
(76) |
Mar
(64) |
Apr
(75) |
May
(36) |
Jun
(54) |
Jul
(98) |
Aug
(137) |
Sep
(58) |
Oct
(177) |
Nov
(84) |
Dec
(52) |
| 2025 |
Jan
(70) |
Feb
(53) |
Mar
(72) |
Apr
(47) |
May
(88) |
Jun
(49) |
Jul
(86) |
Aug
(51) |
Sep
(65) |
Oct
(91) |
Nov
(18) |
Dec
|
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
|
1
(10) |
2
(24) |
3
(34) |
4
(24) |
5
(25) |
6
(33) |
7
(116) |
|
8
(20) |
9
(14) |
10
(7) |
11
(10) |
12
(16) |
13
(6) |
14
(11) |
|
15
(44) |
16
(6) |
17
(21) |
18
(19) |
19
(10) |
20
(12) |
21
(5) |
|
22
(8) |
23
(3) |
24
(11) |
25
(8) |
26
|
27
(1) |
28
(9) |
|
29
(6) |
30
(29) |
31
|
|
|
|
|
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 22:17:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17247/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBSetCollectionPermissions.java Log Message: Corrected documentation for xmldb:set-collection-permissions. Index: XMLDBSetCollectionPermissions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBSetCollectionPermissions.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBSetCollectionPermissions.java 7 Jan 2006 21:47:11 -0000 1.4 --- XMLDBSetCollectionPermissions.java 30 Jan 2006 22:17:01 -0000 1.5 *************** *** 46,51 **** new FunctionSignature( new QName("set-collection-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), ! "Sets the permissions of the specified Collection. Required: user, group, mode (as xs:integer). "+ ! "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), --- 46,54 ---- new FunctionSignature( new QName("set-collection-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), ! "Sets the permissions of the specified collection. $a is the collection, which can be specified " + ! "as a simple collection path, an XMLDB URI or a collection object. $b specifies the user which " + ! "will become the owner of the resource, $c the group. " + ! "The final argument contains the permissions, specified as an xs:integer value. "+ ! "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE), |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 22:16:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16879/src/org/exist/xquery/functions/xmldb Modified Files: XMLDBSetResourcePermissions.java Log Message: Corrected documentation for xmldb:set-resource-permissions. Index: XMLDBSetResourcePermissions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/xmldb/XMLDBSetResourcePermissions.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** XMLDBSetResourcePermissions.java 7 Jan 2006 21:47:11 -0000 1.4 --- XMLDBSetResourcePermissions.java 30 Jan 2006 22:15:52 -0000 1.5 *************** *** 47,51 **** new FunctionSignature( new QName("set-resource-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), ! "Sets the permissions of the specified Resource. Required: user, group, mode (as xs:integer). "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { --- 47,54 ---- new FunctionSignature( new QName("set-resource-permissions", XMLDBModule.NAMESPACE_URI, XMLDBModule.PREFIX), ! "Sets the permissions of the specified resource. $a is the collection, which can be specified " + ! "as a simple collection path, an XMLDB URI or a collection object. $b denotes the resource to" + ! "change. $c specifies the user which will become the owner of the resource, $d the group. " + ! "The final argument contains the permissions, specified as an xs:integer value. "+ "PLEASE REMEMBER that 0755 is 7*64+5*8+5, NOT decimal 755.", new SequenceType[] { |
|
From: DeliriumSky <del...@us...> - 2006-01-30 21:58:49
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10495/src/org/exist/client Modified Files: ClientFrame.java Log Message: Commented about work TODO in copyAction() Removed redundant imports Index: ClientFrame.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/ClientFrame.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** ClientFrame.java 29 Jan 2006 17:41:53 -0000 1.49 --- ClientFrame.java 30 Jan 2006 21:58:41 -0000 1.50 *************** *** 49,53 **** import java.util.Comparator; import java.util.Date; - import java.util.Enumeration; import java.util.List; import java.util.Properties; --- 49,52 ---- *************** *** 55,59 **** import javax.swing.BorderFactory; - import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JButton; --- 54,57 ---- *************** *** 70,74 **** import javax.swing.JPasswordField; import javax.swing.JPopupMenu; - import javax.swing.JRadioButtonMenuItem; import javax.swing.JScrollPane; import javax.swing.JSplitPane; --- 68,71 ---- *************** *** 878,898 **** private void copyAction(ActionEvent ev) { - final ResourceDescriptor[] res = getSelectedResources(); ! String[] collections = null; ! try { ! Collection root = client.getCollection(DBBroker.ROOT_COLLECTION); Vector collectionsVec = getCollections(root, new Vector()); collections = new String[collectionsVec.size()]; collectionsVec.toArray(collections); ! } catch (XMLDBException e) { showErrorMessage(e.getMessage(), e); return; } ! Object val = JOptionPane.showInputDialog(this, "Select target collection", "Copy", JOptionPane.QUESTION_MESSAGE, ! null, collections, collections[0]); if(val == null) return; final String destinationPath = (String)val; Runnable moveTask = new Runnable() { public void run() { --- 875,903 ---- private void copyAction(ActionEvent ev) { ! final ResourceDescriptor[] res = getSelectedResources(); ! String[] collections = null; ! ! //get an array of collection paths ! try ! { ! Collection root = client.getCollection(DBBroker.ROOT_COLLECTION); Vector collectionsVec = getCollections(root, new Vector()); collections = new String[collectionsVec.size()]; collectionsVec.toArray(collections); ! } ! catch (XMLDBException e) ! { showErrorMessage(e.getMessage(), e); return; } ! ! //prompt the user for a destination collection from the list ! Object val = JOptionPane.showInputDialog(this, "Select target collection", "Copy", JOptionPane.QUESTION_MESSAGE, null, collections, collections[0]); if(val == null) return; + final String destinationPath = (String)val; + Runnable moveTask = new Runnable() { public void run() { *************** *** 901,904 **** --- 906,919 ---- client.current.getService("CollectionManagementService", "1.0"); for(int i = 0; i < res.length; i++) { + + //TODO + //what happens if the source and destination paths are the same? + //we need to check and prompt the user to either skip or choose a new name + //this function can copy multiple resources/collections selected by the user, + //so may need to prompt the user multiple times? is in this thread the correct + //place to do it? also need to do something similar for moveAction() + // + //Its too late and brain hurts - deliriumsky + setStatus("Copying " + res[i].getName() + " to " + destinationPath + "..."); if(res[i].isCollection()) |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:57:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9994/src/org/exist/util Modified Files: Configuration.java Log Message: Refactored SecurityManager into an interface (thanks to Alex Milowski). Index: Configuration.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Configuration.java,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** Configuration.java 15 Jan 2006 14:21:01 -0000 1.49 --- Configuration.java 30 Jan 2006 21:57:08 -0000 1.50 *************** *** 449,452 **** --- 449,466 ---- } catch (NumberFormatException nfe) { } + NodeList securityConf = con.getElementsByTagName("security"); + String securityManagerClassName = "org.exist.security.XMLSecurityManager"; + if (securityConf.getLength()>0) { + securityManagerClassName = ((Element)securityConf.item(0)).getAttribute("class"); + } + try { + config.put("db-connection.security.class",config.getClass().forName(securityManagerClassName)); + } catch (Throwable ex) { + if (ex instanceof ClassNotFoundException) { + throw new DatabaseConfigurationException("Cannot find security manager class "+securityManagerClassName); + } else { + throw new DatabaseConfigurationException("Cannot load security manager class "+securityManagerClassName+" due to "+ex.getMessage()); + } + } NodeList poolConf = con.getElementsByTagName("pool"); if (poolConf.getLength() > 0) { |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:56:51
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9889/src/org/exist/storage Modified Files: BrokerPool.java Log Message: Refactored SecurityManager into an interface (thanks to Alex Milowski). Index: BrokerPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/BrokerPool.java,v retrieving revision 1.68 retrieving revision 1.69 diff -C2 -d -r1.68 -r1.69 *** BrokerPool.java 6 Jan 2006 22:34:43 -0000 1.68 --- BrokerPool.java 30 Jan 2006 21:56:44 -0000 1.69 *************** *** 581,584 **** --- 581,594 ---- return true; } + protected SecurityManager newSecurityManager() + { + try { + Class smClass = (Class)conf.getProperty("db-connection.security.class"); + return (SecurityManager)smClass.newInstance(); + } catch (Throwable ex) { + LOG.warn("Exception while instantiating security manager class.", ex); + } + return null; + } /**Initializes the database instance. *************** *** 653,657 **** // WM: there's only one security manager per BrokerPool, but it needs a DBBroker instance to read // the system collection. ! securityManager = new org.exist.security.SecurityManager(this, broker); initializing = false; --- 663,670 ---- // WM: there's only one security manager per BrokerPool, but it needs a DBBroker instance to read // the system collection. ! SecurityManager localSecurityManager = newSecurityManager(); ! securityManager = null; ! localSecurityManager.attach(this, broker); ! securityManager = localSecurityManager; initializing = false; *************** *** 999,1003 **** // A broker is already available in these methods, so we use it here. public void reloadSecurityManager(DBBroker broker) { ! securityManager = new SecurityManager(this, broker); LOG.debug("Security manager reloaded"); } --- 1012,1017 ---- // A broker is already available in these methods, so we use it here. public void reloadSecurityManager(DBBroker broker) { ! securityManager = newSecurityManager(); ! securityManager.attach(this, broker); LOG.debug("Security manager reloaded"); } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:56:27
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/security In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9807/src/org/exist/security Modified Files: SecurityManager.java Added Files: XMLSecurityManager.java Log Message: Refactored SecurityManager into an interface (thanks to Alex Milowski). Index: SecurityManager.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/security/SecurityManager.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** SecurityManager.java 7 Jan 2006 14:07:27 -0000 1.33 --- SecurityManager.java 30 Jan 2006 21:56:19 -0000 1.34 *************** *** 58,398 **** * users.xml only during database startup and shutdown. */ ! public class SecurityManager { ! public final static String ACL_FILE = "users.xml"; ! public final static String DBA_GROUP = "dba"; ! public final static String DBA_USER = "admin"; ! public final static String GUEST_GROUP = "guest"; ! public final static String GUEST_USER = "guest"; ! ! public final static User SYSTEM_USER = new User(DBA_USER, null, DBA_GROUP); ! ! private final static Logger LOG = ! Logger.getLogger(SecurityManager.class); ! private BrokerPool pool; ! private Int2ObjectHashMap groups = new Int2ObjectHashMap(65); ! private Int2ObjectHashMap users = new Int2ObjectHashMap(65); ! private int nextUserId = 0; ! private int nextGroupId = 0; ! private int defCollectionPermissions = Permission.DEFAULT_PERM; ! private int defResourcePermissions = Permission.DEFAULT_PERM; ! ! private ExistPDP pdp; ! ! /** ! * Initialize the security manager. ! * ! * Checks if the file users.xml exists in the system collection of the database. ! * If not, it is created with two default users: admin and guest. ! * ! * @param pool ! * @param sysBroker ! */ ! public SecurityManager(BrokerPool pool, DBBroker sysBroker) { ! this.pool = pool; ! ! TransactionManager transact = pool.getTransactionManager(); ! Txn txn = null; ! DBBroker broker = sysBroker; ! try { ! Collection sysCollection = broker.getCollection(DBBroker.SYSTEM_COLLECTION); ! if (sysCollection == null) { ! txn = transact.beginTransaction(); ! sysCollection = broker.getOrCreateCollection(txn, DBBroker.SYSTEM_COLLECTION); ! sysCollection.setPermissions(0770); ! broker.saveCollection(txn, sysCollection); ! transact.commit(txn); ! } ! Document acl = sysCollection.getDocument(broker, ACL_FILE); ! Element docElement = null; ! if (acl != null) ! docElement = acl.getDocumentElement(); ! if (docElement == null) { ! LOG.debug("creating system users"); ! User user = new User(DBA_USER, null); ! user.addGroup(DBA_GROUP); ! user.setUID(++nextUserId); ! users.put(user.getUID(), user); ! user = new User(GUEST_USER, GUEST_USER, GUEST_GROUP); ! user.setUID(++nextUserId); ! users.put(user.getUID(), user); ! addGroup(DBA_GROUP); ! addGroup(GUEST_GROUP); ! txn = transact.beginTransaction(); ! save(broker, txn); ! transact.commit(txn); ! } else { ! LOG.debug("loading acl"); ! Element root = acl.getDocumentElement(); ! NodeList nl = root.getChildNodes(); ! Node node; ! Element next; ! User user; ! NodeList ul; ! String lastId; ! Group group; ! for (int i = 0; i < nl.getLength(); i++) { ! if(nl.item(i).getNodeType() != Node.ELEMENT_NODE) ! continue; ! next = (Element) nl.item(i); ! if (next.getTagName().equals("users")) { ! lastId = next.getAttribute("last-id"); ! try { ! nextUserId = Integer.parseInt(lastId); ! } catch (NumberFormatException e) { ! } ! ul = next.getChildNodes(); ! for (int j = 0; j < ul.getLength(); j++) { ! node = ul.item(j); ! if(node.getNodeType() == Node.ELEMENT_NODE && ! node.getLocalName().equals("user")) { ! user = new User((Element)node); ! users.put(user.getUID(), user); ! } ! } ! } else if (next.getTagName().equals("groups")) { ! lastId = next.getAttribute("last-id"); ! try { ! nextGroupId = Integer.parseInt(lastId); ! } catch (NumberFormatException e) { ! } ! ul = next.getChildNodes(); ! for (int j = 0; j < ul.getLength(); j++) { ! node = ul.item(j); ! if(node.getNodeType() == Node.ELEMENT_NODE && ! node.getLocalName().equals("group")) { ! group = new Group((Element)node); ! groups.put(group.getId(), group); ! } ! } ! } ! } ! } ! } catch (Exception e) { ! transact.abort(txn); ! e.printStackTrace(); ! LOG.debug("loading acl failed: " + e.getMessage()); ! } ! // read default collection and resource permissions ! Integer defOpt = (Integer) ! broker.getConfiguration().getProperty("indexer.permissions.collection"); ! if (defOpt != null) ! defCollectionPermissions = defOpt.intValue(); ! defOpt = (Integer) ! broker.getConfiguration().getProperty("indexer.permissions.resource"); ! if (defOpt != null) ! defResourcePermissions = defOpt.intValue(); ! Boolean enableXACML = (Boolean)broker.getConfiguration().getProperty("xacml.enable"); ! if(enableXACML != null && enableXACML.booleanValue()) { ! pdp = new ExistPDP(pool); ! LOG.debug("XACML enabled"); ! } ! } ! public ExistPDP getPDP() { ! return pdp; ! } ! public synchronized void deleteUser(String name) throws PermissionDeniedException { ! deleteUser(getUser(name)); ! } ! ! public synchronized void deleteUser(User user) throws PermissionDeniedException { ! if(user == null) ! return; ! user = (User)users.remove(user.getUID()); ! if(user != null) ! LOG.debug("user " + user.getName() + " removed"); ! else ! LOG.debug("user not found"); ! DBBroker broker = null; ! TransactionManager transact = pool.getTransactionManager(); ! Txn txn = transact.beginTransaction(); ! try { ! broker = pool.get(); ! save(broker, txn); ! transact.commit(txn); ! } catch (EXistException e) { ! transact.abort(txn); ! e.printStackTrace(); ! } finally { ! pool.release(broker); ! } ! } ! public synchronized User getUser(String name) { ! User user; ! for (Iterator i = users.valueIterator(); i.hasNext();) { ! user = (User) i.next(); ! if (user.getName().equals(name)) ! return user; ! } ! LOG.debug("user " + name + " not found"); ! return null; ! } ! public synchronized User getUser(int uid) { ! final User user = (User)users.get(uid); ! if(user == null) ! LOG.debug("user with uid " + uid + " not found"); ! return user; ! } ! ! public synchronized User[] getUsers() { ! User u[] = new User[users.size()]; ! int j = 0; ! for (Iterator i = users.valueIterator(); i.hasNext(); j++) ! u[j] = (User) i.next(); ! return u; ! } ! public synchronized void addGroup(String name) { ! Group group = new Group(name, ++nextGroupId); ! groups.put(group.getId(), group); ! } ! public synchronized boolean hasGroup(String name) { ! Group group; ! for (Iterator i = groups.valueIterator(); i.hasNext();) { ! group = (Group) i.next(); ! if (group.getName().equals(name)) ! return true; ! } ! return false; ! } ! public synchronized Group getGroup(String name) { ! Group group; ! for (Iterator i = groups.valueIterator(); i.hasNext();) { ! group = (Group) i.next(); ! if (group.getName().equals(name)) ! return group; ! } ! return null; ! } ! public synchronized Group getGroup(int gid) { ! return (Group)groups.get(gid); ! } ! ! public synchronized String[] getGroups() { ! ArrayList list = new ArrayList(groups.size()); ! Group group; ! for(Iterator i = groups.valueIterator(); i.hasNext(); ) { ! group = (Group) i.next(); ! list.add(group.getName()); ! } ! String[] gl = new String[list.size()]; ! list.toArray(gl); ! return gl; ! } ! ! public synchronized boolean hasAdminPrivileges(User user) { ! return user.hasDbaRole(); ! } ! public synchronized boolean hasUser(String name) { ! User user; ! for (Iterator i = users.valueIterator(); i.hasNext();) { ! user = (User) i.next(); ! if (user.getName().equals(name)) ! return true; ! } ! return false; ! } ! private synchronized void save(DBBroker broker, Txn transaction) throws EXistException { ! LOG.debug("storing acl file"); ! StringBuffer buf = new StringBuffer(); ! buf.append("<auth>"); ! // save groups ! buf.append("<groups last-id=\""); ! buf.append(Integer.toString(nextGroupId)); ! buf.append("\">"); ! for (Iterator i = groups.valueIterator(); i.hasNext();) ! buf.append(((Group) i.next()).toString()); ! buf.append("</groups>"); ! //save users ! buf.append("<users last-id=\""); ! buf.append(Integer.toString(nextUserId)); ! buf.append("\">"); ! for (Iterator i = users.valueIterator(); i.hasNext();) ! buf.append(((User) i.next()).toString()); ! buf.append("</users>"); ! buf.append("</auth>"); ! ! // store users.xml ! broker.flush(); ! broker.sync(Sync.MAJOR_SYNC); ! try { ! broker.setUser(getUser(DBA_USER)); ! Collection sysCollection = broker.getCollection(DBBroker.SYSTEM_COLLECTION); ! String data = buf.toString(); ! IndexInfo info = sysCollection.validateXMLResource(transaction, broker, ACL_FILE, data); ! DocumentImpl doc = info.getDocument(); ! doc.getMetadata().setMimeType(MimeType.XML_TYPE.getName()); ! sysCollection.store(transaction, broker, info, data, false); ! doc.setPermissions(0770); ! broker.saveCollection(transaction, doc.getCollection()); ! } catch (SAXException e) { ! throw new EXistException(e.getMessage()); ! } catch (PermissionDeniedException e) { ! throw new EXistException(e.getMessage()); ! } catch (TriggerException e) { ! throw new EXistException(e.getMessage()); ! } catch (LockException e) { ! throw new EXistException(e.getMessage()); ! } ! broker.flush(); ! broker.sync(Sync.MAJOR_SYNC); ! } ! public synchronized void setUser(User user) { ! if (user.getUID() < 0) ! user.setUID(++nextUserId); ! users.put(user.getUID(), user); ! String[] groups = user.getGroups(); ! for (int i = 0; i < groups.length; i++) { ! if (!hasGroup(groups[i])) ! addGroup(groups[i]); ! } ! TransactionManager transact = pool.getTransactionManager(); ! Txn txn = transact.beginTransaction(); ! DBBroker broker = null; ! try { ! broker = pool.get(); ! save(broker, txn); ! createUserHome(broker, txn, user); ! transact.commit(txn); ! } catch (EXistException e) { ! transact.abort(txn); ! LOG.debug("error while creating user", e); ! } catch (PermissionDeniedException e) { ! transact.abort(txn); ! LOG.debug("error while creating home collection", e); ! } finally { ! pool.release(broker); ! } ! } ! ! public int getResourceDefaultPerms() { ! return defResourcePermissions; ! } ! ! public int getCollectionDefaultPerms() { ! return defCollectionPermissions; ! } ! private void createUserHome(DBBroker broker, Txn transaction, User user) ! throws EXistException, PermissionDeniedException { ! if(user.getHome() == null) ! return; ! broker.setUser(getUser(DBA_USER)); ! Collection home = broker.getOrCreateCollection(transaction, user.getHome()); ! home.getPermissions().setOwner(user.getName()); ! home.getPermissions().setGroup(user.getPrimaryGroup()); ! broker.saveCollection(transaction, home); ! } ! } \ No newline at end of file --- 58,106 ---- * users.xml only during database startup and shutdown. */ ! public interface SecurityManager { ! public final static String ACL_FILE = "users.xml"; ! public final static String DBA_GROUP = "dba"; ! public final static String DBA_USER = "admin"; ! public final static String GUEST_GROUP = "guest"; ! public final static String GUEST_USER = "guest"; ! public final static User SYSTEM_USER = new User(DBA_USER, null, DBA_GROUP); ! ! void attach(BrokerPool pool, DBBroker sysBroker); ! ExistPDP getPDP(); ! void deleteUser(String name) ! throws PermissionDeniedException; ! void deleteUser(User user) ! throws PermissionDeniedException; ! User getUser(String name); ! User getUser(int uid); ! User[] getUsers(); ! void addGroup(String name); ! boolean hasGroup(String name); ! Group getGroup(String name); ! Group getGroup(int gid); ! String[] getGroups(); ! boolean hasAdminPrivileges(User user); ! ! boolean hasUser(String name); ! ! void setUser(User user); ! ! int getResourceDefaultPerms(); ! ! int getCollectionDefaultPerms(); ! } --- NEW FILE: XMLSecurityManager.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001 Wolfgang M. Meier * me...@if... * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ package org.exist.security; import java.util.ArrayList; import java.util.Iterator; import org.apache.log4j.Logger; import org.exist.EXistException; import org.exist.collections.Collection; import org.exist.collections.IndexInfo; import org.exist.collections.triggers.TriggerException; import org.exist.dom.DocumentImpl; import org.exist.security.xacml.ExistPDP; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.exist.storage.sync.Sync; import org.exist.storage.txn.TransactionManager; import org.exist.storage.txn.Txn; import org.exist.util.LockException; import org.exist.util.MimeType; import org.exist.util.hashtable.Int2ObjectHashMap; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; /** * SecurityManager is responsible for managing users and groups. * * There's only one SecurityManager for each database instance, which * may be obtained by {@link BrokerPool#getSecurityManager()}. * * Users and groups are stored in the system collection, in document * users.xml. While it is possible to edit this file by hand, it * may lead to unexpected results, since SecurityManager reads * users.xml only during database startup and shutdown. */ public class XMLSecurityManager implements SecurityManager { public final static String DBA_GROUP = "dba"; public final static String DBA_USER = "admin"; public final static String GUEST_GROUP = "guest"; public final static String GUEST_USER = "guest"; public final static User SYSTEM_USER = new User(DBA_USER, null, DBA_GROUP); private final static Logger LOG = Logger.getLogger(SecurityManager.class); private BrokerPool pool; private Int2ObjectHashMap groups = new Int2ObjectHashMap(65); private Int2ObjectHashMap users = new Int2ObjectHashMap(65); private int nextUserId = 0; private int nextGroupId = 0; private int defCollectionPermissions = Permission.DEFAULT_PERM; private int defResourcePermissions = Permission.DEFAULT_PERM; private ExistPDP pdp; public XMLSecurityManager() { } /** * Initialize the security manager. * * Checks if the file users.xml exists in the system collection of the database. * If not, it is created with two default users: admin and guest. * * @param pool * @param sysBroker */ public void attach(BrokerPool pool, DBBroker sysBroker) { this.pool = pool; TransactionManager transact = pool.getTransactionManager(); Txn txn = null; DBBroker broker = sysBroker; try { Collection sysCollection = broker.getCollection(DBBroker.SYSTEM_COLLECTION); if (sysCollection == null) { txn = transact.beginTransaction(); sysCollection = broker.getOrCreateCollection(txn, DBBroker.SYSTEM_COLLECTION); sysCollection.setPermissions(0770); broker.saveCollection(txn, sysCollection); transact.commit(txn); } Document acl = sysCollection.getDocument(broker, ACL_FILE); Element docElement = null; if (acl != null) docElement = acl.getDocumentElement(); if (docElement == null) { LOG.debug("creating system users"); User user = new User(DBA_USER, null); user.addGroup(DBA_GROUP); user.setUID(++nextUserId); users.put(user.getUID(), user); user = new User(GUEST_USER, GUEST_USER, GUEST_GROUP); user.setUID(++nextUserId); users.put(user.getUID(), user); addGroup(DBA_GROUP); addGroup(GUEST_GROUP); txn = transact.beginTransaction(); save(broker, txn); transact.commit(txn); } else { LOG.debug("loading acl"); Element root = acl.getDocumentElement(); NodeList nl = root.getChildNodes(); Node node; Element next; User user; NodeList ul; String lastId; Group group; for (int i = 0; i < nl.getLength(); i++) { if(nl.item(i).getNodeType() != Node.ELEMENT_NODE) continue; next = (Element) nl.item(i); if (next.getTagName().equals("users")) { lastId = next.getAttribute("last-id"); try { nextUserId = Integer.parseInt(lastId); } catch (NumberFormatException e) { } ul = next.getChildNodes(); for (int j = 0; j < ul.getLength(); j++) { node = ul.item(j); if(node.getNodeType() == Node.ELEMENT_NODE && node.getLocalName().equals("user")) { user = new User((Element)node); users.put(user.getUID(), user); } } } else if (next.getTagName().equals("groups")) { lastId = next.getAttribute("last-id"); try { nextGroupId = Integer.parseInt(lastId); } catch (NumberFormatException e) { } ul = next.getChildNodes(); for (int j = 0; j < ul.getLength(); j++) { node = ul.item(j); if(node.getNodeType() == Node.ELEMENT_NODE && node.getLocalName().equals("group")) { group = new Group((Element)node); groups.put(group.getId(), group); } } } } } } catch (Exception e) { transact.abort(txn); e.printStackTrace(); LOG.debug("loading acl failed: " + e.getMessage()); } // read default collection and resource permissions Integer defOpt = (Integer) broker.getConfiguration().getProperty("indexer.permissions.collection"); if (defOpt != null) defCollectionPermissions = defOpt.intValue(); defOpt = (Integer) broker.getConfiguration().getProperty("indexer.permissions.resource"); if (defOpt != null) defResourcePermissions = defOpt.intValue(); Boolean enableXACML = (Boolean)broker.getConfiguration().getProperty("xacml.enable"); if(enableXACML != null && enableXACML.booleanValue()) { pdp = new ExistPDP(pool); LOG.debug("XACML enabled"); } } public ExistPDP getPDP() { return pdp; } public synchronized void deleteUser(String name) throws PermissionDeniedException { deleteUser(getUser(name)); } public synchronized void deleteUser(User user) throws PermissionDeniedException { if(user == null) return; user = (User)users.remove(user.getUID()); if(user != null) LOG.debug("user " + user.getName() + " removed"); else LOG.debug("user not found"); DBBroker broker = null; TransactionManager transact = pool.getTransactionManager(); Txn txn = transact.beginTransaction(); try { broker = pool.get(); save(broker, txn); transact.commit(txn); } catch (EXistException e) { transact.abort(txn); e.printStackTrace(); } finally { pool.release(broker); } } public synchronized User getUser(String name) { User user; for (Iterator i = users.valueIterator(); i.hasNext();) { user = (User) i.next(); if (user.getName().equals(name)) return user; } LOG.debug("user " + name + " not found"); return null; } public synchronized User getUser(int uid) { final User user = (User)users.get(uid); if(user == null) LOG.debug("user with uid " + uid + " not found"); return user; } public synchronized User[] getUsers() { User u[] = new User[users.size()]; int j = 0; for (Iterator i = users.valueIterator(); i.hasNext(); j++) u[j] = (User) i.next(); return u; } public synchronized void addGroup(String name) { Group group = new Group(name, ++nextGroupId); groups.put(group.getId(), group); } public synchronized boolean hasGroup(String name) { Group group; for (Iterator i = groups.valueIterator(); i.hasNext();) { group = (Group) i.next(); if (group.getName().equals(name)) return true; } return false; } public synchronized Group getGroup(String name) { Group group; for (Iterator i = groups.valueIterator(); i.hasNext();) { group = (Group) i.next(); if (group.getName().equals(name)) return group; } return null; } public synchronized Group getGroup(int gid) { return (Group)groups.get(gid); } public synchronized String[] getGroups() { ArrayList list = new ArrayList(groups.size()); Group group; for(Iterator i = groups.valueIterator(); i.hasNext(); ) { group = (Group) i.next(); list.add(group.getName()); } String[] gl = new String[list.size()]; list.toArray(gl); return gl; } public synchronized boolean hasAdminPrivileges(User user) { return user.hasDbaRole(); } public synchronized boolean hasUser(String name) { User user; for (Iterator i = users.valueIterator(); i.hasNext();) { user = (User) i.next(); if (user.getName().equals(name)) return true; } return false; } private synchronized void save(DBBroker broker, Txn transaction) throws EXistException { LOG.debug("storing acl file"); StringBuffer buf = new StringBuffer(); buf.append("<auth>"); // save groups buf.append("<groups last-id=\""); buf.append(Integer.toString(nextGroupId)); buf.append("\">"); for (Iterator i = groups.valueIterator(); i.hasNext();) buf.append(((Group) i.next()).toString()); buf.append("</groups>"); //save users buf.append("<users last-id=\""); buf.append(Integer.toString(nextUserId)); buf.append("\">"); for (Iterator i = users.valueIterator(); i.hasNext();) buf.append(((User) i.next()).toString()); buf.append("</users>"); buf.append("</auth>"); // store users.xml broker.flush(); broker.sync(Sync.MAJOR_SYNC); try { broker.setUser(getUser(DBA_USER)); Collection sysCollection = broker.getCollection(DBBroker.SYSTEM_COLLECTION); String data = buf.toString(); IndexInfo info = sysCollection.validateXMLResource(transaction, broker, ACL_FILE, data); DocumentImpl doc = info.getDocument(); doc.getMetadata().setMimeType(MimeType.XML_TYPE.getName()); sysCollection.store(transaction, broker, info, data, false); doc.setPermissions(0770); broker.saveCollection(transaction, doc.getCollection()); } catch (SAXException e) { throw new EXistException(e.getMessage()); } catch (PermissionDeniedException e) { throw new EXistException(e.getMessage()); } catch (TriggerException e) { throw new EXistException(e.getMessage()); } catch (LockException e) { throw new EXistException(e.getMessage()); } broker.flush(); broker.sync(Sync.MAJOR_SYNC); } public synchronized void setUser(User user) { if (user.getUID() < 0) user.setUID(++nextUserId); users.put(user.getUID(), user); String[] groups = user.getGroups(); for (int i = 0; i < groups.length; i++) { if (!hasGroup(groups[i])) addGroup(groups[i]); } TransactionManager transact = pool.getTransactionManager(); Txn txn = transact.beginTransaction(); DBBroker broker = null; try { broker = pool.get(); save(broker, txn); createUserHome(broker, txn, user); transact.commit(txn); } catch (EXistException e) { transact.abort(txn); LOG.debug("error while creating user", e); } catch (PermissionDeniedException e) { transact.abort(txn); LOG.debug("error while creating home collection", e); } finally { pool.release(broker); } } public int getResourceDefaultPerms() { return defResourcePermissions; } public int getCollectionDefaultPerms() { return defCollectionPermissions; } private void createUserHome(DBBroker broker, Txn transaction, User user) throws EXistException, PermissionDeniedException { if(user.getHome() == null) return; broker.setUser(getUser(DBA_USER)); Collection home = broker.getOrCreateCollection(transaction, user.getHome()); home.getPermissions().setOwner(user.getName()); home.getPermissions().setGroup(user.getPrimaryGroup()); broker.saveCollection(transaction, home); } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:55:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9555/src/org/exist/collections Modified Files: Collection.java CollectionCache.java Log Message: Refactored SecurityManager into an interface (thanks to Alex Milowski). Index: CollectionCache.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/CollectionCache.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** CollectionCache.java 15 Jan 2006 11:17:34 -0000 1.14 --- CollectionCache.java 30 Jan 2006 21:55:49 -0000 1.15 *************** *** 91,95 **** if (cacheManager != null && accounting.resizeNeeded()) { cacheManager.requestMem(this); - accounting.stats(); } return old; --- 91,94 ---- Index: Collection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/Collection.java,v retrieving revision 1.115 retrieving revision 1.116 diff -C2 -d -r1.115 -r1.116 *** Collection.java 29 Jan 2006 18:19:52 -0000 1.115 --- Collection.java 30 Jan 2006 21:55:48 -0000 1.116 *************** *** 55,58 **** --- 55,59 ---- import org.exist.security.PermissionDeniedException; import org.exist.security.SecurityManager; + import org.exist.security.XMLSecurityManager; import org.exist.security.User; import org.exist.storage.DBBroker; *************** *** 848,853 **** LOG.debug("document stored."); // if we are running in privileged mode (e.g. backup/restore), notify the SecurityManager about changes ! if (getName().equals(DBBroker.SYSTEM_COLLECTION) && document.getFileName().equals(SecurityManager.ACL_FILE) ! && privileged == false) { // inform the security manager that system data has changed LOG.debug("users.xml changed"); --- 849,855 ---- LOG.debug("document stored."); // if we are running in privileged mode (e.g. backup/restore), notify the SecurityManager about changes ! if (getName().equals(DBBroker.SYSTEM_COLLECTION) ! && document.getFileName().equals(XMLSecurityManager.ACL_FILE) ! && privileged == false) { // inform the security manager that system data has changed LOG.debug("users.xml changed"); |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:53:02
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7799/src/org/exist/xquery/test Modified Files: XPathQueryTest.java Log Message: Changed XQueryService.compile to actually compile and check the query. Index: XPathQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XPathQueryTest.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** XPathQueryTest.java 30 Jan 2006 19:31:35 -0000 1.59 --- XPathQueryTest.java 30 Jan 2006 21:52:53 -0000 1.60 *************** *** 419,424 **** --- 419,442 ---- XQueryService service = storeXMLStringAndGetQueryService("nested2.xml", nested2); + String numbers = + "<test>" + + "<item id='1' type='alphanum'><price>5.6</price><stock>22</stock></item>" + + "<item id='2'><price>7.4</price><stock>43</stock></item>" + + "<item id='3'><price>18.4</price><stock>5</stock></item>" + + "<item id='4'><price>65.54</price><stock>16</stock></item>" + + "</test>"; queryResource(service, "nested2.xml", "(<a/>, <b/>, <c/>)/parent::*", 0); + queryResource(service, "nested2.xml", "/RootElement//ChildB/parent::*", 1); + queryResource(service, "nested2.xml", "/RootElement//ChildB/parent::*/ChildB", 1); + queryResource(service, "nested2.xml", "/RootElement/ChildA/parent::*/ChildA/ChildB", 1); + + service = + storeXMLStringAndGetQueryService("numbers.xml", numbers); + queryResource(service, "numbers.xml", "//price[. = 18.4]/parent::*[@id = '3']", 1); + queryResource(service, "numbers.xml", "//price[. = 18.4]/parent::item[@id = '3']", 1); + queryResource(service, "numbers.xml", "//price/parent::item[@id = '3']", 1); + queryResource(service, "numbers.xml", + "for $price in //price where $price/parent::*[@id = '3']/stock = '5' return $price", 1); } catch (XMLDBException e) { fail(e.getMessage()); *************** *** 1331,1347 **** String invalidQuery = "for $i in (1 to 10)\n return $b"; String validQuery = "for $i in (1 to 10) return $i"; org.exist.xmldb.XQueryService service = (org.exist.xmldb.XQueryService) getQueryService(); boolean exceptionOccurred = false; try { ! service.compileAndCheck(invalidQuery); ! } catch (XPathException e) { ! assertEquals(e.getLine(), 2); exceptionOccurred = true; } assertTrue("Expected an exception", exceptionOccurred); try { ! service.compileAndCheck(validQuery); } catch (XPathException e) { fail(e.getMessage()); } --- 1349,1379 ---- String invalidQuery = "for $i in (1 to 10)\n return $b"; String validQuery = "for $i in (1 to 10) return $i"; + String validModule = "module namespace foo=\"urn:foo\";\n" + + "declare function foo:test() { \"Hello World!\" };"; + String invalidModule = "module namespace foo=\"urn:foo\";\n" + + "declare function foo:test() { \"Hello World! };"; + org.exist.xmldb.XQueryService service = (org.exist.xmldb.XQueryService) getQueryService(); boolean exceptionOccurred = false; try { ! service.compile(invalidQuery); ! } catch (XMLDBException e) { ! assertEquals(((XPathException)e.getCause()).getLine(), 2); exceptionOccurred = true; } assertTrue("Expected an exception", exceptionOccurred); + exceptionOccurred = false; try { ! service.compileAndCheck(invalidModule); } catch (XPathException e) { + exceptionOccurred = true; + } + assertTrue("Expected an exception", exceptionOccurred); + + try { + service.compile(validQuery); + service.compile(validModule); + } catch (XMLDBException e) { fail(e.getMessage()); } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:52:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5483/src/org/exist/xmldb Modified Files: RemoteXPathQueryService.java Log Message: Changed XQueryService.compile to actually compile and check the query. Index: RemoteXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteXPathQueryService.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** RemoteXPathQueryService.java 30 Jan 2006 19:01:26 -0000 1.27 --- RemoteXPathQueryService.java 30 Jan 2006 21:51:55 -0000 1.28 *************** *** 68,71 **** --- 68,79 ---- } + public CompiledExpression compile(String query) throws XMLDBException { + try { + return compileAndCheck(query); + } catch (XPathException e) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, e.getMessage(), e ); + } + } + public CompiledExpression compileAndCheck(String query) throws XMLDBException, XPathException { try { *************** *** 229,242 **** variableDecls.put(qname, initialValue); } - - /** - * The XML-RPC server automatically caches compiled queries. - * Thus calling this method has no effect. - * - * @see org.exist.xmldb.XQueryService#compile(java.lang.String) - */ - public CompiledExpression compile(String query) throws XMLDBException { - return new RemoteCompiledExpression(query); - } /* (non-Javadoc) --- 237,240 ---- |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 21:07:44
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16574/src/org/exist/xquery Modified Files: XPathException.java Log Message: Added method to retrieve just the error message, excluding line numbers or stack trace. Index: XPathException.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XPathException.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** XPathException.java 30 Sep 2005 15:36:13 -0000 1.11 --- XPathException.java 30 Jan 2006 21:07:25 -0000 1.12 *************** *** 108,111 **** --- 108,121 ---- } + /** + * Returns just the error message, not including + * line numbers or the call stack. + * + * @return + */ + public String getDetailMessage() { + return message; + } + public String getMessageAsHTML() { StringBuffer buf = new StringBuffer(); |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 20:25:12
|
Update of /cvsroot/exist/eXist-1.0 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv318 Modified Files: build.xml Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: build.xml =================================================================== RCS file: /cvsroot/exist/eXist-1.0/build.xml,v retrieving revision 1.121 retrieving revision 1.122 diff -C2 -d -r1.121 -r1.122 *** build.xml 17 Jan 2006 21:34:40 -0000 1.121 --- build.xml 30 Jan 2006 20:24:54 -0000 1.122 *************** *** 408,411 **** --- 408,412 ---- <junit haltonfailure="false" printsummary="on" showoutput="${junit.output}" fork="no"> <classpath refid="classpath.core"/> + <classpath refid="classpath.jetty"/> <formatter type="plain"/> <formatter type="xml"/> *************** *** 457,460 **** --- 458,462 ---- <test fork="yes" name="org.exist.xmlrpc.test.XmlRpcTest" todir="${junit.reports.dat}"/> <test fork="yes" name="org.exist.xmldb.test.RemoteTests" todir="${junit.reports.dat}"/> + <test fork="yes" name="org.exist.xquery.test.RemoteTests" todir="${junit.reports.dat}"/> <test fork="yes" name="org.exist.http.test.RESTServiceTest" todir="${junit.reports.dat}"/> </junit> |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:35:16
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13664/src/org/exist/util Modified Files: Compressor.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: Compressor.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Compressor.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Compressor.java 11 Nov 2005 22:13:55 -0000 1.1 --- Compressor.java 30 Jan 2006 19:34:58 -0000 1.2 *************** *** 24,27 **** --- 24,28 ---- import java.io.ByteArrayOutputStream; import java.io.IOException; + import java.io.OutputStream; import java.util.zip.ZipEntry; *************** *** 72,87 **** public static byte[] uncompress(byte[] whatToUncompress) throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(whatToUncompress); ZipInputStream gzis = new ZipInputStream(bais); ZipEntry zipentry = gzis.getNextEntry(); ! int len = Integer.parseInt(zipentry.getName()); ! ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[512]; int bread; while ((bread = gzis.read(buf)) != -1) ! baos.write(buf, 0, bread); gzis.closeEntry(); gzis.close(); - return baos.toByteArray(); } } --- 73,93 ---- public static byte[] uncompress(byte[] whatToUncompress) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + uncompress(whatToUncompress, baos); + return baos.toByteArray(); + } + + public static void uncompress(byte[] whatToUncompress, OutputStream os) + throws IOException { ByteArrayInputStream bais = new ByteArrayInputStream(whatToUncompress); ZipInputStream gzis = new ZipInputStream(bais); ZipEntry zipentry = gzis.getNextEntry(); ! Integer.parseInt(zipentry.getName()); byte[] buf = new byte[512]; int bread; while ((bread = gzis.read(buf)) != -1) ! os.write(buf, 0, bread); gzis.closeEntry(); gzis.close(); } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:34:18
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13371/src/org/exist/xquery/test Modified Files: XQueryTest.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: XQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XQueryTest.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** XQueryTest.java 28 Jan 2006 15:44:29 -0000 1.40 --- XQueryTest.java 30 Jan 2006 19:34:06 -0000 1.41 *************** *** 147,150 **** --- 147,153 ---- "DatabaseInstanceManager", "1.0"); dim.shutdown(); + testCollection = null; + database = null; + System.out.println("tearDown PASSED"); } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:32:10
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12478/src/org/exist/xquery/test Modified Files: ValueIndexTest.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: ValueIndexTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/ValueIndexTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ValueIndexTest.java 14 Nov 2005 17:38:05 -0000 1.13 --- ValueIndexTest.java 30 Jan 2006 19:31:56 -0000 1.14 *************** *** 27,30 **** --- 27,31 ---- import org.exist.storage.DBBroker; + import org.exist.xmldb.DatabaseInstanceManager; import org.exist.xmldb.IndexQueryService; import org.xmldb.api.DatabaseManager; *************** *** 89,92 **** --- 90,104 ---- } + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + DatabaseInstanceManager dim = + (DatabaseInstanceManager) testCollection.getService("DatabaseInstanceManager", "1.0"); + dim.shutdown(); + testCollection = null; + //System.out.println("tearDown PASSED"); + } + /** * @throws XMLDBException |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:31:50
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12314/src/org/exist/xquery/test Modified Files: XPathQueryTest.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: XPathQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/XPathQueryTest.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** XPathQueryTest.java 28 Jan 2006 10:43:03 -0000 1.58 --- XPathQueryTest.java 30 Jan 2006 19:31:35 -0000 1.59 *************** *** 1,4 **** --- 1,6 ---- package org.exist.xquery.test; + import java.net.BindException; + import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; *************** *** 7,12 **** --- 9,20 ---- import org.custommonkey.xmlunit.XMLTestCase; + import org.exist.StandaloneServer; import org.exist.storage.DBBroker; + import org.exist.xmldb.CollectionImpl; + import org.exist.xmldb.DatabaseInstanceManager; import org.exist.xmldb.XPathQueryServiceImpl; + import org.exist.xquery.XPathException; + import org.mortbay.util.MultiException; + import org.w3c.dom.Node; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; *************** *** 23,28 **** public class XPathQueryTest extends XMLTestCase { - - private final static String URI = "xmldb:exist://" + DBBroker.ROOT_COLLECTION; private final static String nested = --- 31,34 ---- *************** *** 108,119 **** "<test-self><a>Hello</a><b>World!</b></test-self>"; private Collection testCollection; private String query; - - public XPathQueryTest(String name) { - super(name); - } protected void setUp() { try { // initialize driver --- 114,131 ---- "<test-self><a>Hello</a><b>World!</b></test-self>"; + private static String uri = "xmldb:exist://" + DBBroker.ROOT_COLLECTION; + + public static void setURI(String collectionURI) { + uri = collectionURI; + } + + private static StandaloneServer server = null; + private Collection testCollection; private String query; protected void setUp() { + if (uri.startsWith("xmldb:exist://localhost")) + initServer(); try { // initialize driver *************** *** 125,129 **** Collection root = DatabaseManager.getCollection( ! URI, "admin", null); --- 137,141 ---- Collection root = DatabaseManager.getCollection( ! uri, "admin", null); *************** *** 134,142 **** testCollection = service.createCollection("test"); assertNotNull(testCollection); - - // XMLResource doc = - // (XMLResource) root.createResource("r_and_j.xml", "XMLResource"); - // doc.setContent(new File("samples/shakespeare/r_and_j.xml")); - // root.storeResource(doc); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { --- 146,149 ---- *************** *** 147,150 **** --- 154,207 ---- } + private void initServer() { + try { + if (server == null) { + server = new StandaloneServer(); + if (!server.isStarted()) { + try { + System.out.println("Starting standalone server..."); + String[] args = {}; + server.run(args); + while (!server.isStarted()) { + Thread.sleep(1000); + } + } catch (MultiException e) { + boolean rethrow = true; + Iterator i = e.getExceptions().iterator(); + while (i.hasNext()) { + Exception e0 = (Exception)i.next(); + if (e0 instanceof BindException) { + System.out.println("A server is running already !"); + rethrow = false; + break; + } + } + if (rethrow) throw e; + } + } + } + } catch(Exception e) { + fail(e.getMessage()); + } + } + + protected void tearDown() throws Exception { + try { + if (!((CollectionImpl) testCollection).isRemoteCollection()) { + DatabaseInstanceManager dim = + (DatabaseInstanceManager) testCollection.getService( + "DatabaseInstanceManager", "1.0"); + dim.shutdown(); + } + testCollection = null; + + System.out.println("tearDown PASSED"); + + } catch (XMLDBException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + public void testPathExpression() { try { *************** *** 153,162 **** //Invalid path expression left operand (not a node set). - boolean exceptionThrown = false; String message = ""; try { queryAndAssert(service, "('a', 'b', 'c')/position()", -1, null); } catch (XMLDBException e) { - exceptionThrown = true; message = e.getMessage(); } --- 210,217 ---- *************** *** 164,178 **** //Undefined context sequence - exceptionThrown = false; message = ""; try { queryAndAssert(service, "for $a in (<a/>, <b/>, doh, <c/>) return $a", -1, null); } catch (XMLDBException e) { - exceptionThrown = true; message = e.getMessage(); } assertTrue("Exception wanted: " + message, message.indexOf("XPDY0002") > -1); - exceptionThrown = false; message = ""; try { --- 219,230 ---- *************** *** 180,184 **** queryAndAssert(service, "let $a := (1, 2, 3) for $b in $a[1 to 2] return $b", -1, null); } catch (XMLDBException e) { - exceptionThrown = true; message = e.getMessage(); } --- 232,235 ---- *************** *** 211,215 **** XMLResource resource = (XMLResource)result.getResource(0); ! assertEquals("XPath: " + query, "item", resource.getContentAsDOM().getNodeName()); query = "/test/item [ @type='alphanum' ]"; --- 262,269 ---- XMLResource resource = (XMLResource)result.getResource(0); ! Node node = resource.getContentAsDOM(); ! if (node.getNodeType() == Node.DOCUMENT_NODE) ! node = node.getFirstChild(); ! assertEquals("XPath: " + query, "item", node.getNodeName()); query = "/test/item [ @type='alphanum' ]"; *************** *** 833,838 **** ResourceSet result = service.execute(expr); ! Resource r = result.getResource(0); ! assertEquals("string", ((XMLResource)r).getContentAsDOM().getNodeName()); } catch (XMLDBException e) { System.out.println("testExternalVars(): XMLDBException"); --- 887,895 ---- ResourceSet result = service.execute(expr); ! XMLResource r = (XMLResource) result.getResource(0); ! Node node = r.getContentAsDOM(); ! if (node.getNodeType() == Node.DOCUMENT_NODE) ! node = node.getFirstChild(); ! assertEquals("string", node.getNodeName()); } catch (XMLDBException e) { System.out.println("testExternalVars(): XMLDBException"); *************** *** 1196,1214 **** try { XQueryService service = getQueryService(); - ResourceSet result; query = "() except ()"; ! result = queryAndAssert( service, query, 0, ""); query = "() except (1)"; ! result = queryAndAssert( service, query, 0, ""); - boolean exceptionThrown = false; String message = ""; try { query = "(1) except ()"; ! result = queryAndAssert( service, query, 0, ""); } catch (XMLDBException e) { - exceptionThrown = true; message = e.getMessage(); } --- 1253,1268 ---- try { XQueryService service = getQueryService(); query = "() except ()"; ! queryAndAssert( service, query, 0, ""); query = "() except (1)"; ! queryAndAssert( service, query, 0, ""); String message = ""; try { query = "(1) except ()"; ! queryAndAssert( service, query, 0, ""); } catch (XMLDBException e) { message = e.getMessage(); } *************** *** 1216,1225 **** query = "<a/> except ()"; ! result = queryAndAssert( service, query, 1, ""); query = "() except <a/>"; ! result = queryAndAssert( service, query, 0, ""); //Not the same nodes query = "<a/> except <a/>"; ! result = queryAndAssert( service, query, 1, ""); } catch (XMLDBException e) { --- 1270,1279 ---- query = "<a/> except ()"; ! queryAndAssert( service, query, 1, ""); query = "() except <a/>"; ! queryAndAssert( service, query, 0, ""); //Not the same nodes query = "<a/> except <a/>"; ! queryAndAssert( service, query, 1, ""); } catch (XMLDBException e) { *************** *** 1274,1279 **** } public static void main(String[] args) { junit.textui.TestRunner.run(XPathQueryTest.class); } ! } --- 1328,1353 ---- } + public void testCompile() throws XMLDBException { + String invalidQuery = "for $i in (1 to 10)\n return $b"; + String validQuery = "for $i in (1 to 10) return $i"; + org.exist.xmldb.XQueryService service = (org.exist.xmldb.XQueryService) getQueryService(); + boolean exceptionOccurred = false; + try { + service.compileAndCheck(invalidQuery); + } catch (XPathException e) { + assertEquals(e.getLine(), 2); + exceptionOccurred = true; + } + assertTrue("Expected an exception", exceptionOccurred); + + try { + service.compileAndCheck(validQuery); + } catch (XPathException e) { + fail(e.getMessage()); + } + } + public static void main(String[] args) { junit.textui.TestRunner.run(XPathQueryTest.class); } ! } \ No newline at end of file |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:09:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3028/src/org/exist/xquery/test Modified Files: SeqOpTest.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: SeqOpTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/SeqOpTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** SeqOpTest.java 14 Nov 2005 17:38:05 -0000 1.3 --- SeqOpTest.java 30 Jan 2006 19:09:37 -0000 1.4 *************** *** 242,245 **** --- 242,247 ---- try { if (c != null) c.close(); + c = null; + query = null; } catch (XMLDBException e) { throw new RuntimeException("failed teardown", e); |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:09:30
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2918/src/org/exist/xquery/test Added Files: RemoteTests.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. --- NEW FILE: RemoteTests.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-06 The eXist Project * http://exist-db.org * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ package org.exist.xquery.test; import junit.framework.Test; import junit.framework.TestSuite; import org.exist.storage.DBBroker; public class RemoteTests { public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { TestSuite suite = new TestSuite("Test for org.exist.xquery.test"); //$JUnit-BEGIN$ XPathQueryTest.setURI("xmldb:exist://localhost:8088/xmlrpc" + DBBroker.ROOT_COLLECTION); suite.addTestSuite(XPathQueryTest.class); //$JUnit-END$ return suite; } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:08:35
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2321/src/org/exist/xquery/test Modified Files: LexerTest.java OpNumericTest.java DeepEqualTest.java FtQueryTest.java Added Files: QueryPoolTest.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: FtQueryTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/FtQueryTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** FtQueryTest.java 16 Nov 2005 17:17:54 -0000 1.6 --- FtQueryTest.java 30 Jan 2006 19:08:16 -0000 1.7 *************** *** 254,257 **** --- 254,259 ---- "DatabaseInstanceManager", "1.0"); dim.shutdown(); + database = null; + testCollection = null; System.out.println("tearDown PASSED"); } catch (XMLDBException e) { Index: LexerTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/LexerTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** LexerTest.java 14 Jan 2006 21:50:31 -0000 1.12 --- LexerTest.java 30 Jan 2006 19:08:16 -0000 1.13 *************** *** 138,140 **** --- 138,143 ---- } + protected void tearDown() throws Exception { + BrokerPool.stopAll(false); + } } Index: DeepEqualTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/DeepEqualTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** DeepEqualTest.java 15 Nov 2005 17:58:07 -0000 1.5 --- DeepEqualTest.java 30 Jan 2006 19:08:16 -0000 1.6 *************** *** 312,315 **** --- 312,317 ---- try { if (c != null) c.close(); + c = null; + query = null; } catch (XMLDBException e) { throw new RuntimeException("failed teardown", e); Index: OpNumericTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/OpNumericTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** OpNumericTest.java 17 Nov 2005 16:26:24 -0000 1.3 --- OpNumericTest.java 30 Jan 2006 19:08:16 -0000 1.4 *************** *** 51,54 **** --- 51,56 ---- BrokerPool.getInstance().release(broker); BrokerPool.stopAll(false); + broker = null; + context = null; } catch (Exception e) { fail(e.getMessage()); --- NEW FILE: QueryPoolTest.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-06 The eXist Project * http://exist-db.org * http://exist.sourceforge.net * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Id$ */ package org.exist.xquery.test; import org.exist.source.StringSource; import org.exist.storage.DBBroker; import org.exist.xmldb.XQueryService; import org.xmldb.api.DatabaseManager; import org.xmldb.api.base.Collection; import org.xmldb.api.base.Database; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; import org.xmldb.api.modules.XMLResource; import junit.framework.TestCase; import junit.textui.TestRunner; public class QueryPoolTest extends TestCase { private final static String URI = "xmldb:exist://" + DBBroker.ROOT_COLLECTION; private Collection testCollection; public static void main(String[] args) { TestRunner.run(QueryPoolTest.class); } public void testDifferentQueries() { try { XQueryService service = (XQueryService) testCollection.getService("XQueryService", "1.0"); for (int i = 0; i < 10000; i++) { System.out.println("Inserting node " + i + "..."); String query = "update insert <node id='id" + Integer.toHexString(i) + "'>" + "<p>Some longer text <b>content</b> in this node. Some longer text <b>content</b> in this node. " + "Some longer text <b>content</b> in this node. Some longer text <b>content</b> in this node.</p>" + "</node> " + "into //test[@id = 't1']"; service.execute(new StringSource(query)); } } catch (XMLDBException e) { e.printStackTrace(); fail(e.getMessage()); } } public void testRead() { try { XMLResource res = (XMLResource) testCollection.getResource("large_list.xml"); assertNotNull(res); System.out.println(res.getContent()); } catch (XMLDBException e) { e.printStackTrace(); fail(e.getMessage()); } } protected void setUp() { try { // initialize driver Class cl = Class.forName("org.exist.xmldb.DatabaseImpl"); Database database = (Database) cl.newInstance(); database.setProperty("create-database", "true"); DatabaseManager.registerDatabase(database); Collection root = DatabaseManager.getCollection( URI, "admin", null); CollectionManagementService service = (CollectionManagementService) root.getService( "CollectionManagementService", "1.0"); testCollection = service.createCollection("test-pool"); assertNotNull(testCollection); XMLResource doc = (XMLResource) testCollection.createResource("large_list.xml", "XMLResource"); doc.setContent("<test id='t1'/>"); testCollection.storeResource(doc); } catch (ClassNotFoundException e) { } catch (InstantiationException e) { } catch (IllegalAccessException e) { } catch (XMLDBException e) { e.printStackTrace(); } } protected void tearDown() throws Exception { try { CollectionManagementService service = (CollectionManagementService) testCollection.getService("CollectionManagementService", "1.0"); service.removeCollection("/db/test-pool"); } catch (XMLDBException e) { e.printStackTrace(); fail(e.getMessage()); } } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:08:10
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2036/src/org/exist/xquery/test Modified Files: AllTests.java Log Message: 1) JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected 2) Included XPathQueryTest into remote server tests. Index: AllTests.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/test/AllTests.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AllTests.java 7 Jan 2006 21:47:15 -0000 1.13 --- AllTests.java 30 Jan 2006 19:07:57 -0000 1.14 *************** *** 23,26 **** --- 23,28 ---- package org.exist.xquery.test; + import org.exist.storage.DBBroker; + import junit.framework.Test; import junit.framework.TestSuite; *************** *** 31,54 **** public class AllTests { ! public static void main(String[] args) { ! junit.swingui.TestRunner.run(AllTests.class); ! } ! public static Test suite() { ! TestSuite suite = new TestSuite("Test for org.exist.xquery.test"); ! //$JUnit-BEGIN$ ! suite.addTestSuite(XPathQueryTest.class); ! suite.addTestSuite(XQueryTest.class); ! suite.addTestSuite(ValueIndexTest.class); ! suite.addTestSuite(LexerTest.class); // jmv: Note: LexerTest needs /db/test created by XPathQueryTest ! suite.addTestSuite(DeepEqualTest.class); ! suite.addTestSuite(SeqOpTest.class); ! suite.addTestSuite(XMLNodeAsXQueryParameterTest.class); ! suite.addTestSuite(OpNumericTest.class); suite.addTestSuite(FtQueryTest.class); ! //suite.addTestSuite(XQueryFunctionsTest.class); ! // suite.addTestSuite(XQueryUseCasesTest.class); ! //$JUnit-END$ ! return suite; ! } } --- 33,57 ---- public class AllTests { ! public static void main(String[] args) { ! junit.textui.TestRunner.run(suite()); ! } ! public static Test suite() { ! TestSuite suite = new TestSuite("Test for org.exist.xquery.test"); ! //$JUnit-BEGIN$ ! XPathQueryTest.setURI("xmldb:exist://" + DBBroker.ROOT_COLLECTION); ! suite.addTestSuite(XQueryFunctionsTest.class); ! suite.addTestSuite(XPathQueryTest.class); ! suite.addTestSuite(XQueryTest.class); ! suite.addTestSuite(ValueIndexTest.class); ! suite.addTestSuite(LexerTest.class); // jmv: Note: LexerTest needs /db/test created by XPathQueryTest ! suite.addTestSuite(DeepEqualTest.class); ! suite.addTestSuite(SeqOpTest.class); ! suite.addTestSuite(XMLNodeAsXQueryParameterTest.class); ! suite.addTestSuite(OpNumericTest.class); suite.addTestSuite(FtQueryTest.class); ! // suite.addTestSuite(XQueryUseCasesTest.class); ! //$JUnit-END$ ! return suite; ! } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:05:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32436/src/org/exist/xmlrpc Modified Files: RpcConnection.java RpcServer.java RpcAPI.java Log Message: New method added to XQueryService: compileAndCheck(). Contrary to the compile() method, compileAndCheck() will not only prepare the query for execution, but also perform all static checks. Index: RpcServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcServer.java,v retrieving revision 1.65 retrieving revision 1.66 diff -C2 -d -r1.65 -r1.66 *** RpcServer.java 18 Jan 2006 13:13:08 -0000 1.65 --- RpcServer.java 30 Jan 2006 19:04:52 -0000 1.66 *************** *** 49,53 **** import org.xml.sax.SAXException; - /** * Handler class for XMLRPC calls. <p> --- 49,52 ---- *************** *** 70,75 **** * correct character encoding is preserved during transport.</p> * [...1918 lines suppressed...] ! return null; ! } finally { ! pool.release(con); ! } ! } ! ! public boolean setDocType(User user, String documentName, String doctypename, String publicid, ! String systemid) throws EXistException, PermissionDeniedException { ! RpcConnection con = null; ! try { ! con = pool.get(); ! return con.setDocType(user, documentName, doctypename, publicid, systemid); ! } catch (Exception e) { ! handleException(e); ! return false; ! } finally { ! pool.release(con); ! } ! } } Index: RpcAPI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcAPI.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** RpcAPI.java 3 Jan 2006 15:23:40 -0000 1.52 --- RpcAPI.java 30 Jan 2006 19:04:52 -0000 1.53 *************** *** 296,299 **** --- 296,301 ---- throws EXistException, PermissionDeniedException; + Hashtable compile(User user, byte[] xquery, Hashtable parameters) throws Exception; + Hashtable queryP(User user, byte[] 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.131 retrieving revision 1.132 diff -C2 -d -r1.131 -r1.132 *** RpcConnection.java 18 Jan 2006 13:13:08 -0000 1.131 --- RpcConnection.java 30 Jan 2006 19:04:51 -0000 1.132 *************** *** 80,83 **** --- 80,84 ---- import org.exist.storage.txn.TransactionManager; import org.exist.storage.txn.Txn; + import org.exist.util.Compressor; import org.exist.util.Configuration; import org.exist.util.LockException; *************** *** 232,278 **** } - protected PathExpr compile(User user, DBBroker broker, String xquery, - Hashtable parameters) throws Exception { - String baseURI = (String) parameters.get(RpcAPI.BASE_URI); - XQueryContext context = new XQueryContext(broker); - context.setBaseURI(baseURI); - Hashtable namespaces = (Hashtable)parameters.get(RpcAPI.NAMESPACES); - if(namespaces != null && namespaces.size() > 0) { - 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(context, new StringReader(xquery)); - XQueryParser parser = new XQueryParser(lexer); - XQueryTreeParser treeParser = new XQueryTreeParser(context); - - parser.xpath(); - if (parser.foundErrors()) { - throw new EXistException(parser.getErrorMessage()); - } - - AST ast = parser.getAST(); - - PathExpr expr = new PathExpr(context); - treeParser.xpath(ast, expr); - if (treeParser.foundErrors()) { - throw new EXistException(treeParser.getErrorMessage()); - } - expr.analyze(new AnalyzeContextInfo()); - return expr; - } - protected QueryResult doQuery(User user, DBBroker broker, String xpath, NodeSet contextSet, Hashtable parameters) throws Exception { Source source = new StringSource(xpath); XQuery xquery = broker.getXQueryService(); XQueryPool pool = xquery.getXQueryPool(); --- 233,260 ---- } protected QueryResult doQuery(User user, DBBroker broker, String xpath, NodeSet contextSet, Hashtable parameters) throws Exception { + XQuery xquery = broker.getXQueryService(); + XQueryPool pool = xquery.getXQueryPool(); Source source = new StringSource(xpath); + CompiledXQuery compiled = compile(user, broker, source, parameters); + checkPragmas(compiled.getContext(), parameters); + try { + long start = System.currentTimeMillis(); + Sequence result = xquery.execute(compiled, contextSet); + // pass last modified date to the HTTP response + HTTPUtils.addLastModifiedHeader( result, compiled.getContext() ); + LOG.info("query took " + (System.currentTimeMillis() - start) + "ms."); + return new QueryResult(compiled.getContext(), result); + } catch (XPathException e) { + return new QueryResult(e); + } finally { + if(compiled != null) + pool.returnCompiledXQuery(source, compiled); + } + } + + private CompiledXQuery compile(User user, DBBroker broker, Source source, Hashtable parameters) throws XPathException, IOException { XQuery xquery = broker.getXQueryService(); XQueryPool pool = xquery.getXQueryPool(); *************** *** 288,292 **** context.declareNamespaces(namespaces); } ! // declare static variables Hashtable variableDecls = (Hashtable)parameters.get(RpcAPI.VARIABLES); if(variableDecls != null) { --- 270,274 ---- context.declareNamespaces(namespaces); } ! // declare static variables Hashtable variableDecls = (Hashtable)parameters.get(RpcAPI.VARIABLES); if(variableDecls != null) { *************** *** 309,329 **** context.setStaticallyKnownDocuments(new String[] { context.getBaseURI() }); } ! try { ! if(compiled == null) ! compiled = xquery.compile(context, source); ! checkPragmas(context, parameters); ! ! long start = System.currentTimeMillis(); ! Sequence result = xquery.execute(compiled, contextSet); ! // pass last modified date to the HTTP response ! HTTPUtils.addLastModifiedHeader( result, context ); ! LOG.info("query took " + (System.currentTimeMillis() - start) + "ms."); ! return new QueryResult(context, result); ! } catch (XPathException e) { ! return new QueryResult(e); ! } finally { ! if(compiled != null) ! pool.returnCompiledXQuery(source, compiled); ! } } --- 291,297 ---- context.setStaticallyKnownDocuments(new String[] { context.getBaseURI() }); } ! if(compiled == null) ! compiled = xquery.compile(context, source); ! return compiled; } *************** *** 337,341 **** CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source); if(compiled == null) ! compiled = compile(user, broker, query, parameters); StringWriter writer = new StringWriter(); compiled.dump(writer); --- 305,309 ---- CompiledXQuery compiled = pool.borrowCompiledXQuery(broker, source); if(compiled == null) ! compiled = compile(user, broker, source, parameters); StringWriter writer = new StringWriter(); compiled.dump(writer); *************** *** 1305,1309 **** } ! public String upload(User user, byte[] chunk, int length, String fileName) throws EXistException, IOException { File file; --- 1273,1277 ---- } ! public String upload(User user, byte[] chunk, int length, String fileName, boolean compressed) throws EXistException, IOException { File file; *************** *** 1314,1324 **** LOG.debug("created temporary file " + file.getAbsolutePath()); } else { ! LOG.debug("appending to file " + fileName); file = new File(fileName); } if (!file.canWrite()) throw new EXistException("cannot write to file " + fileName); ! FileOutputStream os = new FileOutputStream(file.getAbsolutePath(), true); ! os.write(chunk, 0, length); os.close(); return fileName; --- 1282,1295 ---- LOG.debug("created temporary file " + file.getAbsolutePath()); } else { ! // LOG.debug("appending to file " + fileName); file = new File(fileName); } if (!file.canWrite()) throw new EXistException("cannot write to file " + fileName); ! FileOutputStream os = new FileOutputStream(file, true); ! if (compressed) ! Compressor.uncompress(chunk, os); ! else ! os.write(chunk, 0, length); os.close(); return fileName; *************** *** 1372,1375 **** --- 1343,1371 ---- } + public Hashtable compile(User user, String query, Hashtable parameters) throws Exception { + Hashtable ret = new Hashtable(); + DBBroker broker = null; + XQueryPool pool = null; + CompiledXQuery compiled = null; + Source source = new StringSource(query); + try { + broker = brokerPool.get(user); + XQuery xquery = broker.getXQueryService(); + pool = xquery.getXQueryPool(); + compiled = compile(user, broker, source, parameters); + } catch (XPathException e) { + ret.put(RpcAPI.ERROR, e.getMessage()); + if(e.getLine() != 0) { + ret.put(RpcAPI.LINE, new Integer(e.getLine())); + ret.put(RpcAPI.COLUMN, new Integer(e.getColumn())); + } + } finally { + brokerPool.release(broker); + if(compiled != null && pool != null) + pool.returnCompiledXQuery(source, compiled); + } + return ret; + } + public String query(User user, String xpath, int howmany, int start, Hashtable parameters) throws Exception { |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:04:24
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32187/src/org/exist/xmldb/test/concurrent Modified Files: ConcurrentTestBase.java DBUtils.java Log Message: JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected. Index: DBUtils.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent/DBUtils.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** DBUtils.java 28 Jul 2005 17:36:02 -0000 1.12 --- DBUtils.java 30 Jan 2006 19:04:14 -0000 1.13 *************** *** 75,79 **** } ! public static File generateXMLFile(int elementCnt, int attrCnt, String[] wordList, boolean namespaces) throws Exception { File file = File.createTempFile(Thread.currentThread().getName(), ".xml"); if(file.exists() && !file.canWrite()) --- 75,83 ---- } ! public static File generateXMLFile(int elementCnt, int attrCnt, String[] wordList, boolean namespaces) throws Exception { ! return generateXMLFile(3, elementCnt, attrCnt, wordList, false); ! } ! ! public static File generateXMLFile(int depth, int elementCnt, int attrCnt, String[] wordList, boolean namespaces) throws Exception { File file = File.createTempFile(Thread.currentThread().getName(), ".xml"); if(file.exists() && !file.canWrite()) *************** *** 83,87 **** Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); ! XMLGenerator gen = new XMLGenerator(elementCnt, attrCnt, 3, wordList, namespaces); gen.generateXML(writer); writer.close(); --- 87,91 ---- Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8")); ! XMLGenerator gen = new XMLGenerator(elementCnt, attrCnt, depth, wordList, namespaces); gen.generateXML(writer); writer.close(); Index: ConcurrentTestBase.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/concurrent/ConcurrentTestBase.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ConcurrentTestBase.java 13 Nov 2005 10:34:58 -0000 1.5 --- ConcurrentTestBase.java 30 Jan 2006 19:04:14 -0000 1.6 *************** *** 38,190 **** public abstract class ConcurrentTestBase extends TestCase { ! protected String rootColURI; ! protected Collection rootCol; ! protected String testColName; ! protected Collection testCol; ! ! protected List actions = new ArrayList(5); ! ! protected volatile boolean failed = false; ! ! /** ! * @param name the name of the test. ! * @param uri the XMLDB URI of the root collection. ! * @param testCollection the name of the collection that will be created for the test. ! */ ! public ConcurrentTestBase(String name, String uri, String testCollection) { ! super(name); ! this.rootColURI = uri; ! this.testColName = testCollection; ! } ! /** ! * Add an {@link Action} to the list of actions that will be processed ! * concurrently. Should be called after {@link #setUp()}. ! * ! * @param action the action. ! * @param repeat number of times the actions should be repeated. ! */ ! public void addAction(Action action, int repeat, long delayBeforeStart, long delay) { ! actions.add(new Runner(action, repeat, delayBeforeStart, delay)); ! } ! ! public Collection getTestCollection() { ! return testCol; ! } ! ! public void testConcurrent() { ! // start all threads ! for(int i = 0; i < actions.size(); i++) { ! Thread t = (Thread)actions.get(i); ! t.start(); ! } ! ! // wait for threads to finish ! try { ! for(int i = 0; i < actions.size(); i++) { ! Thread t = (Thread)actions.get(i); ! t.join(); ! } ! } catch(Exception e) { ! e.printStackTrace(); ! failed = true; ! } ! ! assertFalse(failed); ! } ! ! /* ! * @see TestCase#setUp() ! */ ! protected void setUp() { ! try { ! rootCol = DBUtils.setupDB(rootColURI); ! assertNotNull(rootCol); ! testCol = rootCol.getChildCollection(testColName); ! if(testCol != null) { ! CollectionManagementService mgr = DBUtils.getCollectionManagementService(rootCol); ! mgr.removeCollection(testColName); ! } ! testCol = DBUtils.addCollection(rootCol, testColName); ! assertNotNull(testCol); ! DBUtils.addXMLResource(rootCol, "biblio.rdf", new File("samples/biblio.rdf")); ! } catch (Exception e) { ! fail(e.getMessage()); ! } ! } ! /* ! * @see TestCase#tearDown() ! */ ! protected void tearDown() { ! try { ! Resource res = rootCol.getResource("biblio.rdf"); ! assertNotNull(res); ! rootCol.removeResource(res); ! DBUtils.removeCollection(rootCol, testColName); ! DBUtils.shutdownDB(rootColURI); ! } catch (Exception e) { ! fail(e.getMessage()); ! } ! } ! ! /** ! * Runs the specified Action a number of times. ! * ! * @author wolf ! */ ! class Runner extends Thread { ! ! private Action action; ! private int repeat; ! private long delay = 0; ! private long delayBeforeStart = 0; ! ! public Runner(Action action, int repeat, long delayBeforeStart, long delay) { ! super(); ! this.action = action; ! this.repeat = repeat; ! this.delay = delay; ! this.delayBeforeStart = delayBeforeStart; ! } ! ! /* (non-Javadoc) ! * @see java.lang.Thread#run() ! */ ! public void run() { ! if(delayBeforeStart > 0) { ! synchronized(this) { ! try { ! wait(delayBeforeStart); ! } catch (InterruptedException e) { ! System.err.println("Action failed in Thread " + getName() + ": " + e.getMessage()); ! e.printStackTrace(); ! failed = true; ! } ! } ! } ! try ! { ! for (int i = 0; i < repeat; i++) ! { ! if (failed) ! { ! break; ! } ! failed = action.execute(); ! if(delay > 0) ! synchronized(this) { ! wait(delay); ! } ! } ! } ! catch (Exception e) ! { ! System.err.println("Action failed in Thread " + getName() + ": " + e.getMessage()); ! e.printStackTrace(); ! failed = true; ! } ! } ! } } --- 38,195 ---- public abstract class ConcurrentTestBase extends TestCase { ! protected String rootColURI; ! protected Collection rootCol; ! protected String testColName; ! protected Collection testCol; ! ! protected List actions = new ArrayList(5); ! ! protected volatile boolean failed = false; ! ! /** ! * @param name the name of the test. ! * @param uri the XMLDB URI of the root collection. ! * @param testCollection the name of the collection that will be created for the test. ! */ ! public ConcurrentTestBase(String name, String uri, String testCollection) { ! super(name); ! this.rootColURI = uri; ! this.testColName = testCollection; ! } ! ! /** ! * Add an {@link Action} to the list of actions that will be processed ! * concurrently. Should be called after {@link #setUp()}. ! * ! * @param action the action. ! * @param repeat number of times the actions should be repeated. ! */ ! public void addAction(Action action, int repeat, long delayBeforeStart, long delay) { ! actions.add(new Runner(action, repeat, delayBeforeStart, delay)); ! } ! ! public Collection getTestCollection() { ! return testCol; ! } ! ! public void testConcurrent() { ! // start all threads ! for (int i = 0; i < actions.size(); i++) { ! Thread t = (Thread) actions.get(i); ! t.start(); ! } ! ! // wait for threads to finish ! try { ! for (int i = 0; i < actions.size(); i++) { ! Thread t = (Thread) actions.get(i); ! t.join(); ! } ! } catch (Exception e) { ! e.printStackTrace(); ! failed = true; ! } ! ! assertFalse(failed); ! } ! ! /* ! * @see TestCase#setUp() ! */ ! protected void setUp() { ! try { ! rootCol = DBUtils.setupDB(rootColURI); ! assertNotNull(rootCol); ! testCol = rootCol.getChildCollection(testColName); ! if (testCol != null) { ! CollectionManagementService mgr = DBUtils.getCollectionManagementService(rootCol); ! mgr.removeCollection(testColName); ! } ! testCol = DBUtils.addCollection(rootCol, testColName); ! assertNotNull(testCol); ! DBUtils.addXMLResource(rootCol, "biblio.rdf", new File("samples/biblio.rdf")); ! } catch (Exception e) { ! fail(e.getMessage()); ! } ! } ! ! /* ! * @see TestCase#tearDown() ! */ ! protected void tearDown() { ! try { ! Resource res = rootCol.getResource("biblio.rdf"); ! assertNotNull(res); ! rootCol.removeResource(res); ! DBUtils.removeCollection(rootCol, testColName); ! DBUtils.shutdownDB(rootColURI); ! ! rootCol = null; ! testCol = null; ! } catch (Exception e) { ! fail(e.getMessage()); ! } ! } ! ! /** ! * Runs the specified Action a number of times. ! * ! * @author wolf ! */ ! class Runner extends Thread { ! ! private Action action; ! ! private int repeat; ! ! private long delay = 0; ! ! private long delayBeforeStart = 0; ! ! public Runner(Action action, int repeat, long delayBeforeStart, long delay) { ! super(); ! this.action = action; ! this.repeat = repeat; ! this.delay = delay; ! this.delayBeforeStart = delayBeforeStart; ! } ! ! /* (non-Javadoc) ! * @see java.lang.Thread#run() ! */ ! public void run() { ! if (delayBeforeStart > 0) { ! synchronized (this) { ! try { ! wait(delayBeforeStart); ! } catch (InterruptedException e) { ! System.err.println("Action failed in Thread " + getName() + ": " ! + e.getMessage()); ! e.printStackTrace(); ! failed = true; ! } ! } ! } ! try { ! for (int i = 0; i < repeat; i++) { ! if (failed) { ! break; ! } ! ! failed = action.execute(); ! if (delay > 0) ! synchronized (this) { ! wait(delay); ! } ! } ! } catch (Exception e) { ! System.err.println("Action failed in Thread " + getName() + ": " + e.getMessage()); ! e.printStackTrace(); ! failed = true; ! } ! } ! } } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:04:05
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32021/src/org/exist/xmldb/test Modified Files: CreateCollectionsTest.java ContentAsDOMTest.java RemoteCollectionTest.java TestEXistXMLSerialize.java Log Message: JUnit seems to keep references to test instances. To save memory, references to collections or services should be explicitely nulled in tearDown(), so they can be garbage collected. Index: RemoteCollectionTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/RemoteCollectionTest.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** RemoteCollectionTest.java 10 Nov 2005 08:03:13 -0000 1.12 --- RemoteCollectionTest.java 30 Jan 2006 19:03:54 -0000 1.13 *************** *** 38,42 **** public RemoteCollectionTest(String name) { super(name); ! } protected void setUp() { --- 38,42 ---- public RemoteCollectionTest(String name) { super(name); ! } protected void setUp() { Index: ContentAsDOMTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/ContentAsDOMTest.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ContentAsDOMTest.java 6 Nov 2005 20:24:13 -0000 1.4 --- ContentAsDOMTest.java 30 Jan 2006 19:03:54 -0000 1.5 *************** *** 124,127 **** --- 124,129 ---- root.getService("DatabaseInstanceManager", "1.0"); mgr.shutdown(); + + root = null; } catch (Exception e) { fail(e.getMessage()); Index: CreateCollectionsTest.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/CreateCollectionsTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** CreateCollectionsTest.java 20 Nov 2005 16:52:57 -0000 1.13 --- CreateCollectionsTest.java 30 Jan 2006 19:03:54 -0000 1.14 *************** *** 49,52 **** --- 49,56 ---- } + protected void tearDown() throws Exception { + root = null; + } + public void testCreateCollection() { try { Index: TestEXistXMLSerialize.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/test/TestEXistXMLSerialize.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** TestEXistXMLSerialize.java 11 Nov 2005 21:00:15 -0000 1.6 --- TestEXistXMLSerialize.java 30 Jan 2006 19:03:54 -0000 1.7 *************** *** 76,79 **** --- 76,81 ---- try { DatabaseManager.deregisterDatabase(database); + c = null; + database = null; } catch (Exception e) { fail(e.getMessage()); |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 19:01:44
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30769/src/org/exist/xmldb Modified Files: RemoteCollection.java LocalXPathQueryService.java XQueryService.java RemoteXPathQueryService.java Log Message: New method added to XQueryService: compileAndCheck(). Contrary to the compile() method, compileAndCheck() will not only prepare the query for execution, but also perform all static checks. Index: RemoteXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteXPathQueryService.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** RemoteXPathQueryService.java 10 Aug 2005 10:09:45 -0000 1.26 --- RemoteXPathQueryService.java 30 Jan 2006 19:01:26 -0000 1.27 *************** *** 68,73 **** --- 68,98 ---- } + public CompiledExpression compileAndCheck(String query) throws XMLDBException, XPathException { + try { + Hashtable optParams = new Hashtable(); + if(namespaceMappings.size() > 0) + optParams.put(RpcAPI.NAMESPACES, namespaceMappings); + if(variableDecls.size() > 0) + optParams.put(RpcAPI.VARIABLES, variableDecls); + optParams.put(RpcAPI.BASE_URI, + outputProperties.getProperty("base-uri", collection.getPath())); + Vector params = new Vector(); + params.addElement(query.getBytes("UTF-8")); + params.addElement(optParams); + Hashtable result = (Hashtable) collection.getClient().execute( "compile", params ); + + if (result.get(RpcAPI.ERROR) != null) + throwXPathException(result); + return new RemoteCompiledExpression(query); + } catch ( XmlRpcException xre ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, xre.getMessage(), xre ); + } catch ( IOException ioe ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, ioe.getMessage(), ioe ); + } + } + /** * @param result + * @throws XPathException */ private void throwException(Hashtable result) throws XMLDBException { *************** *** 81,84 **** --- 106,118 ---- } + private void throwXPathException(Hashtable result) throws XPathException { + String message = (String)result.get(RpcAPI.ERROR); + Integer lineInt = (Integer)result.get(RpcAPI.LINE); + Integer columnInt = (Integer)result.get(RpcAPI.COLUMN); + int line = lineInt == null ? 0 : lineInt.intValue(); + int column = columnInt == null ? 0 : columnInt.intValue(); + throw new XPathException(message, line, column); + } + /* (non-Javadoc) * @see org.exist.xmldb.XQueryService#execute(org.exist.source.Source) Index: LocalXPathQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalXPathQueryService.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** LocalXPathQueryService.java 7 Jan 2006 21:47:13 -0000 1.57 --- LocalXPathQueryService.java 30 Jan 2006 19:01:26 -0000 1.58 *************** *** 197,222 **** public CompiledExpression compile(String query) throws XMLDBException { - DBBroker broker = null; try { ! long start = System.currentTimeMillis(); ! broker = brokerPool.get(user); ! XQuery xquery = broker.getXQueryService(); ! XQueryContext context = xquery.newContext(); ! setupContext(context); ! CompiledXQuery expr = xquery.compile(context, new StringReader(query)); ! checkPragmas(context); ! LOG.debug("compilation took " + (System.currentTimeMillis() - start)); ! return expr; ! } catch (EXistException e) { ! throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } catch (XPathException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); - } catch (IllegalArgumentException e) { - throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); - } finally { - brokerPool.release(broker); } } public ResourceSet queryResource(String resource, String query) throws XMLDBException { --- 197,228 ---- public CompiledExpression compile(String query) throws XMLDBException { try { ! return compileAndCheck(query); } catch (XPathException e) { throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); } } + public CompiledExpression compileAndCheck(String query) throws XMLDBException, XPathException { + DBBroker broker = null; + try { + long start = System.currentTimeMillis(); + broker = brokerPool.get(user); + XQuery xquery = broker.getXQueryService(); + XQueryContext context = xquery.newContext(); + setupContext(context); + CompiledXQuery expr = xquery.compile(context, new StringReader(query)); + checkPragmas(context); + LOG.debug("compilation took " + (System.currentTimeMillis() - start)); + return expr; + } catch (EXistException e) { + throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); + } catch (IllegalArgumentException e) { + throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); + } finally { + brokerPool.release(broker); + } + } + public ResourceSet queryResource(String resource, String query) throws XMLDBException { Index: XQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/XQueryService.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** XQueryService.java 7 Jan 2006 21:47:13 -0000 1.8 --- XQueryService.java 30 Jan 2006 19:01:26 -0000 1.9 *************** *** 26,29 **** --- 26,30 ---- import org.exist.source.Source; + import org.exist.xquery.XPathException; import org.xmldb.api.base.ResourceSet; import org.xmldb.api.base.XMLDBException; *************** *** 73,76 **** --- 74,87 ---- public CompiledExpression compile(String query) throws XMLDBException; + /** + * Tries to compile the specified XQuery and returns a handle to the compiled + * code, which can then be passed to {@link #execute(CompiledExpression)}. + * If a static error is detected, an {@link XPathException} will be thrown. + * + * @param query + * @return + */ + public CompiledExpression compileAndCheck(String query) throws XMLDBException, XPathException; + public ResourceSet execute(Source source) throws XMLDBException; Index: RemoteCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteCollection.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** RemoteCollection.java 6 Jan 2006 16:43:12 -0000 1.34 --- RemoteCollection.java 30 Jan 2006 19:01:26 -0000 1.35 *************** *** 62,66 **** // junks and uploaded to the server via the update() call private static final int MAX_CHUNK_LENGTH = 512 * 1024; ! private static final int MAX_UPLOAD_CHUNK = 1 * 1024 * 1024; protected Map childCollections = null; --- 62,66 ---- // junks and uploaded to the server via the update() call private static final int MAX_CHUNK_LENGTH = 512 * 1024; ! private static final int MAX_UPLOAD_CHUNK = 10 * 1024 * 1024; protected Map childCollections = null; |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 17:43:59
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/journal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30927/src/org/exist/storage/journal Modified Files: Journal.java Log Message: Explicitely set direct byte buffers to null upon shutdown. Index: Journal.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/journal/Journal.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Journal.java 5 Jan 2006 16:46:38 -0000 1.9 --- Journal.java 30 Jan 2006 17:43:50 -0000 1.10 *************** *** 424,427 **** --- 424,428 ---- } catch (InterruptedException e) { } + currentBuffer = null; } |
|
From: Wolfgang M. M. <wol...@us...> - 2006-01-30 16:38:58
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31327/src/org/exist/util Modified Files: XMLReaderPool.java Log Message: Before returning an XMLReader to the pool, clear the ContentHandler, LexicalHandler and ErrorHandlers set on it. Otherwise, some of the temporary data structures used during indexing will not be garbage collected. Index: XMLReaderPool.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/XMLReaderPool.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** XMLReaderPool.java 12 Aug 2004 18:54:20 -0000 1.2 --- XMLReaderPool.java 30 Jan 2006 16:38:45 -0000 1.3 *************** *** 23,27 **** --- 23,29 ---- import org.apache.commons.pool.PoolableObjectFactory; import org.apache.commons.pool.impl.StackObjectPool; + import org.exist.storage.BrokerPool; import org.xml.sax.XMLReader; + import org.xml.sax.ext.DefaultHandler2; /** *************** *** 33,62 **** public class XMLReaderPool extends StackObjectPool { ! /** ! * @param arg0 ! * @param arg1 ! * @param arg2 ! */ ! public XMLReaderPool(PoolableObjectFactory factory, int maxIdle, int initIdleCapacity) { ! super(factory, maxIdle, initIdleCapacity); ! } ! public synchronized XMLReader borrowXMLReader() { ! try { ! return (XMLReader)borrowObject(); ! } catch(Exception e) { ! throw new IllegalStateException("error while returning XMLReader: " + e.getMessage()); ! } ! } ! ! public synchronized void returnXMLReader(XMLReader reader) { ! if(reader == null) { ! return; ! } ! try { ! returnObject(reader); ! } catch (Exception e) { ! throw new IllegalStateException("error while returning XMLReader: " + e.getMessage()); ! } ! } } --- 35,69 ---- public class XMLReaderPool extends StackObjectPool { ! private final static DefaultHandler2 DUMMY_HANDLER = new DefaultHandler2(); ! ! /** ! * @param arg0 ! * @param arg1 ! * @param arg2 ! */ ! public XMLReaderPool(PoolableObjectFactory factory, int maxIdle, int initIdleCapacity) { ! super(factory, maxIdle, initIdleCapacity); ! } ! public synchronized XMLReader borrowXMLReader() { ! try { ! return (XMLReader) borrowObject(); ! } catch (Exception e) { ! throw new IllegalStateException("error while returning XMLReader: " + e.getMessage()); ! } ! } ! ! public synchronized void returnXMLReader(XMLReader reader) { ! if (reader == null) { ! return; ! } ! try { ! reader.setContentHandler(DUMMY_HANDLER); ! reader.setErrorHandler(DUMMY_HANDLER); ! reader.setProperty("http://xml.org/sax/properties/lexical-handler", DUMMY_HANDLER); ! returnObject(reader); ! } catch (Exception e) { ! throw new IllegalStateException("error while returning XMLReader: " + e.getMessage()); ! } ! } } |