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
(3) |
2
(3) |
3
(7) |
4
(10) |
5
(11) |
6
(10) |
|
7
(12) |
8
(7) |
9
(5) |
10
(5) |
11
(6) |
12
(6) |
13
(9) |
|
14
(1) |
15
(1) |
16
(4) |
17
(4) |
18
(2) |
19
(6) |
20
(10) |
|
21
(14) |
22
(9) |
23
(3) |
24
(3) |
25
(4) |
26
(18) |
27
(3) |
|
28
(7) |
29
(7) |
30
(7) |
31
(2) |
|
|
|
|
From: <wol...@us...> - 2007-01-31 19:49:58
|
Revision: 5301
http://svn.sourceforge.net/exist/?rev=5301&view=rev
Author: wolfgang_m
Date: 2007-01-31 11:49:53 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Added documentation on how to trigger a backup from XQuery.
Modified Paths:
--------------
trunk/eXist/webapp/backup.xml
Modified: trunk/eXist/webapp/backup.xml
===================================================================
--- trunk/eXist/webapp/backup.xml 2007-01-31 19:48:08 UTC (rev 5300)
+++ trunk/eXist/webapp/backup.xml 2007-01-31 19:49:53 UTC (rev 5301)
@@ -244,7 +244,8 @@
<param name="prefix" value="backup-"/>
<param name="collection" value="/db"/>
</parameters>
-system:trigger-system-task("org.exist.storage.BackupSystemTask", $params)]]></programlisting>
+ return
+ system:trigger-system-task("org.exist.storage.BackupSystemTask", $params)]]></programlisting>
</example>
<para>The function will schedule a backup to be executed as soon as possible. As explained above,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-31 19:48:11
|
Revision: 5300
http://svn.sourceforge.net/exist/?rev=5300&view=rev
Author: wolfgang_m
Date: 2007-01-31 11:48:08 -0800 (Wed, 31 Jan 2007)
Log Message:
-----------
Added documentation on how to trigger a backup from XQuery.
Modified Paths:
--------------
trunk/eXist/webapp/backup.xml
Modified: trunk/eXist/webapp/backup.xml
===================================================================
--- trunk/eXist/webapp/backup.xml 2007-01-30 19:26:58 UTC (rev 5299)
+++ trunk/eXist/webapp/backup.xml 2007-01-31 19:48:08 UTC (rev 5300)
@@ -228,5 +228,28 @@
Unix cron utility, though there are small differences. Please consult the Quartz documentation about
<ulink url="CronTrigger" rel="nofollow">http://www.opensymphony.com/quartz/wikidocs/TutorialLesson6.html">CronTrigger</ulink> configuration.</para>
</section>
+ <section>
+ <title>Triggering a Backup</title>
+
+ <para>The <classname>BackupSystemTask</classname> can also be triggered via XQuery, using the
+ <command>system:trigger-system-task</command> function defined in the "system" module:
+ </para>
+
+ <example>
+ <title>Triggering a Backup From XQuery</title>
+ <programlisting><![CDATA[let $params :=
+ <parameters>
+ <param name="dir" value="backup"/>
+ <param name="suffix" value=".zip"/>
+ <param name="prefix" value="backup-"/>
+ <param name="collection" value="/db"/>
+ </parameters>
+system:trigger-system-task("org.exist.storage.BackupSystemTask", $params)]]></programlisting>
+ </example>
+
+ <para>The function will schedule a backup to be executed as soon as possible. As explained above,
+ the database will be switched to service mode, and eXist
+ will wait for all pending transactions to complete before the backup starts.</para>
+ </section>
</chapter>
</book>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-30 19:27:15
|
Revision: 5299
http://svn.sourceforge.net/exist/?rev=5299&view=rev
Author: dizzzz
Date: 2007-01-30 11:26:58 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Fixed -again- a long standing bug, found while implementing some upcoming goodies. thnx all for testing. now without threading issues during validation tests
Modified Paths:
--------------
trunk/eXist/src/org/exist/validation/internal/BlockingInputStream.java
trunk/eXist/src/org/exist/validation/internal/ResourceInputStream.java
trunk/eXist/src/org/exist/validation/internal/ResourceThread.java
Modified: trunk/eXist/src/org/exist/validation/internal/BlockingInputStream.java
===================================================================
--- trunk/eXist/src/org/exist/validation/internal/BlockingInputStream.java 2007-01-30 18:09:39 UTC (rev 5298)
+++ trunk/eXist/src/org/exist/validation/internal/BlockingInputStream.java 2007-01-30 19:26:58 UTC (rev 5299)
@@ -121,7 +121,7 @@
*
* @throws IOException if an I/O error occurs.
*/
- public synchronized void close() throws IOException {
+ public synchronized void closeInputStream() throws IOException {
closed = true;
notifyAll();
}
@@ -224,7 +224,7 @@
*
* @throws IOException if an I/O error occurs.
*/
- public synchronized void closeOutputStream() throws IOException {
+ public synchronized void close() throws IOException {
try {
while(!empty() && !closed) wait();
if (!empty()) throw new IOException("Closing non empty stream.");
Modified: trunk/eXist/src/org/exist/validation/internal/ResourceInputStream.java
===================================================================
--- trunk/eXist/src/org/exist/validation/internal/ResourceInputStream.java 2007-01-30 18:09:39 UTC (rev 5298)
+++ trunk/eXist/src/org/exist/validation/internal/ResourceInputStream.java 2007-01-30 19:26:58 UTC (rev 5299)
@@ -22,6 +22,7 @@
package org.exist.validation.internal;
+import java.io.IOException;
import java.io.InputStream;
import org.apache.log4j.Logger;
@@ -30,7 +31,7 @@
/**
- * Wrapper between ResourceThread that writes data into outputstream and
+ * Wrapper between ResourceThread that writes data into outputstream and
* the needed InputStream that is needed for the Validator. The glue is the
* circulair buffer BlockingOutputStream.
*
@@ -43,10 +44,11 @@
private final static Logger logger = Logger.getLogger(ResourceInputStream.class);
private BlockingOutputStream bis = null;
+ private ResourceThread rt = null;
/**
* Creates a new instance of ResourceInputStream.
- *
+ *
* @param brokerPool BrokerPool
* @param docUri XML resource that must be streamed.
*/
@@ -56,57 +58,81 @@
bis = new BlockingOutputStream();
- ResourceThread rt = new ResourceThread(brokerPool, docUri, bis);
+ rt = new ResourceThread(brokerPool, docUri, bis);
rt.start();
logger.debug("Initializing ResourceInputStream done");
}
-
+
public int read(byte[] b, int off, int len) throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
return bis.read(b, off, len);
}
-
+
public int read(byte[] b) throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
return bis.read(b, 0, b.length);
}
-
+
// public void mark(int readlimit) {
//
// bis.mark(readlimit);
// }
-
+
public long skip(long n) throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
return super.skip(n);
}
-
+
public void reset() throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
super.reset();
}
-
+
public int read() throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
return bis.read();
}
-
+
// public boolean markSupported() {
//
// boolean retValue;
-//
+//
// retValue = bis.markSupported();
// return retValue;
// }
-
+
public void close() throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
bis.close();
}
//DWES
public void flush() throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
bis.flush();
}
-
-
+
+
public int available() throws java.io.IOException {
+ if(rt.isExceptionThrown()) {
+ throw new IOException(rt.getThrownException().getMessage());
+ }
return bis.available();
}
Modified: trunk/eXist/src/org/exist/validation/internal/ResourceThread.java
===================================================================
--- trunk/eXist/src/org/exist/validation/internal/ResourceThread.java 2007-01-30 18:09:39 UTC (rev 5298)
+++ trunk/eXist/src/org/exist/validation/internal/ResourceThread.java 2007-01-30 19:26:58 UTC (rev 5299)
@@ -51,6 +51,8 @@
private BrokerPool brokerPool;
private XmldbURI docUri;
private OutputStream outputStream;
+ private Exception exception=null;
+
/** Creates a new instance of ResourceThread */
public ResourceThread(BrokerPool pool, XmldbURI docUri, OutputStream os) {
@@ -60,6 +62,14 @@
this.outputStream=os;
}
+ public boolean isExceptionThrown(){
+ return (exception!=null);
+ }
+
+ public Exception getThrownException(){
+ return this.exception;
+ }
+
/**
* Start Thread.
*/
@@ -101,12 +111,16 @@
} catch (EXistException ex){
logger.error(ex);
+ exception=ex;
} catch (PermissionDeniedException ex){
logger.error(ex);
+ exception=ex;
} catch (SAXException ex){
logger.error(ex);
+ exception=ex;
} catch (IOException ex){
logger.error(ex);
+ exception=ex;
} finally {
if(brokerPool!=null){
brokerPool.release(broker);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-30 18:09:46
|
Revision: 5298
http://svn.sourceforge.net/exist/?rev=5298&view=rev
Author: dizzzz
Date: 2007-01-30 10:09:39 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Applied patch [1597055] users' groups eXtensions
by Massimo Martinelli, Marco Tampucci, and Ovidio Salvetti
( http://sourceforge.net/support/tracker.php?aid=1597055 )
=> tests and examples will follow <=
"During our work we needed to extend eXist owing to its lack in the management of user groups.
In particular we added some methods to modify the information about the users' groups.
Initially, we noticed that modifying a user (getting it's information from the remote db connection interfaces) the database would have lost his password ( userUpdate(User) method).
It was not even possible to remove a group from the list of the groups a user belongs to.
Then we have modified the classes RemoteUserManagementService, RpcConnection, RpcServer User and also the UserManagementService and the RpcAPI interfaces.
In particolar we added the following methods:
addUserGroup(User), removeGroup(User, String) in the RemoteUserManagementService class
addUserGroup(User), removeGroup(User, String) in the UserManagementService interface
setUser(User, String, Vector), setUser(User, String, Vector, String) in the RpcConnection class
setUser(User, String, Vector, String), setUser(User, String, Vector, String, String) in the RpcServer class
setUser(User, String, Vector, String), setUser(User, String, Vector, String, String) in the RpcAPI interface
remGroup(String) in the User class
Furthermore, being the UserManagementService interface implemented also by the LocalUserManagementService class we added the addUserGroup(User) and the removeGroup(User, String) methods.
"
Modified Paths:
--------------
trunk/eXist/src/org/exist/security/User.java
trunk/eXist/src/org/exist/xmldb/LocalUserManagementService.java
trunk/eXist/src/org/exist/xmldb/RemoteUserManagementService.java
trunk/eXist/src/org/exist/xmldb/UserManagementService.java
trunk/eXist/src/org/exist/xmlrpc/RpcAPI.java
trunk/eXist/src/org/exist/xmlrpc/RpcConnection.java
trunk/eXist/src/org/exist/xmlrpc/RpcServer.java
Modified: trunk/eXist/src/org/exist/security/User.java
===================================================================
--- trunk/eXist/src/org/exist/security/User.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/security/User.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -11,13 +11,12 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import org.exist.storage.BrokerPool;
-import org.exist.EXistException;
/**
* Represents a user within the database.
*
*@author Wolfgang Meier <wol...@ex...>
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
*/
public class User {
@@ -39,8 +38,8 @@
public static int PASSWORD_ENCODING;
public static boolean CHECK_PASSWORDS = true;
-
- static {
+
+ static {
Properties props = new Properties();
try {
props.load(
@@ -52,8 +51,8 @@
setPasswordEncoding(option);
option = props.getProperty("passwords.check", "yes");
CHECK_PASSWORDS = option.equalsIgnoreCase("yes") || option.equalsIgnoreCase("true");
- }
-
+ }
+
static public void setPasswordEncoding(String encoding) {
if (encoding != null) {
LOG.equals("Setting password encoding to "+encoding);
@@ -190,6 +189,47 @@
if (SecurityManager.DBA_GROUP.equals(group))
hasDbaRole = true;
}
+
+ /**
+ * Remove the user to a group
+ * Added by {Marco.Tampucci and Massimo.Martinelli}@isti.cnr.it
+ *
+ *@param group The feature to be removed to the Group attribute
+ */
+ public final void remGroup( String group ) {
+ if (groups == null) {
+ groups = new String[1];
+ groups[0] = "guest";
+ } else {
+ int len = groups.length;
+
+ String[] rgroup = null;
+ if (len>1)
+ rgroup = new String[len-1];
+ else {
+ rgroup = new String[1];
+ len=1;
+ }
+
+ boolean found = false;
+ for (int i=0; i<len; i++) {
+ if (!groups[i].equals(group)) {
+ if (found == true)
+ rgroup[i-1] = groups[i];
+ else
+ rgroup[i] = groups[i];
+ }
+ else {
+ found = true;
+ }
+ }
+ if (found == true && len==1)
+ rgroup[0] = "guest";
+ groups=rgroup;
+ }
+ if (SecurityManager.DBA_GROUP.equals(group))
+ hasDbaRole = false;
+ }
public final void setGroups(String[] groups) {
this.groups = groups;
@@ -360,24 +400,6 @@
if ( passwd == null ) {
return false;
}
-
- //Try to authenticate using LDAP
- try {
- sm=BrokerPool.getInstance().getSecurityManager();
- }
- catch (EXistException e)
- {
- LOG.warn("Failed to get security manager in validate: ",e);
- return false;
- }
- if(sm instanceof LDAPbindSecurityManager )
- {
- if( ((LDAPbindSecurityManager)sm).bind(user,passwd))
- return true;
- else
- return false;
- }
-
if (password!=null) {
if (MD5.md(passwd,true).equals( password )) {
return true;
@@ -429,3 +451,5 @@
}
+
+
Modified: trunk/eXist/src/org/exist/xmldb/LocalUserManagementService.java
===================================================================
--- trunk/eXist/src/org/exist/xmldb/LocalUserManagementService.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmldb/LocalUserManagementService.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -19,6 +19,9 @@
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.XMLDBException;
+/*************************************************
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+**************************************/
public class LocalUserManagementService implements UserManagementService {
private LocalCollection collection;
@@ -630,4 +633,13 @@
u.setUID(old.getUID());
manager.setUser(u);
}
+
+ public void addUserGroup(User user) throws XMLDBException {
+
+ }
+
+ public void removeGroup(User user, String rmgroup) throws XMLDBException {
+
+ }
}
+
Modified: trunk/eXist/src/org/exist/xmldb/RemoteUserManagementService.java
===================================================================
--- trunk/eXist/src/org/exist/xmldb/RemoteUserManagementService.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmldb/RemoteUserManagementService.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -7,13 +7,18 @@
import org.apache.xmlrpc.XmlRpcException;
import org.exist.security.Permission;
-import org.exist.security.PermissionFactory;
+import org.exist.security.UnixStylePermission;
import org.exist.security.User;
import org.xmldb.api.base.Collection;
import org.xmldb.api.base.ErrorCodes;
import org.xmldb.api.base.Resource;
import org.xmldb.api.base.XMLDBException;
+
+/*************************************************
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+**************************************/
+
public class RemoteUserManagementService implements UserManagementService {
private RemoteCollection parent;
@@ -289,7 +294,8 @@
Vector params = new Vector();
params.addElement(((RemoteCollection) coll).getPath());
Hashtable result = (Hashtable) parent.getClient().execute("getPermissions", params);
- perm = PermissionFactory.getPermission((String) result.get("owner"), (String) result.get("group"),
+ perm =
+ new UnixStylePermission((String) result.get("owner"), (String) result.get("group"),
((Integer) result.get("permissions")).intValue());
return perm;
} catch (XmlRpcException e) {
@@ -318,7 +324,8 @@
Vector params = new Vector();
params.addElement(path);
Hashtable result = (Hashtable) parent.getClient().execute("getPermissions", params);
- Permission perm = PermissionFactory.getPermission((String) result.get("owner"), (String) result.get("group"),
+ Permission perm =
+ new UnixStylePermission((String) result.get("owner"), (String) result.get("group"),
((Integer) result.get("permissions")).intValue());
return perm;
} catch (XmlRpcException e) {
@@ -339,7 +346,7 @@
Vector t;
for (int i = 0; i < resources.length; i++) {
t = (Vector) result.get(resources[i]);
- perm[i] = PermissionFactory.getPermission();
+ perm[i] = new UnixStylePermission();
perm[i].setOwner((String) t.elementAt(0));
perm[i].setGroup((String) t.elementAt(1));
perm[i].setPermissions(((Integer) t.elementAt(2)).intValue());
@@ -363,7 +370,7 @@
Vector t;
for (int i = 0; i < collections.length; i++) {
t = (Vector) result.get(collections[i]);
- perm[i] = PermissionFactory.getPermission();
+ perm[i] = new UnixStylePermission();
perm[i].setOwner((String) t.elementAt(0));
perm[i].setGroup((String) t.elementAt(1));
perm[i].setPermissions(((Integer) t.elementAt(2)).intValue());
@@ -450,7 +457,10 @@
}
/**
- *@exception XMLDBException
+ * Description of the Method
+ *
+ *@param name Description of the Parameter
+ *@exception XMLDBException Description of the Exception
*/
public void removeUser(User u) throws XMLDBException {
try {
@@ -510,6 +520,60 @@
throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);
}
}
+
+ /**
+ * Update the specified user without update user's password
+ * Method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ *@param user Description of the Parameter
+ *@exception XMLDBException Description of the Exception
+ */
+ public void addUserGroup(User user) throws XMLDBException {
+ try {
+ Vector params = new Vector();
+ params.addElement(user.getName());
+ Vector groups = new Vector();
+ String[] gl = user.getGroups();
+ for (int i = 0; i < gl.length; i++)
+ groups.addElement(gl[i]);
+ params.addElement(groups);
+ if (user.getHome() != null)
+ params.addElement(user.getHome());
+ parent.getClient().execute("setUser", params);
+ } catch (XmlRpcException e) {
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);
+ } catch (IOException e) {
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);
+ }
+ }
+
+ /**
+ * Update the specified user removing a group from user's group
+ * method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ *@param user Description of the Parameter
+ *@param rmgroup Description of group to remove
+ *@exception XMLDBException Description of the Exception
+ */
+ public void removeGroup(User user, String rmgroup) throws XMLDBException {
+ try {
+ Vector params = new Vector();
+ params.addElement(user.getName());
+ Vector groups = new Vector();
+ String[] gl = user.getGroups();
+ for (int i = 0; i < gl.length; i++)
+ groups.addElement(gl[i]);
+ params.addElement(groups);
+ if (user.getHome() != null)
+ params.addElement(user.getHome());
+ params.addElement(rmgroup);
+ parent.getClient().execute("setUser", params);
+ } catch (XmlRpcException e) {
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);
+ } catch (IOException e) {
+ throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e);
+ }
+ }
/* (non-Javadoc)
* @see org.exist.xmldb.UserManagementService#getGroups()
@@ -531,3 +595,4 @@
}
// -- end class UserManagementServiceImpl
+
Modified: trunk/eXist/src/org/exist/xmldb/UserManagementService.java
===================================================================
--- trunk/eXist/src/org/exist/xmldb/UserManagementService.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmldb/UserManagementService.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -12,6 +12,7 @@
* permissions.
*
*@author Wolfgang Meier <me...@if...>
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
*/
public interface UserManagementService extends Service {
@@ -130,6 +131,7 @@
* if no lock has been set on the resource.
*
* @param res
+ * @return
* @throws XMLDBException
*/
public String hasUserLock(Resource res) throws XMLDBException;
@@ -187,6 +189,7 @@
* Please note: new groups are created automatically if a new group
* is assigned to a user. You can't add or remove them.
*
+ * @return
* @throws XMLDBException
*/
public String[] getGroups() throws XMLDBException;
@@ -265,9 +268,31 @@
/**
* Delete a user from the database
*
- *@param user
- *@exception XMLDBException
+ *@param name Description of the Parameter
+ *@exception XMLDBException Description of the Exception
*/
public void removeUser( User user ) throws XMLDBException;
+
+ /**
+ * Update the specified user without update user's password
+ * Method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ *@param user Description of the Parameter
+ *@exception XMLDBException Description of the Exception
+ */
+ public void addUserGroup(User user) throws XMLDBException;
+
+ /**
+ * Update the specified user removing a group from user's group
+ * Method added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ *@param user Description of the Parameter
+ *@param rmgroup Description of group to remove
+ *@exception XMLDBException Description of the Exception
+ */
+ public void removeGroup(User user, String rmgroup) throws XMLDBException;
}
+
+
+
Modified: trunk/eXist/src/org/exist/xmlrpc/RpcAPI.java
===================================================================
--- trunk/eXist/src/org/exist/xmlrpc/RpcAPI.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmlrpc/RpcAPI.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -1,24 +1,3 @@
-
-/*
- * eXist Open Source Native XML Database
- * Copyright (C) 2001, Wolfgang M. Meier (me...@if...)
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This library 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 Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
package org.exist.xmlrpc;
import java.io.IOException;
import java.util.Date;
@@ -35,6 +14,7 @@
* Defines the methods callable through the XMLRPC interface.
*
*@author Wolfgang Meier <me...@if...>
+ * modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
*/
public interface RpcAPI {
@@ -61,15 +41,9 @@
* @throws PermissionDeniedException
*/
public boolean shutdown(User user, long delay) throws PermissionDeniedException;
-
- boolean enterServiceMode(User user) throws PermissionDeniedException, EXistException;
-
- boolean exitServiceMode(User user) throws PermissionDeniedException, EXistException;
-
- boolean isInServiceMode(User user) throws PermissionDeniedException, EXistException;
-
- public boolean sync(User user);
+ public boolean sync(User user);
+
/**
* Returns true if XACML is enabled for the current database instance
* @return if XACML is enabled
@@ -144,6 +118,7 @@
* @param user
* @param name
* @param parameters
+ * @return
* @throws EXistException
* @throws PermissionDeniedException
*/
@@ -258,14 +233,15 @@
throws EXistException, PermissionDeniedException;
/**
- * Returns the number of resources in the collection identified by
- * collectionName.
- * @param collectionName
- * @param user
- * @throws EXistException
- * @throws PermissionDeniedException
- * @return number of resources
- */
+ * Returns the number of resources in the collection identified by
+ * collectionName.
+ *
+ * @param user
+ * @param collection
+ * @return
+ * @throws EXistException
+ * @throws PermissionDeniedException
+ */
int getResourceCount(User user, String collectionName)
throws EXistException, PermissionDeniedException;
@@ -284,16 +260,18 @@
throws EXistException, PermissionDeniedException;
/**
- * Retrieve a single node from a document. The node is identified by it's
- * internal id.
- *
- * @param parameters
- * @param doc the document containing the node
- * @param id the node's internal id
- * @param user Description of the Parameter
- * @exception EXistException Description of the Exception
- * @exception PermissionDeniedException Description of the Exception
- */
+ * Retrieve a single node from a document. The node is identified by it's
+ * internal id.
+ *
+ *@param doc the document containing the node
+ *@param id the node's internal id
+ *@param prettyPrint result is pretty printed if >0
+ *@param encoding character encoding to use
+ *@param user Description of the Parameter
+ *@return Description of the Return Value
+ *@exception EXistException Description of the Exception
+ *@exception PermissionDeniedException Description of the Exception
+ */
byte[] retrieve(User user, String doc, String id, Hashtable parameters)
throws EXistException, PermissionDeniedException;
@@ -312,19 +290,25 @@
throws EXistException, PermissionDeniedException;
/**
- * execute XPath query and return howmany nodes from the result set,
- * starting at position <code>start</code>. If <code>prettyPrint</code> is
- * set to >0 (true), results are pretty printed.
- *
- * @param xquery
- * @param parameters
- * @param howmany maximum number of results to return.
- * @param start item in the result set to start with.
- * @param user
- * @exception EXistException
- * @exception PermissionDeniedException
- * @deprecated use Vector query() or int executeQuery() instead
- */
+ * execute XPath query and return howmany nodes from the result set,
+ * starting at position <code>start</code>. If <code>prettyPrint</code> is
+ * set to >0 (true), results are pretty printed.
+ *
+ *@param xpath the XPath query to execute
+ *@param howmany maximum number of results to
+ * return.
+ *@param start item in the result set to start
+ * with.
+ *@param prettyPrint turn on pretty printing if >0.
+ *@param encoding the character encoding to use.
+ *@param sortExpr Description of the Parameter
+ *@param user Description of the Parameter
+ *@return Description of the Return Value
+ *@exception EXistException Description of the Exception
+ *@exception PermissionDeniedException Description of the Exception
+ *@depreceated use Vector query() or int
+ * executeQuery() instead
+ */
byte[] query(
User user,
byte[] xquery,
@@ -334,73 +318,73 @@
throws EXistException, PermissionDeniedException;
/**
- * execute XPath query and return a summary of hits per document and hits
- * per doctype. This method returns a struct with the following fields:
- *
- * <table border="1">
- *
- * <tr>
- *
- * <td>
- * "queryTime"
- * </td>
- *
- * <td>
- * int
- * </td>
- *
- * </tr>
- *
- * <tr>
- *
- * <td>
- * "hits"
- * </td>
- *
- * <td>
- * int
- * </td>
- *
- * </tr>
- *
- * <tr>
- *
- * <td>
- * "documents"
- * </td>
- *
- * <td>
- * array of array: Object[][3]
- * </td>
- *
- * </tr>
- *
- * <tr>
- *
- * <td>
- * "doctypes"
- * </td>
- *
- * <td>
- * array of array: Object[][2]
- * </td>
- *
- * </tr>
- *
- * </table>
- * Documents and doctypes represent tables where each row describes one
- * document or doctype for which hits were found. Each document entry has
- * the following structure: docId (int), docName (string), hits (int) The
- * doctype entry has this structure: doctypeName (string), hits (int)
- *
- *
-
- * @param xquery
- * @param user Description of the Parameter
- * @exception EXistException Description of the Exception
- * @exception PermissionDeniedException Description of the Exception
- * @deprecated use Vector query() or int executeQuery() instead
- */
+ * execute XPath query and return a summary of hits per document and hits
+ * per doctype. This method returns a struct with the following fields:
+ *
+ * <table border="1">
+ *
+ * <tr>
+ *
+ * <td>
+ * "queryTime"
+ * </td>
+ *
+ * <td>
+ * int
+ * </td>
+ *
+ * </tr>
+ *
+ * <tr>
+ *
+ * <td>
+ * "hits"
+ * </td>
+ *
+ * <td>
+ * int
+ * </td>
+ *
+ * </tr>
+ *
+ * <tr>
+ *
+ * <td>
+ * "documents"
+ * </td>
+ *
+ * <td>
+ * array of array: Object[][3]
+ * </td>
+ *
+ * </tr>
+ *
+ * <tr>
+ *
+ * <td>
+ * "doctypes"
+ * </td>
+ *
+ * <td>
+ * array of array: Object[][2]
+ * </td>
+ *
+ * </tr>
+ *
+ * </table>
+ * Documents and doctypes represent tables where each row describes one
+ * document or doctype for which hits were found. Each document entry has
+ * the following structure: docId (int), docName (string), hits (int) The
+ * doctype entry has this structure: doctypeName (string), hits (int)
+ *
+ *@param xpath Description of the Parameter
+ *@param user Description of the Parameter
+ *@return Description of the Return Value
+ *@exception EXistException Description of the Exception
+ *@exception PermissionDeniedException Description of the Exception
+ *@depreceated use Vector query() or int
+ * executeQuery() instead
+ */
Hashtable querySummary(User user, String xquery)
throws EXistException, PermissionDeniedException;
@@ -411,6 +395,7 @@
*
* @param user
* @param query
+ * @return
* @throws EXistException
*/
public String printDiagnostics(User user, String query, Hashtable parameters)
@@ -429,6 +414,7 @@
*
*@param xmlData The document data
*@param docName The path where the document will be stored
+ *@return
*@exception EXistException
*@exception PermissionDeniedException
*/
@@ -446,6 +432,7 @@
*@param xmlData The document data
*@param docName The path where the document will be stored
*@param overwrite Overwrite an existing document with the same path?
+ *@return
*@exception EXistException
*@exception PermissionDeniedException
*/
@@ -522,6 +509,7 @@
* @param data the data to be stored
* @param docName the path to the new document
* @param replace if true, an old document with the same path will be overwritten
+ * @return
* @throws EXistException
* @throws PermissionDeniedException
*/
@@ -547,6 +535,7 @@
*
*@param name path to the collection to be removed.
*@param user
+ *@return
*@exception EXistException
*@exception PermissionDeniedException
*/
@@ -558,6 +547,7 @@
*
* @param user
* @param name the path to the new collection.
+ * @return
* @throws EXistException
* @throws PermissionDeniedException
*/
@@ -682,18 +672,18 @@
int getHits(User user, int resultId) throws EXistException, PermissionDeniedException;
/**
- * Retrieve a single result from the result-set identified by resultId. The
- * XML fragment at position num in the result set is returned.
- *
- *
- * @return Description of the Return Value
- * @param parameters
- * @param resultId
- * @param num
- * @param user
- * @exception EXistException
- * @exception PermissionDeniedException
- */
+ * Retrieve a single result from the result-set identified by resultId. The
+ * XML fragment at position num in the result set is returned.
+ *
+ *@param resultId Description of the Parameter
+ *@param num Description of the Parameter
+ *@param prettyPrint Description of the Parameter
+ *@param encoding Description of the Parameter
+ *@param user Description of the Parameter
+ *@return Description of the Return Value
+ *@exception EXistException Description of the Exception
+ *@exception PermissionDeniedException Description of the Exception
+ */
byte[] retrieve(User user, int resultId, int num, Hashtable parameters)
throws EXistException, PermissionDeniedException;
@@ -813,3 +803,4 @@
boolean setDocType(User user, String documentName, String doctypename, String publicid, String systemid)
throws EXistException, PermissionDeniedException;
}
+
Modified: trunk/eXist/src/org/exist/xmlrpc/RpcConnection.java
===================================================================
--- trunk/eXist/src/org/exist/xmlrpc/RpcConnection.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmlrpc/RpcConnection.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -46,12 +46,14 @@
import java.util.Random;
import java.util.Vector;
import java.util.WeakHashMap;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import org.exist.backup.Backup;
import org.apache.log4j.Logger;
import org.exist.EXistException;
import org.exist.collections.Collection;
+import org.exist.collections.CollectionConfigurationException;
import org.exist.collections.CollectionConfigurationManager;
import org.exist.collections.IndexInfo;
import org.exist.dom.BinaryDocument;
@@ -73,7 +75,10 @@
import org.exist.security.xacml.AccessContext;
import org.exist.source.Source;
import org.exist.source.StringSource;
-import org.exist.storage.*;
+import org.exist.storage.BrokerPool;
+import org.exist.storage.DBBroker;
+import org.exist.storage.DataBackup;
+import org.exist.storage.XQueryPool;
import org.exist.storage.lock.Lock;
import org.exist.storage.serializers.Serializer;
import org.exist.storage.sync.Sync;
@@ -81,9 +86,11 @@
import org.exist.storage.txn.Txn;
import org.exist.util.Compressor;
import org.exist.util.Configuration;
+import org.exist.util.LockException;
import org.exist.util.MimeTable;
import org.exist.util.MimeType;
import org.exist.util.Occurrences;
+import org.exist.util.SyntaxException;
import org.exist.util.serializer.SAXSerializer;
import org.exist.util.serializer.SerializerPool;
import org.exist.validation.ValidationReport;
@@ -91,8 +98,8 @@
import org.exist.validation.internal.ResourceInputStream;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.CompiledXQuery;
+import org.exist.xquery.Option;
import org.exist.xquery.PathExpr;
-import org.exist.xquery.Option;
import org.exist.xquery.XPathException;
import org.exist.xquery.XQuery;
import org.exist.xquery.XQueryContext;
@@ -108,6 +115,7 @@
import org.w3c.dom.DocumentType;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
@@ -115,6 +123,7 @@
* {@link org.exist.xmlrpc.RpcAPI}.
*
* @author Wolfgang Meier (wol...@ex...)
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
*/
public class RpcConnection extends Thread {
@@ -143,11 +152,13 @@
brokerPool = BrokerPool.getInstance(this.databaseid);
}
- public void createCollection(User user, String name, Date created) throws Exception {
+ public void createCollection(User user, String name, Date created) throws Exception,
+ PermissionDeniedException, URISyntaxException {
createCollection(user,XmldbURI.xmldbUriFor(name),created);
}
- public void createCollection(User user, XmldbURI collUri, Date created) throws Exception {
+ public void createCollection(User user, XmldbURI collUri, Date created) throws Exception,
+ PermissionDeniedException {
DBBroker broker = null;
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
@@ -172,11 +183,11 @@
}
public void configureCollection(User user, String collName, String configuration)
- throws Exception {
+ throws EXistException, URISyntaxException {
configureCollection(user,XmldbURI.xmldbUriFor(collName),configuration);
}
public void configureCollection(User user, XmldbURI collUri, String configuration)
- throws Exception {
+ throws EXistException {
DBBroker broker = null;
Collection collection = null;
TransactionManager transact = brokerPool.getTransactionManager();
@@ -185,15 +196,16 @@
broker = brokerPool.get(user);
collection = broker.openCollection(collUri, Lock.READ_LOCK);
if (collection == null) {
+ transact.abort(txn);
throw new EXistException("collection " + collUri + " not found!");
}
CollectionConfigurationManager mgr = brokerPool.getConfigurationManager();
mgr.addConfiguration(txn, broker, collection, configuration);
transact.commit(txn);
- LOG.info("Configured '" + collection.getURI() + "'");
- } catch (Exception e) {
+ LOG.info("Configured '" + collection.getURI() + "'");
+ } catch (CollectionConfigurationException e) {
transact.abort(txn);
- throw e;
+ throw new EXistException(e.getMessage());
} finally {
if(collection != null)
collection.release();
@@ -508,7 +520,7 @@
}
}
public String getDocument(User user, String docName, Hashtable parametri)
- throws Exception {
+ throws Exception, URISyntaxException {
return getDocument(user,XmldbURI.xmldbUriFor(docName), parametri);
}
public String getDocument(User user, XmldbURI docUri, Hashtable parametri)
@@ -539,8 +551,9 @@
throw new PermissionDeniedException("Insufficient privileges to read resource " + docUri);
Serializer serializer = broker.getSerializer();
serializer.setProperties(parametri);
- return serializer.serialize(doc);
-
+ String xml = serializer.serialize(doc);
+
+ return xml;
} catch (NoSuchMethodError nsme) {
nsme.printStackTrace();
return null;
@@ -698,12 +711,14 @@
}
public int xupdate(User user, String collectionName, String xupdate)
- throws Exception {
+ throws SAXException, LockException, PermissionDeniedException, EXistException,
+ XPathException, URISyntaxException {
return xupdate(user,XmldbURI.xmldbUriFor(collectionName),xupdate);
}
public int xupdate(User user, XmldbURI collUri, String xupdate)
- throws Exception {
+ throws SAXException, LockException, PermissionDeniedException, EXistException,
+ XPathException {
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
DBBroker broker = null;
@@ -711,6 +726,7 @@
broker = brokerPool.get(user);
Collection collection = broker.getCollection(collUri);
if (collection == null) {
+ transact.abort(transaction);
throw new EXistException("collection " + collUri
+ " not found");
}
@@ -726,20 +742,25 @@
}
transact.commit(transaction);
return (int) mods;
- } catch (Exception e) {
+ } catch (ParserConfigurationException e) {
transact.abort(transaction);
- throw e;
+ throw new EXistException(e.getMessage());
+ } catch (IOException e) {
+ transact.abort(transaction);
+ throw new EXistException(e.getMessage());
} finally {
brokerPool.release(broker);
}
}
public int xupdateResource(User user, String resource, String xupdate)
- throws Exception {
+ throws SAXException, LockException, PermissionDeniedException, EXistException,
+ XPathException, URISyntaxException {
return xupdateResource(user,XmldbURI.xmldbUriFor(resource),xupdate);
}
public int xupdateResource(User user, XmldbURI docUri, String xupdate)
- throws Exception {
+ throws SAXException, LockException, PermissionDeniedException, EXistException,
+ XPathException {
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
DBBroker broker = null;
@@ -747,9 +768,11 @@
broker = brokerPool.get(user);
DocumentImpl doc = (DocumentImpl)broker.getXMLResource(docUri);
if (doc == null) {
+ transact.abort(transaction);
throw new EXistException("document " + docUri + " not found");
}
if(!doc.getPermissions().validate(user, Permission.READ)) {
+ transact.abort(transaction);
throw new PermissionDeniedException("Insufficient privileges to read resource");
}
DocumentSet docs = new DocumentSet();
@@ -764,9 +787,12 @@
}
transact.commit(transaction);
return (int) mods;
- } catch (Exception e) {
+ } catch (ParserConfigurationException e) {
transact.abort(transaction);
- throw e;
+ throw new EXistException(e.getMessage());
+ } catch (IOException e) {
+ transact.abort(transaction);
+ throw new EXistException(e.getMessage());
} finally {
brokerPool.release(broker);
}
@@ -783,7 +809,7 @@
}
return true;
}
-
+
public boolean isXACMLEnabled() {
return brokerPool.getSecurityManager().isXACMLEnabled();
}
@@ -1153,7 +1179,7 @@
}
public boolean parse(User user, byte[] xml, String documentPath,
- boolean replace, Date created, Date modified) throws Exception {
+ boolean replace, Date created, Date modified) throws Exception, URISyntaxException {
return parse(user,xml,XmldbURI.xmldbUriFor(documentPath),replace,created,modified);
}
public boolean parse(User user, byte[] xml, XmldbURI docUri,
@@ -1170,12 +1196,14 @@
try {
collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
if (collection == null) {
+ transact.abort(txn);
throw new EXistException("Collection " + docUri.removeLastSegment()
+ " not found");
}
if (!replace) {
DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
if (old != null) {
+ transact.abort(txn);
throw new PermissionDeniedException(
"Document exists and overwrite is not allowed");
}
@@ -1258,12 +1286,14 @@
try {
collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
if (collection == null) {
+ transact.abort(txn);
throw new EXistException("Collection " + docUri.removeLastSegment()
+ " not found");
}
if (!replace) {
DocumentImpl old = collection.getDocument(broker, docUri.lastSegment());
if (old != null) {
+ transact.abort(txn);
throw new PermissionDeniedException(
"Old document exists and overwrite is not allowed");
}
@@ -1324,7 +1354,7 @@
public boolean storeBinary(User user, byte[] data, String documentPath, String mimeType,
- boolean replace) throws Exception {
+ boolean replace) throws Exception, URISyntaxException {
return storeBinary(user, data, documentPath, mimeType, replace, null, null);
}
@@ -1685,11 +1715,13 @@
broker = brokerPool.get(user);
collection = broker.openCollection(docUri.removeLastSegment(), Lock.WRITE_LOCK);
if (collection == null) {
+ transact.abort(txn);
throw new EXistException("Collection " + docUri.removeLastSegment()
+ " not found");
}
DocumentImpl doc = collection.getDocument(broker, docUri.lastSegment());
if(doc == null) {
+ transact.abort(txn);
throw new EXistException("Document " + docUri + " not found");
}
@@ -1699,9 +1731,6 @@
collection.removeXMLResource(txn, broker, docUri.lastSegment());
transact.commit(txn);
documentCache.clear();
- } catch (Exception e) {
- transact.abort(txn);
- throw e;
} finally {
if(collection != null)
collection.release();
@@ -1750,7 +1779,7 @@
}
public String retrieve(User user, String documentPath, String s_id,
- Hashtable parameters) throws Exception {
+ Hashtable parameters) throws Exception, URISyntaxException {
return retrieve(user,XmldbURI.xmldbUriFor(documentPath),s_id,parameters);
}
public String retrieve(User user, XmldbURI docUri, String s_id,
@@ -1872,11 +1901,13 @@
}
public boolean setPermissions(User user, String resource, String owner,
- String ownerGroup, String permissions) throws Exception {
+ String ownerGroup, String permissions) throws EXistException,
+ PermissionDeniedException, URISyntaxException {
return setPermissions(user,XmldbURI.xmldbUriFor(resource),owner,ownerGroup,permissions);
}
public boolean setPermissions(User user, XmldbURI uri, String owner,
- String ownerGroup, String permissions) throws Exception {
+ String ownerGroup, String permissions) throws EXistException,
+ PermissionDeniedException {
DBBroker broker = null;
Collection collection = null;
DocumentImpl doc = null;
@@ -1909,6 +1940,7 @@
broker.flush();
return true;
}
+ transact.abort(transaction);
throw new PermissionDeniedException("not allowed to change permissions");
} else {
LOG.debug("changing permissions on collection " + uri);
@@ -1930,12 +1962,16 @@
broker.flush();
return true;
}
+ transact.abort(transaction);
throw new PermissionDeniedException(
"not allowed to change permissions");
}
- } catch (Exception e) {
+ } catch (SyntaxException e) {
transact.abort(transaction);
- throw e;
+ throw new EXistException(e.getMessage());
+ } catch (PermissionDeniedException e) {
+ transact.abort(transaction);
+ throw new EXistException(e.getMessage());
} finally {
if(doc != null)
doc.getUpdateLock().release(Lock.WRITE_LOCK);
@@ -1944,11 +1980,13 @@
}
public boolean setPermissions(User user, String resource, String owner,
- String ownerGroup, int permissions) throws Exception {
+ String ownerGroup, int permissions) throws EXistException,
+ PermissionDeniedException, URISyntaxException {
return setPermissions(user,XmldbURI.xmldbUriFor(resource),owner,ownerGroup,permissions);
}
public boolean setPermissions(User user, XmldbURI uri, String owner,
- String ownerGroup, int permissions) throws Exception {
+ String ownerGroup, int permissions) throws EXistException,
+ PermissionDeniedException {
DBBroker broker = null;
Collection collection = null;
DocumentImpl doc = null;
@@ -1980,6 +2018,7 @@
broker.flush();
return true;
}
+ transact.abort(transaction);
throw new PermissionDeniedException("not allowed to change permissions");
}
LOG.debug("changing permissions on collection " + uri);
@@ -1999,10 +2038,11 @@
broker.flush();
return true;
}
+ transact.abort(transaction);
throw new PermissionDeniedException("not allowed to change permissions");
- } catch (Exception e) {
+ } catch (PermissionDeniedException e) {
transact.abort(transaction);
- throw e;
+ throw new EXistException(e.getMessage());
} finally {
if(doc != null)
doc.getUpdateLock().release(Lock.WRITE_LOCK);
@@ -2055,6 +2095,76 @@
return true;
}
+ /**
+ * Added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ */
+ public boolean setUser(User user, String name, Vector groups) throws EXistException,
+ PermissionDeniedException {
+
+ org.exist.security.SecurityManager manager = brokerPool
+ .getSecurityManager();
+ User u;
+ if (!manager.hasUser(name)) {
+ if (!manager.hasAdminPrivileges(user))
+ throw new PermissionDeniedException(
+ "not allowed to create user");
+ u = new User(name);
+ } else {
+ u = manager.getUser(name);
+ if (!(u.getName().equals(user.getName()) || manager
+ .hasAdminPrivileges(user)))
+ throw new PermissionDeniedException(
+ "you are not allowed to change this user");
+ }
+ String g;
+ for (Iterator i = groups.iterator(); i.hasNext(); ) {
+ g = (String) i.next();
+ if (!u.hasGroup(g)) {
+ if(!manager.hasAdminPrivileges(user))
+ throw new PermissionDeniedException(
+ "User is not allowed to add groups");
+ u.addGroup(g);
+ }
+ }
+ manager.setUser(u);
+ return true;
+ }
+
+ /**
+ * Added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ */
+ public boolean setUser(User user, String name, Vector groups, String rgroup) throws EXistException,
+ PermissionDeniedException {
+
+ org.exist.security.SecurityManager manager = brokerPool
+ .getSecurityManager();
+ User u;
+ if (!manager.hasUser(name)) {
+ if (!manager.hasAdminPrivileges(user))
+ throw new PermissionDeniedException(
+ "not allowed to create user");
+ u = new User(name);
+ } else {
+ u = manager.getUser(name);
+ if (!(u.getName().equals(user.getName()) || manager
+ .hasAdminPrivileges(user)))
+ throw new PermissionDeniedException(
+ "you are not allowed to change this user");
+ }
+ String g;
+ for (Iterator i = groups.iterator(); i.hasNext(); ) {
+ g = (String) i.next();
+ if (g.equals(rgroup)) {
+ if(!manager.hasAdminPrivileges(user))
+ throw new PermissionDeniedException(
+ "User is not allowed to remove groups");
+ u.remGroup(g);
+ }
+ }
+ manager.setUser(u);
+ return true;
+ }
+
public boolean lockResource(User user, String documentPath, String userName) throws Exception, URISyntaxException {
return lockResource(user,XmldbURI.xmldbUriFor(documentPath),userName);
}
@@ -2137,14 +2247,9 @@
lockOwner.getName());
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
- try {
- doc.setUserLock(null);
- broker.storeXMLResource(transaction, doc);
- transact.commit(transaction);
- } catch (Exception e) {
- transact.abort(transaction);
- throw e;
- }
+ doc.setUserLock(null);
+ broker.storeXMLResource(transaction, doc);
+ transact.commit(transaction);
return true;
} finally {
if(doc != null)
@@ -2378,6 +2483,7 @@
}
/**
+ * @param user
* @param start
* @param end
* @param broker
@@ -2488,13 +2594,13 @@
public boolean moveOrCopyResource(User user, String documentPath, String destinationPath,
String newName, boolean move)
- throws Exception {
+ throws EXistException, PermissionDeniedException, URISyntaxException {
return moveOrCopyResource(user,XmldbURI.xmldbUriFor(documentPath),
XmldbURI.xmldbUriFor(destinationPath),XmldbURI.xmldbUriFor(newName),move);
}
public boolean moveOrCopyResource(User user, XmldbURI docUri, XmldbURI destUri,
XmldbURI newName, boolean move)
- throws Exception {
+ throws EXistException, PermissionDeniedException {
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
DBBroker broker = null;
@@ -2505,17 +2611,20 @@
broker = brokerPool.get(user);
collection = broker.openCollection(docUri.removeLastSegment(), move ? Lock.WRITE_LOCK : Lock.READ_LOCK);
if (collection == null) {
+ transact.abort(transaction);
throw new EXistException("Collection " + docUri.removeLastSegment()
+ " not found");
}
doc = collection.getDocumentWithLock(broker, docUri.lastSegment(), Lock.WRITE_LOCK);
if(doc == null) {
+ transact.abort(transaction);
throw new EXistException("Document " + docUri + " not found");
}
// get destination collection
destination = broker.openCollection(destUri, Lock.WRITE_LOCK);
if(destination == null) {
+ transact.abort(transaction);
throw new EXistException("Destination collection " + destUri + " not found");
}
if(move)
@@ -2525,9 +2634,9 @@
transact.commit(transaction);
documentCache.clear();
return true;
- } catch (Exception e) {
+ } catch (LockException e) {
transact.abort(transaction);
- throw e;
+ throw new PermissionDeniedException("Could not acquire lock on document " + docUri);
} finally {
if(collection != null)
collection.release();
@@ -2541,13 +2650,13 @@
public boolean moveOrCopyCollection(User user, String collectionName, String destinationPath,
String newName, boolean move)
- throws Exception {
+ throws EXistException, PermissionDeniedException, URISyntaxException {
return moveOrCopyCollection(user,XmldbURI.xmldbUriFor(collectionName),
XmldbURI.xmldbUriFor(destinationPath),XmldbURI.xmldbUriFor(newName),move);
}
public boolean moveOrCopyCollection(User user, XmldbURI collUri, XmldbURI destUri,
XmldbURI newName, boolean move)
- throws Exception {
+ throws EXistException, PermissionDeniedException {
TransactionManager transact = brokerPool.getTransactionManager();
Txn transaction = transact.beginTransaction();
DBBroker broker = null;
@@ -2558,12 +2667,14 @@
// get source document
collection = broker.openCollection(collUri, move ? Lock.WRITE_LOCK : Lock.READ_LOCK);
if (collection == null) {
+ transact.abort(transaction);
throw new EXistException("Collection " + collUri
+ " not found");
}
// get destination collection
destination = broker.openCollection(destUri, Lock.WRITE_LOCK);
if(destination == null) {
+ transact.abort(transaction);
throw new EXistException("Destination collection " + destUri + " not found");
}
if(move)
@@ -2573,9 +2684,9 @@
transact.commit(transaction);
documentCache.clear();
return true;
- } catch (Exception e) {
+ } catch (LockException e) {
transact.abort(transaction);
- throw e;
+ throw new PermissionDeniedException(e.getMessage());
} finally {
if(collection != null)
collection.release();
@@ -2586,10 +2697,11 @@
}
public void reindexCollection(User user, String collectionName) throws Exception,
- URISyntaxException {
+ PermissionDeniedException, URISyntaxException {
reindexCollection(user,XmldbURI.xmldbUriFor(collectionName));
}
- public void reindexCollection(User user, XmldbURI collUri) throws Exception {
+ public void reindexCollection(User user, XmldbURI collUri) throws Exception,
+ PermissionDeniedException {
DBBroker broker = null;
try {
broker = brokerPool.get(user);
@@ -2604,13 +2716,13 @@
}
public void backup(User user, String userbackup, String password,
- String destcollection, String collection) throws Exception {
+ String destcollection, String collection) throws Exception,
+ PermissionDeniedException {
try {
-
Backup backup = new Backup(
userbackup,
password,
- (destcollection.endsWith(".zip") ? destcollection.substring(0, destcollection.length()-4)+"-backup.zip" : destcollection+"-backup"),
+ destcollection+"-backup",
XmldbURI.xmldbUriFor(XmldbURI.EMBEDDED_SERVER_URI.toString() + collection));
backup.backup(false, null);
} catch (Exception e) {
@@ -2623,17 +2735,17 @@
* Validate if specified document is Valid.
*
* @param user Name of user
- * @param documentPath Path to XML document in database
+ * @param docPath Path to XML document in database
* @throws java.lang.Exception Generic exception
* @throws PermissionDeniedException User is not allowed to perform action.
* @return TRUE if document is valid, FALSE if not or errors or.....
*/
public boolean isValid(User user, String documentPath)
- throws Exception {
+ throws PermissionDeniedException, Exception, URISyntaxException {
return isValid(user,XmldbURI.xmldbUriFor(documentPath));
}
public boolean isValid(User user, XmldbURI docUri)
- throws Exception{
+ throws PermissionDeniedException, Exception{
boolean retVal=false;
DBBroker broker = null;
@@ -2713,7 +2825,7 @@
public boolean setDocType(User user, String documentPath, String doctypename, String publicid, String systemid) throws
- Exception {
+ Exception, URISyntaxException {
return setDocType(user,XmldbURI.xmldbUriFor(documentPath),doctypename, publicid, systemid);
}
public boolean setDocType(User user, XmldbURI docUri, String doctypename, String publicid, String systemid) throws
@@ -2755,3 +2867,6 @@
}
}
+
+
+
Modified: trunk/eXist/src/org/exist/xmlrpc/RpcServer.java
===================================================================
--- trunk/eXist/src/org/exist/xmlrpc/RpcServer.java 2007-01-30 16:38:05 UTC (rev 5297)
+++ trunk/eXist/src/org/exist/xmlrpc/RpcServer.java 2007-01-30 18:09:39 UTC (rev 5298)
@@ -1,23 +1,3 @@
-/*
- * eXist Open Source Native XML Database Copyright (C) 2001-06, Wolfgang M.
- * Meier (me...@if...)
- *
- * This library is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Library General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option) any
- * later version.
- *
- * This library 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 Library General Public License for more
- * details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id$
- */
package org.exist.xmlrpc;
import java.io.File;
@@ -70,6 +50,7 @@
* correct character encoding is preserved during transport.</p>
*
*@author Wolfgang Meier
+ * Modified by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
*/
public class RpcServer implements RpcAPI {
@@ -81,8 +62,6 @@
protected ConnectionPool pool;
- private String databaseId;
-
/**
* Constructor for the RpcServer object
*
@@ -94,8 +73,7 @@
public RpcServer(Configuration conf, String databaseid) throws EXistException {
databaseid = (databaseid != null && !"".equals(databaseid)) ? databaseid
: BrokerPool.DEFAULT_INSTANCE_NAME;
- this.pool = new ConnectionPool(MIN_CONNECT, MAX_CONNECT, conf, databaseid);
- this.databaseId = databaseid;
+ pool = new ConnectionPool(MIN_CONNECT, MAX_CONNECT, conf, databaseid);
}
public boolean createCollection(User user, String name) throws EXistException,
@@ -1201,6 +1179,10 @@
* the document containing the node
* @param id
* the node's internal id
+ * @param prettyPrint
+ * result is pretty printed if >0
+ * @param encoding
+ * character encoding to use
* @param user
* Description of the Parameter
* @return Description of the Return Value
@@ -1437,6 +1419,64 @@
throws EXistException, PermissionDeniedException {
return setUser(user, name, password, digestPassword,groups, null);
}
+
+ /**
+ * Sets the groups attribute of the RpcServer object.
+ * Added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ * @param user
+ * The new user value
+ * @param groups
+ * The new user's group value
+ * @return Description of the Return Value
+ * @exception EXistException
+ * Description of the Exception
+ * @exception PermissionDeniedException
+ * Description of the Exception
+ */
+ public boolean setUser(User user, String name, Vector groups, String home)
+ throws EXistException, PermissionDeniedException {
+ RpcConnection con = null;
+ try {
+ con = pool.get();
+ return con.setUser(user, name, groups);
+ } catch (Exception e) {
+ handleException(e);
+ return false;
+ } finally {
+ pool.release(con);
+ }
+ }
+
+ /**
+ * Sets the groups attribute of the RpcServer object.
+ * Added by {Marco.Tampucci, Massimo.Martinelli} @isti.cnr.it
+ *
+ * @param user
+ * The new user value
+ * @param groups
+ * The new user's group value
+ * @param rgroups
+ * The group to remove value
+ * @return Description of the Return Value
+ * @exception EXistException
+ * Description of the Exception
+ * @exception PermissionDeniedException
+ * Description of the Exception
+ */
+ public boolean setUser(User user, String name, Vector groups, String home, String rgroup)
+ throws EXistException, PermissionDeniedException {
+ RpcConnection con = null;
+ try {
+ con = pool.get();
+ return con.setUser(user, name, groups, rgroup);
+ } catch (Exception e) {
+ handleException(e);
+ return false;
+ } finally {
+ pool.release(con);
+ }
+ }
/*
* (non-Javadoc)
@@ -1491,24 +1531,6 @@
}
}
- public boolean enterServiceMode(User user) throws PermissionDeniedException, EXistException {
- BrokerPool brokerPool = BrokerPool.getInstance(databaseId);
- brokerPool.enterServiceMode(user);
- return true;
- }
-
- public boolean exitServiceMode(User user) throws PermissionDeniedException, EXistException {
- BrokerPool brokerPool = BrokerPool.getInstance(databaseId);
- brokerPool.exitServiceMode(user);
- return true;
- }
-
- public boolean isInServiceMode(User user) throws PermissionDeniedException, EXistException {
- BrokerPool brokerPool = BrokerPool.getInstance(databaseId);
- return brokerPool.isInServiceMode();
-
- }
-
public boolean shutdown(User user) throws PermissionDeniedException {
return shutdown(user, 0);
}
@@ -1912,3 +1934,4 @@
}
}
}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-30 16:38:16
|
Revision: 5297
http://svn.sourceforge.net/exist/?rev=5297&view=rev
Author: wolfgang_m
Date: 2007-01-30 08:38:05 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Updated Java service wrapper.jar to version 3.2.3.
Modified Paths:
--------------
trunk/eXist/tools/wrapper/lib/wrapper.jar
Modified: trunk/eXist/tools/wrapper/lib/wrapper.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-30 14:15:59
|
Revision: 5296
http://svn.sourceforge.net/exist/?rev=5296&view=rev
Author: brihaye
Date: 2007-01-30 06:15:55 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Commented out apparently unnecessary calls to cleanUp() : the DB seems to be consistent
Refactored logging.
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-30 10:27:25 UTC (rev 5295)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-30 14:15:55 UTC (rev 5296)
@@ -316,7 +316,7 @@
page.len += vlen;
ph.incRecordCount();
ph.setDataLength(page.len);
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page, 2);
// return pointer from pageNum and offset into page
@@ -598,7 +598,7 @@
rec.getPage().getPageHeader().incRecordCount();
if (doc != null && rec.getPage().getPageHeader().getCurrentTID() >= ItemId.DEFRAG_LIMIT)
doc.triggerDefrag();
- rec.getPage().cleanUp();
+ //rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
return StorageAddress.createPointer((int) rec.getPage().getPageNum(), tid);
@@ -654,6 +654,7 @@
// the old rec.page now contains a copy of the data up to the split
// point
rec.getPage().len = rec.offset;
+ ph.setDataLength(rec.getPage().len);
rec.getPage().setDirty(true);
// create a first split page
@@ -705,6 +706,7 @@
ph.setNextDataPage(newPage.getPageNum());
ph.setDataLength(rec.getPage().len);
ph.setRecordCount(countRecordsInPage(rec.getPage()));
+ rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
//switch record to new page...
@@ -757,6 +759,7 @@
nextSplitPage.getPageHeader().setNextDataPage(newPage.getPageNum());
nextSplitPage.getPageHeader().setDataLength(nextSplitPage.len);
nextSplitPage.getPageHeader().setRecordCount(splitRecordCount);
+ nextSplitPage.cleanUp();
nextSplitPage.setDirty(true);
dataCache.add(nextSplitPage);
dataCache.add(newPage);
@@ -850,6 +853,7 @@
ph.setNextDataPage(newPage.getPageNum());
ph.setDataLength(rec.getPage().len);
ph.setRecordCount(countRecordsInPage(rec.getPage()));
+ rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
//switch record to new page...
@@ -904,6 +908,7 @@
nextSplitPage.getPageHeader().setDataLength(nextSplitPage.len);
nextSplitPage.getPageHeader().setNextDataPage(ph.getNextDataPage());
nextSplitPage.getPageHeader().setRecordCount(splitRecordCount);
+ nextSplitPage.cleanUp();
nextSplitPage.setDirty(true);
dataCache.add(nextSplitPage);
@@ -951,6 +956,7 @@
}
ph.setDataLength(rec.getPage().len);
ph.setRecordCount(countRecordsInPage(rec.getPage()));
+ rec.getPage().cleanUp();
rec.offset = rec.getPage().len;
return rec;
}
@@ -1013,9 +1019,15 @@
pos += vlen;
}
}
- buf.append("; records in page: " + count);
+ buf.append("; records in page: " + count + " (header says " + page.getPageHeader().getRecordCount() + ")");
buf.append("; nextTID: " + page.getPageHeader().getCurrentTID());
buf.append("; length: " + page.getPageHeader().getDataLength());
+ for (int i = page.data.length ; i > 0 ; i--) {
+ if (page.data[i - 1] != 0) {
+ buf.append(" (last non-zero byte: " + i + ")");
+ break;
+ }
+ }
return buf.toString();
}
@@ -1496,7 +1508,7 @@
removePage(rec.getPage());
rec.setPage(null);
} else {
- rec.getPage().cleanUp();
+ //rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
}
@@ -1580,7 +1592,7 @@
removePage(rec.getPage());
rec.setPage(null);
} else {
- rec.getPage().cleanUp();
+ //rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
}
@@ -2109,7 +2121,7 @@
LOG.warn("page length <= 0");
ph.setDataLength(page.len);
ph.decRecordCount();
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
}
@@ -2182,7 +2194,7 @@
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2240,7 +2252,7 @@
}
ph.incRecordCount();
ph.setDataLength(page.len);
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page, 2);
}
@@ -2470,7 +2482,7 @@
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2501,7 +2513,7 @@
LOG.warn("page length <= 0");
ph.setDataLength(page.len);
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2518,7 +2530,7 @@
ph.setDataLength(page.len);
ph.setLsn(loggable.getLsn());
ph.incRecordCount();
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2536,7 +2548,7 @@
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2584,7 +2596,7 @@
ph.setNextTID(ItemId.getId(loggable.tid));
ph.incRecordCount();
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page, 2);
} catch (ArrayIndexOutOfBoundsException e) {
@@ -2621,7 +2633,7 @@
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
- page.cleanUp();
+ //page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -3053,8 +3065,11 @@
}
}
ph.setNextTID(maxTID);
+ //Uncommented because of recovery runs where both are not in sync
+ /*
if (ph.getRecordCount() != recordCount)
LOG.warn("page record count differs from computed record count");
+ */
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-30 10:27:26
|
Revision: 5295
http://svn.sourceforge.net/exist/?rev=5295&view=rev
Author: brihaye
Date: 2007-01-30 02:27:25 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
More code cleaning.
Commented out a wrong computation or page's record count... without any benefic effect so far :-(
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-30 09:54:51 UTC (rev 5294)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-30 10:27:25 UTC (rev 5295)
@@ -489,20 +489,20 @@
rec.getPage().getPageHeader().setNextDataPage(newPage.getPageNum());
if (nph.getNextDataPage() != Page.NO_PAGE) {
// link the next page in the chain back to the new page inserted
- final DOMPage nextInChain = getCurrentPage(nph.getNextDataPage());
- final DOMFilePageHeader nicph = nextInChain.getPageHeader();
+ final DOMPage nextPage = getCurrentPage(nph.getNextDataPage());
+ final DOMFilePageHeader nextph = nextPage.getPageHeader();
if (isTransactional && transaction != null) {
UpdateHeaderLoggable loggable =
- new UpdateHeaderLoggable(transaction, newPage.getPageNum(), nextInChain.getPageNum(),
- nicph.getNextDataPage(), nicph.getPrevDataPage(),
- nicph.getNextDataPage());
- writeToLog(loggable, nextInChain.page);
+ new UpdateHeaderLoggable(transaction, newPage.getPageNum(), nextPage.getPageNum(),
+ nextph.getNextDataPage(), nextph.getPrevDataPage(),
+ nextph.getNextDataPage());
+ writeToLog(loggable, nextPage.page);
}
- nicph.setPrevDataPage(newPage.getPageNum());
- nextInChain.setDirty(true);
- dataCache.add(nextInChain);
+ nextph.setPrevDataPage(newPage.getPageNum());
+ nextPage.setDirty(true);
+ dataCache.add(nextPage);
}
rec.getPage().setDirty(true);
@@ -512,14 +512,14 @@
rec.offset = 0;
rec.getPage().len = LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
- rec.getPage().getPageHeader().setRecordCount((short) 1);
+ //rec.getPage().getPageHeader().setRecordCount((short) 1);
//enough space in split page
} else {
rec.getPage().len = rec.offset + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
}
}
- // does value fit into page?
+ // the value doesn't fit into page : create new page
} else if (dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length > fileHeader.getWorkSize()
|| !rec.getPage().getPageHeader().hasRoom()) {
final DOMPage newPage = new DOMPage();
@@ -570,6 +570,7 @@
rec.offset = 0;
rec.getPage().len = LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
+ //append the value
} else {
rec.getPage().len = dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
@@ -1331,6 +1332,23 @@
LOG.error("io error while removing overflow value", e);
}
}
+
+ /**
+ * Set the last page in the sequence to which nodes are currently appended.
+ *
+ * @param page
+ * The new currentPage value
+ */
+ private final void setCurrentPage(DOMPage page) {
+ long pnum = pages.get(owner);
+ if (pnum == page.page.getPageNum())
+ return;
+ // pages.remove(owner);
+ // LOG.debug("current page set: " + page.getPage().getPageNum() + " by " +
+ // owner.hashCode() +
+ // "; thread: " + Thread.currentThread().getName());
+ pages.put(owner, page.page.getPageNum());
+ }
/**
* Retrieve the last page in the current sequence.
@@ -1693,23 +1711,6 @@
}
/**
- * Set the last page in the sequence to which nodes are currently appended.
- *
- * @param page
- * The new currentPage value
- */
- private final void setCurrentPage(DOMPage page) {
- long pnum = pages.get(owner);
- if (pnum == page.page.getPageNum())
- return;
- // pages.remove(owner);
- // LOG.debug("current page set: " + page.getPage().getPageNum() + " by " +
- // owner.hashCode() +
- // "; thread: " + Thread.currentThread().getName());
- pages.put(owner, page.page.getPageNum());
- }
-
- /**
* Get the active Lock object for this file.
*
* @see org.exist.util.Lockable#getLock()
@@ -2424,7 +2425,7 @@
System.arraycopy(loggable.value, 0, page.data, offset, loggable.value.length);
offset += loggable.value.length;
page.len += loggable.value.length;
- ph.incRecordCount();
+ ph.incRecordCount();
ph.setDataLength(page.len);
ph.setNextTID(ItemId.getId(loggable.tid));
page.setDirty(true);
@@ -2577,7 +2578,7 @@
// save data
System.arraycopy(loggable.value, 0, page.data, page.len, vlen);
page.len += vlen;
- //TODO : why 2 in ph.incRecordCount(); ?
+ //TODO : why 2 occurences of ph.incRecordCount(); ?
ph.incRecordCount();
ph.setDataLength(page.len);
ph.setNextTID(ItemId.getId(loggable.tid));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-30 09:54:54
|
Revision: 5294
http://svn.sourceforge.net/exist/?rev=5294&view=rev
Author: wolfgang_m
Date: 2007-01-30 01:54:51 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Removed all dependencies on NativeValueIndexByQName.
Modified Paths:
--------------
trunk/eXist/src/org/exist/security/xacml/XACMLUtil.java
trunk/eXist/src/org/exist/storage/DBBroker.java
trunk/eXist/src/org/exist/storage/NativeBroker.java
trunk/eXist/src/org/exist/storage/report/Statistics.java
trunk/eXist/src/org/exist/storage/report/XMLStatistics.java
trunk/eXist/src/org/exist/xquery/functions/util/QNameIndexLookup.java
Removed Paths:
-------------
trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java
Modified: trunk/eXist/src/org/exist/security/xacml/XACMLUtil.java
===================================================================
--- trunk/eXist/src/org/exist/security/xacml/XACMLUtil.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/security/xacml/XACMLUtil.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -43,12 +43,13 @@
import org.exist.security.PermissionDeniedException;
import org.exist.security.XMLSecurityManager;
import org.exist.storage.DBBroker;
-import org.exist.storage.NativeValueIndexByQName;
import org.exist.storage.UpdateListener;
+import org.exist.storage.NativeValueIndex;
import org.exist.storage.txn.TransactionManager;
import org.exist.storage.txn.Txn;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.XPathException;
+import org.exist.xquery.Constants;
import org.exist.xquery.value.AnyURIValue;
import org.exist.xquery.value.AtomicValue;
import org.exist.xquery.value.Sequence;
@@ -307,8 +308,9 @@
DocumentSet documentSet = getPolicyDocuments(broker, true);
NodeSet nodeSet = documentSet.toNodeSet();
- NativeValueIndexByQName index = broker.getQNameValueIndex();
- Sequence results = index.findByQName(attributeQName, comparison, nodeSet);
+ NativeValueIndex valueIndex = broker.getValueIndex();
+ Sequence results = valueIndex.find(Constants.EQ, documentSet, null, attributeQName, comparison);
+// Sequence results = index.findByQName(attributeQName, comparison, nodeSet);
//TODO : should we honour (# exist:force-index-use #) ?
return (results == null) ? null : results.getDocumentSet();
Modified: trunk/eXist/src/org/exist/storage/DBBroker.java
===================================================================
--- trunk/eXist/src/org/exist/storage/DBBroker.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/storage/DBBroker.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -427,8 +427,6 @@
public abstract NativeValueIndex getValueIndex();
- public abstract NativeValueIndexByQName getQNameValueIndex();
-
/**
* Is string comparison case sensitive?
*
Modified: trunk/eXist/src/org/exist/storage/NativeBroker.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeBroker.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/storage/NativeBroker.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -129,7 +129,6 @@
public static final byte VALUES_DBX_ID = 2;
public static final byte WORDS_DBX_ID = 3;
public static final byte DOM_DBX_ID = 4;
- public static final byte VALUES_QNAME_DBX_ID = 5;
//Note : no ID for symbols ? Too bad...
public static final String PROPERTY_PAGE_SIZE = "db-connection.page-size";
@@ -138,7 +137,7 @@
private static final byte[] ALL_STORAGE_FILES = {
COLLECTIONS_DBX_ID, ELEMENTS_DBX_ID, VALUES_DBX_ID,
- VALUES_QNAME_DBX_ID, WORDS_DBX_ID, DOM_DBX_ID
+ WORDS_DBX_ID, DOM_DBX_ID
};
private static final String TEMP_FRAGMENT_REMOVE_ERROR = "Could not remove temporary fragment";
@@ -169,7 +168,6 @@
/** the index processors */
protected NativeElementIndex elementIndex;
protected NativeValueIndex valueIndex;
- protected NativeValueIndexByQName qnameValueIndex;
protected NativeTextEngine textEngine;
protected IndexSpec indexConfiguration;
@@ -258,8 +256,7 @@
readOnly = readOnly || !symbols.getFile().canWrite();
elementIndex = new NativeElementIndex(this, ELEMENTS_DBX_ID, dataDir, config);
- valueIndex = new NativeValueIndex(this, VALUES_DBX_ID, dataDir, config);
- qnameValueIndex = new NativeValueIndexByQName(this, VALUES_QNAME_DBX_ID, dataDir, config);
+ valueIndex = new NativeValueIndex(this, VALUES_DBX_ID, dataDir, config);
textEngine = new NativeTextEngine(this, WORDS_DBX_ID, dataDir, config);
if (readOnly)
@@ -505,8 +502,6 @@
return elementIndex.dbNodes;
case VALUES_DBX_ID :
return valueIndex.dbValues;
- case VALUES_QNAME_DBX_ID :
- return qnameValueIndex.dbValues;
case WORDS_DBX_ID :
return textEngine.dbTokens;
default:
@@ -534,10 +529,6 @@
return valueIndex;
}
- public NativeValueIndexByQName getQNameValueIndex() {
- return qnameValueIndex;
- }
-
public TextSearchEngine getTextEngine() {
return textEngine;
}
@@ -2719,7 +2710,6 @@
try {
elementIndex = new NativeElementIndex(this, ELEMENTS_DBX_ID, dataDir, config);
valueIndex = new NativeValueIndex(this, VALUES_DBX_ID, dataDir, config);
- qnameValueIndex = new NativeValueIndexByQName(this, VALUES_QNAME_DBX_ID, dataDir, config);
textEngine = new NativeTextEngine(this, WORDS_DBX_ID, dataDir, config);
} catch (DBException e) {
LOG.warn("Exception during repair: " + e.getMessage(), e);
Deleted: trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -1,333 +0,0 @@
-/* * eXist Open Source Native XML Database
- * Copyright (C) 2001-04 The eXist Project
- * http://exist-db.org
- *
- * 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.
- *
- * Created on 25 mai 2005
-$Id$ */
-
-package org.exist.storage;
-
-import java.io.IOException;
-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.dom.AttrImpl;
-import org.exist.dom.DocumentImpl;
-import org.exist.dom.DocumentSet;
-import org.exist.dom.ElementImpl;
-import org.exist.dom.ExtArrayNodeSet;
-import org.exist.dom.NodeSet;
-import org.exist.dom.QName;
-import org.exist.dom.StoredNode;
-import org.exist.dom.SymbolTable;
-import org.exist.storage.btree.BTreeException;
-import org.exist.storage.btree.DBException;
-import org.exist.storage.btree.IndexQuery;
-import org.exist.storage.btree.Value;
-import org.exist.storage.lock.Lock;
-import org.exist.util.ByteConversion;
-import org.exist.util.Configuration;
-import org.exist.util.LockException;
-import org.exist.util.ReadOnlyException;
-import org.exist.xquery.Constants;
-import org.exist.xquery.TerminatedException;
-import org.exist.xquery.XPathException;
-import org.exist.xquery.value.AtomicValue;
-import org.exist.xquery.value.Sequence;
-import org.exist.xquery.value.StringValue;
-import org.exist.xquery.value.Type;
-
-/** The new index by QName that will make queries like
-<pre>
-/ root [ key = 123 ]
-</pre>
-very quick.
-It is used by an Xquery extension function with this signature :
-<pre>
-qname-index-lookup( $qname as xs:string,
- $key as xs:string ) as node*
-</pre>
-
-that can be used this way :
-
-<pre>
-$key := qname-index-lookup( "key", "123")
-$user := $key / parent::root
-</pre>
-
-The way of indexing is the same as current range indices {@link NativeValueIndex},
-except that for each QName like <key> mentioned above, the QName will be stored .
-Related test: @link org.exist.xquery.test.ValueIndexByQNameTest
-
- * @author Jean-Marc Vanel http://jmvanel.free.fr/
- */
-public class NativeValueIndexByQName extends NativeValueIndex implements ContentLoadingObserver {
-
- private final static Logger LOG = Logger.getLogger(NativeValueIndexByQName.class);
-
- public static final String FILE_NAME = "values-by-qname.dbx";
- public static final String FILE_KEY_IN_CONFIG = "db-connection2.values";
-
- public static int OFFSET_COLLECTION_ID = 0;
- //Notice that the conventional design is to serialize OFFSET_SYMBOL *then* OFFSET_NSSYMBOL
- //TODO : investigate
- public static int OFFSET_NS_URI = OFFSET_COLLECTION_ID + Collection.LENGTH_COLLECTION_ID; //2
- public static int OFFSET_LOCAL_NAME = OFFSET_NS_URI + SymbolTable.LENGTH_NS_URI; //4
- public static int OFFSET_VALUE = OFFSET_LOCAL_NAME + SymbolTable.LENGTH_LOCAL_NAME; //6
-
- public NativeValueIndexByQName(DBBroker broker, byte id, String dataDir, Configuration config) throws DBException {
- super(broker, id, dataDir, config);
- }
-
- public String getFileName() {
- return FILE_NAME;
- }
-
- public String getConfigKeyForFile() {
- return FILE_KEY_IN_CONFIG;
- }
-
- public NativeValueIndex getInstance() {
- return this;
- }
-
- public void storeAttribute(RangeIndexSpec spec, AttrImpl node, NodePath currentPath, boolean index) {
- DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
- //Here's the point : 2 configuration objects !
- QNameRangeIndexSpec qnIdx = doc.getCollection().getIndexByQNameConfiguration(broker, node.getQName());
- if (qnIdx != null) {
- this.setDocument(doc);
- ValueIndexKeyFactory keyFactory = computeTemporaryKey(spec.getType(), node.getValue(), node.getQName());
- updatePendingIndexEntry(node, keyFactory);
- }
- }
-
- /** @see org.exist.storage.NativeValueIndex#storeElement(int, org.exist.dom.ElementImpl, java.lang.String)
- */
- public void storeElement(int xpathType, ElementImpl node, String content) {
- ValueIndexKeyFactory keyFactory = computeTemporaryKey( xpathType, content, node.getQName() );
- updatePendingIndexEntry(node, keyFactory);
- }
-
- /** updates the index type of given node according to the Index By QName config. */
- public void startElement(ElementImpl node, NodePath currentPath, boolean index) {
- DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
- QNameRangeIndexSpec qnIdx = doc.getCollection().getIndexByQNameConfiguration(broker, node.getQName());
- if (qnIdx != null) {
- int newIndexType = RangeIndexSpec.QNAME_INDEX;
- ElementImpl elementImpl = (ElementImpl) node;
- elementImpl.setIndexType(newIndexType | elementImpl.getIndexType());
- }
- }
-
- public void endElement(ElementImpl node, NodePath currentPath, String content) {
- localMarkElement(node, currentPath, content);
- }
-
- public void removeElement( ElementImpl node, NodePath currentPath, String content ) {
- localMarkElement(node, currentPath, content);
- }
-
- /** adds or updates an entry in the {@link #pending} map
- * @param node the DOM node
- * @param keyFactory a {@link QNameValueIndexKeyFactory}
- */
- private void updatePendingIndexEntry(StoredNode node, ValueIndexKeyFactory keyFactory) {
- if(keyFactory == null)
- return; // skip
- ArrayList buf;
- if (pending[IDX_GENERIC].containsKey(keyFactory))
- buf = (ArrayList) pending[IDX_GENERIC].get(keyFactory);
- else {
- buf = new ArrayList(8);
- pending[IDX_GENERIC].put(keyFactory, buf);
- }
- buf.add(node.getNodeId());
- }
-
- /** compute a key for the {@link #pending} map */
- private ValueIndexKeyFactory computeTemporaryKey(int xpathType, String value, QName qname) {
- final StringValue str = new StringValue(value);
- AtomicValue atomic = null;
- QNameValueIndexKeyFactory ret = null;
-
- if(Type.subTypeOf(xpathType, Type.STRING))
- atomic = str;
- else {
- try {
- atomic = str.convertTo(xpathType);
- } catch (XPathException e) {
- LOG.warn("Node value: '" + value + "' cannot be converted to type " +
- Type.getTypeName(xpathType));
- }
- }
-
- if( atomic instanceof Indexable ) {
- if ( atomic != null )
- ret = new QNameValueIndexKeyFactory((Indexable)atomic, qname );
- } else {
- LOG.warn("The specified type: '" + Type.getTypeName(xpathType) +
- "' and value '" + value + "'" +
- " cannot be used as index key. It is null or does not implement interface Indexable.");
- atomic = null;
- }
- return ret;
- }
-
-
- /** key for the {@link #pending} map ; the order is lexicographic on
- * qname first, indexable second ;
- * this class also provides through serialize() the persistant storage key :
- * (collectionId, qname, indexType, indexData)
- */
- // TODO "ValueIndexKeyFactory" refactoring: remove after refactoring NativeValueIndex
- private class QNameValueIndexKeyFactory implements ValueIndexKeyFactory, Indexable {
- private QName qname;
- private Indexable indexable;
-
- public QNameValueIndexKeyFactory(Indexable indexable, QName qname) {
- this.indexable = indexable;
- this.qname = qname;
- }
-
- /** called from {@link NativeValueIndex};
- * provides the persistant storage key :
- * (collectionId, qname, indexType, indexData) */
- public byte[] serialize(short collectionId, boolean caseSensitive) throws EXistException {
- final byte[] data = indexable.serializeValue(OFFSET_VALUE, caseSensitive);
- ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
- SymbolTable symbols = broker.getSymbols();
- short namespaceId = symbols.getNSSymbol(qname.getNamespaceURI());
- ByteConversion.shortToByte(namespaceId, data, OFFSET_NS_URI);
- short localNameId = symbols.getSymbol(qname.getLocalName());
- ByteConversion.shortToByte(localNameId, data, OFFSET_LOCAL_NAME);
- return data;
- }
-
- public byte[] serialize(short collectionId) throws EXistException {
- final byte[] data = indexable.serializeValue(OFFSET_VALUE);
- ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
- SymbolTable symbols = broker.getSymbols();
- short namespaceId = symbols.getNSSymbol(qname.getNamespaceURI());
- ByteConversion.shortToByte(namespaceId, data, OFFSET_NS_URI);
- short localNameId = symbols.getSymbol(qname.getLocalName());
- ByteConversion.shortToByte(localNameId, data, OFFSET_LOCAL_NAME);
- return data;
- }
-
- /** @return negative value <==> this object is less than other */
- public int compareTo(Object other) {
- int ret = 0;
- if ( other instanceof QNameValueIndexKeyFactory ) {
- QNameValueIndexKeyFactory otherIndexable = (QNameValueIndexKeyFactory)other;
- int qnameComparison = qname.compareTo(otherIndexable.qname);
- if ( qnameComparison != 0 ) {
- ret = qnameComparison;
- } else {
- ret = indexable.compareTo(otherIndexable.indexable);
- }
- }
- return ret;
- }
-
- /** unused - TODO "ValueIndexKeyFactory" refactoring: remove after refactoring NativeValueIndex */
- public byte[] serializeValue( int offset, boolean caseSensitive) {
- return null;
- }
-
- /** unused - TODO "ValueIndexKeyFactory" refactoring: remove after refactoring NativeValueIndex */
- public byte[] serializeValue( int offset) {
- return null;
- }
-
- public int getType() {
- return indexable.getType();
- }
- }
-
- /** called from the special XQuery function util:qname-index-lookup() */
- public Sequence findByQName(QName qname, AtomicValue comparisonCriterium, Sequence contextSequence) throws XPathException {
- NodeSet contextSet = contextSequence.toNodeSet();
- DocumentSet docSet = contextSet.getDocumentSet();
-
- ValueIndexKeyFactory
- // Indexable
- indexable = new QNameValueIndexKeyFactory( (Indexable)comparisonCriterium, qname);
- int relation = Constants.EQ;
- return find(relation, docSet, contextSet, indexable);
- }
-
- /** find
- * @param relation binary operator used for the comparison
- * @param value right hand comparison value */
- public NodeSet find(int relation, DocumentSet docs, NodeSet contextSet, ValueIndexKeyFactory value)
- throws TerminatedException {
- int idxOp = checkRelationOp(relation);
- NodeSet result = new ExtArrayNodeSet();
- Lock lock = dbValues.getLock();
- for (Iterator iter = docs.getCollectionIterator(); iter.hasNext();) {
- Collection collection = (Collection) iter.next();
- short collectionId = collection.getId();
- try {
- Value key = new Value(value.serialize(collectionId, caseSensitive));
- IndexQuery query = new IndexQuery(idxOp, key);
- lock.acquire();
- try {
- SearchCallback callback = new SearchCallback(docs, contextSet, result, false);
- dbValues.query(query, callback );
- } catch (IOException ioe) {
- //TODO : error ?
- LOG.warn(ioe);
- } catch (BTreeException bte) {
- //TODO : error ?
- LOG.warn(bte);
- }
- } catch (EXistException e) {
- LOG.error(e.getMessage(), e);
- } catch (LockException e) {
- LOG.warn(e);
- } finally {
- lock.release();
- }
- }
- return result;
- }
-
- private void localMarkElement(ElementImpl node, NodePath currentPath, String content) {
- DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
- QNameRangeIndexSpec qnIdx = doc.getCollection().getIndexByQNameConfiguration(broker, node.getQName());
- if (qnIdx != null) {
- this.setDocument(doc);
- this.storeElement(qnIdx.getType(), (ElementImpl) node, content);
- }
- }
-
- public void dropIndex(DocumentImpl doc) throws ReadOnlyException {
- super.dropIndex(doc);
- }
-
- public void closeAndRemove() {
- super.closeAndRemove();
- }
-
- public boolean close() throws DBException {
- return super.close();
- }
-}
Modified: trunk/eXist/src/org/exist/storage/report/Statistics.java
===================================================================
--- trunk/eXist/src/org/exist/storage/report/Statistics.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/storage/report/Statistics.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -4,18 +4,17 @@
*/
package org.exist.storage.report;
-import java.util.Map;
-
import org.exist.storage.IndexStats;
import org.exist.storage.NativeElementIndex;
import org.exist.storage.NativeTextEngine;
import org.exist.storage.NativeValueIndex;
-import org.exist.storage.NativeValueIndexByQName;
import org.exist.storage.dom.DOMFile;
import org.exist.storage.index.BFile;
import org.exist.storage.index.CollectionStore;
import org.exist.util.Configuration;
+import java.util.Map;
+
/**
* @author jmv
*/
@@ -37,10 +36,7 @@
indexStats.put(NativeElementIndex.FILE_NAME, new IndexStats(db));
db = (BFile) conf.getProperty(NativeValueIndex.FILE_KEY_IN_CONFIG);
if(db != null)
- indexStats.put(NativeValueIndex.FILE_NAME, new IndexStats(db));
- db = (BFile) conf.getProperty(NativeValueIndexByQName.FILE_KEY_IN_CONFIG);
- if(db != null)
- indexStats.put(NativeValueIndexByQName.FILE_NAME, new IndexStats(db));
+ indexStats.put(NativeValueIndex.FILE_NAME, new IndexStats(db));
db = (BFile) conf.getProperty(NativeTextEngine.FILE_KEY_IN_CONFIG);
if(db != null)
indexStats.put(NativeTextEngine.FILE_NAME, new IndexStats(db));
Modified: trunk/eXist/src/org/exist/storage/report/XMLStatistics.java
===================================================================
--- trunk/eXist/src/org/exist/storage/report/XMLStatistics.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/storage/report/XMLStatistics.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -11,7 +11,6 @@
import org.exist.storage.NativeElementIndex;
import org.exist.storage.NativeTextEngine;
import org.exist.storage.NativeValueIndex;
-import org.exist.storage.NativeValueIndexByQName;
import org.exist.storage.dom.DOMFile;
import org.exist.storage.index.BFile;
import org.exist.storage.index.CollectionStore;
@@ -70,7 +69,7 @@
}
this.contentHandler.endElement(NAMESPACE, "database-instances",
- PREFIX + "database-instances");
+ PREFIX + ":database-instances");
}
private void genBufferStatus(BrokerPool instance) throws SAXException {
@@ -88,9 +87,6 @@
db = (BFile) conf.getProperty(NativeValueIndex.FILE_KEY_IN_CONFIG);
if (db != null)
genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Values index ("+ db.getFile().getName() + ")");
- db = (BFile) conf.getProperty(NativeValueIndexByQName.FILE_KEY_IN_CONFIG);
- if (db != null)
- genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "QName values index ("+ db.getFile().getName() + ")");
db = (BFile) conf.getProperty(NativeTextEngine.FILE_KEY_IN_CONFIG);
if (db != null)
genBufferDetails(db.getIndexBufferStats(), db.getDataBufferStats(), "Fulltext index ("+ db.getFile().getName() + ")");
Modified: trunk/eXist/src/org/exist/xquery/functions/util/QNameIndexLookup.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/functions/util/QNameIndexLookup.java 2007-01-30 09:53:14 UTC (rev 5293)
+++ trunk/eXist/src/org/exist/xquery/functions/util/QNameIndexLookup.java 2007-01-30 09:54:51 UTC (rev 5294)
@@ -26,7 +26,6 @@
import org.exist.dom.QName;
import org.exist.storage.Indexable;
-import org.exist.storage.NativeValueIndexByQName;
import org.exist.storage.NativeValueIndex;
import org.exist.xquery.AnalyzeContextInfo;
import org.exist.xquery.Cardinality;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-30 09:53:15
|
Revision: 5293
http://svn.sourceforge.net/exist/?rev=5293&view=rev
Author: wolfgang_m
Date: 2007-01-30 01:53:14 -0800 (Tue, 30 Jan 2007)
Log Message:
-----------
Fixed test failure.
Modified Paths:
--------------
trunk/eXist/test/src/org/exist/xquery/LexerTest.java
Modified: trunk/eXist/test/src/org/exist/xquery/LexerTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/LexerTest.java 2007-01-29 23:05:14 UTC (rev 5292)
+++ trunk/eXist/test/src/org/exist/xquery/LexerTest.java 2007-01-30 09:53:14 UTC (rev 5293)
@@ -10,12 +10,15 @@
import junit.framework.TestCase;
import org.exist.EXistException;
+import org.exist.test.TestConstants;
import org.exist.collections.Collection;
import org.exist.collections.IndexInfo;
import org.exist.security.User;
import org.exist.security.xacml.AccessContext;
import org.exist.storage.BrokerPool;
import org.exist.storage.DBBroker;
+import org.exist.storage.txn.TransactionManager;
+import org.exist.storage.txn.Txn;
import org.exist.util.Configuration;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.parser.XQueryLexer;
@@ -78,11 +81,18 @@
try {
// parse the xml source
broker = pool.get(user);
- Collection collection = broker.getCollection(XmldbURI.ROOT_COLLECTION_URI.append("test"));
- IndexInfo info = collection.validateXMLResource(null, broker, XmldbURI.create("test.xml"), xml);
- collection.store(null, broker, info, xml, false);
+ TransactionManager transact = pool.getTransactionManager();
+ assertNotNull(transact);
+ Txn transaction = transact.beginTransaction();
+ assertNotNull(transaction);
+ Collection collection = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
+ broker.saveCollection(transaction, collection);
- // parse the query into the internal syntax tree
+ IndexInfo info = collection.validateXMLResource(transaction, broker, XmldbURI.create("test.xml"), xml);
+ collection.store(transaction, broker, info, xml, false);
+ transact.commit(transaction);
+
+ // parse the query into the internal syntax tree
XQueryContext context = new XQueryContext(broker, AccessContext.TEST);
XQueryLexer lexer = new XQueryLexer(context, new StringReader(query));
XQueryParser xparser = new XQueryParser(lexer);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-29 23:05:19
|
Revision: 5292
http://svn.sourceforge.net/exist/?rev=5292&view=rev
Author: brihaye
Date: 2007-01-29 15:05:14 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
More logging.
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
trunk/eXist/src/org/exist/storage/dom/DOMFileIterator.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-29 22:47:23 UTC (rev 5291)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-29 23:05:14 UTC (rev 5292)
@@ -548,16 +548,17 @@
rec.getPage().getPageHeader().setNextDataPage(newPage.getPageNum());
if (Page.NO_PAGE != nextPageNr) {
final DOMPage nextPage = getCurrentPage(nextPageNr);
+ final DOMFilePageHeader nextph = nextPage.getPageHeader();
if (isTransactional && transaction != null) {
UpdateHeaderLoggable loggable =
new UpdateHeaderLoggable(transaction, newPage.getPageNum(), nextPage.getPageNum(),
- nextPage.getPageHeader().getNextDataPage(), nextPage.getPageHeader().getPrevDataPage(),
- nextPage.getPageHeader().getNextDataPage());
+ nextph.getNextDataPage(),
+ nextph.getPrevDataPage(), nextph.getNextDataPage());
writeToLog(loggable, nextPage.page);
}
- nextPage.getPageHeader().setPrevDataPage(newPage.getPageNum());
+ nextph.setPrevDataPage(newPage.getPageNum());
nextPage.setDirty(true);
dataCache.add(nextPage);
}
@@ -1926,7 +1927,7 @@
readOffset += LENGTH_DLN_LENGTH;
final int nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
readOffset += nodeIdLen;
- os.write(data, readOffset, realLen - (2 + nodeIdLen + 1));
+ os.write(data, readOffset, realLen - (1 + 2 + nodeIdLen));
break;
}
case Node.ATTRIBUTE_NODE:
@@ -2096,13 +2097,13 @@
SanityCheck.ASSERT(pos != null, "Record not found!");
final int startOffset = pos.offset - 2;
// get the record length
- short l = ByteConversion.byteToShort(page.data, pos.offset);
+ final short vlen = ByteConversion.byteToShort(page.data, pos.offset);
// end offset
- final int end = startOffset + LENGTH_TID + LENGTH_DATA_LENGTH + l;
+ final int end = startOffset + LENGTH_TID + LENGTH_DATA_LENGTH + vlen;
final int dlen = ph.getDataLength();
// remove old value
System.arraycopy(page.data, end, page.data, startOffset, dlen - end);
- page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
+ page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + vlen);
if (page.len <= 0)
LOG.warn("page length <= 0");
ph.setDataLength(page.len);
@@ -2600,9 +2601,9 @@
SanityCheck.ASSERT(rec != null, "Record with tid " + ItemId.getId(loggable.tid) + " not found: "
+ debugPageContents(page));
// get the record length
- short l = ByteConversion.byteToShort(page.data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(page.data, rec.offset);
// end offset
- final int end = rec.offset + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + l;
+ final int end = rec.offset + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + vlen;
final int dlen = ph.getDataLength();
// remove value
try {
@@ -2613,7 +2614,7 @@
"; tid: " + loggable.tid +
"; offset: " + (rec.offset - 2) + "; end: " + end + "; len: " + (dlen - end));
}
- page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + l);
+ page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + vlen);
if (page.len <= 0)
LOG.warn("page length <= 0");
ph.setDataLength(page.len);
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFileIterator.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFileIterator.java 2007-01-29 22:47:23 UTC (rev 5291)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFileIterator.java 2007-01-29 23:05:14 UTC (rev 5292)
@@ -78,6 +78,8 @@
try {
lock.acquire();
} catch (LockException e) {
+ LOG.warn(e);
+ System.out.println(e);
return false;
}
if(gotoNextPosition()) {
@@ -112,6 +114,8 @@
try {
lock.acquire();
} catch (LockException e) {
+ LOG.warn(e);
+ System.out.println(e);
return null;
}
Value nextVal = null;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-29 22:47:25
|
Revision: 5291
http://svn.sourceforge.net/exist/?rev=5291&view=rev
Author: wolfgang_m
Date: 2007-01-29 14:47:23 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
Set HTTP status if XQuery source file could not be found.
Modified Paths:
--------------
trunk/eXist/src/org/exist/http/servlets/XQueryServlet.java
Modified: trunk/eXist/src/org/exist/http/servlets/XQueryServlet.java
===================================================================
--- trunk/eXist/src/org/exist/http/servlets/XQueryServlet.java 2007-01-29 22:37:12 UTC (rev 5290)
+++ trunk/eXist/src/org/exist/http/servlets/XQueryServlet.java 2007-01-29 22:47:23 UTC (rev 5291)
@@ -221,6 +221,7 @@
File f = new File(path);
if(!f.canRead()) {
+ response.setStatus(HttpServletResponse.SC_NOT_FOUND);
sendError(output, "Cannot read source file", path);
return;
}
@@ -325,6 +326,7 @@
}
} catch (XMLDBException e) {
LOG.debug(e);
+ response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
sendError(output, e.getMessage(), e);
}
output.flush();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-29 22:37:16
|
Revision: 5290
http://svn.sourceforge.net/exist/?rev=5290&view=rev
Author: wolfgang_m
Date: 2007-01-29 14:37:12 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
Added some test cases for range index.
Modified Paths:
--------------
trunk/eXist/test/src/org/exist/xquery/FtQueryTest.java
trunk/eXist/test/src/org/exist/xquery/LexerTest.java
trunk/eXist/test/src/org/exist/xquery/ValueIndexByQNameTest.java
trunk/eXist/test/src/org/exist/xquery/ValueIndexTest.java
trunk/eXist/test/src/org/exist/xquery/XPathQueryTest.java
Modified: trunk/eXist/test/src/org/exist/xquery/FtQueryTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/FtQueryTest.java 2007-01-29 22:35:58 UTC (rev 5289)
+++ trunk/eXist/test/src/org/exist/xquery/FtQueryTest.java 2007-01-29 22:37:12 UTC (rev 5290)
@@ -396,7 +396,16 @@
System.out.println(resource.getContent());
}
assertEquals(3, result.getSize());
- } catch (XMLDBException e) {
+
+ query = "import module namespace t=\'http://exist-db.org/xquery/text\';\n" +
+ "t:fuzzy-index-terms('node')";
+ result = service.query(query);
+ for (ResourceIterator i = result.getIterator(); i.hasMoreResources(); ) {
+ Resource resource = i.nextResource();
+ System.out.println(resource.getContent());
+ }
+ assertEquals(1, result.getSize());
+ } catch (XMLDBException e) {
e.printStackTrace();
fail(e.getMessage());
}
Modified: trunk/eXist/test/src/org/exist/xquery/LexerTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/LexerTest.java 2007-01-29 22:35:58 UTC (rev 5289)
+++ trunk/eXist/test/src/org/exist/xquery/LexerTest.java 2007-01-29 22:37:12 UTC (rev 5290)
@@ -110,7 +110,8 @@
System.out.println("----------------------------------");
System.out.println("found: " + result.getLength());
} catch (Exception e) {
- fail(e.getMessage());
+ e.printStackTrace();
+ fail(e.getMessage());
} finally {
pool.release(broker);
}
Modified: trunk/eXist/test/src/org/exist/xquery/ValueIndexByQNameTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/ValueIndexByQNameTest.java 2007-01-29 22:35:58 UTC (rev 5289)
+++ trunk/eXist/test/src/org/exist/xquery/ValueIndexByQNameTest.java 2007-01-29 22:37:12 UTC (rev 5290)
@@ -29,10 +29,9 @@
" <create qname='mixed' type='xs:string' />" +
" </index>" +
"</collection>";
-
- /** @see org.exist.xquery.test.ValueIndexTest#testStrings() */
+
public void testStrings() throws Exception {
- configureCollection();
+ configureCollection(config);
XPathQueryService service = storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
// queryResource(service, "items.xml", "//item[name > 'Racing Bicycle']", 4 );
@@ -52,7 +51,6 @@
// queryResource(service, "items.xml", "//item[fn:matches(mixed, 'un.*')]", 2);
}
- /** @see org.exist.xquery.test.ValueIndexTest#getCollectionConfig() */
protected String getCollectionConfig() {
return config;
}
Modified: trunk/eXist/test/src/org/exist/xquery/ValueIndexTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/ValueIndexTest.java 2007-01-29 22:35:58 UTC (rev 5289)
+++ trunk/eXist/test/src/org/exist/xquery/ValueIndexTest.java 2007-01-29 22:37:12 UTC (rev 5290)
@@ -71,6 +71,21 @@
" </index>" +
"</collection>";
+ private String CONFIG_QNAME =
+ "<collection xmlns=\"http://exist-db.org/collection-config/1.0\">" +
+ " <index xmlns:x=\"http://www.foo.com\" xmlns:xx=\"http://test.com\">" +
+ " <fulltext default=\"none\">" +
+ " </fulltext>" +
+ " <create qname=\"itemno\" type=\"xs:integer\"/>" +
+ " <create qname=\"mixed\" type=\"xs:string\"/>" +
+ " <create qname=\"stock\" type=\"xs:integer\"/>" +
+ " <create qname=\"name\" type=\"xs:string\"/>" +
+ " <create qname=\"@id\" type=\"xs:string\"/>" +
+ " <create qname=\"price\" type=\"xs:double\"/>" +
+ " <create path=\"x:rating\" type=\"xs:double\"/>" +
+ " </index>" +
+ "</collection>";
+
private String CITY =
"<mondial>" +
" <city id=\"cty-Germany-Berlin\" is_country_cap=\"yes\" is_state_cap=\"yes\" " +
@@ -114,6 +129,10 @@
* @see TestCase#tearDown()
*/
protected void tearDown() throws Exception {
+ Collection root = DatabaseManager.getCollection(URI, "admin", null);
+ CollectionManagementService service = (CollectionManagementService) root
+ .getService("CollectionManagementService", "1.0");
+ service.removeCollection("test");
DatabaseInstanceManager dim =
(DatabaseInstanceManager) testCollection.getService("DatabaseInstanceManager", "1.0");
dim.shutdown();
@@ -124,38 +143,44 @@
/**
* @throws XMLDBException
*/
- protected void configureCollection() throws XMLDBException {
+ protected void configureCollection(String config) throws XMLDBException {
IndexQueryService idxConf = (IndexQueryService)
testCollection.getService("IndexQueryService", "1.0");
- idxConf.configureCollection(getCollectionConfig());
+ idxConf.configureCollection(config);
}
public void testStrings() throws Exception {
- configureCollection();
- XPathQueryService service = storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
- queryResource(service, "items.xml", "//item[@id = 'i2']", 1);
- queryResource(service, "items.xml", "//item[name = 'Racing Bicycle']", 1);
- queryResource(service, "items.xml", "//item[name > 'Racing Bicycle']", 4);
- queryResource(service, "items.xml", "//item[itemno = 3]", 1);
- ResourceSet result = queryResource(service, "items.xml", "for $i in //item[stock <= 10] return $i/itemno", 5);
- for (long i = 0; i < result.getSize(); i++) {
- Resource res = result.getResource(i);
- System.out.println(res.getContent());
+ try {
+ configureCollection(CONFIG);
+ XPathQueryService service = storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
+ queryResource(service, "items.xml", "//item[@id = 'i2']", 1);
+ queryResource(service, "items.xml", "//item[name = 'Racing Bicycle']", 1);
+ queryResource(service, "items.xml", "//item[name > 'Racing Bicycle']", 4);
+ queryResource(service, "items.xml", "//item[itemno = 3]", 1);
+ ResourceSet result = queryResource(service, "items.xml", "for $i in //item[stock <= 10] return $i/itemno", 5);
+ for (long i = 0; i < result.getSize(); i++) {
+ Resource res = result.getResource(i);
+ System.out.println(res.getContent());
+ }
+
+ queryResource(service, "items.xml", "//item[stock > 20]", 1);
+ queryResource(service, "items.xml", "declare namespace x=\"http://www.foo.com\"; //item[x:rating > 8.0]", 2);
+ queryResource(service, "items.xml", "declare namespace xx=\"http://test.com\"; //item[@xx:test = 123]", 1);
+ queryResource(service, "items.xml", "//item[name &= 'Racing Bicycle']", 1);
+ queryResource(service, "items.xml", "//item[mixed = 'uneven']", 1);
+ queryResource(service, "items.xml", "//item[mixed = 'external']", 1);
+ queryResource(service, "items.xml", "//item[fn:matches(mixed, 'un.*')]", 2);
+ queryResource(service, "items.xml", "//item[price/@specialprice = false()]", 2);
+ queryResource(service, "items.xml", "//item[price/@specialprice = true()]", 1);
+ } catch (XMLDBException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
}
-
- queryResource(service, "items.xml", "//item[stock > 20]", 1);
- queryResource(service, "items.xml", "declare namespace x=\"http://www.foo.com\"; //item[x:rating > 8.0]", 2);
- queryResource(service, "items.xml", "declare namespace xx=\"http://test.com\"; //item[@xx:test = 123]", 1);
- queryResource(service, "items.xml", "//item[name &= 'Racing Bicycle']", 1);
- queryResource(service, "items.xml", "//item[mixed = 'uneven']", 1);
- queryResource(service, "items.xml", "//item[mixed = 'external']", 1);
- queryResource(service, "items.xml", "//item[fn:matches(mixed, 'un.*')]", 2);
- queryResource(service, "items.xml", "//item[price/@specialprice = false()]", 2);
- queryResource(service, "items.xml", "//item[price/@specialprice = true()]", 1);
}
public void testStrFunctions() {
try {
+ configureCollection(CONFIG);
XMLResource resource = (XMLResource) testCollection.createResource("mondial-test.xml", "XMLResource");
resource.setContent(CITY);
testCollection.storeResource(resource);
@@ -187,15 +212,36 @@
}
}
+ public void testQNameIndex() {
+ try {
+ configureCollection(CONFIG_QNAME);
+ XPathQueryService service = storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[stock = 10] })", 1);
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[stock > 20] })", 1);
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[stock < 16] })", 6);
+ queryResource(service, "items.xml", "declare namespace x=\"http://www.foo.com\"; " +
+ "//((#exist:optimize#) { item[x:rating > 8.0] })", 2);
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[mixed = 'uneven'] })", 1);
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[mixed = 'external'] })", 1);
+ queryResource(service, "items.xml", "//((#exist:optimize#) { item[@id = 'i1'] })",1);
+ queryResource(service, "items.xml", "declare namespace xx=\"http://test.com\";" +
+ "//((#exist:optimize#) { item[@xx:test = 123] })", 1);
+ } catch (XMLDBException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
public void testIndexScan() {
try {
System.out.println("----- testIndexScan -----");
+ configureCollection(CONFIG);
String queryBody =
"declare namespace f=\'http://exist-db.org/xquery/test\';\n" +
"declare namespace mods='http://www.loc.gov/mods/v3';\n" +
"import module namespace u=\'http://exist-db.org/xquery/util\';\n" +
"\n" +
- "declare function f:term-callback($term as xs:string, $data as xs:int+)\n" +
+ "declare function f:term-callback($term as item(), $data as xs:int+)\n" +
"as element()+ {\n" +
" <item>\n" +
" <term>{$term}</term>\n" +
@@ -211,38 +257,91 @@
System.out.println(i.nextResource().getContent());
}
assertEquals(7, result.getSize());
+
+ query = queryBody + "u:index-keys(//item/stock, 0, util:function(\'f:term-callback\', 2), 1000)";
+ result = service.query(query);
+ for (ResourceIterator i = result.getIterator(); i.hasMoreResources(); ) {
+ System.out.println(i.nextResource().getContent());
+ }
+ assertEquals(5, result.getSize());
} catch (XMLDBException e) {
fail(e.getMessage());
- }
+ }
}
public void testUpdates() throws Exception {
- String append =
- "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
- "<xu:append select=\"/items\">" +
- "<item id=\"i100\">" +
- "<itemno>10</itemno>" +
- "<name>New Item</name>" +
- "<price>55.50</price>" +
- "</item>" +
- "</xu:append>" +
- "</xu:modifications>";
- String remove =
- "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
- "<xu:remove select=\"/items/item[itemno=7]\"/>" +
- "</xu:modifications>";
-
- XPathQueryService query = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
- XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
- long mods = update.updateResource("items.xml", append);
- assertEquals(mods, 1);
- queryResource(query, "items.xml", "//item[price = 55.50]", 1);
- queryResource(query, "items.xml", "//item[@id = 'i100']",1);
- mods = update.updateResource("items.xml", remove);
- assertEquals(mods, 1);
- queryResource(query, "items.xml", "//item[itemno = 7]", 0);
+ try {
+ configureCollection(CONFIG);
+ storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
+ for (int i = 100; i <= 150; i++) {
+ String append =
+ "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
+ " <xu:append select=\"/items\">" +
+ " <item id=\"i" + i + "\">" +
+ " <itemno>" + i + "</itemno>" +
+ " <name>New Item</name>" +
+ " <price>55.50</price>" +
+ " </item>" +
+ " </xu:append>" +
+ "</xu:modifications>";
+ String remove =
+ "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
+ " <xu:remove select=\"/items/item[itemno=" + i + "]\"/>" +
+ "</xu:modifications>";
+
+ XPathQueryService query = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
+ XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
+ long mods = update.updateResource("items.xml", append);
+ assertEquals(mods, 1);
+ queryResource(query, "items.xml", "//item[price = 55.50]", 1);
+ queryResource(query, "items.xml", "//item[@id = 'i" + i + "']",1);
+ mods = update.updateResource("items.xml", remove);
+ assertEquals(mods, 1);
+ queryResource(query, "items.xml", "//item[itemno = " + i + "]", 0);
+ }
+ } catch (XMLDBException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
}
-
+
+ public void testUpdatesQName() throws Exception {
+ try {
+ configureCollection(CONFIG_QNAME);
+ storeXMLFileAndGetQueryService("items.xml", "test/src/org/exist/xquery/items.xml");
+ for (int i = 100; i <= 150; i++) {
+ String append =
+ "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
+ " <xu:append select=\"/items\">" +
+ " <item id=\"i" + i + "\">" +
+ " <itemno>" + i + "</itemno>" +
+ " <name>New Item</name>" +
+ " <price>55.50</price>" +
+ " </item>" +
+ " </xu:append>" +
+ "</xu:modifications>";
+ String remove =
+ "<xu:modifications xmlns:xu=\"http://www.xmldb.org/xupdate\" version=\"1.0\">" +
+ " <xu:remove select=\"/items/item[itemno=" + i + "]\"/>" +
+ "</xu:modifications>";
+
+ XPathQueryService query = (XPathQueryService) testCollection.getService("XPathQueryService", "1.0");
+ XUpdateQueryService update = (XUpdateQueryService) testCollection.getService("XUpdateQueryService", "1.0");
+ long mods = update.updateResource("items.xml", append);
+ assertEquals(mods, 1);
+ queryResource(query, "items.xml", "//((#exist:optimize#) { item[price = 55.50] })", 1);
+ queryResource(query, "items.xml", "//((#exist:optimize#) { item[@id = 'i" + i + "']})",1);
+ queryResource(query, "items.xml", "//((#exist:optimize#) { item[itemno = " + i + "] })", 1);
+ mods = update.updateResource("items.xml", remove);
+ assertEquals(mods, 1);
+ queryResource(query, "items.xml", "//((#exist:optimize#) { item[itemno = " + i + "] })", 0);
+ }
+ } catch (XMLDBException e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
+
protected ResourceSet queryResource(XPathQueryService service,
String resource, String query, int expected) throws XMLDBException {
return queryResource(service, resource, query, expected, null);
@@ -284,18 +383,4 @@
public static void main(String[] args) {
junit.textui.TestRunner.run(ValueIndexTest.class);
}
-
- /**
- * @param cONFIG The cONFIG to set.
- */
- protected void setCollectionConfig(String cONFIG) {
- CONFIG = cONFIG;
- }
-
- /**
- * @return Returns the cONFIG.
- */
- protected String getCollectionConfig() {
- return CONFIG;
- }
}
\ No newline at end of file
Modified: trunk/eXist/test/src/org/exist/xquery/XPathQueryTest.java
===================================================================
--- trunk/eXist/test/src/org/exist/xquery/XPathQueryTest.java 2007-01-29 22:35:58 UTC (rev 5289)
+++ trunk/eXist/test/src/org/exist/xquery/XPathQueryTest.java 2007-01-29 22:37:12 UTC (rev 5290)
@@ -641,6 +641,7 @@
assertXMLEqual("<div id='4'/>", rs.getResource(2).getContent().toString());
} catch (Exception e) {
+ e.printStackTrace();
fail(e.getMessage());
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-29 22:36:06
|
Revision: 5289
http://svn.sourceforge.net/exist/?rev=5289&view=rev
Author: wolfgang_m
Date: 2007-01-29 14:35:58 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
Added performance tests for new range index on named nodes.
Modified Paths:
--------------
trunk/eXist/test/src/org/exist/performance/ActionSequence.java
trunk/eXist/test/src/org/exist/performance/log2html.xql
trunk/eXist/test/src/org/exist/performance/style.css
trunk/eXist/test/src/org/exist/performance/test.xml
Modified: trunk/eXist/test/src/org/exist/performance/ActionSequence.java
===================================================================
--- trunk/eXist/test/src/org/exist/performance/ActionSequence.java 2007-01-29 22:33:42 UTC (rev 5288)
+++ trunk/eXist/test/src/org/exist/performance/ActionSequence.java 2007-01-29 22:35:58 UTC (rev 5289)
@@ -86,7 +86,7 @@
long elapsed = System.currentTimeMillis() - start;
LOG.debug('[' + Thread.currentThread().getName() + "] " + action.getClass().getName() + " took " + elapsed + "ms.");
runner.getResults().report(action, null, elapsed);
-// System.gc();
+ System.gc();
}
}
}
Modified: trunk/eXist/test/src/org/exist/performance/log2html.xql
===================================================================
--- trunk/eXist/test/src/org/exist/performance/log2html.xql 2007-01-29 22:33:42 UTC (rev 5288)
+++ trunk/eXist/test/src/org/exist/performance/log2html.xql 2007-01-29 22:35:58 UTC (rev 5289)
@@ -91,7 +91,7 @@
for $group in //t:group
return
<div class="group">
- <h1>Group {string($group/@name)}</h1>
+ <h1>Test Group: "{string($group/@name)}"</h1>
{
for $thread in distinct-values($group//t:action/@thread)
return
Modified: trunk/eXist/test/src/org/exist/performance/style.css
===================================================================
--- trunk/eXist/test/src/org/exist/performance/style.css 2007-01-29 22:33:42 UTC (rev 5288)
+++ trunk/eXist/test/src/org/exist/performance/style.css 2007-01-29 22:35:58 UTC (rev 5289)
@@ -25,6 +25,8 @@
.group h1 {
font-size: 125%;
margin-bottom: 10px;
+ margin-top: 15px;
+ padding-top: 8px;
border-top: 1px solid black;
}
Modified: trunk/eXist/test/src/org/exist/performance/test.xml
===================================================================
--- trunk/eXist/test/src/org/exist/performance/test.xml 2007-01-29 22:33:42 UTC (rev 5288)
+++ trunk/eXist/test/src/org/exist/performance/test.xml 2007-01-29 22:35:58 UTC (rev 5289)
@@ -58,12 +58,16 @@
<xquery collection="/db" query="//book[@n < 100]"/>
<xquery collection="/db" query="//book[@n > 100]"/>
<xquery collection="/db" query="//chapter[title &= 'k*']"/>
- <xquery collection="/db" query="//chapter[para &= 'is']"/>
+ <xquery collection="/db" query="//chapter[.//para &= 'is']"/>
+ <xquery collection="/db">
+ for $chapter in //chapter[.//para &= 'is'] order by $chapter/title
+ return $chapter/title
+ </xquery>
</sequence>
</thread>
- <tear-down connection="con">
+ <!--tear-down connection="con">
<remove-collection parent="/db" collection="test" description="remove /db/test"/>
- </tear-down>
+ </tear-down-->
</group>
<group name="ft-tests">
<setup connection="con">
@@ -180,6 +184,12 @@
<include path="title"/>
<include path="booktitle"/>
</fulltext>
+
+ <create path="//author" type="xs:string"/>
+ <create path="//year" type="xs:int"/>
+
+ <create qname="author" type="xs:string"/>
+ <create qname="year" type="xs:integer"/>
</index>
</collection>
</store>
@@ -188,7 +198,7 @@
<create-collection parent="/db" name="library"/>
<store-files dir="test/benchmark/data/dblp" includes="*.xml" collection="/db/library"
description="storing DBLP library data" overwrite="no"/>
- <sequence repeat="10">
+ <sequence repeat="15" description="Fulltext queries">
<xquery collection="/db/library" query="//book[author &= 'kernighan']"/>
<xquery collection="/db/library" query="//((#exist:optimize#) { book[author &= 'kernighan'] })"/>
<xquery collection="/db/library" query="//book[author &= 'brian kernighan']"/>
@@ -206,6 +216,29 @@
<xquery collection="/db/library" query="//*[title &= 'xslt']"/>
<xquery collection="/db/library" query="//((#exist:optimize#) { *[title &= 'xslt'] })"/>
</sequence>
+ <sequence repeat="15" description="General comparisons/regular expressions">
+ <xquery collection="/db/library" query="//inproceedings[author = 'Bjarne Stroustrup'] "/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[author = 'Bjarne Stroustrup'] })"/>
+ <xquery collection="/db/library" query="//article[author = 'Linus Torvalds']"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { article[author = 'Linus Torvalds'] })"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { *[author = 'Bjarne Stroustrup'] })"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { *[author = 'Linus Torvalds'] })"/>
+ <xquery collection="/db/library" query="//inproceedings[matches(author, '^Bjarne.*')]"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[matches(author, '^Bjarne.*')] })"/>
+ <xquery collection="/db/library" query="//inproceedings[starts-with(author, 'Bjarne')]"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[starts-with(author, 'Bjarne')] })"/>
+ <xquery collection="/db/library" query="//article[starts-with(author, 'Erich')]"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { article[starts-with(author, 'Erich')] })"/>
+ <xquery collection="/db/library" query="//inproceedings[ends-with(author, 'strup')]"/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[ends-with(author, 'strup')] })"/>
+
+ <xquery collection="/db/library" query="//inproceedings[year = 2002] "/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[year = 2002] })"/>
+ <xquery collection="/db/library" query="//inproceedings[year > 2005] "/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[year > 2005] })"/>
+ <xquery collection="/db/library" query="//inproceedings[year < 2000] "/>
+ <xquery collection="/db/library" query="//((#exist:optimize#) { inproceedings[year < 2000] })"/>
+ </sequence>
</thread>
</group>
</test>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-29 22:33:43
|
Revision: 5288
http://svn.sourceforge.net/exist/?rev=5288&view=rev
Author: wolfgang_m
Date: 2007-01-29 14:33:42 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
New combined range index on named element or attribute. This mirrors recent changes on the fulltext index. In addition to the general range index, e.g. configured with
<create path="//author" type="xs:string"/>
one can now create an index on a given, fixed element or attribute qname:
<create qname="author" type="xs:string"/>
The existance of this index allows eXist to apply better optimization techniques, reducing the cost for a query like //book[author = 'John Doe"] to a single index lookup. However, eXist will currently not apply the new optimization methods automatically, so - for the time being - you have to give it a hint:
//((#exist:optimize#) { book[author = "John Doe"] })
For more examples see test/src/org/exist/performance/test.xml. The plan is to have the XQuery compiler insert those optimization hints automatically when analyzing the query. Right now this has to be done manually though.
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/NativeBroker.java
trunk/eXist/src/org/exist/storage/NativeTextEngine.java
trunk/eXist/src/org/exist/storage/NativeValueIndex.java
trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java
trunk/eXist/src/org/exist/storage/RangeIndexSpec.java
trunk/eXist/src/org/exist/storage/ValueIndexFactory.java
trunk/eXist/src/org/exist/xquery/BasicExpressionVisitor.java
trunk/eXist/src/org/exist/xquery/ExpressionVisitor.java
trunk/eXist/src/org/exist/xquery/GeneralComparison.java
trunk/eXist/src/org/exist/xquery/Optimize.java
trunk/eXist/src/org/exist/xquery/functions/FunMatches.java
trunk/eXist/src/org/exist/xquery/functions/util/QNameIndexLookup.java
trunk/eXist/src/org/exist/xquery/value/AtomicValue.java
Modified: trunk/eXist/src/org/exist/storage/NativeBroker.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeBroker.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/NativeBroker.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -409,7 +409,7 @@
//p.setInternalAddress(node.getInternalAddress());
}
valueIndex.setDocument((DocumentImpl) node.getOwnerDocument());
- valueIndex.storeElement((ElementImpl) node, content, RangeIndexSpec.indexTypeToXPath(indexType));
+ valueIndex.storeElement((ElementImpl) node, content, RangeIndexSpec.indexTypeToXPath(indexType), NativeValueIndex.IDX_GENERIC);
}
// TODO : move to NativeValueIndexByQName
@@ -423,8 +423,10 @@
//Curious... I assume getNodeValue() needs the old address
//p.setInternalAddress(node.getInternalAddress());
}
- qnameValueIndex.setDocument((DocumentImpl) node.getOwnerDocument());
- qnameValueIndex.endElement((ElementImpl) node, currentPath, content);
+ valueIndex.setDocument((DocumentImpl) node.getOwnerDocument());
+ valueIndex.storeElement((ElementImpl) node, content, RangeIndexSpec.indexTypeToXPath(indexType), NativeValueIndex.IDX_QNAME);
+// qnameValueIndex.setDocument((DocumentImpl) node.getOwnerDocument());
+// qnameValueIndex.endElement((ElementImpl) node, currentPath, content);
}
// TODO : move to NativeTextEngine
@@ -2383,10 +2385,13 @@
GeneralRangeIndexSpec spec1 = doc.getCollection().getIndexByPathConfiguration(this, currentPath);
if(spec1 != null) {
valueIndex.setDocument(doc);
- valueIndex.storeElement((ElementImpl) node, content, spec1.getType());
+ valueIndex.storeElement((ElementImpl) node, content, spec1.getType(), NativeValueIndex.IDX_GENERIC);
}
- // qnameValueIndex.removeElement((ElementImpl) node, currentPath, content);
- notifyRemoveElement( (ElementImpl) node, currentPath, content );
+ QNameRangeIndexSpec qnSpec = doc.getCollection().getIndexByQNameConfiguration(this, qname);
+ if (qnSpec != null) {
+ valueIndex.setDocument(doc);
+ valueIndex.storeElement((ElementImpl) node, content, qnSpec.getType(), NativeValueIndex.IDX_QNAME);
+ }
break;
case Node.ATTRIBUTE_NODE :
@@ -2412,9 +2417,12 @@
valueIndex.setDocument(doc);
valueIndex.storeAttribute((AttrImpl) node, null, NativeValueIndex.WITHOUT_PATH, spec2);
}
+ qnSpec = doc.getCollection().getIndexByQNameConfiguration(this, qname);
+ if (qnSpec != null) {
+ valueIndex.setDocument(doc);
+ valueIndex.storeAttribute((AttrImpl) node, null, NativeValueIndex.WITHOUT_PATH, qnSpec);
+ }
- qnameValueIndex.storeAttribute(null, (AttrImpl)node, currentPath, true);
-
// check if attribute value should be fulltext-indexed
// by calling IndexPaths.match(path)
if(ftIdx != null && ftIdx.matchAttribute(currentPath)) {
@@ -2782,7 +2790,7 @@
collectionsDb.close();
notifyClose();
} catch (Exception e) {
- LOG.warn(e);
+ LOG.warn(e.getMessage(), e);
}
super.shutdown();
}
@@ -2922,9 +2930,16 @@
if(node.getChildCount() - node.getAttributesCount() > 1) {
indexType |= RangeIndexSpec.MIXED_CONTENT;
}
-
- ((ElementImpl) node).setIndexType(indexType);
- notifyStartElement((ElementImpl)node, currentPath, fullTextIndex);
+ if (idxSpec != null) {
+ QNameRangeIndexSpec qnIdx = idxSpec.getIndexByQName(node.getQName());
+ if (qnIdx != null) {
+ indexType |= RangeIndexSpec.QNAME_INDEX;
+ if (!RangeIndexSpec.hasRangeIndex(indexType))
+ indexType |= qnIdx.getIndexType();
+ }
+ }
+ ((ElementImpl) node).setIndexType(indexType);
+// notifyStartElement((ElementImpl)node, currentPath, fullTextIndex);
if (mode != MODE_REMOVE) {
NodeProxy p = new NodeProxy(node);
@@ -2950,15 +2965,27 @@
indexType |= RangeIndexSpec.TEXT;
fullTextIndexing = true;
}
- if (idxSpec != null && idxSpec.getIndexByPath(currentPath) != null) {
- indexType |= idxSpec.getIndexByPath(currentPath).getIndexType();
- }
- if (idxSpec != null && idxSpec.getIndexByPath(currentPath) != null) {
- valueIndex.setDocument((DocumentImpl)node.getOwnerDocument());
- //Oh dear : is it the right semantics then ?
- valueIndex.storeAttribute((AttrImpl) node, currentPath, NativeValueIndex.WITHOUT_PATH, idxSpec.getIndexByPath(currentPath));
- }
- //Special handling for fulltext index
+ if (idxSpec != null) {
+ RangeIndexSpec rangeSpec = idxSpec.getIndexByPath(currentPath);
+ if (rangeSpec != null) {
+ indexType |= rangeSpec.getIndexType();
+ }
+ if (rangeSpec != null) {
+ valueIndex.setDocument((DocumentImpl)node.getOwnerDocument());
+ //Oh dear : is it the right semantics then ?
+ valueIndex.storeAttribute((AttrImpl) node, currentPath, NativeValueIndex.WITHOUT_PATH, rangeSpec);
+ }
+ QNameRangeIndexSpec qnIdx = idxSpec.getIndexByQName(node.getQName());
+ if (qnIdx != null) {
+ indexType |= RangeIndexSpec.QNAME_INDEX;
+ if (!RangeIndexSpec.hasRangeIndex(indexType))
+ indexType |= qnIdx.getIndexType();
+ valueIndex.setDocument((DocumentImpl)node.getOwnerDocument());
+ //Oh dear : is it the right semantics then ?
+ valueIndex.storeAttribute((AttrImpl) node, currentPath, NativeValueIndex.WITHOUT_PATH, qnIdx);
+ }
+ }
+ //Special handling for fulltext index
//TODO : harmonize
if (fullTextIndexing && !isTemp ) {
textEngine.setDocument((DocumentImpl)node.getOwnerDocument());
@@ -2969,7 +2996,7 @@
textEngine.storeAttribute((AttrImpl) node, null, NativeTextEngine.ATTRIBUTE_BY_QNAME, ftIdx);
}
- notifyStoreAttribute((AttrImpl)node, currentPath, NativeValueIndex.WITH_PATH, null);
+// notifyStoreAttribute((AttrImpl)node, currentPath, NativeValueIndex.WITH_PATH, null);
elementIndex.setDocument(doc);
final NodeProxy tempProxy = new NodeProxy(doc, node.getNodeId(), address);
Modified: trunk/eXist/src/org/exist/storage/NativeTextEngine.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeTextEngine.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/NativeTextEngine.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -375,12 +375,15 @@
* @see org.exist.storage.ContentLoadingObserver#dropIndex(org.exist.collections.Collection)
*/
public void dropIndex(Collection collection) {
- final WordRef value = new WordRef(collection.getId());
- final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, value);
final Lock lock = dbTokens.getLock();
try {
lock.acquire(Lock.WRITE_LOCK);
- dbTokens.removeAll(null, query);
+ // remove generic index
+ Value value = new WordRef(collection.getId());
+ dbTokens.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, value));
+ // remove QName index
+ value = new QNameWordRef(collection.getId());
+ dbTokens.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, value));
} catch (LockException e) {
LOG.warn("Failed to acquire lock for '" + dbTokens.getFile().getName() + "'", e);
} catch (BTreeException e) {
Modified: trunk/eXist/src/org/exist/storage/NativeValueIndex.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeValueIndex.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/NativeValueIndex.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -41,6 +41,8 @@
import org.exist.dom.NodeProxy;
import org.exist.dom.NodeSet;
import org.exist.dom.TextImpl;
+import org.exist.dom.QName;
+import org.exist.dom.SymbolTable;
import org.exist.numbering.NodeId;
import org.exist.storage.btree.BTreeCallback;
import org.exist.storage.btree.BTreeException;
@@ -105,8 +107,11 @@
public static int LENGTH_VALUE_TYPE = 1; //sizeof byte
public static int OFFSET_DATA = OFFSET_VALUE_TYPE + NativeValueIndex.LENGTH_VALUE_TYPE; //3
public static int LENGTH_NODE_IDS = 4; //sizeof int
-
- /** The broker that is using this value index */
+
+ public final static byte IDX_GENERIC = 0;
+ public final static byte IDX_QNAME = 1;
+
+ /** The broker that is using this value index */
DBBroker broker;
/** The datastore for this value index */
@@ -119,7 +124,7 @@
* The values are {@link org.exist.util.LongLinkedList lists} containing
* the nodes GIDs (global identifiers.
*/
- protected TreeMap pending = new TreeMap();
+ protected Map[] pending = new Map[2];
/** The current document */
private DocumentImpl doc;
@@ -135,7 +140,9 @@
public NativeValueIndex(DBBroker broker, byte id, String dataDir, Configuration config) throws DBException {
this.broker = broker;
this.config = config;
- //use inheritance if necessary !
+ this.pending[IDX_GENERIC] = new TreeMap();
+ this.pending[IDX_QNAME] = new TreeMap();
+ //use inheritance if necessary !
//TODO : read from configuration (key ?)
double cacheGrowth = NativeValueIndex.DEFAULT_VALUE_CACHE_GROWTH;
double cacheKeyThresdhold = NativeValueIndex.DEFAULT_VALUE_KEY_THRESHOLD;
@@ -182,24 +189,29 @@
* @param node The element
* @param content The string representation of the value
*/
- public void storeElement(ElementImpl node, String content, int xpathType) {
+ public void storeElement(ElementImpl node, String content, int xpathType, byte indexType) {
if (doc.getDocId() != node.getDocId()) {
throw new IllegalArgumentException("Document id ('" + doc.getDocId() + "') and proxy id ('" +
node.getDocId() + "') differ !");
- }
+ }
AtomicValue atomic = convertToAtomic(xpathType, content);
//Ignore if the value can't be successfully atomized
//(this is logged elsewhere)
if (atomic == null)
return;
+ Object key;
+ if (indexType == IDX_QNAME) {
+ key = new QNameKey(node.getQName(), atomic);
+ } else
+ key = atomic;
ArrayList buf;
//Is this indexable value already pending ?
- if (pending.containsKey(atomic))
- buf = (ArrayList) pending.get(atomic);
+ if (pending[indexType].containsKey(key))
+ buf = (ArrayList) pending[indexType].get(key);
else {
//Create a NodeId list
buf = new ArrayList(8);
- pending.put(atomic, buf);
+ pending[indexType].put(key, buf);
}
//Add node's NodeId to the list
buf.add(node.getNodeId());
@@ -224,15 +236,21 @@
//(this is logged elsewhere)
if(atomic == null)
return;
+ int indexType = spec.getQName() == null ? IDX_GENERIC : IDX_QNAME;
+ Object key;
+ if (indexType == IDX_QNAME) {
+ key = new QNameKey(node.getQName(), atomic);
+ } else
+ key = atomic;
ArrayList buf;
//Is this indexable value already pending ?
- if (pending.containsKey(atomic))
+ if (pending[indexType].containsKey(key))
//Reuse the existing NodeId list
- buf = (ArrayList) pending.get(atomic);
+ buf = (ArrayList) pending[indexType].get(key);
else {
//Create a NodeId list
buf = new ArrayList(8);
- pending.put(atomic, buf);
+ pending[indexType].put(key, buf);
}
//Add node's GID to the list
buf.add(node.getNodeId());
@@ -277,161 +295,179 @@
* @see org.exist.storage.IndexGenerator#flush()
*/
public void flush() {
- //TODO : return if doc == null? -pb
- if (pending.size() == 0)
- return;
+ //TODO : return if doc == null? -pb
+ int keyCount = pending[IDX_GENERIC].size() + pending[IDX_QNAME].size();
+ if (keyCount == 0)
+ return;
final short collectionId = this.doc.getCollection().getId();
final Lock lock = dbValues.getLock();
- for (Iterator i = pending.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- Indexable indexable = (Indexable) entry.getKey();
- //TODO : NativeElementIndex uses ArrayLists -pb
- ArrayList gids = (ArrayList) entry.getValue();
- int gidsCount = gids.size();
- //Don't forget this one
- FastQSort.sort(gids, 0, gidsCount - 1);
- os.clear();
- os.writeInt(this.doc.getDocId());
- os.writeInt(gidsCount);
- //Mark position
- int nodeIDsLength = os.position();
- //Dummy value : actual one will be written below
- os.writeFixedInt(0);
- //Compute the GID list
- for (int j = 0; j < gidsCount; j++) {
- NodeId nodeId = (NodeId) gids.get(j);
+ for (byte section = 0; section <= IDX_QNAME; section++) {
+ for (Iterator i = pending[section].entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ Object key = entry.getKey();
+ //TODO : NativeElementIndex uses ArrayLists -pb
+ ArrayList gids = (ArrayList) entry.getValue();
+ int gidsCount = gids.size();
+ //Don't forget this one
+ FastQSort.sort(gids, 0, gidsCount - 1);
+ os.clear();
+ os.writeInt(this.doc.getDocId());
+ os.writeInt(gidsCount);
+ //Mark position
+ int nodeIDsLength = os.position();
+ //Dummy value : actual one will be written below
+ os.writeFixedInt(0);
+ //Compute the GID list
+ for (int j = 0; j < gidsCount; j++) {
+ NodeId nodeId = (NodeId) gids.get(j);
+ try {
+ nodeId.write(os);
+ } catch (IOException e) {
+ LOG.warn("IO error while writing range index: " + e.getMessage(), e);
+ //TODO : throw exception?
+ }
+ }
+ //Write (variable) length of node IDs
+ os.writeFixedInt(nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS);
try {
- nodeId.write(os);
+ lock.acquire(Lock.WRITE_LOCK);
+ Value v;
+ if (section == IDX_GENERIC)
+ v = new SimpleValue(collectionId, (Indexable) key);
+ else {
+ QNameKey qnk = (QNameKey) key;
+ v = new QNameValue(collectionId, qnk.qname, qnk.value, broker.getSymbols());
+ }
+ if (dbValues.append(v, os.data()) == BFile.UNKNOWN_ADDRESS) {
+ LOG.error("Could not append index data for key '" + key + "'");
+ //TODO : throw exception ?
+ }
+ } catch (EXistException e) {
+ LOG.error(e.getMessage(), e);
+ } catch (LockException e) {
+ LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
+ //TODO : return ?
} catch (IOException e) {
- LOG.warn("IO error while writing range index: " + e.getMessage(), e);
- //TODO : throw exception?
+ LOG.error(e.getMessage(), e);
+ //TODO : return ?
+ } catch (ReadOnlyException e) {
+ LOG.warn(e.getMessage(), e);
+ //Return without clearing the pending entries
+ return;
+ } finally {
+ lock.release();
+ os.clear();
}
}
- //Write (variable) length of node IDs
- os.writeFixedInt(nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS);
- try {
- lock.acquire(Lock.WRITE_LOCK);
- Value key = new Value(indexable.serialize(collectionId, caseSensitive));
- if (dbValues.append(key, os.data()) == BFile.UNKNOWN_ADDRESS) {
- LOG.error("Could not append index data for key '" + key + "'");
- //TODO : throw exception ?
- }
- } catch (EXistException e) {
- LOG.error(e.getMessage(), e);
- } catch (LockException e) {
- LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
- //TODO : return ?
- } catch (IOException e) {
- LOG.error(e.getMessage(), e);
- //TODO : return ?
- } catch (ReadOnlyException e) {
- LOG.warn(e.getMessage(), e);
- //Return without clearing the pending entries
- return;
- } finally {
- lock.release();
- os.clear();
- }
+ pending[section].clear();
}
- pending.clear();
}
/* (non-Javadoc)
* @see org.exist.storage.IndexGenerator#remove()
*/
public void remove() {
- //TODO : return if doc == null? -pb
- if (pending.size() == 0)
+ //TODO : return if doc == null? -pb
+ int keyCount = pending[IDX_GENERIC].size() + pending[IDX_QNAME].size();
+ if (keyCount == 0)
return;
final short collectionId = this.doc.getCollection().getId();
- final Lock lock = dbValues.getLock();
- for (Iterator i = pending.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- Indexable indexable = (Indexable) entry.getKey();
- ArrayList storedGIDList = (ArrayList) entry.getValue();
- ArrayList newGIDList = new ArrayList();
- os.clear();
- try {
- lock.acquire(Lock.WRITE_LOCK);
- //Compute a key for the value
- Value searchKey = new Value(indexable.serialize(collectionId, caseSensitive));
- Value value = dbValues.get(searchKey);
- //Does the value already has data in the index ?
- if (value != null) {
- //Add its data to the new list
- VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
- while (is.available() > 0) {
- int storedDocId = is.readInt();
- int gidsCount = is.readInt();
- int size = is.readFixedInt();
- if (storedDocId != this.doc.getDocId()) {
- // data are related to another document:
- // append them to any existing data
- os.writeInt(storedDocId);
+ final Lock lock = dbValues.getLock();
+ for (byte section = 0; section <= IDX_QNAME; section++) {
+ for (Iterator i = pending[section].entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ Object key = entry.getKey();
+ ArrayList storedGIDList = (ArrayList) entry.getValue();
+ ArrayList newGIDList = new ArrayList();
+ os.clear();
+ try {
+ lock.acquire(Lock.WRITE_LOCK);
+ //Compute a key for the value
+ Value searchKey;
+ if (section == IDX_GENERIC)
+ searchKey = new SimpleValue(collectionId, (Indexable) key);
+ else {
+ QNameKey qnk = (QNameKey) key;
+ searchKey = new QNameValue(collectionId, qnk.qname, qnk.value, broker.getSymbols());
+ }
+ Value value = dbValues.get(searchKey);
+ //Does the value already has data in the index ?
+ if (value != null) {
+ //Add its data to the new list
+ VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
+ while (is.available() > 0) {
+ int storedDocId = is.readInt();
+ int gidsCount = is.readInt();
+ int size = is.readFixedInt();
+ if (storedDocId != this.doc.getDocId()) {
+ // data are related to another document:
+ // append them to any existing data
+ os.writeInt(storedDocId);
+ os.writeInt(gidsCount);
+ os.writeFixedInt(size);
+ is.copyRaw(os, size);
+ } else {
+ // data are related to our document:
+ // feed the new list with the GIDs
+ for (int j = 0; j < gidsCount; j++) {
+ NodeId nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is);
+ // add the node to the new list if it is not
+ // in the list of removed nodes
+ if (!containsNode(storedGIDList, nodeId)) {
+ newGIDList.add(nodeId);
+ }
+ }
+ }
+ }
+ //append the data from the new list
+ if (newGIDList.size() > 0) {
+ int gidsCount = newGIDList.size();
+ //Don't forget this one
+ FastQSort.sort(newGIDList, 0, gidsCount - 1);
+ os.writeInt(this.doc.getDocId());
os.writeInt(gidsCount);
- os.writeFixedInt(size);
- is.copyRaw(os, size);
- } else {
- // data are related to our document:
- // feed the new list with the GIDs
+ //Mark position
+ int nodeIDsLength = os.position();
+ //Dummy value : actual one will be written below
+ os.writeFixedInt(0);
for (int j = 0; j < gidsCount; j++) {
- NodeId nodeId = broker.getBrokerPool().getNodeFactory().createFromStream(is);
- // add the node to the new list if it is not
- // in the list of removed nodes
- if (!containsNode(storedGIDList, nodeId)) {
- newGIDList.add(nodeId);
+ NodeId nodeId = (NodeId) newGIDList.get(j);
+ try {
+ nodeId.write(os);
+ } catch (IOException e) {
+ LOG.warn("IO error while writing range index: " + e.getMessage(), e);
+ //TODO : throw exception ?
}
}
+ //Write (variable) length of node IDs
+ os.writeFixedInt(nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS);
}
- }
- //append the data from the new list
- if (newGIDList.size() > 0) {
- int gidsCount = newGIDList.size();
- //Don't forget this one
- FastQSort.sort(newGIDList, 0, gidsCount - 1);
- os.writeInt(this.doc.getDocId());
- os.writeInt(gidsCount);
- //Mark position
- int nodeIDsLength = os.position();
- //Dummy value : actual one will be written below
- os.writeFixedInt(0);
- for (int j = 0; j < gidsCount; j++) {
- NodeId nodeId = (NodeId) newGIDList.get(j);
- try {
- nodeId.write(os);
- } catch (IOException e) {
- LOG.warn("IO error while writing range index: " + e.getMessage(), e);
- //TODO : throw exception ?
- }
+ if (dbValues.update(value.getAddress(), searchKey, os.data()) == BFile.UNKNOWN_ADDRESS) {
+ LOG.error("Could not update index data for value '" + searchKey + "'");
+ //TODO: throw exception ?
}
- //Write (variable) length of node IDs
- os.writeFixedInt(nodeIDsLength, os.position() - nodeIDsLength - LENGTH_NODE_IDS);
+ } else {
+ if (dbValues.put(searchKey, os.data()) == BFile.UNKNOWN_ADDRESS) {
+ LOG.error("Could not put index data for value '" + searchKey + "'");
+ //TODO : throw exception ?
+ }
}
- if (dbValues.update(value.getAddress(), searchKey, os.data()) == BFile.UNKNOWN_ADDRESS) {
- LOG.error("Could not update index data for value '" + searchKey + "'");
- //TODO: throw exception ?
- }
- } else {
- if (dbValues.put(searchKey, os.data()) == BFile.UNKNOWN_ADDRESS) {
- LOG.error("Could not put index data for value '" + searchKey + "'");
- //TODO : throw exception ?
- }
- }
- } catch (EXistException e) {
- LOG.error(e.getMessage(), e);
- } catch (LockException e) {
- LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
- //TODO : return ?
- } catch (ReadOnlyException e) {
- LOG.warn("Read-only error on '" + dbValues.getFile().getName() + "'", e);
- } catch (IOException e) {
- LOG.error(e.getMessage(), e);
- } finally {
- lock.release();
- os.clear();
+ } catch (EXistException e) {
+ LOG.error(e.getMessage(), e);
+ } catch (LockException e) {
+ LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
+ //TODO : return ?
+ } catch (ReadOnlyException e) {
+ LOG.warn("Read-only error on '" + dbValues.getFile().getName() + "'", e);
+ } catch (IOException e) {
+ LOG.error(e.getMessage(), e);
+ } finally {
+ lock.release();
+ os.clear();
+ }
}
+ pending[section].clear();
}
- pending.clear();
}
private static boolean containsNode(List list, NodeId nodeId) {
@@ -445,14 +481,17 @@
/* Drop all index entries for the given collection.
* @see org.exist.storage.IndexGenerator#dropIndex(org.exist.collections.Collection)
*/
- public void dropIndex(Collection collection) {
- final Value ref = new ElementValue(collection.getId());
- final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref);
+ public void dropIndex(Collection collection) {
final Lock lock = dbValues.getLock();
try {
lock.acquire(Lock.WRITE_LOCK);
//TODO : flush ? -pb
- dbValues.removeAll(null, query);
+ // remove generic index
+ Value ref = new SimpleValue(collection.getId());
+ dbValues.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, ref));
+ // remove QName index
+ ref = new QNameValue(collection.getId());
+ dbValues.removeAll(null, new IndexQuery(IndexQuery.TRUNC_RIGHT, ref));
} catch (LockException e) {
LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
} catch (BTreeException e) {
@@ -468,55 +507,64 @@
* @see org.exist.storage.IndexGenerator#dropIndex(org.exist.dom.DocumentImpl)
*/
//TODO : note that this is *not* this.doc -pb
- public void dropIndex(DocumentImpl document) throws ReadOnlyException {
+ public void dropIndex(DocumentImpl document) throws ReadOnlyException {
final short collectionId = document.getCollection().getId();
final Lock lock = dbValues.getLock();
try {
lock.acquire(Lock.WRITE_LOCK);
- for (Iterator i = pending.entrySet().iterator(); i.hasNext();) {
- Map.Entry entry = (Map.Entry) i.next();
- Indexable indexable = (Indexable) entry.getKey();
- //Compute a key for the indexed value in the collection
- Value searchKey = new Value(indexable.serialize(collectionId, caseSensitive));
- Value value = dbValues.get(searchKey);
- if (value == null)
- continue;
- VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
- boolean changed = false;
- os.clear();
- while (is.available() > 0) {
- int storedDocId = is.readInt();
- int gidsCount = is.readInt();
- int size = is.readFixedInt();
- if (storedDocId != document.getDocId()) {
- // data are related to another document:
- // copy them (keep them)
- os.writeInt(storedDocId);
- os.writeInt(gidsCount);
- os.writeFixedInt(size);
- is.copyRaw(os, size);
- } else {
- // data are related to our document:
- // skip them (remove them)
- is.skipBytes(size);
- changed = true;
+ for (int section = 0; section <= IDX_QNAME; section++) {
+ for (Iterator i = pending[section].entrySet().iterator(); i.hasNext();) {
+ Map.Entry entry = (Map.Entry) i.next();
+ Object key = entry.getKey();
+ //Compute a key for the indexed value in the collection
+ Value v;
+ if (section == IDX_GENERIC)
+ v = new SimpleValue(collectionId, (Indexable) key);
+ else {
+ QNameKey qnk = (QNameKey) key;
+ v = new QNameValue(collectionId, qnk.qname, qnk.value, broker.getSymbols());
}
- }
- //Store new data, if relevant
- if (changed) {
- if (os.data().size() == 0) {
- // nothing to store:
- // remove the existing key/value pair
- dbValues.remove(searchKey);
- } else {
- // still something to store:
- // modify the existing value for the key
- if (dbValues.put(searchKey, os.data()) == BFile.UNKNOWN_ADDRESS) {
- LOG.error("Could not put index data for key '" + searchKey + "'");
- //TODO : throw exception ?
+ Value value = dbValues.get(v);
+ if (value == null)
+ continue;
+ VariableByteArrayInput is = new VariableByteArrayInput(value.getData());
+ boolean changed = false;
+ os.clear();
+ while (is.available() > 0) {
+ int storedDocId = is.readInt();
+ int gidsCount = is.readInt();
+ int size = is.readFixedInt();
+ if (storedDocId != document.getDocId()) {
+ // data are related to another document:
+ // copy them (keep them)
+ os.writeInt(storedDocId);
+ os.writeInt(gidsCount);
+ os.writeFixedInt(size);
+ is.copyRaw(os, size);
+ } else {
+ // data are related to our document:
+ // skip them (remove them)
+ is.skipBytes(size);
+ changed = true;
}
}
+ //Store new data, if relevant
+ if (changed) {
+ if (os.data().size() == 0) {
+ // nothing to store:
+ // remove the existing key/value pair
+ dbValues.remove(v);
+ } else {
+ // still something to store:
+ // modify the existing value for the key
+ if (dbValues.put(v, os.data()) == BFile.UNKNOWN_ADDRESS) {
+ LOG.error("Could not put index data for key '" + v + "'");
+ //TODO : throw exception ?
+ }
+ }
+ }
}
+ pending[section].clear();
}
} catch (LockException e) {
LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
@@ -527,14 +575,13 @@
} finally {
os.clear();
lock.release();
- pending.clear();
}
}
/** find
* @param relation binary operator used for the comparison
* @param value right hand comparison value */
- public NodeSet find(int relation, DocumentSet docs, NodeSet contextSet, Indexable value)
+ public NodeSet find(int relation, DocumentSet docs, NodeSet contextSet, QName qname, Indexable value)
throws TerminatedException {
final NodeSet result = new ExtArrayNodeSet();
final SearchCallback cb = new SearchCallback(docs, contextSet, result, true);
@@ -544,13 +591,17 @@
lock.acquire();
final short collectionId = ((Collection) iter.next()).getId();
//Compute a key for the value in the collection
- final Value searchKey = new Value(value.serialize(collectionId, caseSensitive));
+ final Value searchKey, prefixKey;
+ if (qname == null) {
+ searchKey = new SimpleValue(collectionId, value);
+ prefixKey = new SimplePrefixValue(collectionId, value.getType());
+ } else {
+ searchKey = new QNameValue(collectionId, qname, value, broker.getSymbols());
+ prefixKey = new QNamePrefixValue(collectionId, qname, value.getType(), broker.getSymbols());
+ }
final int idxOp = checkRelationOp(relation);
final IndexQuery query = new IndexQuery(idxOp, searchKey);
- //Compute a key for the value's type in the collection
- //final Value keyPrefix = computeTypedKey(collectionId, value.getType());
- //dbValues.query(query, keyPrefix, cb);
- dbValues.query(query, cb);
+ dbValues.query(query, prefixKey, cb);
} catch (EXistException e) {
LOG.error(e.getMessage(), e);
} catch (LockException e) {
@@ -566,16 +617,16 @@
return result;
}
- public NodeSet match(DocumentSet docs, NodeSet contextSet, String expr, int type)
+ public NodeSet match(DocumentSet docs, NodeSet contextSet, String expr, QName qname, int type)
throws TerminatedException, EXistException {
- return match(docs, contextSet, expr, type, 0, true);
+ return match(docs, contextSet, expr, qname, type, 0, true);
}
/** Regular expression search
* @param type like type argument for {@link org.exist.storage.RegexMatcher} constructor
* @param flags like flags argument for {@link org.exist.storage.RegexMatcher} constructor
* */
- public NodeSet match(DocumentSet docs, NodeSet contextSet, String expr, int type, int flags, boolean caseSensitiveQuery)
+ public NodeSet match(DocumentSet docs, NodeSet contextSet, String expr, QName qname, int type, int flags, boolean caseSensitiveQuery)
throws TerminatedException, EXistException {
// if the regexp starts with a char sequence, we restrict the index scan to entries starting with
// the same sequence. Otherwise, we have to scan the whole index.
@@ -591,7 +642,7 @@
startTerm = new StringValue(term.toString());
LOG.debug("Match will begin index scan at '" + startTerm + "'");
}
- }
+ }
final TermMatcher comparator = new RegexMatcher(expr, type, flags);
final NodeSet result = new ExtArrayNodeSet();
final RegexCallback cb = new RegexCallback(docs, contextSet, result, comparator);
@@ -601,15 +652,23 @@
lock.acquire();
final short collectionId = ((Collection) iter.next()).getId();
Value searchKey;
- if (startTerm != null) {
- //Compute a key for the start term in the collection
- searchKey = new Value(startTerm.serialize(collectionId, caseSensitive));
+ if (qname == null) {
+ if (startTerm != null) {
+ //Compute a key for the start term in the collection
+ searchKey = new SimpleValue(collectionId, startTerm);
+ } else {
+ //Compute a key for an arbitrary string in the collection
+ searchKey = new SimplePrefixValue(collectionId, Type.STRING);
+ }
} else {
- //Compute a key for an arbitrary string in the collection
- searchKey = computeTypedKey(collectionId, Type.STRING);
+ if (startTerm != null) {
+ searchKey = new QNameValue(collectionId, qname, startTerm, broker.getSymbols());
+ } else {
+ searchKey = new QNamePrefixValue(collectionId, qname, Type.STRING, broker.getSymbols());
+ }
}
- final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, searchKey);
- dbValues.query(query, cb);
+ final IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, searchKey);
+ dbValues.query(query, cb);
} catch (LockException e) {
LOG.warn("Failed to acquire lock for '" + dbValues.getFile().getName() + "'", e);
} catch (IOException e) {
@@ -624,7 +683,7 @@
}
public ValueOccurrences[] scanIndexKeys(DocumentSet docs, NodeSet contextSet, Indexable start) {
- final int type = ((Item) start).getType();
+ final int type = start.getType();
final boolean stringType = Type.subTypeOf(type, Type.STRING);
final IndexScanCallback cb = new IndexScanCallback(docs, contextSet, type);
final Lock lock = dbValues.getLock();
@@ -634,16 +693,14 @@
final short collectionId = ((Collection) i.next()).getId();
//Compute a key for the start value in the collection
if (stringType) {
- final Value startKey = new Value(start.serialize(collectionId, caseSensitive));
+ final Value startKey = new SimpleValue(collectionId, start);
IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, startKey);
dbValues.query(query, cb);
} else {
- final Value startKey = new Value(start.serialize(collectionId));
- final IndexQuery query = new IndexQuery(IndexQuery.GEQ, startKey);
- //Compute a key for the start value's type in the collection
- //Value keyPrefix = computeTypedKey(collectionId, start.getType());
- //dbValues.query(query, keyPrefix, cb);
- dbValues.query(query, cb);
+ final Value startKey = new SimpleValue(collectionId, start);
+ final Value prefixKey = new SimplePrefixValue(collectionId, start.getType());
+ final IndexQuery query = new IndexQuery(IndexQuery.GEQ, startKey);
+ dbValues.query(query, prefixKey, cb);
}
} catch (EXistException e) {
LOG.error(e.getMessage(), e);
@@ -663,16 +720,6 @@
ValueOccurrences[] result = new ValueOccurrences[map.size()];
return (ValueOccurrences[]) map.values().toArray(result);
}
-
- /**
- * Returns a search key for a collectionId/type combination.
- */
- private Value computeTypedKey(short collectionId, int type) {
- byte[] data = new byte[Collection.LENGTH_COLLECTION_ID + NativeValueIndex.LENGTH_VALUE_TYPE];
- ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
- data[OFFSET_VALUE_TYPE] = (byte) type;
- return new Value(data);
- }
protected int checkRelationOp(int relation) {
int indexOp;
@@ -707,7 +754,7 @@
* Should we throw an exception instead ? -pb
*/
private AtomicValue convertToAtomic(int xpathType, String value) {
- AtomicValue atomic = null;
+ AtomicValue atomic;
if (Type.subTypeOf(xpathType, Type.STRING)) {
atomic = new StringValue(value);
} else {
@@ -830,9 +877,14 @@
}
public boolean indexInfo(Value value, long pointer) throws TerminatedException {
+ int offset;
+ if (value.data()[value.start()] == IDX_GENERIC)
+ offset = SimpleValue.OFFSET_VALUE + NativeValueIndex.LENGTH_VALUE_TYPE;
+ else
+ offset = QNameValue.OFFSET_VALUE + NativeValueIndex.LENGTH_VALUE_TYPE;
key.reuse();
- UTF8.decode(value.data(), value.start() + OFFSET_DATA,
- value.getLength() - (Collection.LENGTH_COLLECTION_ID + NativeValueIndex.LENGTH_VALUE_TYPE), key);
+ UTF8.decode(value.data(), value.start() + offset,
+ value.getLength() - offset, key);
if(matcher.matches(key)) {
super.indexInfo(value, pointer);
}
@@ -859,7 +911,7 @@
public boolean indexInfo(Value key, long pointer) throws TerminatedException {
AtomicValue atomic;
try {
- atomic = (AtomicValue)ValueIndexFactory.deserialize(key.data(), key.start(), key.getLength());
+ atomic = (AtomicValue) SimpleValue.deserialize(key.data(), key.start(), key.getLength());
if (atomic.getType() != type)
return false;
} catch (EXistException e) {
@@ -873,7 +925,7 @@
} catch (IOException e) {
LOG.error(e.getMessage(), e);
return true;
- }
+ }
ValueOccurrences oc = (ValueOccurrences) map.get(atomic);
try {
@@ -922,4 +974,118 @@
return true;
}
}
+
+ private static class QNameKey implements Comparable {
+
+ private QName qname;
+ private AtomicValue value;
+
+ public QNameKey(QName qname, AtomicValue atomic) {
+ this.qname = qname;
+ this.value = atomic;
+ }
+
+ public int compareTo(Object o) {
+ QNameKey other = (QNameKey) o;
+ int cmp = qname.compareTo(other.qname);
+ if (cmp == 0)
+ return value.compareTo(other.value);
+ else
+ return cmp;
+ }
+ }
+
+ private static class SimpleValue extends Value {
+
+ public static int OFFSET_IDX_TYPE = 0;
+ public static int LENGTH_IDX_TYPE = 1; //sizeof byte
+ public static int OFFSET_COLLECTION_ID = OFFSET_IDX_TYPE + LENGTH_IDX_TYPE; //1
+ public static int OFFSET_VALUE = OFFSET_COLLECTION_ID + Collection.LENGTH_COLLECTION_ID; // 3
+
+ public SimpleValue(short collectionId) {
+ len = LENGTH_IDX_TYPE + Collection.LENGTH_COLLECTION_ID;
+ data = new byte[len];
+ data[OFFSET_IDX_TYPE] = IDX_GENERIC;
+ ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
+ pos = OFFSET_IDX_TYPE;
+ }
+
+ public SimpleValue(short collectionId, Indexable atomic) throws EXistException {
+ data = atomic.serializeValue(OFFSET_VALUE);
+ len = data.length;
+ pos = OFFSET_IDX_TYPE;
+ data[OFFSET_IDX_TYPE] = IDX_GENERIC;
+ ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
+ }
+
+ public static Indexable deserialize(byte[] data, int start, int len) throws EXistException {
+ return ValueIndexFactory.deserialize(data, start + OFFSET_VALUE, len - OFFSET_VALUE);
+ }
+ }
+
+ private static class SimplePrefixValue extends Value {
+
+ public static int LENGTH_VALUE_TYPE = 1; //sizeof byte
+
+ public SimplePrefixValue(short collectionId, int type) {
+ len = SimpleValue.LENGTH_IDX_TYPE + Collection.LENGTH_COLLECTION_ID + LENGTH_VALUE_TYPE;
+ data = new byte[len];
+ data[SimpleValue.OFFSET_IDX_TYPE] = IDX_GENERIC;
+ ByteConversion.shortToByte(collectionId, data, SimpleValue.OFFSET_COLLECTION_ID);
+ data[SimpleValue.OFFSET_VALUE] = (byte) type;
+ pos = SimpleValue.OFFSET_IDX_TYPE;
+ }
+ }
+
+ private static class QNameValue extends Value {
+
+ public static int OFFSET_IDX_TYPE = 0;
+ public static int LENGTH_IDX_TYPE = 1; //sizeof byte
+ public static int OFFSET_COLLECTION_ID = OFFSET_IDX_TYPE + LENGTH_IDX_TYPE; //1
+ public static int OFFSET_QNAME = OFFSET_COLLECTION_ID + Collection.LENGTH_COLLECTION_ID; //3
+ public static int LENGTH_QNAME_TYPE = 1; //sizeof byte
+ public static int OFFSET_NS_URI = OFFSET_QNAME + LENGTH_QNAME_TYPE; //4
+ public static int OFFSET_LOCAL_NAME = OFFSET_NS_URI + SymbolTable.LENGTH_NS_URI; //6
+ public static int OFFSET_VALUE = OFFSET_LOCAL_NAME + SymbolTable.LENGTH_LOCAL_NAME; //8
+
+ public QNameValue(short collectionId) {
+ len = LENGTH_IDX_TYPE + Collection.LENGTH_COLLECTION_ID;
+ data = new byte[len];
+ data[OFFSET_IDX_TYPE] = IDX_QNAME;
+ ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
+ pos = OFFSET_IDX_TYPE;
+ }
+
+ public QNameValue(short collectionId, QName qname, Indexable atomic, SymbolTable symbols) throws EXistException {
+ data = atomic.serializeValue(OFFSET_VALUE);
+ len = data.length;
+ pos = OFFSET_IDX_TYPE;
+ final short namespaceId = symbols.getNSSymbol(qname.getNamespaceURI());
+ final short localNameId = symbols.getSymbol(qname.getLocalName());
+ data[OFFSET_IDX_TYPE] = IDX_QNAME;
+ ByteConversion.shortToByte(collectionId, data, OFFSET_COLLECTION_ID);
+ data[OFFSET_QNAME] = qname.getNameType();
+ ByteConversion.shortToByte(namespaceId, data, OFFSET_NS_URI);
+ ByteConversion.shortToByte(localNameId, data, OFFSET_LOCAL_NAME);
+ }
+ }
+
+ private static class QNamePrefixValue extends Value {
+
+ public static int LENGTH_VALUE_TYPE = 1; //sizeof byte
+
+ public QNamePrefixValue(short collectionId, QName qname, int type, SymbolTable symbols) {
+ len = QNameValue.OFFSET_VALUE + LENGTH_VALUE_TYPE;
+ data = new byte[len];
+ data[QNameValue.OFFSET_IDX_TYPE] = IDX_QNAME;
+ ByteConversion.shortToByte(collectionId, data, QNameValue.OFFSET_COLLECTION_ID);
+ final short namespaceId = symbols.getNSSymbol(qname.getNamespaceURI());
+ final short localNameId = symbols.getSymbol(qname.getLocalName());
+ data[QNameValue.OFFSET_QNAME] = qname.getNameType();
+ ByteConversion.shortToByte(namespaceId, data, QNameValue.OFFSET_NS_URI);
+ ByteConversion.shortToByte(localNameId, data, QNameValue.OFFSET_LOCAL_NAME);
+ data[QNameValue.OFFSET_VALUE] = (byte) type;
+ pos = QNameValue.OFFSET_IDX_TYPE;
+ }
+ }
}
\ No newline at end of file
Modified: trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java
===================================================================
--- trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/NativeValueIndexByQName.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -153,11 +153,11 @@
if(keyFactory == null)
return; // skip
ArrayList buf;
- if (pending.containsKey(keyFactory))
- buf = (ArrayList) pending.get(keyFactory);
+ if (pending[IDX_GENERIC].containsKey(keyFactory))
+ buf = (ArrayList) pending[IDX_GENERIC].get(keyFactory);
else {
buf = new ArrayList(8);
- pending.put(keyFactory, buf);
+ pending[IDX_GENERIC].put(keyFactory, buf);
}
buf.add(node.getNodeId());
}
Modified: trunk/eXist/src/org/exist/storage/RangeIndexSpec.java
===================================================================
--- trunk/eXist/src/org/exist/storage/RangeIndexSpec.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/RangeIndexSpec.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -25,6 +25,7 @@
import java.util.Arrays;
import org.exist.xquery.value.Type;
+import org.exist.dom.QName;
public abstract class RangeIndexSpec {
@@ -184,4 +185,13 @@
return indexTypes[type];
}
+ /**
+ * Returns the QName for which this index is created. Might be
+ * null if it is a generic index.
+ *
+ * @return
+ */
+ public QName getQName() {
+ return null;
+ }
}
Modified: trunk/eXist/src/org/exist/storage/ValueIndexFactory.java
===================================================================
--- trunk/eXist/src/org/exist/storage/ValueIndexFactory.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/storage/ValueIndexFactory.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -61,7 +61,7 @@
public final static Indexable deserialize(byte[] data, int start, int len) throws EXistException {
- int type = data[start + Collection.LENGTH_COLLECTION_ID];
+ int type = data[start];
//TODO : improve deserialization (use static methods in the org.exist.xquery.Value package
@@ -70,8 +70,8 @@
{
String s;
try {
- s = new String(data, start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE),
- len - (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE), "UTF-8");
+ s = new String(data, start + (ValueIndexFactory.LENGTH_VALUE_TYPE),
+ len - (ValueIndexFactory.LENGTH_VALUE_TYPE), "UTF-8");
} catch (UnsupportedEncodingException e) {
LOG.error(e);
throw new EXistException(e);
@@ -82,7 +82,7 @@
/* xs:dateTime */
else if(Type.subTypeOf(type, Type.DATE_TIME)) {
//get the dateTime back as a long
- long value = ByteConversion.byteToLong(data, start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE));
+ long value = ByteConversion.byteToLong(data, start + (ValueIndexFactory.LENGTH_VALUE_TYPE));
//Create a GregorianCalendar from the long (normalized datetime as milliseconds since the Epoch)
GregorianCalendar utccal = new GregorianCalendar();
utccal.setTimeInMillis(value);
@@ -101,14 +101,14 @@
/* xs:integer */
else if(Type.subTypeOf(type, Type.INTEGER))
{
- return new IntegerValue(ByteConversion.byteToLong(data, start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x8000000000000000L);
+ return new IntegerValue(ByteConversion.byteToLong(data, start + (ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x8000000000000000L);
}
/* xs:double */
else if (type == Type.DOUBLE)
{
- long bits = ByteConversion.byteToLong(data, start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x8000000000000000L;
+ long bits = ByteConversion.byteToLong(data, start + (ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x8000000000000000L;
double d = Double.longBitsToDouble(bits);
return new DoubleValue(d);
}
@@ -116,7 +116,7 @@
/* xs:float */
else if (type == Type.FLOAT)
{
- int bits = ByteConversion.byteToInt(data, start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x80000000;
+ int bits = ByteConversion.byteToInt(data, start + (ValueIndexFactory.LENGTH_VALUE_TYPE)) ^ 0x80000000;
float f = Float.intBitsToFloat(bits);
return new FloatValue(f);
}
@@ -124,7 +124,7 @@
/* xs:boolean */
else if(type == Type.BOOLEAN)
{
- return new BooleanValue(data[start + (Collection.LENGTH_COLLECTION_ID + ValueIndexFactory.LENGTH_VALUE_TYPE)] == 1);
+ return new BooleanValue(data[start + (ValueIndexFactory.LENGTH_VALUE_TYPE)] == 1);
}
/* unknown! */
Modified: trunk/eXist/src/org/exist/xquery/BasicExpressionVisitor.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/BasicExpressionVisitor.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/xquery/BasicExpressionVisitor.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -34,6 +34,12 @@
}
}
+ public void visitGeneralComparison(GeneralComparison comparison) {
+ }
+
+ public void visitUnionExpr(Union union) {
+ }
+
public void visitLocationStep(LocationStep locationStep) {
}
Modified: trunk/eXist/src/org/exist/xquery/ExpressionVisitor.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/ExpressionVisitor.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/xquery/ExpressionVisitor.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -26,9 +26,13 @@
public void visitLocationStep(LocationStep locationStep);
public void visitPredicate(Predicate predicate);
+
+ public void visitGeneralComparison(GeneralComparison comparison);
/** Found a CastExpression */
public void visitCastExpr(CastExpression expression);
- void visitFtExpression(ExtFulltext fulltext);
+ public void visitUnionExpr(Union union);
+
+ public void visitFtExpression(ExtFulltext fulltext);
}
Modified: trunk/eXist/src/org/exist/xquery/GeneralComparison.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/GeneralComparison.java 2007-01-29 16:25:57 UTC (rev 5287)
+++ trunk/eXist/src/org/exist/xquery/GeneralComparison.java 2007-01-29 22:33:42 UTC (rev 5288)
@@ -25,6 +25,8 @@
import java.util.Iterator;
i...
[truncated message content] |
|
From: <br...@us...> - 2007-01-29 16:26:30
|
Revision: 5287
http://svn.sourceforge.net/exist/?rev=5287&view=rev
Author: brihaye
Date: 2007-01-29 08:25:57 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
More use of cleanup() and setDirty.
Removed (unnecessary ?) synchronization
More logging and consistency checks
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-29 13:50:23 UTC (rev 5286)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-29 16:25:57 UTC (rev 5287)
@@ -316,6 +316,7 @@
page.len += vlen;
ph.incRecordCount();
ph.setDataLength(page.len);
+ page.cleanUp();
page.setDirty(true);
dataCache.add(page, 2);
// return pointer from pageNum and offset into page
@@ -595,6 +596,7 @@
rec.getPage().getPageHeader().incRecordCount();
if (doc != null && rec.getPage().getPageHeader().getCurrentTID() >= ItemId.DEFRAG_LIMIT)
doc.triggerDefrag();
+ rec.getPage().cleanUp();
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
return StorageAddress.createPointer((int) rec.getPage().getPageNum(), tid);
@@ -877,7 +879,7 @@
+ " is empty. Remove it");
// if nothing has been copied to the last split page,
// remove it
- dataCache.remove(nextSplitPage);
+ //dataCache.remove(nextSplitPage);
if (nextSplitPage == firstSplitPage)
firstSplitPage = null;
try {
@@ -885,6 +887,8 @@
} catch (IOException e) {
LOG.warn("Failed to remove empty split page: " + e.getMessage(), e);
}
+ nextSplitPage.setDirty(true);
+ dataCache.remove(nextSplitPage);
nextSplitPage = null;
} else {
@@ -1332,7 +1336,7 @@
*
* @return The currentPage value
*/
- private final synchronized DOMPage getCurrentPage(Txn transaction) {
+ private final DOMPage getCurrentPage(Txn transaction) {
long pnum = pages.get(owner);
if (pnum == Page.NO_PAGE) {
final DOMPage page = new DOMPage();
@@ -1454,12 +1458,15 @@
System.arraycopy(rec.getPage().data, end, rec.getPage().data,
rec.offset - 2, rec.getPage().len - end);
rec.getPage().len = rec.getPage().len - (LENGTH_TID + 8);
- ph.setDataLength(rec.getPage().len);
- rec.getPage().setDirty(true);
- ph.decRecordCount();
- // LOG.debug("size = " + ph.getRecordCount());
+ if (rec.getPage().len < 0)
+ LOG.warn("page length < 0");
+ ph.setDataLength(rec.getPage().len);
+ ph.decRecordCount();
if (rec.getPage().len == 0) {
+ if (ph.getRecordCount() > 0)
+ LOG.warn("empty page seems to have record !");
+
if (isTransactional && transaction != null) {
RemoveEmptyPageLoggable loggable = new RemoveEmptyPageLoggable(
transaction, rec.getPage().getPageNum(),
@@ -1470,8 +1477,9 @@
removePage(rec.getPage());
rec.setPage(null);
} else {
- dataCache.add(rec.getPage());
- // printPageContents(rec.page);
+ rec.getPage().cleanUp();
+ rec.getPage().setDirty(true);
+ dataCache.add(rec.getPage());
}
}
@@ -1531,12 +1539,17 @@
System.arraycopy(rec.getPage().data, end, rec.getPage().data, startOffset, dlen - end);
rec.getPage().setDirty(true);
rec.getPage().len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + realLen);
+ if (rec.getPage().len < 0)
+ LOG.warn("page length < 0");
rec.getPage().setDirty(true);
ph.setDataLength(rec.getPage().len);
ph.decRecordCount();
if (rec.getPage().len == 0) {
LOG.debug("removing page " + rec.getPage().getPageNum());
+ if (ph.getRecordCount() > 0)
+ LOG.warn("empty page seems to have record !");
+
if (isTransactional && transaction != null) {
RemoveEmptyPageLoggable loggable = new RemoveEmptyPageLoggable(
transaction, rec.getPage().getPageNum(), rec.getPage().ph
@@ -1549,6 +1562,7 @@
rec.setPage(null);
} else {
rec.getPage().cleanUp();
+ rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
}
}
@@ -1578,15 +1592,14 @@
* @param page
*/
public void removePage(DOMPage page) {
- dataCache.remove(page);
- DOMFilePageHeader ph = page.getPageHeader();
+ //dataCache.remove(page);
+ final DOMFilePageHeader ph = page.getPageHeader();
if (ph.getNextDataPage() != Page.NO_PAGE) {
final DOMPage next = getCurrentPage(ph.getNextDataPage());
next.getPageHeader().setPrevDataPage(ph.getPrevDataPage());
// LOG.debug(next.getPageNum() + ".prev = " + ph.getPrevDataPage());
next.setDirty(true);
- dataCache.add(next);
-
+ dataCache.add(next);
}
if (ph.getPrevDataPage() != Page.NO_PAGE) {
@@ -1604,6 +1617,8 @@
ph.setNextTID(ItemId.UNKNOWN_ID);
ph.setRecordCount((short) 0);
unlinkPages(page.page);
+ page.setDirty(true);
+ dataCache.remove(page);
} catch (IOException ioe) {
LOG.warn(ioe);
}
@@ -1622,6 +1637,8 @@
// StringBuffer debug = new StringBuffer();
// debug.append("Removed pages: ");
long pnum = StorageAddress.pageFromPointer(p);
+ if (Page.NO_PAGE == pnum)
+ LOG.warn("tried to remove unknown page. p = " + pnum);
while (Page.NO_PAGE != pnum) {
final DOMPage page = getCurrentPage(pnum);
final DOMFilePageHeader ph = page.getPageHeader();
@@ -1634,8 +1651,7 @@
writeToLog(loggable, page.page);
}
- pnum = ph.getNextDataPage();
- dataCache.remove(page);
+ pnum = ph.getNextDataPage();
try {
ph.setNextDataPage(Page.NO_PAGE);
ph.setPrevDataPage(Page.NO_PAGE);
@@ -1644,6 +1660,8 @@
ph.setRecordCount((short) 0);
page.len = 0;
unlinkPages(page.page);
+ page.setDirty(true);
+ dataCache.remove(page);
} catch (IOException e) {
LOG.warn("Error while removing page: " + e.getMessage(), e);
}
@@ -1659,9 +1677,11 @@
.getFirstChild()).getInternalAddress());
while (Page.NO_PAGE != pnum) {
final DOMPage page = getCurrentPage(pnum);
+ final DOMFilePageHeader ph = page.getPageHeader();
+
dataCache.add(page);
buf.append(' ').append(pnum);
- pnum = page.getPageHeader().getNextDataPage();
+ pnum = ph.getNextDataPage();
if (showPageContents)
LOG.debug(debugPageContents(page));
}
@@ -1706,6 +1726,9 @@
public final void setOwnerObject(Object obj) {
// if(owner != obj && obj != null)
// LOG.debug("owner set -> " + obj.hashCode());
+ if (obj == null) {
+ LOG.warn("setOwnerObject(null)");
+ }
owner = obj;
}
@@ -1986,30 +2009,30 @@
protected void redoCreatePage(CreatePageLoggable loggable) {
final DOMPage newPage = getCurrentPage(loggable.newPage);
- final DOMFilePageHeader ph = newPage.getPageHeader();
- if (ph.getLsn() == Lsn.LSN_INVALID || requiresRedo(loggable, newPage)) {
+ final DOMFilePageHeader nph = newPage.getPageHeader();
+ if (nph.getLsn() == Lsn.LSN_INVALID || requiresRedo(loggable, newPage)) {
try {
reuseDeleted(newPage.page);
- ph.setStatus(RECORD);
- ph.setDataLength(0);
- ph.setNextTID(ItemId.UNKNOWN_ID);
- ph.setRecordCount((short) 0);
+ nph.setStatus(RECORD);
+ nph.setDataLength(0);
+ nph.setNextTID(ItemId.UNKNOWN_ID);
+ nph.setRecordCount((short) 0);
newPage.len = 0;
newPage.data = new byte[fileHeader.getWorkSize()];
- ph.setPrevDataPage(Page.NO_PAGE);
+ nph.setPrevDataPage(Page.NO_PAGE);
if (loggable.nextTID != ItemId.UNKNOWN_ID)
- ph.setNextTID(loggable.nextTID);
- ph.setLsn(loggable.getLsn());
+ nph.setNextTID(loggable.nextTID);
+ nph.setLsn(loggable.getLsn());
newPage.setDirty(true);
if (loggable.nextPage == Page.NO_PAGE)
- ph.setNextDataPage(Page.NO_PAGE);
+ nph.setNextDataPage(Page.NO_PAGE);
else
- ph.setNextDataPage(loggable.nextPage);
+ nph.setNextDataPage(loggable.nextPage);
if (loggable.prevPage == Page.NO_PAGE)
- ph.setPrevDataPage(Page.NO_PAGE);
+ nph.setPrevDataPage(Page.NO_PAGE);
else
- ph.setPrevDataPage(loggable.prevPage);
+ nph.setPrevDataPage(loggable.prevPage);
} catch (IOException e) {
LOG.warn("Failed to redo " + loggable.dump() + ": "
+ e.getMessage(), e);
@@ -2021,7 +2044,7 @@
protected void undoCreatePage(CreatePageLoggable loggable) {
final DOMPage page = getCurrentPage(loggable.newPage);
final DOMFilePageHeader ph = page.getPageHeader();
- dataCache.remove(page);
+ //dataCache.remove(page);
try {
ph.setNextDataPage(Page.NO_PAGE);
ph.setPrevDataPage(Page.NO_PAGE);
@@ -2030,6 +2053,8 @@
ph.setRecordCount((short) 0);
page.len = 0;
unlinkPages(page.page);
+ page.setDirty(true);
+ dataCache.remove(page);
} catch (IOException e) {
LOG.warn("Error while removing page: " + e.getMessage(), e);
}
@@ -2077,11 +2102,13 @@
final int dlen = ph.getDataLength();
// remove old value
System.arraycopy(page.data, end, page.data, startOffset, dlen - end);
+ page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
+ ph.setDataLength(page.len);
+ ph.decRecordCount();
+ page.cleanUp();
page.setDirty(true);
- page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
- ph.setDataLength(page.len);
- page.setDirty(true);
- ph.decRecordCount();
}
protected void redoUpdateValue(UpdateValueLoggable loggable) {
@@ -2148,7 +2175,9 @@
page.setDirty(true);
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
}
- ph.setDataLength(page.len);
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
+ ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
@@ -2259,7 +2288,7 @@
final DOMPage page = getCurrentPage(loggable.pageNum);
final DOMFilePageHeader ph = page.getPageHeader();
if (ph.getLsn() != Lsn.LSN_INVALID && requiresRedo(loggable, page)) {
- dataCache.remove(page);
+ //dataCache.remove(page);
try {
ph.setNextDataPage(Page.NO_PAGE);
ph.setPrevDataPage(Page.NO_PAGE);
@@ -2269,6 +2298,8 @@
ph.setRecordCount((short) 0);
page.len = 0;
unlinkPages(page.page);
+ page.setDirty(true);
+ dataCache.remove(page);
} catch (IOException e) {
LOG.warn("Error while removing page: " + e.getMessage(), e);
}
@@ -2283,7 +2314,7 @@
ph.setStatus(RECORD);
ph.setNextDataPage(loggable.nextPage);
ph.setPrevDataPage(loggable.prevPage);
- ph.setNextTID(loggable.oldTid);
+ ph.setNextTID(ItemId.getId(loggable.oldTid));
ph.setRecordCount(loggable.oldRecCnt);
ph.setDataLength(loggable.oldLen);
System.arraycopy(loggable.oldData, 0, page.data, 0, loggable.oldLen);
@@ -2394,7 +2425,7 @@
page.len += loggable.value.length;
ph.incRecordCount();
ph.setDataLength(page.len);
- ph.setNextTID(loggable.tid);
+ ph.setNextTID(ItemId.getId(loggable.tid));
page.setDirty(true);
dataCache.add(page);
}
@@ -2432,8 +2463,10 @@
}
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
}
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
ph.setDataLength(page.len);
- ph.decRecordCount();
+ ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
page.setDirty(true);
@@ -2448,6 +2481,8 @@
page.data = new byte[fileHeader.getWorkSize()];
System.arraycopy(oldData, 0, page.data, 0, loggable.splitOffset);
page.len = loggable.splitOffset;
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
ph.setDataLength(page.len);
ph.setRecordCount(countRecordsInPage(page));
page.setDirty(true);
@@ -2460,6 +2495,8 @@
final DOMFilePageHeader ph = page.getPageHeader();
page.data = loggable.oldData;
page.len = loggable.oldLen;
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
ph.setDataLength(page.len);
ph.setLsn(loggable.getLsn());
page.cleanUp();
@@ -2479,6 +2516,7 @@
ph.setDataLength(page.len);
ph.setLsn(loggable.getLsn());
ph.incRecordCount();
+ page.cleanUp();
page.setDirty(true);
dataCache.add(page);
}
@@ -2491,8 +2529,10 @@
final int end = rec.offset + LENGTH_FORWARD_LOCATION;
System.arraycopy(page.data, end, page.data, rec.offset - 2, page.len - end);
page.len = page.len - (LENGTH_TID + LENGTH_FORWARD_LOCATION);
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
ph.setDataLength(page.len);
- ph.decRecordCount();
+ ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
page.setDirty(true);
@@ -2536,11 +2576,13 @@
// save data
System.arraycopy(loggable.value, 0, page.data, page.len, vlen);
page.len += vlen;
+ //TODO : why 2 in ph.incRecordCount(); ?
ph.incRecordCount();
ph.setDataLength(page.len);
ph.setNextTID(ItemId.getId(loggable.tid));
ph.incRecordCount();
ph.setLsn(loggable.getLsn());
+ page.cleanUp();
page.setDirty(true);
dataCache.add(page, 2);
} catch (ArrayIndexOutOfBoundsException e) {
@@ -2572,6 +2614,8 @@
"; offset: " + (rec.offset - 2) + "; end: " + end + "; len: " + (dlen - end));
}
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + l);
+ if (page.len <= 0)
+ LOG.warn("page length <= 0");
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
@@ -2982,9 +3026,10 @@
* insertions.
*/
public void cleanUp() {
- final int dlen = ph.getDataLength();
+ final int dlen = ph.getDataLength();
short maxTID = 0;
- for (int pos = 0; pos < dlen;) {
+ short recordCount = 0;
+ for (int pos = 0; pos < dlen; recordCount++) {
short tid = ByteConversion.byteToShort(data, pos);
pos += LENGTH_TID;
if (ItemId.getId(tid) > ItemId.MAX_ID) {
@@ -3006,6 +3051,8 @@
}
}
ph.setNextTID(maxTID);
+ if (ph.getRecordCount() != recordCount)
+ LOG.warn("page record count differs from computed record count");
}
}
@@ -3074,6 +3121,8 @@
// Read remaining stream
while ( len > -1 ) {
+ if (len == 0)
+ LOG.warn("len == 0");
// If there are bytes in stream, read
if (len > 0){
Value value = new Value(buf, 0, len);
@@ -3188,7 +3237,7 @@
writeToLog(loggable, page);
}
- unlinkPages(page);
+ unlinkPages(page);
page = (nextPageNumber == Page.NO_PAGE) ? null : getPage(nextPageNumber);
}
}
@@ -3198,7 +3247,7 @@
}
}
- public final void addToBuffer(DOMPage page) {
+ public synchronized final void addToBuffer(DOMPage page) {
dataCache.add(page);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <wol...@us...> - 2007-01-29 13:50:27
|
Revision: 5286
http://svn.sourceforge.net/exist/?rev=5286&view=rev
Author: wolfgang_m
Date: 2007-01-29 05:50:23 -0800 (Mon, 29 Jan 2007)
Log Message:
-----------
Updated link to Cocoon-block build.
Modified Paths:
--------------
trunk/eXist/webapp/index.xml
Modified: trunk/eXist/webapp/index.xml
===================================================================
--- trunk/eXist/webapp/index.xml 2007-01-28 20:16:23 UTC (rev 5285)
+++ trunk/eXist/webapp/index.xml 2007-01-29 13:50:23 UTC (rev 5286)
@@ -130,11 +130,11 @@
</tr>
<tr>
<td>
- <a href="" rel="nofollow">http://prdownloads.sourceforge.net/exist/cocoon-2.1.9-with-eXist-1.1.1.war">
- cocoon-2.1.9-with-eXist-1.1.1.war
+ <a href="" rel="nofollow">http://prdownloads.sourceforge.net/exist/cocoon-2.1.10-with-eXist-1.1.1.war">
+ cocoon-2.1.10-with-eXist-1.1.1.war
</a>
</td>
- <td>This is Cocoon version 2.1.9 build with standard options and eXist 1.1.1 as a block. You
+ <td>This is Cocoon version 2.1.10 build with standard options and eXist 1.1.1 as a block. You
should find eXist in <tt>http://my-server:port/cocoon/samples/blocks/exist/</tt>.</td>
</tr>
</table>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-28 20:16:27
|
Revision: 5285
http://svn.sourceforge.net/exist/?rev=5285&view=rev
Author: brihaye
Date: 2007-01-28 12:16:23 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Cleaned code in DOMFile
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-28 13:43:04 UTC (rev 5284)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-28 20:16:23 UTC (rev 5285)
@@ -415,7 +415,7 @@
public long insertAfter(Txn transaction, DocumentImpl doc, long address, byte[] value) {
// check if we need an overflow page
boolean isOverflow = false;
- if (value.length + LENGTH_TID + LENGTH_DATA_LENGTH > fileHeader.getWorkSize()) {
+ if (LENGTH_TID + LENGTH_DATA_LENGTH + value.length > fileHeader.getWorkSize()) {
OverflowDOMPage overflow = new OverflowDOMPage(transaction);
LOG.debug("creating overflow page: " + overflow.getPageNum());
overflow.write(transaction, value);
@@ -436,29 +436,29 @@
rec.offset += LENGTH_OVERFLOW_LOCATION;
else
rec.offset += vlen;
+ //OK : we now have an offset
- //See the statement below that prevents the method to be final
- //final int dlen = rec.getPage().getPageHeader().getDataLength();
- int dlen = rec.getPage().getPageHeader().getDataLength();
+ final int dlen = rec.getPage().getPageHeader().getDataLength();
// insert in the middle of the page?
if (rec.offset < dlen) {
+ // new value fits into the page
if (dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length < fileHeader.getWorkSize()
&& rec.getPage().getPageHeader().hasRoom()) {
// LOG.debug("copying data in page " + rec.getPage().getPageNum()
// + "; offset = " + rec.offset + "; dataLen = "
// + dataLen + "; valueLen = " + value.length);
- // new value fits into the page
+
final int end = rec.offset + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
System.arraycopy(rec.getPage().data, rec.offset, rec.getPage().data, end,
dlen - rec.offset);
rec.getPage().len = dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
+ // doesn't fit: split the page
} else {
- // doesn't fit: split the page
rec = splitDataPage(transaction, doc, rec);
+ // still not enough free space: create a new page
if (rec.offset + LENGTH_TID + LENGTH_DATA_LENGTH + value.length > fileHeader.getWorkSize()
|| !rec.getPage().getPageHeader().hasRoom()) {
- // still not enough free space: create a new page
final DOMPage newPage = new DOMPage();
final DOMFilePageHeader nph = newPage.getPageHeader();
@@ -506,21 +506,21 @@
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
+ //switch record to new page...
rec.setPage(newPage);
rec.offset = 0;
rec.getPage().len = LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
rec.getPage().getPageHeader().setRecordCount((short) 1);
+ //enough space in split page
} else {
rec.getPage().len = rec.offset + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
- //Ooops ! this prevents dlen to be final :-(
- dlen = rec.offset;
}
}
+ // does value fit into page?
} else if (dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length > fileHeader.getWorkSize()
|| !rec.getPage().getPageHeader().hasRoom()) {
- // does value fit into page?
final DOMPage newPage = new DOMPage();
final DOMFilePageHeader nph = newPage.getPageHeader();
LOG.debug("creating new page: " + newPage.getPageNum());
@@ -561,8 +561,9 @@
dataCache.add(nextPage);
}
- rec.getPage().setDirty(true);
+ rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
+ //switch record to new page
rec.setPage(newPage);
rec.offset = 0;
rec.getPage().len = LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
@@ -571,6 +572,7 @@
rec.getPage().len = dlen + LENGTH_TID + LENGTH_DATA_LENGTH + value.length;
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
}
+
// write the data
final short tid = rec.getPage().getPageHeader().getNextTID();
@@ -591,12 +593,10 @@
System.arraycopy(value, 0, rec.getPage().data, rec.offset, value.length);
rec.offset += value.length;
rec.getPage().getPageHeader().incRecordCount();
- rec.getPage().setDirty(true);
if (doc != null && rec.getPage().getPageHeader().getCurrentTID() >= ItemId.DEFRAG_LIMIT)
doc.triggerDefrag();
- // LOG.debug(debugPageContents(rec.page));
+ rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
-// LOG.debug(debugPages(doc));
return StorageAddress.createPointer((int) rec.getPage().getPageNum(), tid);
}
@@ -703,9 +703,10 @@
ph.setRecordCount(countRecordsInPage(rec.getPage()));
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
- dataCache.add(newPage);
+ //switch record to new page...
rec.setPage(newPage);
rec.getPage().len = 0;
+ dataCache.add(newPage);
}
if (isTransactional && transaction != null) {
@@ -847,9 +848,10 @@
ph.setRecordCount(countRecordsInPage(rec.getPage()));
rec.getPage().setDirty(true);
dataCache.add(rec.getPage());
- dataCache.add(newPage);
+ //switch record to new page...
rec.setPage(newPage);
rec.getPage().len = 0;
+ dataCache.add(newPage);
}
final long forwardLink = StorageAddress.createPointer(
@@ -1151,9 +1153,7 @@
final StoredNode n = (StoredNode) iter.next();
final long address = findNode(n, node.getNodeId(), iter);
if (address == StoredNode.UNKNOWN_NODE_IMPL_ADDRESS) {
- // if(LOG.isDebugEnabled())
- // LOG.debug("Node data location not found for node " +
- // node.gid);
+ LOG.warn("Node data location not found for node " + node);
return KEY_NOT_FOUND;
} else
return address;
@@ -1903,7 +1903,7 @@
readOffset += LENGTH_DLN_LENGTH;
final int nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
readOffset += nodeIdLen;
- os.write(data, readOffset, realLen - (2 + nodeIdLen + 1));
+ os.write(data, readOffset, realLen - (2 + nodeIdLen + 1));
break;
}
case Node.ATTRIBUTE_NODE:
@@ -2149,10 +2149,10 @@
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
}
ph.setDataLength(page.len);
- page.setDirty(true);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page);
}
// LOG.debug(debugPageContents(page));
@@ -2209,10 +2209,9 @@
}
ph.incRecordCount();
ph.setDataLength(page.len);
- page.setDirty(true);
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page, 2);
-// LOG.debug(debugPageContents(page));
}
protected void redoRemoveEmptyPage(RemoveEmptyPageLoggable loggable) {
@@ -2233,10 +2232,10 @@
else {
final DOMPage oldPage = getCurrentPage(loggable.prevPage);
final DOMFilePageHeader oph = oldPage.getPageHeader();
+ nph.setPrevDataPage(oldPage.getPageNum());
oph.setNextDataPage(newPage.getPageNum());
oldPage.setDirty(true);
- dataCache.add(oldPage);
- nph.setPrevDataPage(oldPage.getPageNum());
+ dataCache.add(oldPage);
}
if (loggable.nextPage == Page.NO_PAGE)
nph.setNextDataPage(Page.NO_PAGE);
@@ -2434,10 +2433,10 @@
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + l);
}
ph.setDataLength(page.len);
- page.setDirty(true);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page);
}
@@ -2462,9 +2461,9 @@
page.data = loggable.oldData;
page.len = loggable.oldLen;
ph.setDataLength(page.len);
- page.setDirty(true);
ph.setLsn(loggable.getLsn());
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page);
}
@@ -2476,11 +2475,11 @@
page.len += LENGTH_TID;
ByteConversion.longToByte(loggable.link, page.data, page.len);
page.len += LENGTH_FORWARD_LOCATION;
- page.setDirty(true);
ph.setNextTID(ItemId.getId(loggable.tid));
ph.setDataLength(page.len);
ph.setLsn(loggable.getLsn());
ph.incRecordCount();
+ page.setDirty(true);
dataCache.add(page);
}
}
@@ -2493,10 +2492,10 @@
System.arraycopy(page.data, end, page.data, rec.offset - 2, page.len - end);
page.len = page.len - (LENGTH_TID + LENGTH_FORWARD_LOCATION);
ph.setDataLength(page.len);
- page.setDirty(true);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page);
}
@@ -2505,8 +2504,8 @@
final DOMFilePageHeader ph = page.getPageHeader();
if (ph.getLsn() != Lsn.LSN_INVALID && requiresRedo(loggable, page)) {
ByteConversion.longToByte(loggable.link, page.data, loggable.offset);
- page.setDirty(true);
ph.setLsn(loggable.getLsn());
+ page.setDirty(true);
dataCache.add(page);
}
}
@@ -2515,8 +2514,8 @@
final DOMPage page = getCurrentPage(loggable.pageNum);
final DOMFilePageHeader ph = page.getPageHeader();
ByteConversion.longToByte(loggable.oldLink, page.data, loggable.offset);
- page.setDirty(true);
ph.setLsn(loggable.getLsn());
+ page.setDirty(true);
dataCache.add(page);
}
@@ -2539,10 +2538,10 @@
page.len += vlen;
ph.incRecordCount();
ph.setDataLength(page.len);
- page.setDirty(true);
ph.setNextTID(ItemId.getId(loggable.tid));
ph.incRecordCount();
ph.setLsn(loggable.getLsn());
+ page.setDirty(true);
dataCache.add(page, 2);
} catch (ArrayIndexOutOfBoundsException e) {
LOG.warn("page: " + page.getPageNum() + "; len = " + page.len
@@ -2572,12 +2571,12 @@
"; tid: " + loggable.tid +
"; offset: " + (rec.offset - 2) + "; end: " + end + "; len: " + (dlen - end));
}
- page.setDirty(true);
page.len = dlen - (LENGTH_TID + LENGTH_DATA_LENGTH + LENGTH_ORIGINAL_LOCATION + l);
ph.setDataLength(page.len);
ph.decRecordCount();
ph.setLsn(loggable.getLsn());
page.cleanUp();
+ page.setDirty(true);
dataCache.add(page);
}
@@ -2589,8 +2588,8 @@
ph.setNextDataPage(loggable.nextPage);
if (loggable.prevPage != Page.NO_PAGE)
ph.setPrevDataPage(loggable.prevPage);
- page.setDirty(true);
ph.setLsn(loggable.getLsn());
+ page.setDirty(true);
dataCache.add(page, 2);
}
}
@@ -2602,8 +2601,8 @@
ph.setPrevDataPage(loggable.oldPrev);
if (loggable.oldNext != Page.NO_PAGE)
ph.setNextDataPage(loggable.oldNext);
- page.setDirty(true);
ph.setLsn(loggable.getLsn());
+ page.setDirty(true);
dataCache.add(page, 2);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 13:43:13
|
Revision: 5284
http://svn.sourceforge.net/exist/?rev=5284&view=rev
Author: dizzzz
Date: 2007-01-28 05:43:04 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Added jug-lgpl-2.0.0.jar to additional download target......
Modified Paths:
--------------
trunk/eXist/build/scripts/build-impl.xml
Modified: trunk/eXist/build/scripts/build-impl.xml
===================================================================
--- trunk/eXist/build/scripts/build-impl.xml 2007-01-28 13:26:32 UTC (rev 5283)
+++ trunk/eXist/build/scripts/build-impl.xml 2007-01-28 13:43:04 UTC (rev 5284)
@@ -568,6 +568,9 @@
<target name="download-additional-jars" description="Download optional third-party jar files.">
<get src="http://prdownloads.sourceforge.net/icu/icu4j-3_6.jar"
dest="${lib.user}/icu4j-3_6.jar" verbose="true" />
+
+ <get src="http://jug.safehaus.org/curr/jug-lgpl-2.0.0.jar"
+ dest="${lib.user}/jug-lgpl-2.0.0.jar" verbose="true" />
</target>
</project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 13:26:35
|
Revision: 5283
http://svn.sourceforge.net/exist/?rev=5283&view=rev
Author: dizzzz
Date: 2007-01-28 05:26:32 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Remove of all references lib/optional/jug-lgpl-2.0.0.jar
Modified Paths:
--------------
trunk/eXist/.classpath
trunk/eXist/eXist.ipr
trunk/eXist/nbproject/project.xml
Modified: trunk/eXist/.classpath
===================================================================
--- trunk/eXist/.classpath 2007-01-28 13:19:19 UTC (rev 5282)
+++ trunk/eXist/.classpath 2007-01-28 13:26:32 UTC (rev 5283)
@@ -56,7 +56,6 @@
<classpathentry kind="lib" path="lib/optional/commons-httpclient-3.0.1.jar"/>
<classpathentry kind="lib" path="lib/optional/commons-io-1.1.jar"/>
<classpathentry kind="lib" path="lib/optional/jaxrpc.jar"/>
- <classpathentry kind="lib" path="lib/optional/jug-lgpl-2.0.0.jar"/>
<classpathentry kind="lib" path="lib/optional/saaj.jar"/>
<classpathentry kind="lib" path="lib/optional/wsdl4j-1.5.1.jar"/>
<classpathentry kind="lib" path="thirdparty/tomcat5/bin/jmx.jar"/>
Modified: trunk/eXist/eXist.ipr
===================================================================
--- trunk/eXist/eXist.ipr 2007-01-28 13:19:19 UTC (rev 5282)
+++ trunk/eXist/eXist.ipr 2007-01-28 13:26:32 UTC (rev 5283)
@@ -319,7 +319,6 @@
<root url="jar://$PROJECT_DIR$/lib/optional/commons-httpclient-3.0.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/optional/saaj.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/optional/nekohtml-0.9.5.jar!/" />
- <root url="jar://$PROJECT_DIR$/lib/optional/jug-lgpl-2.0.0.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/optional/commons-io-1.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/optional/wsdl4j-1.5.1.jar!/" />
<root url="jar://$PROJECT_DIR$/lib/optional/commons-discovery-0.2.jar!/" />
Modified: trunk/eXist/nbproject/project.xml
===================================================================
--- trunk/eXist/nbproject/project.xml 2007-01-28 13:19:19 UTC (rev 5282)
+++ trunk/eXist/nbproject/project.xml 2007-01-28 13:26:32 UTC (rev 5283)
@@ -313,7 +313,7 @@
<java-data xmlns="" rel="nofollow">http://www.netbeans.org/ns/freeform-project-java/2">
<compilation-unit>
<package-root>src</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -323,7 +323,7 @@
</compilation-unit>
<compilation-unit>
<package-root>tools/wrapper/src</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -332,7 +332,7 @@
</compilation-unit>
<compilation-unit>
<package-root>samples</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -341,7 +341,7 @@
</compilation-unit>
<compilation-unit>
<package-root>extensions/modules/src</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -350,7 +350,7 @@
</compilation-unit>
<compilation-unit>
<package-root>tools/requestlog/src</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -359,7 +359,7 @@
</compilation-unit>
<compilation-unit>
<package-root>tools/ircbot/src</package-root>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>build/classes</built-to>
<built-to>extensions/modules/classes</built-to>
<built-to>tools/wrapper/classes</built-to>
@@ -369,7 +369,7 @@
<compilation-unit>
<package-root>test/src</package-root>
<unit-tests/>
- <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/jug-lgpl-2.0.0.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
+ <classpath mode="compile">lib/core/antlr-2.7.6.jar;lib/core/commons-collections-3.1.jar;lib/core/commons-logging-1.0.4.jar;lib/core/commons-pool-1.2.jar;lib/core/excalibur-cli-1.0.jar;lib/core/javax.servlet-1.4.jar;lib/core/jEdit-syntax.jar;lib/core/jgroups-all.jar;lib/core/jline-0_9_5.jar;lib/core/jta.jar;lib/core/log4j-1.2.14.jar;lib/core/quartz-1.6.0.jar;lib/core/resolver-1.2.jar;lib/core/sunxacml.jar;lib/core/xmldb.jar;lib/core/xmlrpc-1.2-patched.jar;lib/endorsed/serializer-2.9.0.jar;lib/endorsed/xalan-2.7.0.jar;lib/endorsed/xercesImpl-2.9.0.jar;lib/endorsed/xml-apis.jar;lib/optional/axis-ant.jar;lib/optional/axis-schema.jar;lib/optional/axis.jar;lib/optional/commons-discovery-0.2.jar;lib/optional/commons-fileupload-1.1.1.jar;lib/optional/commons-httpclient-3.0.1.jar;lib/optional/commons-io-1.1.jar;lib/optional/jaxrpc.jar;lib/optional/saaj.jar;lib/optional/wsdl4j-1.5.1.jar;lib/user/xmlunit1.0.jar;tools/ant/lib/ant.jar;tools/ant/lib/ant-jdepend.jar;tools/ant/lib/junit.jar;tools/ant/lib/xmlunit1.0.jar;tools/ircbot/lib/pircbot.jar;tools/jetty/lib/org.mortbay.jetty.jar;tools/wrapper/lib/wrapper.jar;thirdparty/tomcat5/bin/jmx.jar;thirdparty/tomcat5/server/lib/catalina-5.0.28.jar</classpath>
<built-to>test/classes</built-to>
<built-to>build/classes</built-to>
<source-level>1.4</source-level>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 13:19:21
|
Revision: 5282
http://svn.sourceforge.net/exist/?rev=5282&view=rev
Author: dizzzz
Date: 2007-01-28 05:19:19 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Removed safehause jar file
Removed Paths:
-------------
trunk/eXist/lib/optional/jug-lgpl-2.0.0.jar
Deleted: trunk/eXist/lib/optional/jug-lgpl-2.0.0.jar
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 13:17:50
|
Revision: 5281
http://svn.sourceforge.net/exist/?rev=5281&view=rev
Author: dizzzz
Date: 2007-01-28 05:17:48 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Updated webdav and atom code to use new UUIDgen classes.
Modified Paths:
--------------
trunk/eXist/src/org/exist/atom/http/WebDAVServlet.java
trunk/eXist/src/org/exist/atom/modules/AtomProtocol.java
trunk/eXist/src/org/exist/dom/LockToken.java
Modified: trunk/eXist/src/org/exist/atom/http/WebDAVServlet.java
===================================================================
--- trunk/eXist/src/org/exist/atom/http/WebDAVServlet.java 2007-01-28 12:54:59 UTC (rev 5280)
+++ trunk/eXist/src/org/exist/atom/http/WebDAVServlet.java 2007-01-28 13:17:48 UTC (rev 5281)
@@ -32,6 +32,7 @@
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+
import org.apache.log4j.Logger;
import org.exist.EXistException;
import org.exist.atom.Atom;
@@ -55,6 +56,7 @@
import org.exist.http.webdav.methods.Move;
import org.exist.http.webdav.methods.Put;
import org.exist.security.PermissionDeniedException;
+import org.exist.security.UUIDGenerator;
import org.exist.security.User;
import org.exist.storage.BrokerPool;
import org.exist.storage.DBBroker;
@@ -67,8 +69,6 @@
import org.exist.util.MimeType;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.value.StringValue;
-import org.safehaus.uuid.UUID;
-import org.safehaus.uuid.UUIDGenerator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -203,7 +203,7 @@
String created = DateFormatter.toXSDDateTime(new Date());
ElementImpl feedRoot = (ElementImpl)feedDoc.getDocumentElement();
DOMDB.replaceTextElement(transaction,feedRoot,Atom.NAMESPACE_STRING,"updated",created,true);
- String id = "urn:uuid:"+UUIDGenerator.getInstance().generateRandomBasedUUID();
+ String id = "urn:uuid:"+UUIDGenerator.getUUID();
Element mediaEntry = AtomProtocol.generateMediaEntry(id,created,title,filename.toString(),mime.getName());
DOMDB.appendChild(transaction,feedRoot,mediaEntry);
broker.storeXMLResource(transaction, feedDoc);
@@ -339,7 +339,7 @@
TransactionManager transact = broker.getBrokerPool().getTransactionManager();
Txn transaction = transact.beginTransaction();
try {
- UUID id = UUIDGenerator.getInstance().generateRandomBasedUUID();
+ String id = UUIDGenerator.getUUID();
String currentDateTime = DateFormatter.toXSDDateTime(new Date());
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
Modified: trunk/eXist/src/org/exist/atom/modules/AtomProtocol.java
===================================================================
--- trunk/eXist/src/org/exist/atom/modules/AtomProtocol.java 2007-01-28 12:54:59 UTC (rev 5280)
+++ trunk/eXist/src/org/exist/atom/modules/AtomProtocol.java 2007-01-28 13:17:48 UTC (rev 5281)
@@ -46,8 +46,8 @@
import org.exist.http.BadRequestException;
import org.exist.http.NotFoundException;
import org.exist.security.PermissionDeniedException;
+import org.exist.security.UUIDGenerator;
import org.exist.storage.DBBroker;
-import org.exist.storage.NativeBroker;
import org.exist.storage.StorageAddress;
import org.exist.storage.lock.Lock;
import org.exist.storage.txn.TransactionManager;
@@ -56,8 +56,6 @@
import org.exist.util.MimeTable;
import org.exist.util.MimeType;
import org.exist.xmldb.XmldbURI;
-import org.safehaus.uuid.UUID;
-import org.safehaus.uuid.UUIDGenerator;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -180,7 +178,7 @@
DocumentImpl feedDoc = null;
TransactionManager transact = broker.getBrokerPool().getTransactionManager();
Txn transaction = transact.beginTransaction();
- String id = "urn:uuid:"+UUIDGenerator.getInstance().generateRandomBasedUUID();
+ String id = "urn:uuid:"+UUIDGenerator.getUUID();
String currentDateTime = DateFormatter.toXSDDateTime(new Date());
Element publishedE = DOM.replaceTextElement(root,Atom.NAMESPACE_STRING,"published",currentDateTime,true,true);
DOM.replaceTextElement(root,Atom.NAMESPACE_STRING,"updated",currentDateTime,true,true);
@@ -259,7 +257,7 @@
collection = broker.getOrCreateCollection(transaction,pathUri);
broker.saveCollection(transaction, collection);
}
- UUID id = UUIDGenerator.getInstance().generateRandomBasedUUID();
+ String id = UUIDGenerator.getUUID();
String currentDateTime = DateFormatter.toXSDDateTime(new Date());
DOM.replaceTextElement(root,Atom.NAMESPACE_STRING,"updated",currentDateTime,true);
DOM.replaceTextElement(root,Atom.NAMESPACE_STRING,"id","urn:uuid:"+id,true);
@@ -353,7 +351,7 @@
String created = DateFormatter.toXSDDateTime(new Date());
ElementImpl feedRoot = (ElementImpl)feedDoc.getDocumentElement();
DOMDB.replaceTextElement(transaction,feedRoot,Atom.NAMESPACE_STRING,"updated",created,true);
- String id = "urn:uuid:"+UUIDGenerator.getInstance().generateRandomBasedUUID();
+ String id = "urn:uuid:"+UUIDGenerator.getUUID();
Element mediaEntry = generateMediaEntry(id,created,title,filename,mime.getName());
DOMDB.appendChild(transaction,feedRoot,mediaEntry);
LOG.debug("Storing change...");
Modified: trunk/eXist/src/org/exist/dom/LockToken.java
===================================================================
--- trunk/eXist/src/org/exist/dom/LockToken.java 2007-01-28 12:54:59 UTC (rev 5280)
+++ trunk/eXist/src/org/exist/dom/LockToken.java 2007-01-28 13:17:48 UTC (rev 5281)
@@ -24,11 +24,11 @@
import java.io.IOException;
+import org.exist.security.UUIDGenerator;
+
import org.exist.storage.io.VariableByteInput;
import org.exist.storage.io.VariableByteOutputStream;
-import org.safehaus.uuid.UUIDGenerator;
-
/**
* Class representing a locktoken. Introduced for webDAV locking.
*
@@ -114,7 +114,7 @@
// Helper function.
public static String generateUUID(){
- return UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
+ return UUIDGenerator.getUUID();
}
public void write(VariableByteOutputStream ostream) throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 12:55:02
|
Revision: 5280
http://svn.sourceforge.net/exist/?rev=5280&view=rev
Author: dizzzz
Date: 2007-01-28 04:54:59 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
util:util:uuid() ; minor repairs
Modified Paths:
--------------
trunk/eXist/src/org/exist/security/UUIDGenerator.java
Modified: trunk/eXist/src/org/exist/security/UUIDGenerator.java
===================================================================
--- trunk/eXist/src/org/exist/security/UUIDGenerator.java 2007-01-28 12:18:06 UTC (rev 5279)
+++ trunk/eXist/src/org/exist/security/UUIDGenerator.java 2007-01-28 12:54:59 UTC (rev 5280)
@@ -53,7 +53,7 @@
} catch (Exception ex) { // ClassNotFoundException
// quick escape
- LOG.debug("java.util.UUID not found");
+ LOG.debug("Skipping java.util.UUID");
return null;
}
@@ -63,7 +63,7 @@
method = clazz.getMethod("randomUUID", null);
} catch (Exception ex) { // SecurityException and NoSuchMethodException
// quick escape
- LOG.error("Method UUID.randomUUID not found.",ex);
+ LOG.error("Method UUID.randomUUID not found",ex);
return null;
}
@@ -74,10 +74,10 @@
} catch (Exception ex) { //IllegalAccessException and InvocationTargetException
// quick escape
- LOG.error("Could not invoke method randomUUID.",ex);
+ LOG.error("Could not invoke method randomUUID",ex);
return null;
}
-
+ LOG.debug("Using preferred java.util.UUID");
return result.toString();
}
@@ -91,7 +91,7 @@
} catch (Exception ex) { // ClassNotFoundException
// quick escape
- LOG.debug("org.safehaus.uuid.UUIDGenerator no found.");
+ LOG.debug("Skipping org.safehaus.uuid.UUIDGenerator");
return null;
}
@@ -101,7 +101,7 @@
method = clazz.getMethod("getInstance", null);
} catch (Exception ex) { // SecurityException and NoSuchMethodException
// quick escape
- LOG.error("Method UUIDGenerator.getInstance not found.",ex);
+ LOG.error("Method UUIDGenerator.getInstance not found",ex);
return null;
}
@@ -112,7 +112,7 @@
} catch (Exception ex) { //IllegalAccessException and InvocationTargetException
// quick escape
- LOG.error("Could not invoke method UUIDGenerator.getInstance.",ex);
+ LOG.error("Could not invoke method UUIDGenerator.getInstance",ex);
return null;
}
@@ -136,16 +136,16 @@
} catch (Exception ex) { //IllegalAccessException and InvocationTargetException
// quick escape
- LOG.error("Could not invoke method generateRandomBasedUUID.",ex);;
+ LOG.error("Could not invoke method generateRandomBasedUUID",ex);;
return null;
}
-
+ LOG.debug("Fallback to org.safehaus.uuid.UUIDGenerator");
return result2.toString();
}
// http://www.javaexchange.com/aboutRandomGUID.html
private static String getJavaExchangeGUID(){
- LOG.debug("Using org.exist.security.RandomGUID");
+ LOG.debug("Fallback to org.exist.security.RandomGUID");
RandomGUID rg = new RandomGUID(false);
return rg.toString();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <di...@us...> - 2007-01-28 12:18:11
|
Revision: 5279
http://svn.sourceforge.net/exist/?rev=5279&view=rev
Author: dizzzz
Date: 2007-01-28 04:18:06 -0800 (Sun, 28 Jan 2007)
Log Message:
-----------
Added util:uuid() generator
Modified Paths:
--------------
trunk/eXist/src/org/exist/xquery/functions/util/UtilModule.java
Added Paths:
-----------
trunk/eXist/src/org/exist/security/RandomGUID.java
trunk/eXist/src/org/exist/security/UUIDGenerator.java
trunk/eXist/src/org/exist/xquery/functions/util/UUID.java
Added: trunk/eXist/src/org/exist/security/RandomGUID.java
===================================================================
--- trunk/eXist/src/org/exist/security/RandomGUID.java (rev 0)
+++ trunk/eXist/src/org/exist/security/RandomGUID.java 2007-01-28 12:18:06 UTC (rev 5279)
@@ -0,0 +1,227 @@
+/*
+ * Copyright 2002-2004 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ * This class is taken from the spring framework.
+ */
+package org.exist.security;
+
+/*
+ * RandomGUID from http://www.javaexchange.com/aboutRandomGUID.html
+ * @version 1.2.1 11/05/02
+ * @author Marc A. Mnich
+ *
+ * From www.JavaExchange.com, Open Software licensing
+ *
+ * 11/05/02 -- Performance enhancement from Mike Dubman.
+ * Moved InetAddr.getLocal to static block. Mike has measured
+ * a 10 fold improvement in run time.
+ * 01/29/02 -- Bug fix: Improper seeding of nonsecure Random object
+ * caused duplicate GUIDs to be produced. Random object
+ * is now only created once per JVM.
+ * 01/19/02 -- Modified random seeding and added new constructor
+ * to allow secure random feature.
+ * 01/14/02 -- Added random function seeding with JVM run time
+ */
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Random;
+
+/**
+ * Globally unique identifier generator.
+ *
+ * <p>
+ * In the multitude of java GUID generators, I found none that guaranteed
+ * randomness. GUIDs are guaranteed to be globally unique by using ethernet
+ * MACs, IP addresses, time elements, and sequential numbers. GUIDs are not
+ * expected to be random and most often are easy/possible to guess given a
+ * sample from a given generator. SQL Server, for example generates GUID that
+ * are unique but sequencial within a given instance.
+ * <p>
+ * GUIDs can be used as security devices to hide things such as files within a
+ * filesystem where listings are unavailable (e.g. files that are served up from
+ * a Web server with indexing turned off). This may be desireable in cases where
+ * standard authentication is not appropriate. In this scenario, the RandomGuids
+ * are used as directories. Another example is the use of GUIDs for primary keys
+ * in a database where you want to ensure that the keys are secret. Random GUIDs
+ * can then be used in a URL to prevent hackers (or users) from accessing
+ * records by guessing or simply by incrementing sequential numbers.
+ * <p>
+ * There are many other possiblities of using GUIDs in the realm of security and
+ * encryption where the element of randomness is important. This class was
+ * written for these purposes but can also be used as a general purpose GUID
+ * generator as well.
+ * <p>
+ * RandomGuid generates truly random GUIDs by using the system's IP address
+ * (name/IP), system time in milliseconds (as an integer), and a very large
+ * random number joined together in a single String that is passed through an
+ * MD5 hash. The IP address and system time make the MD5 seed globally unique
+ * and the random number guarantees that the generated GUIDs will have no
+ * discernable pattern and cannot be guessed given any number of previously
+ * generated GUIDs. It is generally not possible to access the seed information
+ * (IP, time, random number) from the resulting GUIDs as the MD5 hash algorithm
+ * provides one way encryption.
+ * <p>
+ * <b>Security of RandomGuid</b>: RandomGuid can be called one of two ways --
+ * with the basic java Random number generator or a cryptographically strong
+ * random generator (SecureRandom). The choice is offered because the secure
+ * random generator takes about 3.5 times longer to generate its random numbers
+ * and this performance hit may not be worth the added security especially
+ * considering the basic generator is seeded with a cryptographically strong
+ * random seed.
+ * <p>
+ * Seeding the basic generator in this way effectively decouples the random
+ * numbers from the time component making it virtually impossible to predict the
+ * random number component even if one had absolute knowledge of the System
+ * time. Thanks to Ashutosh Narhari for the suggestion of using the static
+ * method to prime the basic random generator.
+ * <p>
+ * Using the secure random option, this class complies with the statistical
+ * random number generator tests specified in FIPS 140-2, Security Requirements
+ * for Cryptographic Modules, secition 4.9.1.
+ * <p>
+ * I converted all the pieces of the seed to a String before handing it over to
+ * the MD5 hash so that you could print it out to make sure it contains the data
+ * you expect to see and to give a nice warm fuzzy. If you need better
+ * performance, you may want to stick to byte[] arrays.
+ * <p>
+ * I believe that it is important that the algorithm for generating random GUIDs
+ * be open for inspection and modification. This class is free for all uses.
+ *
+ * @version 1.2.1 11/05/02
+ * @author Marc A. Mnich
+ */
+public class RandomGUID extends Object {
+
+ private static Random random;
+
+ private static SecureRandom secureRandom;
+
+ private static String id;
+
+ private String valueBeforeMD5 = "";
+
+ private String valueAfterMD5 = "";
+
+ /*
+ * Static block to take care of one time secureRandom seed. It takes a few
+ * seconds to initialize SecureRandom. You might want to consider removing
+ * this static block or replacing it with a "time since first loaded" seed
+ * to reduce this time. This block will run only once per JVM instance.
+ */
+ static {
+ secureRandom = new SecureRandom();
+ long secureInitializer = secureRandom.nextLong();
+ random = new Random(secureInitializer);
+ try {
+ id = InetAddress.getLocalHost().toString();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Default constructor. With no specification of security option, this
+ * constructor defaults to lower security, high performance.
+ */
+ public RandomGUID() {
+ getRandomGuid(false);
+ }
+
+ /**
+ * Constructor with security option. Setting secure true enables each random
+ * number generated to be cryptographically strong. Secure false defaults to
+ * the standard Random function seeded with a single cryptographically
+ * strong random number.
+ */
+ public RandomGUID(boolean secure) {
+ getRandomGuid(secure);
+ }
+
+ /**
+ * Method to generate the random GUID
+ */
+ private void getRandomGuid(boolean secure) {
+ MessageDigest md5 = null;
+ StringBuffer sbValueBeforeMD5 = new StringBuffer();
+
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ System.out.println("Error: " + e);
+ }
+
+ try {
+ long time = System.currentTimeMillis();
+ long rand = 0;
+
+ if (secure) {
+ rand = secureRandom.nextLong();
+ } else {
+ rand = random.nextLong();
+ }
+
+ // This StringBuffer can be a long as you need; the MD5
+ // hash will always return 128 bits. You can change
+ // the seed to include anything you want here.
+ // You could even stream a file through the MD5 making
+ // the odds of guessing it at least as great as that
+ // of guessing the contents of the file!
+ sbValueBeforeMD5.append(id);
+ sbValueBeforeMD5.append(":");
+ sbValueBeforeMD5.append(Long.toString(time));
+ sbValueBeforeMD5.append(":");
+ sbValueBeforeMD5.append(Long.toString(rand));
+
+ valueBeforeMD5 = sbValueBeforeMD5.toString();
+ md5.update(valueBeforeMD5.getBytes());
+
+ byte[] array = md5.digest();
+ StringBuffer sb = new StringBuffer();
+ for (int j = 0; j < array.length; ++j) {
+ int b = array[j] & 0xFF;
+ if (b < 0x10)
+ sb.append('0');
+ sb.append(Integer.toHexString(b));
+ }
+ valueAfterMD5 = sb.toString();
+ } catch (Exception e) {
+ System.out.println("Error:" + e);
+ }
+ }
+
+ /**
+ * Convert to the standard format for GUID (Useful for SQL Server
+ * UniqueIdentifiers, etc.) Example: C2FEEEAC-CFCD-11D1-8B05-00600806D9B6
+ */
+ public String toString() {
+ String raw = valueAfterMD5.toUpperCase();
+ StringBuffer sb = new StringBuffer();
+ sb.append(raw.substring(0, 8));
+ sb.append("-");
+ sb.append(raw.substring(8, 12));
+ sb.append("-");
+ sb.append(raw.substring(12, 16));
+ sb.append("-");
+ sb.append(raw.substring(16, 20));
+ sb.append("-");
+ sb.append(raw.substring(20));
+ return sb.toString();
+ }
+}
Added: trunk/eXist/src/org/exist/security/UUIDGenerator.java
===================================================================
--- trunk/eXist/src/org/exist/security/UUIDGenerator.java (rev 0)
+++ trunk/eXist/src/org/exist/security/UUIDGenerator.java 2007-01-28 12:18:06 UTC (rev 5279)
@@ -0,0 +1,174 @@
+/*
+ * eXist Open Source Native XML Database
+ * Copyright (C) 2001-07 The eXist Project
+ * http://exist-db.org
+ *
+ * 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * $Id$
+ */
+
+package org.exist.security;
+
+import java.lang.reflect.Method;
+import org.apache.log4j.Logger;
+
+/**
+ * UUID or GUID generator. The random code is generated by java's
+ * UUID-class (when available Java5+), safehaus' UUIDGenerator (when evailable)
+ * or javaexchange's RandomGUID as a fallback. (code in exist available)
+ *
+ * <UL>
+ * <LI><a href="UUID" rel="nofollow">http://en.wikipedia.org/wiki/UUID">UUID</a></LI>
+ * <LI><a href="GUID" rel="nofollow">http://en.wikipedia.org/wiki/GUID">GUID</a></LI>
+ * <LI><a href="java.util.UUID" rel="nofollow">http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html">java.util.UUID</a></LI>
+ * <LI><a href="Safehaus" rel="nofollow">http://jug.safehaus.org/">Safehaus</a></LI>
+ * <LI><a href="JavaExchange" rel="nofollow">http://www.javaexchange.com/aboutRandomGUID.html">JavaExchange</a></LI>
+ * </UL>
+ * @author Dannes Wessels
+ */
+public class UUIDGenerator {
+
+ private final static Logger LOG = Logger.getLogger(UUIDGenerator.class);
+
+ // http://java.sun.com/j2se/1.5.0/docs/api/java/util/UUID.html
+ private static String getJavaUUID(){
+
+ // Check does the class exist?
+ Class clazz = null;
+ try {
+ clazz=Class.forName("java.util.UUID");
+
+ } catch (Exception ex) { // ClassNotFoundException
+ // quick escape
+ LOG.debug("java.util.UUID not found");
+ return null;
+ }
+
+ // Get specific method
+ Method method = null;
+ try {
+ method = clazz.getMethod("randomUUID", null);
+ } catch (Exception ex) { // SecurityException and NoSuchMethodException
+ // quick escape
+ LOG.error("Method UUID.randomUUID not found.",ex);
+ return null;
+ }
+
+ // Invoke method
+ Object result = null;
+ try {
+ result = method.invoke(null, null);
+
+ } catch (Exception ex) { //IllegalAccessException and InvocationTargetException
+ // quick escape
+ LOG.error("Could not invoke method randomUUID.",ex);
+ return null;
+ }
+
+ return result.toString();
+ }
+
+ // http://jug.safehaus.org/
+ private static String getSafehausUUID(){
+ //return UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
+ // Check does the class exist?
+ Class clazz = null;
+ try {
+ clazz=Class.forName("org.safehaus.uuid.UUIDGenerator");
+
+ } catch (Exception ex) { // ClassNotFoundException
+ // quick escape
+ LOG.debug("org.safehaus.uuid.UUIDGenerator no found.");
+ return null;
+ }
+
+ // Get specific method
+ Method method = null;
+ try {
+ method = clazz.getMethod("getInstance", null);
+ } catch (Exception ex) { // SecurityException and NoSuchMethodException
+ // quick escape
+ LOG.error("Method UUIDGenerator.getInstance not found.",ex);
+ return null;
+ }
+
+ // Invoke method
+ Object result = null;
+ try {
+ result = method.invoke(null, null);
+
+ } catch (Exception ex) { //IllegalAccessException and InvocationTargetException
+ // quick escape
+ LOG.error("Could not invoke method UUIDGenerator.getInstance.",ex);
+ return null;
+ }
+
+ // Get class from object
+ Class clazz2 = result.getClass();
+
+ // Get specific method
+ Method method2 = null;
+ try {
+ method2 = clazz2.getMethod("generateRandomBasedUUID", null);
+ } catch (Exception ex) { // SecurityException and NoSuchMethodException
+ // quick escape
+ LOG.error("Method generateRandomBasedUUID not found.",ex);
+ return null;
+ }
+
+ // Invoke method
+ Object result2 = null;
+ try {
+ result2 = method2.invoke(result, null);
+
+ } catch (Exception ex) { //IllegalAccessException and InvocationTargetException
+ // quick escape
+ LOG.error("Could not invoke method generateRandomBasedUUID.",ex);;
+ return null;
+ }
+
+ return result2.toString();
+ }
+
+ // http://www.javaexchange.com/aboutRandomGUID.html
+ private static String getJavaExchangeGUID(){
+ LOG.debug("Using org.exist.security.RandomGUID");
+ RandomGUID rg = new RandomGUID(false);
+ return rg.toString();
+ }
+
+ /**
+ * Generate random UUID code.
+ *
+ * @return UUID code, formatted as f271ec43-bf1f-4030-a269-b11576538f71
+ */
+ public static String getUUID(){
+
+ String uuid = getJavaUUID();
+
+ // Alternative implementation
+ if(uuid==null){
+ uuid=getSafehausUUID();
+ }
+
+ // Another alternative implementation
+ if(uuid==null){
+ uuid=getJavaExchangeGUID();
+ }
+
+ return uuid;
+ }
+}
Added: trunk/eXist/src/org/exist/xquery/functions/util/UUID.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/functions/util/UUID.java (rev 0)
+++ trunk/eXist/src/org/exist/xquery/functions/util/UUID.java 2007-01-28 12:18:06 UTC (rev 5279)
@@ -0,0 +1,71 @@
+/*
+ * eXist Open Source Native XML Database
+ * Copyright (C) 2001-07 The eXist Project
+ * http://exist-db.org
+ *
+ * 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * $Id$
+ */
+
+package org.exist.xquery.functions.util;
+
+import org.exist.dom.QName;
+import org.exist.security.UUIDGenerator;
+import org.exist.xquery.Cardinality;
+import org.exist.xquery.Function;
+import org.exist.xquery.FunctionSignature;
+import org.exist.xquery.XPathException;
+import org.exist.xquery.XQueryContext;
+import org.exist.xquery.value.Item;
+import org.exist.xquery.value.Sequence;
+import org.exist.xquery.value.SequenceType;
+import org.exist.xquery.value.StringValue;
+import org.exist.xquery.value.Type;
+/**
+ *
+ * @author wessels
+ */
+public class UUID extends Function {
+
+ private UUIDGenerator ug;
+
+ public final static FunctionSignature signature =
+ new FunctionSignature(
+ new QName("uuid", UtilModule.NAMESPACE_URI, UtilModule.PREFIX),
+ "Generate an UUID string.",
+ FunctionSignature.NO_ARGS,
+ new SequenceType(Type.STRING, Cardinality.EXACTLY_ONE));
+
+ public UUID(XQueryContext context) {
+ super(context, signature);
+ }
+
+ /* (non-Javadoc)
+ * @see org.exist.xquery.Expression#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item)
+ */
+ public Sequence eval(Sequence contextSequence, Item contextItem)
+ throws XPathException {
+
+ String uuid = UUIDGenerator.getUUID();
+
+ if(uuid==null) {
+ throw new XPathException("Could not create UUID.");
+ }
+
+ return new StringValue(uuid);
+ }
+
+}
Modified: trunk/eXist/src/org/exist/xquery/functions/util/UtilModule.java
===================================================================
--- trunk/eXist/src/org/exist/xquery/functions/util/UtilModule.java 2007-01-27 22:04:57 UTC (rev 5278)
+++ trunk/eXist/src/org/exist/xquery/functions/util/UtilModule.java 2007-01-28 12:18:06 UTC (rev 5279)
@@ -86,6 +86,7 @@
new FunctionDef(RandomFunction.signatures[0], RandomFunction.class),
new FunctionDef(RandomFunction.signatures[1], RandomFunction.class),
new FunctionDef(FunUnEscapeURI.signature, FunUnEscapeURI.class),
+ new FunctionDef(UUID.signature, UUID.class),
// deprecated functions
new FunctionDef(GetVersion.deprecated, GetVersion.class),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-27 22:04:59
|
Revision: 5278
http://svn.sourceforge.net/exist/?rev=5278&view=rev
Author: brihaye
Date: 2007-01-27 14:04:57 -0800 (Sat, 27 Jan 2007)
Log Message:
-----------
More final variables.
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-27 17:25:40 UTC (rev 5277)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-27 22:04:57 UTC (rev 5278)
@@ -290,7 +290,6 @@
transaction, page == null ? Page.NO_PAGE : page.getPageNum(),
newPage.getPageNum(), Page.NO_PAGE);
writeToLog(loggable, newPage.page);
-
}
page = newPage;
@@ -531,7 +530,6 @@
transaction, rec.getPage().getPageNum(),
newPage.getPageNum(), rec.getPage().getPageHeader().getNextDataPage());
writeToLog(loggable, newPage.page);
-
}
long nextPageNr = rec.getPage().getPageHeader().getNextDataPage();
@@ -574,7 +572,7 @@
rec.getPage().getPageHeader().setDataLength(rec.getPage().len);
}
// write the data
- short tid = rec.getPage().getPageHeader().getNextTID();
+ final short tid = rec.getPage().getPageHeader().getNextTID();
if (isTransactional && transaction != null) {
Loggable loggable =
@@ -620,7 +618,7 @@
// case, the new record is just appended to a new page linked to the old one.
boolean requireSplit = false;
for (int pos = rec.offset; pos < rec.getPage().len;) {
- short tid = ByteConversion.byteToShort(rec.getPage().data, pos);
+ final short tid = ByteConversion.byteToShort(rec.getPage().data, pos);
pos += LENGTH_TID;
if (!ItemId.isLink(tid)) {
requireSplit = true;
@@ -675,7 +673,7 @@
// start copying records from rec.offset to the new split pages
for (int pos = rec.offset; pos < oldDataLen; splitRecordCount++) {
// read the current id
- short tid = ByteConversion.byteToShort(oldData, pos);
+ final short tid = ByteConversion.byteToShort(oldData, pos);
pos += LENGTH_TID;
if (ItemId.isLink(tid)) {
/* This is already a link, so we just copy it */
@@ -769,8 +767,8 @@
backLink = ByteConversion.byteToLong(oldData, pos);
pos += LENGTH_ORIGINAL_LOCATION;
RecordPos origRec = findRecord(backLink, false);
- long oldLink = ByteConversion.byteToLong(origRec.getPage().data, origRec.offset);
- long forwardLink = StorageAddress.createPointer(
+ final long oldLink = ByteConversion.byteToLong(origRec.getPage().data, origRec.offset);
+ final long forwardLink = StorageAddress.createPointer(
(int) nextSplitPage.getPageNum(), ItemId.getId(tid));
if (isTransactional && transaction != null) {
@@ -854,7 +852,7 @@
rec.getPage().len = 0;
}
- long forwardLink = StorageAddress.createPointer(
+ final long forwardLink = StorageAddress.createPointer(
(int) nextSplitPage.getPageNum(), ItemId.getId(tid));
if (isTransactional && transaction != null) {
@@ -983,7 +981,7 @@
short count = 0;
final int dlen = page.getPageHeader().getDataLength();
for (int pos = 0; pos < dlen; count++) {
- short tid = ByteConversion.byteToShort(page.data, pos);
+ final short tid = ByteConversion.byteToShort(page.data, pos);
pos += LENGTH_TID;
if (ItemId.isLink(tid))
buf.append('L');
@@ -1242,9 +1240,11 @@
*/
public Value get(Value key) {
try {
- long p = findValue(key);
- if (p == KEY_NOT_FOUND)
+ final long p = findValue(key);
+ if (p == KEY_NOT_FOUND) {
+ LOG.warn("value not found : " + key);
return null;
+ }
return get(p);
} catch (BTreeException bte) {
LOG.warn(bte);
@@ -1265,9 +1265,11 @@
*/
public Value get(NodeProxy node) {
try {
- long p = findValue(owner, node);
- if (p == KEY_NOT_FOUND)
+ final long p = findValue(owner, node);
+ if (p == KEY_NOT_FOUND) {
+ LOG.warn("node value not found : " + node);
return null;
+ }
return get(p);
} catch (BTreeException bte) {
LOG.warn(bte);
@@ -1288,8 +1290,7 @@
public Value get(long p) {
RecordPos rec = findRecord(p);
if (rec == null) {
-// SanityCheck.TRACE("object at " + StorageAddress.toString(p)
-// + " not found.");
+ SanityCheck.TRACE("object at " + StorageAddress.toString(p) + " not found.");
return null;
}
final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
@@ -1298,8 +1299,8 @@
rec.offset += LENGTH_ORIGINAL_LOCATION;
Value v;
if (vlen == OVERFLOW) {
- long pnum = ByteConversion.byteToLong(rec.getPage().data, rec.offset);
- byte[] data = getOverflowValue(pnum);
+ final long pnum = ByteConversion.byteToLong(rec.getPage().data, rec.offset);
+ final byte[] data = getOverflowValue(pnum);
v = new Value(data);
} else
v = new Value(rec.getPage().data, rec.offset, vlen);
@@ -1396,7 +1397,7 @@
*/
public long put(Txn transaction, Value key, byte[] value)
throws ReadOnlyException {
- long p = add(transaction, value);
+ final long p = add(transaction, value);
try {
addValue(transaction, key, p);
} catch (IOException ioe) {
@@ -1419,9 +1420,11 @@
public void remove(Txn transaction, Value key) {
try {
- long p = findValue(key);
- if (p == KEY_NOT_FOUND)
+ final long p = findValue(key);
+ if (p == KEY_NOT_FOUND) {
+ LOG.warn("value not found : " + key);
return;
+ }
remove(transaction, key, p);
} catch (BTreeException bte) {
LOG.warn(bte);
@@ -1483,7 +1486,7 @@
}
public void removeNode(Txn transaction, long p) {
- RecordPos rec = findRecord(p);
+ final RecordPos rec = findRecord(p);
final int startOffset = rec.offset - 2;
final DOMFilePageHeader ph = rec.getPage().getPageHeader();
final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
@@ -1719,8 +1722,10 @@
throws ReadOnlyException {
try {
long p = findValue(key);
- if (p == KEY_NOT_FOUND)
+ if (p == KEY_NOT_FOUND) {
+ LOG.warn("node value not found : " + key);
return false;
+ }
update(transaction, p, value);
} catch (BTreeException bte) {
LOG.warn(bte);
@@ -1743,8 +1748,7 @@
*/
public void update(Txn transaction, long p, byte[] value)
throws ReadOnlyException {
- RecordPos rec = findRecord(p);
-
+ final RecordPos rec = findRecord(p);
final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
rec.offset += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(rec.getTID()))
@@ -1790,8 +1794,10 @@
// fallback to a btree lookup if the node could not be found
// by its storage address
address = findValue(this, new NodeProxy(node));
- if (address == BTree.KEY_NOT_FOUND)
+ if (address == BTree.KEY_NOT_FOUND) {
+ LOG.warn("node value not found : " + node);
return null;
+ }
rec = findRecord(address);
SanityCheck.THROW_ASSERT(rec != null, "Node data could not be found!");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <br...@us...> - 2007-01-27 17:25:43
|
Revision: 5277
http://svn.sourceforge.net/exist/?rev=5277&view=rev
Author: brihaye
Date: 2007-01-27 09:25:40 -0800 (Sat, 27 Jan 2007)
Log Message:
-----------
Made more variables final
Modified Paths:
--------------
trunk/eXist/src/org/exist/storage/dom/DOMFile.java
Modified: trunk/eXist/src/org/exist/storage/dom/DOMFile.java
===================================================================
--- trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-27 14:14:10 UTC (rev 5276)
+++ trunk/eXist/src/org/exist/storage/dom/DOMFile.java 2007-01-27 17:25:40 UTC (rev 5277)
@@ -116,6 +116,7 @@
public static final int LENGTH_FORWARD_LOCATION = 8; //sizeof long
public static final int LENGTH_OVERFLOW_LOCATION = 8; //sizeof long
public static final int LENGTH_ELEMENT_CHILD_COUNT = 4; //sizeof int
+ public static final int LENGTH_ATTRIBUTES_COUNT = 2; //sizeof short
public static final int LENGTH_DLN_LENGTH = 2; //sizeof short
/*
@@ -428,7 +429,7 @@
SanityCheck.TRACE("page not found");
return KEY_NOT_FOUND;
}
- short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
rec.offset += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(rec.getTID()))
rec.offset += LENGTH_ORIGINAL_LOCATION;
@@ -963,7 +964,7 @@
if (ItemId.isLink(tid)) {
pos += LENGTH_FORWARD_LOCATION;
} else {
- short vlen = ByteConversion.byteToShort(page.data, pos);
+ final short vlen = ByteConversion.byteToShort(page.data, pos);
pos += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(tid)) {
pos += vlen == OVERFLOW ? LENGTH_ORIGINAL_LOCATION + LENGTH_OVERFLOW_LOCATION : LENGTH_ORIGINAL_LOCATION + vlen;
@@ -993,7 +994,7 @@
buf.append(':').append(LENGTH_FORWARD_LOCATION).append("] ");
pos += LENGTH_FORWARD_LOCATION;
} else {
- short vlen = ByteConversion.byteToShort(page.data, pos);
+ final short vlen = ByteConversion.byteToShort(page.data, pos);
pos += LENGTH_DATA_LENGTH;
if (vlen < 0) {
LOG.warn("Illegal length: " + vlen);
@@ -1291,7 +1292,7 @@
// + " not found.");
return null;
}
- short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
rec.offset += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(rec.getTID()))
rec.offset += LENGTH_ORIGINAL_LOCATION;
@@ -1744,7 +1745,7 @@
throws ReadOnlyException {
RecordPos rec = findRecord(p);
- short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
rec.offset += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(rec.getTID()))
rec.offset += LENGTH_ORIGINAL_LOCATION;
@@ -1849,7 +1850,8 @@
foundNext = true;
} while (!foundNext);
// read the page len
- int vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ int realLen = vlen;
rec.offset += LENGTH_DATA_LENGTH;
// check if the node was relocated
if (ItemId.isRelocated(rec.getTID()))
@@ -1863,7 +1865,7 @@
data = getOverflowValue(op);
//We position the offset *after* the TID
rec.offset += LENGTH_OVERFLOW_LOCATION + LENGTH_TID;
- vlen = data.length;
+ realLen = data.length;
readOffset = 0;
inOverflow = true;
}
@@ -1872,30 +1874,32 @@
final short type = Signatures.getType(data[readOffset++]);
// switch on the node type
switch (type) {
- case Node.ELEMENT_NODE:
- final int children = ByteConversion.byteToInt(data, readOffset);
- readOffset += LENGTH_ELEMENT_CHILD_COUNT;
- int dlnLen = ByteConversion.byteToShort(data, readOffset);
- readOffset += LENGTH_DLN_LENGTH;
- readOffset += doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
- final short attributes = ByteConversion.byteToShort(data, readOffset);
- rec.offset += vlen + 2;
- for (int i = 0; i < children; i++) {
- final boolean extraWhitespace = addWhitespace && children - attributes > 1;
- //recursive call
- getNodeValue(doc, os, rec, false, addWhitespace);
- if (extraWhitespace)
- os.write((byte) ' ');
+ case Node.ELEMENT_NODE: {
+ final int children = ByteConversion.byteToInt(data, readOffset);
+ readOffset += LENGTH_ELEMENT_CHILD_COUNT;
+ final int dlnLen = ByteConversion.byteToShort(data, readOffset);
+ readOffset += LENGTH_DLN_LENGTH;
+ readOffset += doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
+ final short attributes = ByteConversion.byteToShort(data, readOffset);
+ rec.offset += realLen + LENGTH_ATTRIBUTES_COUNT;
+ for (int i = 0; i < children; i++) {
+ final boolean extraWhitespace = addWhitespace && (children - attributes) > 1;
+ //recursive call
+ getNodeValue(doc, os, rec, false, addWhitespace);
+ if (extraWhitespace)
+ os.write((byte) ' ');
+ }
+ return;
}
- return;
case Node.TEXT_NODE:
- case Node.CDATA_SECTION_NODE:
- dlnLen = ByteConversion.byteToShort(data, readOffset);
- readOffset += LENGTH_DLN_LENGTH;
- int nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
- readOffset += nodeIdLen;
- os.write(data, readOffset, vlen - (2 + nodeIdLen + 1));
- break;
+ case Node.CDATA_SECTION_NODE: {
+ final int dlnLen = ByteConversion.byteToShort(data, readOffset);
+ readOffset += LENGTH_DLN_LENGTH;
+ final int nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
+ readOffset += nodeIdLen;
+ os.write(data, readOffset, realLen - (2 + nodeIdLen + 1));
+ break;
+ }
case Node.ATTRIBUTE_NODE:
// use attribute value if the context node is an attribute, i.e.
// if this is the first call to the method
@@ -1903,9 +1907,9 @@
int start = readOffset - 1;
final byte idSizeType = (byte) (data[start] & 0x3);
final boolean hasNamespace = (data[start] & 0x10) == 0x10;
- dlnLen = ByteConversion.byteToShort(data, readOffset);
+ final int dlnLen = ByteConversion.byteToShort(data, readOffset);
readOffset += LENGTH_DLN_LENGTH;
- nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
+ final int nodeIdLen = doc.getBroker().getBrokerPool().getNodeFactory().lengthInBytes(dlnLen, data, readOffset);
readOffset += nodeIdLen;
readOffset += Signatures.getLength(idSizeType);
if (hasNamespace) {
@@ -1913,13 +1917,13 @@
final short prefixLen = ByteConversion.byteToShort(data, readOffset);
readOffset += prefixLen + 2; // skip prefix
}
- os.write(rec.getPage().data, readOffset, vlen - (readOffset - start));
+ os.write(rec.getPage().data, readOffset, realLen - (readOffset - start));
}
break;
}
if (!inOverflow)
// if it isn't an overflow value, add the value length to the current offset
- rec.offset += vlen + 2;
+ rec.offset += realLen + 2;
}
protected RecordPos findRecord(long p) {
@@ -2034,7 +2038,7 @@
page.len += LENGTH_TID;
// save data length
// overflow pages have length 0
- short vlen = (short) loggable.value.length;
+ final short vlen = (short) loggable.value.length;
ByteConversion.shortToByte(vlen, page.data, page.len);
page.len += LENGTH_DATA_LENGTH;
// save data
@@ -2098,7 +2102,7 @@
RecordPos rec = page.findRecord(ItemId.getId(loggable.tid));
SanityCheck.THROW_ASSERT(rec != null, "tid " + ItemId.getId(loggable.tid) + " not found on page " + page.getPageNum() +
"; contents: " + debugPageContents(page));
- short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
SanityCheck.THROW_ASSERT(vlen == loggable.oldValue.length);
rec.offset += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(rec.getTID()))
@@ -2517,7 +2521,7 @@
try {
ByteConversion.shortToByte(ItemId.setIsRelocated(loggable.tid), page.data, page.len);
page.len += LENGTH_TID;
- short vlen = (short) loggable.value.length;
+ final short vlen = (short) loggable.value.length;
// save data length
// overflow pages have length 0
ByteConversion.shortToByte(vlen, page.data, page.len);
@@ -2803,7 +2807,7 @@
} else if (ItemId.isLink(tid)) {
pos += LENGTH_FORWARD_LOCATION;
} else {
- short vlen = ByteConversion.byteToShort(data, pos);
+ final short vlen = ByteConversion.byteToShort(data, pos);
pos += LENGTH_DATA_LENGTH;
if (vlen < 0) {
LOG.warn("page = " + page.getPageNum() + "; pos = "
@@ -2988,7 +2992,7 @@
if (ItemId.isLink(tid)) {
pos += LENGTH_FORWARD_LOCATION;
} else {
- short vlen = ByteConversion.byteToShort(data, pos);
+ final short vlen = ByteConversion.byteToShort(data, pos);
pos += LENGTH_DATA_LENGTH;
if (ItemId.isRelocated(tid)) {
pos += vlen == OVERFLOW ? LENGTH_ORIGINAL_LOCATION + LENGTH_OVERFLOW_LOCATION : LENGTH_ORIGINAL_LOCATION + vlen;
@@ -3214,7 +3218,7 @@
switch (mode) {
case VALUES:
RecordPos rec = findRecord(pointer);
- short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
+ final short vlen = ByteConversion.byteToShort(rec.getPage().data, rec.offset);
values.add(new Value(rec.getPage().data, rec.offset + LENGTH_DATA_LENGTH, vlen));
return true;
case KEYS:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|