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
(19) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:35:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/util Modified Files: ReentrantReadWriteLock.java Lock.java Added Files: MultiReadReentrantLock.java Log Message: Improved locking to handle concurrent XUpdates. Index: Lock.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/Lock.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Lock.java 25 May 2004 09:25:47 -0000 1.3 --- Lock.java 2 Jun 2004 11:34:34 -0000 1.4 *************** *** 1,2 **** --- 1,24 ---- + /* + * eXist Open Source Native XML Database + * Copyright (C) 2001-03 Wolfgang M. Meier + * wol...@ex... + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ package org.exist.util; *************** *** 6,11 **** --- 28,69 ---- public final static int WRITE_LOCK = 1; + /** + * Attempt to acquire a lock for read. + * + * @return + * @throws LockException + */ public boolean acquire( ) throws LockException; + + /** + * Attempt to acquire a lock for read or write. + * mode is one of {@link #READ_LOCK} or + * {@link #WRITE_LOCK}. + * + * @param mode + * @return + * @throws LockException + */ public boolean acquire( int mode ) throws LockException; + + /** + * Release a lock. This method assumes that the + * lock is a read lock. + */ public void release( ); + + /** + * Release a lock of the specified type. + * + * @param mode + */ + public void release( int mode ); + + /** + * Returns true if there are active or pending + * write locks. + * + * @return + */ + public boolean isLockedForWrite(); } --- NEW FILE: MultiReadReentrantLock.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2000-04, Wolfgang M. Meier (wol...@ex...) * * 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 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. * * Original code is * * Copyright 2001-2004 The Apache Software Foundation. * * 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. * * $Id: MultiReadReentrantLock.java,v 1.1 2004/06/02 11:34:34 wolfgang_m Exp $ */ package org.exist.util; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; /** * A reentrant read/write lock, which allows multiple readers to acquire a lock. * Waiting writers are preferred. * * This is an adapted and bug-fixed version of code taken from Apache's Turbine * JCS. * */ public class MultiReadReentrantLock implements Lock { private final static Logger log = Logger .getLogger(MultiReadReentrantLock.class); /** Number of threads waiting to read. */ private int waitingForReadLock = 0; /** Number of threads reading. */ private int outstandingReadLocks = 0; /** The thread that has the write lock or null. */ private Thread writeLockedThread; /** * The number of (nested) write locks that have been requested from * writeLockedThread. */ private int outstandingWriteLocks = 0; /** * Threads waiting to get a write lock are tracked in this ArrayList to * ensure that write locks are issued in the same order they are requested. */ private List waitingForWriteLock = new ArrayList(5); /** Default constructor. */ public MultiReadReentrantLock() { } public boolean acquire() throws LockException { return acquire(Lock.READ_LOCK); } public boolean acquire(int mode) throws LockException { switch (mode) { case Lock.WRITE_LOCK: return writeLock(); default: return readLock(); } } /** * Issue a read lock if there is no outstanding write lock or threads * waiting to get a write lock. Caller of this method must be careful to * avoid synchronizing the calling code so as to avoid deadlock. */ private synchronized boolean readLock() throws LockException { if (writeLockedThread == Thread.currentThread()) { outstandingReadLocks++; return true; } waitingForReadLock++; while (writeLockedThread != null) { // log.debug( "readLock wait" ); try { wait(100); } catch (InterruptedException e) { throw new LockException("Interrupted while waiting for read lock"); } // log.debug( "wake up from readLock wait" ); } // log.debug( "readLock acquired" ); waitingForReadLock--; outstandingReadLocks++; return true; } /** * Issue a write lock if there are no outstanding read or write locks. * Caller of this method must be careful to avoid synchronizing the calling * code so as to avoid deadlock. */ private boolean writeLock() throws LockException { Thread thisThread = Thread.currentThread(); synchronized (this) { if (writeLockedThread == null && outstandingReadLocks == 0) { writeLockedThread = Thread.currentThread(); outstandingWriteLocks++; // log.debug( "writeLock acquired without waiting by " + writeLockedThread.getName()); return true; } // if ( writeLockedThread == thisThread ) // { // log.debug("nested write lock: " + outstandingWriteLocks); // } waitingForWriteLock.add(thisThread); } synchronized (thisThread) { while (thisThread != writeLockedThread) { // log.debug( "writeLock wait: outstanding: " + // outstandingWriteLocks + " / " + outstandingReadLocks); try { // set this so if there is an error the app will not // completely die! thisThread.wait(); } catch (InterruptedException e) { throw new LockException("Interrupted"); } // log.debug( "wake up from writeLock wait" ); } outstandingWriteLocks++; //testing // log.debug( "writeLock acquired " + writeLockedThread.getName()); } synchronized (this) { int i = waitingForWriteLock.indexOf(thisThread); waitingForWriteLock.remove(i); } return true; } public void release() { release(Lock.READ_LOCK); } public void release(int mode) { switch (mode) { case Lock.WRITE_LOCK: releaseWrite(); break; default: releaseRead(); break; } } private synchronized void releaseWrite() { if (Thread.currentThread() == writeLockedThread) { //log.info( "outstandingWriteLocks= " + outstandingWriteLocks ); if (outstandingWriteLocks > 0) outstandingWriteLocks--; // else { // log.info("extra lock release, writelocks are " // + outstandingWriteLocks + "and done was called"); // } if (outstandingWriteLocks > 0) { // log.debug( "writeLock released for a nested writeLock request: " + outstandingWriteLocks + // "; thread: " + writeLockedThread.getName()); return; } // could pull out of sub if block to get nested tracking working. if (outstandingReadLocks == 0 && waitingForWriteLock.size() > 0) { writeLockedThread = (Thread) waitingForWriteLock.get(0); // if ( log.isDebugEnabled() ) // { // log.debug( "writeLock released and before notifying a write // lock waiting thread " // + writeLockedThread ); // } synchronized (writeLockedThread) { writeLockedThread.notify(); } // if ( log.isDebugEnabled() ) // { // log.debug( "writeLock released and after notifying a write // lock waiting thread " // + writeLockedThread ); // } } else { writeLockedThread = null; if (waitingForReadLock > 0) { // log.debug( "writeLock released, notified waiting readers" // ); notifyAll(); } else { // log.debug( "writeLock released, no readers waiting" ); } } } else { log.warn("Illegal lock usage: thread does not hold the write lock"); throw new IllegalStateException("Thread does not have lock"); } // log.debug("writeLock released: " + outstandingWriteLocks + // "; thread: " + Thread.currentThread().getName()); } /** * Threads call this method to relinquish a lock that they previously got * from this object. * * @throws IllegalStateException * if called when there are no outstanding locks or there is a * write lock issued to a different thread. */ private synchronized void releaseRead() { if (outstandingReadLocks > 0) { outstandingReadLocks--; if (outstandingReadLocks == 0 && writeLockedThread == null && waitingForWriteLock.size() > 0) { writeLockedThread = (Thread) waitingForWriteLock.get(0); // if ( log.isDebugEnabled() ) // { // log.debug( "readLock released and before notifying a write // lock waiting thread " // + writeLockedThread ); // } synchronized (writeLockedThread) { writeLockedThread.notifyAll(); } // if ( log.isDebugEnabled() ) // { // log.debug( "readLock released and after notifying a write // lock waiting thread " // + writeLockedThread ); // } } return; } else throw new IllegalStateException("Attempt to release a non-existing read lock."); } public synchronized boolean isLockedForWrite() { return writeLockedThread != null || waitingForWriteLock.size() > 0; } } Index: ReentrantReadWriteLock.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/util/ReentrantReadWriteLock.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ReentrantReadWriteLock.java 2 Feb 2004 15:30:38 -0000 1.3 --- ReentrantReadWriteLock.java 2 Jun 2004 11:34:34 -0000 1.4 *************** *** 99,102 **** --- 99,117 ---- } + + /* (non-Javadoc) + * @see org.exist.util.Lock#isLockedForWrite() + */ + public boolean isLockedForWrite() { + return holds_ > 0 && mode_ == Lock.WRITE_LOCK; + } + + /* (non-Javadoc) + * @see org.exist.util.Lock#release(int) + */ + public void release(int mode) { + release(); + } + /** * Release the lock. |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:35:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/memtree In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/memtree Modified Files: NodeImpl.java Log Message: Improved locking to handle concurrent XUpdates. Index: NodeImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/memtree/NodeImpl.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** NodeImpl.java 28 May 2004 10:54:11 -0000 1.14 --- NodeImpl.java 2 Jun 2004 11:34:34 -0000 1.15 *************** *** 23,26 **** --- 23,27 ---- package org.exist.memtree; + import org.exist.dom.DocumentSet; import org.exist.dom.NodeSet; import org.exist.dom.QName; *************** *** 69,72 **** --- 70,81 ---- } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#getDocumentSet() + */ + public DocumentSet getDocumentSet() { + return DocumentSet.EMPTY_DOCUMENT_SET; + } + /* (non-Javadoc) * @see org.exist.xquery.value.NodeValue#getNode() |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:35:14
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/xquery/value Modified Files: AtomicValue.java AbstractSequence.java Sequence.java Log Message: Improved locking to handle concurrent XUpdates. Index: AtomicValue.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AtomicValue.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** AtomicValue.java 28 May 2004 10:54:10 -0000 1.3 --- AtomicValue.java 2 Jun 2004 11:34:34 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- package org.exist.xquery.value; + import org.exist.dom.DocumentSet; import org.exist.dom.NodeSet; import org.exist.memtree.Receiver; *************** *** 168,171 **** --- 169,180 ---- } + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#getDocumentSet() + */ + public DocumentSet getDocumentSet() { + return DocumentSet.EMPTY_DOCUMENT_SET; + } + public String pprint() { try { Index: AbstractSequence.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/AbstractSequence.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** AbstractSequence.java 28 May 2004 10:54:10 -0000 1.4 --- AbstractSequence.java 2 Jun 2004 11:34:34 -0000 1.5 *************** *** 24,27 **** --- 24,28 ---- import java.util.List; + import org.exist.dom.DocumentSet; import org.exist.dom.NodeProxy; import org.exist.xquery.Cardinality; *************** *** 93,97 **** --- 94,106 ---- */ public abstract Item itemAt(int pos); + + /* (non-Javadoc) + * @see org.exist.xquery.value.Sequence#getDocumentSet() + */ + public DocumentSet getDocumentSet() { + return DocumentSet.EMPTY_DOCUMENT_SET; + } + /* (non-Javadoc) * @see org.exist.xquery.value.Sequence#effectiveBooleanValue() Index: Sequence.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/value/Sequence.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Sequence.java 28 May 2004 10:54:10 -0000 1.3 --- Sequence.java 2 Jun 2004 11:34:34 -0000 1.4 *************** *** 21,24 **** --- 21,25 ---- package org.exist.xquery.value; + import org.exist.dom.DocumentSet; import org.exist.dom.NodeSet; import org.exist.xquery.XPathException; *************** *** 141,144 **** --- 142,147 ---- public NodeSet toNodeSet() throws XPathException; + public DocumentSet getDocumentSet(); + /** * Returns a preference indicator, indicating the preference of |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:49
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/xquery Modified Files: XQueryContext.java PathExpr.java RootNode.java Log Message: Improved locking to handle concurrent XUpdates. Index: XQueryContext.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/XQueryContext.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** XQueryContext.java 28 May 2004 10:54:13 -0000 1.16 --- XQueryContext.java 2 Jun 2004 11:34:36 -0000 1.17 *************** *** 75,92 **** --- 75,106 ---- private final static Logger LOG = Logger.getLogger(XQueryContext.class); + // Static namespace/prefix mappings private Map namespaces; + + // Local in-scope namespace/prefix mappings in the current context private HashMap inScopeNamespaces = new HashMap(); + // Static prefix/namespace mappings private HashMap prefixes; + + // Local prefix/namespace mappings in the current context private HashMap inScopePrefixes = new HashMap(); + // Local namespace stack private Stack namespaceStack = new Stack(); + // Known user defined functions in the local module private TreeMap declaredFunctions = new TreeMap(); + // Globally declare variables private TreeMap globalVariables = new TreeMap(); + + // Local in-scope variables in the current context private TreeMap variables = new TreeMap(); + + // Local in-scope variable stack private Stack variableStack = new Stack(); + // Unresolved references to user defined functions private Stack forwardReferences = new Stack(); *************** *** 131,138 **** --- 145,160 ---- */ private MemTreeBuilder builder = null; + + // Stack for temporary document fragments private Stack fragmentStack = new Stack(); private Expression rootExpression; + /** + * Flag to indicate that the query should put an exclusive + * lock on all documents involved. + */ + private boolean exclusive = false; + public XQueryContext(DBBroker broker) { this.broker = broker; *************** *** 143,150 **** --- 165,184 ---- } + /** + * Called from the XQuery compiler to set the root expression + * for this context. + * + * @param expr + */ public void setRootExpression(Expression expr) { this.rootExpression = expr; } + /** + * Returns the root expression of the XQuery associated with + * this context. + * + * @return + */ public Expression getRootExpression() { return rootExpression; *************** *** 814,821 **** --- 848,866 ---- } + /** + * Add a forward reference to an undeclared function. Forward + * references will be resolved later. + * + * @param call + */ public void addForwardReference(FunctionCall call) { forwardReferences.push(call); } + /** + * Resolve all forward references to previously undeclared functions. + * + * @throws XPathException + */ public void resolveForwardReferences() throws XPathException { while(!forwardReferences.empty()) { *************** *** 828,831 **** --- 873,885 ---- } } + + public void setExclusiveMode(boolean exclusive) { + this.exclusive = exclusive; + } + + public boolean inExclusiveMode() { + return exclusive; + } + /** * Load the default prefix/namespace mappings table and set up Index: PathExpr.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/PathExpr.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PathExpr.java 28 May 2004 10:54:12 -0000 1.6 --- PathExpr.java 2 Jun 2004 11:34:36 -0000 1.7 *************** *** 1,3 **** - /* * eXist Native XML Database --- 1,2 ---- *************** *** 37,80 **** /** ! * PathExpr is just a sequence of XQuery/XPath expressions, which will ! * be called step by step. * * @author Wolfgang Meier (wol...@ex...) */ ! public class PathExpr extends AbstractExpression implements CompiledXQuery, CompiledExpression { ! ! protected static Logger LOG = Logger.getLogger( PathExpr.class ); protected boolean keepVirtual = false; protected LinkedList steps = new LinkedList(); ! protected boolean inPredicate = false; ! ! private long creationTime = 0; ! public PathExpr(XQueryContext context) { ! super(context); } /** ! * Add an arbitrary expression to this object's list of ! * child-expressions. * * @param s */ ! public void add( Expression s ) { ! steps.add( s ); } /** ! * Add all the child-expressions from another PathExpr ! * to this object's child-expressions. ! * * @param path */ ! public void add( PathExpr path ) { ! Expression expr; ! for ( Iterator i = path.steps.iterator(); i.hasNext(); ) { ! expr = (Expression) i.next(); ! add( expr ); } } --- 36,81 ---- /** ! * PathExpr is just a sequence of XQuery/XPath expressions, which will be called ! * step by step. * * @author Wolfgang Meier (wol...@ex...) */ ! public class PathExpr extends AbstractExpression implements CompiledXQuery, ! CompiledExpression { ! ! protected final static Logger LOG = Logger.getLogger(PathExpr.class); protected boolean keepVirtual = false; + protected LinkedList steps = new LinkedList(); ! ! protected boolean inPredicate = false; ! ! private long creationTime = 0; ! public PathExpr(XQueryContext context) { ! super(context); } /** ! * Add an arbitrary expression to this object's list of child-expressions. * * @param s */ ! public void add(Expression s) { ! steps.add(s); } /** ! * Add all the child-expressions from another PathExpr to this object's ! * child-expressions. ! * * @param path */ ! public void add(PathExpr path) { ! Expression expr; ! for (Iterator i = path.steps.iterator(); i.hasNext();) { ! expr = (Expression) i.next(); ! add(expr); } } *************** *** 82,171 **** /** * Add another PathExpr to this object's expression list. * @param path */ ! public void addPath( PathExpr path ) { ! steps.add( path ); } /** ! * Add a predicate expression to the list of expressions. ! * The predicate is added to the last expression in the ! * list. * * @param pred */ ! public void addPredicate( Predicate pred ) { Expression e = (Expression) steps.getLast(); ! if ( e instanceof Step ) ! ( (Step) e ).addPredicate( pred ); } ! public Sequence eval( Sequence contextSequence, Item contextItem) throws XPathException { ! if ( steps.size() == 0 ) ! return Sequence.EMPTY_SEQUENCE; Sequence r; ! if ( contextSequence != null ) r = contextSequence; ! else { ! r = Sequence.EMPTY_SEQUENCE; } DocumentSet contextDocs = null; ! Expression expr = (Expression)steps.getFirst(); ! if(expr instanceof VariableReference) { ! Variable var = ((VariableReference)expr).getVariable(); ! if(var != null) contextDocs = var.getContextDocs(); } NodeSet set; ! Item current; Sequence values; ! for ( Iterator iter = steps.iterator(); iter.hasNext(); ) { expr = (Expression) iter.next(); ! if(contextDocs != null) ! expr.setContextDocSet(contextDocs); if ((expr.getDependencies() & Dependency.CONTEXT_ITEM) != 0) { ! //LOG.debug("single step mode: " + expr.pprint()); ! if(r.getLength() == 0) { ! r = expr.eval( null, null ); ! } else { ! values = null; ! if(r.getLength() > 1) ! values = new ValueSequence(); ! int pos = 0; ! context.setContextPosition(0); ! for ( SequenceIterator iterInner = r.iterate(); iterInner.hasNext(); pos++ ) { ! context.setContextPosition(pos); ! current = iterInner.nextItem(); ! if(values == null) ! values = expr.eval(r, current); ! else ! values.addAll( expr.eval(r, current) ); ! } ! r = values; ! } } else ! r = expr.eval( r ); } return r; } ! public XQueryContext getContext() { ! return context; ! } ! public DocumentSet getDocumentSet() { return null; } ! public Expression getExpression( int pos ) { ! return (Expression) steps.get( pos ); } - public Expression getLastExpression() { - if(steps.size() == 0) - return null; - return (Expression) steps.getLast(); - } - public int getLength() { return steps.size(); --- 83,171 ---- /** * Add another PathExpr to this object's expression list. + * * @param path */ ! public void addPath(PathExpr path) { ! steps.add(path); } /** ! * Add a predicate expression to the list of expressions. The predicate is ! * added to the last expression in the list. * * @param pred */ ! public void addPredicate(Predicate pred) { Expression e = (Expression) steps.getLast(); ! if (e instanceof Step) ((Step) e).addPredicate(pred); } ! public Sequence eval(Sequence contextSequence, Item contextItem) ! throws XPathException { ! if (steps.size() == 0) return Sequence.EMPTY_SEQUENCE; Sequence r; ! if (contextSequence != null) { r = contextSequence; ! } else { ! r = Sequence.EMPTY_SEQUENCE; } DocumentSet contextDocs = null; ! Expression expr = (Expression) steps.getFirst(); ! if (expr instanceof VariableReference) { ! Variable var = ((VariableReference) expr).getVariable(); ! if (var != null) { contextDocs = var.getContextDocs(); + } } + NodeSet set; ! Item current; Sequence values; ! for (Iterator iter = steps.iterator(); iter.hasNext();) { expr = (Expression) iter.next(); ! if (contextDocs != null) expr.setContextDocSet(contextDocs); if ((expr.getDependencies() & Dependency.CONTEXT_ITEM) != 0) { ! //LOG.debug("single step mode: " + expr.pprint()); ! if (r.getLength() == 0) { ! r = expr.eval(null, null); ! } else { ! values = null; ! if (r.getLength() > 1) values = new ValueSequence(); ! int pos = 0; ! context.setContextPosition(0); ! for (SequenceIterator iterInner = r.iterate(); iterInner ! .hasNext(); pos++) { ! context.setContextPosition(pos); ! current = iterInner.nextItem(); ! if (values == null) ! values = expr.eval(r, current); ! else ! values.addAll(expr.eval(r, current)); ! } ! r = values; ! } } else ! r = expr.eval(r); } return r; } ! public XQueryContext getContext() { ! return context; ! } ! public DocumentSet getDocumentSet() { return null; } ! public Expression getExpression(int pos) { ! return (Expression) steps.get(pos); ! } ! ! public Expression getLastExpression() { ! if (steps.size() == 0) return null; ! return (Expression) steps.getLast(); } public int getLength() { return steps.size(); *************** *** 176,283 **** buf.append('('); Expression next; ! for ( Iterator iter = steps.iterator(); iter.hasNext(); ) { ! next = (Expression) iter.next(); ! if ( buf.length() > 1 && next instanceof Step) ! buf.append( '/' ); ! buf.append( next.pprint() ); } ! buf.append( ')' ); return buf.toString(); } public int returnsType() { ! if( steps.size() == 0 ) ! return Type.NODE; ! int rtype = ((Expression) steps.getLast()).returnsType(); ! return rtype; } ! /* (non-Javadoc) ! * @see org.exist.xquery.AbstractExpression#getDependencies() ! */ ! public int getDependencies() { ! Expression next; ! int deps = 0; ! for(Iterator i = steps.iterator(); i.hasNext(); ) { ! next = (Expression)i.next(); ! deps = deps | next.getDependencies(); ! } ! return deps; ! } ! public void setFirstExpression( Expression s ) { ! steps.addFirst( s ); } ! ! public void replaceLastExpression( Expression s ) { ! if(steps.size() == 0) ! return; ! else { ! steps.removeLast(); ! steps.addLast(s); ! } } ! public String getLiteralValue() { ! if(steps.size() == 0) ! return ""; ! Expression next = (Expression)steps.get(0); ! if(next instanceof LiteralValue) ! try { ! return ((LiteralValue)next).getValue().getStringValue(); ! } catch (XPathException e) { ! } ! if(next instanceof PathExpr) ! return ((PathExpr)next).getLiteralValue(); ! return ""; } - - - /* (non-Javadoc) - * @see org.exist.xquery.AbstractExpression#getASTNode() - */ - public XQueryAST getASTNode() { - XQueryAST ast = super.getASTNode(); - if(ast == null && steps.size() == 1) { - return ((Expression)steps.get(0)).getASTNode(); - } - return ast; - } - - /* (non-Javadoc) - * @see org.exist.xquery.Expression#setInPredicate(boolean) - */ - public void setInPredicate(boolean inPredicate) { - this.inPredicate = inPredicate; - if(steps.size() > 0) - ((Expression)steps.get(0)).setInPredicate(inPredicate); - } ! /* (non-Javadoc) ! * @see org.exist.xquery.AbstractExpression#setPrimaryAxis(int) ! */ ! public void setPrimaryAxis(int axis) { ! if(steps.size() > 0) ! ((Expression)steps.get(0)).setPrimaryAxis(axis); ! } ! ! /* (non-Javadoc) ! * @see org.exist.xquery.AbstractExpression#resetState() ! */ ! public void resetState() { ! for(Iterator i = steps.iterator(); i.hasNext(); ) { ! ((Expression)i.next()).resetState(); ! } ! } ! /* (non-Javadoc) ! * @see org.exist.xmldb.CompiledExpression#reset() ! */ ! public void reset() { ! resetState(); ! } ! ! ! /* (non-Javadoc) * @see org.exist.xquery.CompiledXQuery#setCreationTime(long) */ --- 176,289 ---- buf.append('('); Expression next; ! for (Iterator iter = steps.iterator(); iter.hasNext();) { ! next = (Expression) iter.next(); ! if (buf.length() > 1 && next instanceof Step) buf.append('/'); ! buf.append(next.pprint()); } ! buf.append(')'); return buf.toString(); } public int returnsType() { ! if (steps.size() == 0) return Type.NODE; ! int rtype = ((Expression) steps.getLast()).returnsType(); ! return rtype; } ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.AbstractExpression#getDependencies() ! */ ! public int getDependencies() { ! Expression next; ! int deps = 0; ! for (Iterator i = steps.iterator(); i.hasNext();) { ! next = (Expression) i.next(); ! deps = deps | next.getDependencies(); ! } ! return deps; ! } ! public void setFirstExpression(Expression s) { ! steps.addFirst(s); } ! ! public void replaceLastExpression(Expression s) { ! if (steps.size() == 0) ! return; ! else { ! steps.removeLast(); ! steps.addLast(s); ! } } ! public String getLiteralValue() { ! if (steps.size() == 0) return ""; ! Expression next = (Expression) steps.get(0); ! if (next instanceof LiteralValue) try { ! return ((LiteralValue) next).getValue().getStringValue(); ! } catch (XPathException e) { ! } ! if (next instanceof PathExpr) ! return ((PathExpr) next).getLiteralValue(); ! return ""; } ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.AbstractExpression#getASTNode() ! */ ! public XQueryAST getASTNode() { ! XQueryAST ast = super.getASTNode(); ! if (ast == null && steps.size() == 1) { return ((Expression) steps ! .get(0)).getASTNode(); } ! return ast; ! } ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.Expression#setInPredicate(boolean) ! */ ! public void setInPredicate(boolean inPredicate) { ! this.inPredicate = inPredicate; ! if (steps.size() > 0) ! ((Expression) steps.get(0)).setInPredicate(inPredicate); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.AbstractExpression#setPrimaryAxis(int) ! */ ! public void setPrimaryAxis(int axis) { ! if (steps.size() > 0) ((Expression) steps.get(0)).setPrimaryAxis(axis); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.AbstractExpression#resetState() ! */ ! public void resetState() { ! for (Iterator i = steps.iterator(); i.hasNext();) { ! ((Expression) i.next()).resetState(); ! } ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xmldb.CompiledExpression#reset() ! */ ! public void reset() { ! resetState(); ! } ! ! /* ! * (non-Javadoc) ! * * @see org.exist.xquery.CompiledXQuery#setCreationTime(long) */ *************** *** 285,291 **** creationTime = created; } ! ! ! /* (non-Javadoc) * @see org.exist.xquery.CompiledXQuery#getCreationTime() */ --- 291,298 ---- creationTime = created; } ! ! /* ! * (non-Javadoc) ! * * @see org.exist.xquery.CompiledXQuery#getCreationTime() */ Index: RootNode.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/RootNode.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** RootNode.java 28 May 2004 10:54:12 -0000 1.4 --- RootNode.java 2 Jun 2004 11:34:36 -0000 1.5 *************** *** 28,31 **** --- 28,32 ---- import org.exist.dom.NodeProxy; import org.exist.dom.NodeSet; + import org.exist.util.LockException; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; *************** *** 33,85 **** /** ! * Represents the document-root node in an expression. ! * ! *@author Wolfgang Meier <me...@if...> */ public class RootNode extends Step { private Sequence cached = null; private DocumentSet cachedDocs = null; - - /** Constructor for the RootNode object */ - public RootNode(XQueryContext context) { - super(context, Constants.SELF_AXIS); - } ! public Sequence eval( ! Sequence contextSequence, ! Item contextItem) { ! DocumentSet ds = context.getStaticallyKnownDocuments(); ! if(ds == null || ds.getLength() == 0) ! return Sequence.EMPTY_SEQUENCE; ! if(cachedDocs != null && cachedDocs.equals(ds)) ! return cached; ! ! NodeSet result = new ArraySet(ds.getLength()); ! for (Iterator i = ds.iterator(); i.hasNext();) { ! result.add(new NodeProxy((DocumentImpl) i.next(), -1)); ! } ! cached = result; ! cachedDocs = ds; ! return result; ! } ! public String pprint() { ! return "ROOT"; ! } ! ! /* (non-Javadoc) ! * @see org.exist.xquery.Step#returnsType() ! */ ! public int returnsType() { ! return Type.NODE; ! } ! /* (non-Javadoc) ! * @see org.exist.xquery.Step#resetState() ! */ ! public void resetState() { ! cachedDocs = null; ! cached = null; ! } ! } --- 34,98 ---- /** ! * Represents the document root node in an expression. ! * ! * @author Wolfgang Meier <me...@if...> */ public class RootNode extends Step { private Sequence cached = null; + private DocumentSet cachedDocs = null; ! /** Constructor for the RootNode object */ ! public RootNode(XQueryContext context) { ! super(context, Constants.SELF_AXIS); ! } ! public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { ! DocumentSet ds = context.getStaticallyKnownDocuments(); ! if (ds == null || ds.getLength() == 0) return Sequence.EMPTY_SEQUENCE; ! ! try { ! // wait for pending updates ! ds.lock(false); ! ! if (cachedDocs != null && cachedDocs.equals(ds)) return cached; ! NodeSet result = new ArraySet(ds.getLength()); ! DocumentImpl d; ! for (Iterator i = ds.iterator(); i.hasNext();) { ! d = (DocumentImpl) i.next(); ! result.add(new NodeProxy(d, -1)); ! } ! cached = result; ! cachedDocs = ds; ! return result; ! } catch (LockException e) { ! throw new XPathException(getASTNode(), "Failed to acquire lock on the context document set"); ! } finally { ! ds.unlock(false); ! } ! } ! public String pprint() { ! return "ROOT"; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.Step#returnsType() ! */ ! public int returnsType() { ! return Type.NODE; ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.exist.xquery.Step#resetState() ! */ ! public void resetState() { ! cachedDocs = null; ! cached = null; ! } ! } \ No newline at end of file |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:49
|
Update of /cvsroot/exist/eXist-1.0/src/org/apache/xindice/client/xmldb/services In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/apache/xindice/client/xmldb/services Removed Files: CollectionManager.java Log Message: Improved locking to handle concurrent XUpdates. --- CollectionManager.java DELETED --- |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:48
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/dom Modified Files: NodeImpl.java DocumentImpl.java DocumentSet.java Log Message: Improved locking to handle concurrent XUpdates. Index: NodeImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/NodeImpl.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** NodeImpl.java 18 May 2004 14:18:41 -0000 1.21 --- NodeImpl.java 2 Jun 2004 11:34:35 -0000 1.22 *************** *** 43,47 **** * *@author Wolfgang Meier <me...@if...> - *@created 8. Juli 2002 */ public class NodeImpl implements Node { --- 43,46 ---- Index: DocumentImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentImpl.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** DocumentImpl.java 25 May 2004 09:26:12 -0000 1.38 --- DocumentImpl.java 2 Jun 2004 11:34:35 -0000 1.39 *************** *** 42,46 **** import org.exist.storage.store.StorageAddress; import org.exist.util.Lock; ! import org.exist.util.ReentrantReadWriteLock; import org.exist.util.SyntaxException; import org.exist.xquery.DescendantSelector; --- 42,46 ---- import org.exist.storage.store.StorageAddress; import org.exist.util.Lock; ! import org.exist.util.MultiReadReentrantLock; import org.exist.util.SyntaxException; import org.exist.xquery.DescendantSelector; *************** *** 124,134 **** // has document-metadata been loaded? private transient boolean complete = true; - - // true while a write operation is in progress - private transient boolean writeLocked = false; private transient User lockOwner = null; ! private transient Lock updateLock = null; public DocumentImpl(DBBroker broker, Collection collection) { --- 124,131 ---- // has document-metadata been loaded? private transient boolean complete = true; private transient User lockOwner = null; ! private transient Lock updateLock = new MultiReadReentrantLock(); public DocumentImpl(DBBroker broker, Collection collection) { *************** *** 180,193 **** } public byte getResourceType() { return XML_FILE; } ! public void setWriteLock(boolean locked) { ! this.writeLocked = locked; } ! public boolean isLockedForWrite() { ! return writeLocked; } --- 177,202 ---- } + /** + * Returns the type of this resource, either {@link #XML_FILE} or + * {@link #BINARY_FILE}. + * + * @return + */ public byte getResourceType() { return XML_FILE; } ! /** ! * Returns true if the document is currently locked for ! * write. ! * ! * @return ! */ ! public boolean isLockedForWrite() { ! return updateLock.isLockedForWrite(); } ! public void setCollection(Collection parent) { ! this.collection = parent; } *************** *** 240,249 **** } - // jmv - PMD - Avoid unused private methods - // private void checkRange(int level) throws EXistException { - // if (treeLevelStartPoints[level] < 0 || treeLevelStartPoints[level + 1] < 0) - // throw new EXistException("index out of range"); - // } - public int compareTo(Object other) { final long otherId = ((DocumentImpl)other).docId; --- 249,252 ---- *************** *** 832,845 **** } - // jmv - PMD - Avoid unused private methods - // private void checkTree(int size) throws EXistException { - // // check if the tree structure needs to be changed - // System.out.println(treeLevelOrder[0]); - // if (treeLevelOrder[0] < children + size) { - // // recompute the order of the tree - // treeLevelOrder[0] = children + size; - // calculateTreeLevelStartPoints(); - // } - // } /** * @return --- 835,838 ---- *************** *** 874,880 **** } public synchronized Lock getUpdateLock() { - if(updateLock == null) - updateLock = new ReentrantReadWriteLock(getFileName()); return updateLock; } --- 867,877 ---- } + /** + * Returns the update lock associated with this + * resource. + * + * @return + */ public synchronized Lock getUpdateLock() { return updateLock; } Index: DocumentSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/DocumentSet.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** DocumentSet.java 25 May 2004 09:26:12 -0000 1.14 --- DocumentSet.java 2 Jun 2004 11:34:36 -0000 1.15 *************** *** 2,6 **** * eXist Open Source Native XML Database * ! * Copyright (C) 2000, Wolfgang Meier (wol...@ex...) * * This program is free software; you can redistribute it and/or --- 2,6 ---- * eXist Open Source Native XML Database * ! * Copyright (C) 2000-04, Wolfgang Meier (wol...@ex...) * * This program is free software; you can redistribute it and/or *************** *** 17,20 **** --- 17,22 ---- * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * $Id$ */ *************** *** 33,36 **** --- 35,39 ---- import org.exist.util.LockException; import org.exist.util.hashtable.Int2ObjectHashMap; + import org.exist.xquery.XQueryContext; import org.w3c.dom.Node; import org.w3c.dom.NodeList; *************** *** 47,50 **** --- 50,55 ---- public class DocumentSet extends Int2ObjectHashMap implements NodeList { + public final static DocumentSet EMPTY_DOCUMENT_SET = new DocumentSet(9); + private final static Logger LOG = Logger.getLogger(DocumentSet.class.getName()); *************** *** 53,58 **** private TreeSet collections = new TreeSet(); - private boolean exclusive = false; - public DocumentSet() { super(29); --- 58,61 ---- *************** *** 63,71 **** } - public DocumentSet(boolean exclusive) { - super(29); - this.exclusive = exclusive; - } - public void clear() { super.clear(); --- 66,69 ---- *************** *** 115,134 **** doc = (DocumentImpl)i.next(); if(broker == null || doc.getPermissions().validate(broker.getUser(), Permission.READ)) { ! if(doc.isLockedForWrite()) ! continue; ! if(exclusive) { ! Lock lock = doc.getUpdateLock(); ! try { ! lock.acquire(Lock.WRITE_LOCK); ! put(doc.getDocId(), doc); ! } catch (LockException e) { ! LOG.debug("Failed to lock document " + doc.getFileName()); ! continue; ! } finally { ! lock.release(); ! } ! } else ! put(doc.getDocId(), doc); ! } } } --- 113,121 ---- doc = (DocumentImpl)i.next(); if(broker == null || doc.getPermissions().validate(broker.getUser(), Permission.READ)) { ! // if(doc.isLockedForWrite()) ! // continue; ! put(doc.getDocId(), doc); ! } else ! put(doc.getDocId(), doc); } } *************** *** 163,173 **** } - /* - public boolean contains(int docId) { - return containsKey(docId); - //return containsKey(new Integer(docId)); - } - */ - public DocumentImpl getDoc(int docId) { return (DocumentImpl) get(docId); --- 150,153 ---- *************** *** 262,272 **** return false; return hasEqualKeys(o); ! // DocumentImpl d; ! // for (Iterator i = iterator(); i.hasNext();) { ! // d = (DocumentImpl) i.next(); ! // if (!o.containsKey(d.docId)) ! // return false; ! // } ! // return true; } } --- 242,283 ---- return false; return hasEqualKeys(o); ! } ! ! public void lock(XQueryContext context) throws LockException { ! lock(context.inExclusiveMode()); ! } ! ! public void lock(boolean exclusive) throws LockException { ! DocumentImpl d; ! Lock dlock; ! for(int idx = 0; idx < tabSize; idx++) { ! if(values[idx] == null || values[idx] == REMOVED) ! continue; ! d = (DocumentImpl)values[idx]; ! dlock = d.getUpdateLock(); ! if(exclusive) ! dlock.acquire(Lock.WRITE_LOCK); ! else ! dlock.acquire(Lock.READ_LOCK); ! } ! } ! ! public void unlock(XQueryContext context) { ! unlock(context.inExclusiveMode()); ! } ! ! public void unlock(boolean exclusive) { ! DocumentImpl d; ! Lock dlock; ! for(int idx = 0; idx < tabSize; idx++) { ! if(values[idx] == null || values[idx] == REMOVED) ! continue; ! d = (DocumentImpl)values[idx]; ! dlock = d.getUpdateLock(); ! if(exclusive) ! dlock.release(Lock.WRITE_LOCK); ! else ! dlock.release(Lock.READ_LOCK); ! } } } |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:46
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xupdate In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/xupdate Modified Files: Modification.java Log Message: Improved locking to handle concurrent XUpdates. Index: Modification.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xupdate/Modification.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Modification.java 25 May 2004 09:25:48 -0000 1.24 --- Modification.java 2 Jun 2004 11:34:37 -0000 1.25 *************** *** 1,10 **** package org.exist.xupdate; import java.io.StringReader; - import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; - import java.util.List; import java.util.Map; --- 1,30 ---- + /* + * eXist Open Source Native XML Database + * Copyright (C) 2001-03 Wolfgang M. Meier + * wol...@ex... + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ package org.exist.xupdate; import java.io.StringReader; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; *************** *** 15,18 **** --- 35,39 ---- import org.exist.dom.NodeImpl; import org.exist.dom.NodeIndexListener; + import org.exist.dom.NodeSet; import org.exist.dom.XMLUtil; import org.exist.security.PermissionDeniedException; *************** *** 37,41 **** /** ! * Modification.java * * @author Wolfgang Meier --- 58,62 ---- /** ! * Base class for all XUpdate modifications. * * @author Wolfgang Meier *************** *** 50,54 **** protected DocumentSet docs; protected Map namespaces; ! protected List activeLocks; /** --- 71,75 ---- protected DocumentSet docs; protected Map namespaces; ! protected DocumentSet lockedDocuments = null; /** *************** *** 61,65 **** this.docs = docs; this.namespaces = new HashMap(namespaces); - this.activeLocks = new ArrayList(docs.getLength()); } --- 82,85 ---- *************** *** 96,99 **** --- 116,120 ---- try { XQueryContext context = new XQueryContext(broker); + context.setExclusiveMode(true); context.setStaticallyKnownDocuments(docs); Map.Entry entry; *************** *** 148,170 **** Lock globalLock = broker.getBrokerPool().getGlobalUpdateLock(); try { ! globalLock.acquire(Lock.WRITE_LOCK); NodeList nl = select(docs); // acquire a lock on all documents // we have to avoid that node positions change // during the modification NodeImpl ql[] = new NodeImpl[nl.getLength()]; ! DocumentImpl doc, prevDoc = null; ! Lock lock; for (int i = 0; i < ql.length; i++) { ql[i] = (NodeImpl)nl.item(i); doc = (DocumentImpl)ql[i].getOwnerDocument(); ! if(prevDoc == null || doc != prevDoc) { ! lock = doc.getUpdateLock(); ! lock.acquire(Lock.WRITE_LOCK); ! activeLocks.add(lock); ! doc.setBroker(broker); ! } ! prevDoc = doc; } return ql; --- 169,188 ---- Lock globalLock = broker.getBrokerPool().getGlobalUpdateLock(); try { ! globalLock.acquire(Lock.READ_LOCK); ! NodeList nl = select(docs); + lockedDocuments = ((NodeSet)nl).getDocumentSet(); // acquire a lock on all documents // we have to avoid that node positions change // during the modification + lockedDocuments.lock(true); + NodeImpl ql[] = new NodeImpl[nl.getLength()]; ! DocumentImpl doc; for (int i = 0; i < ql.length; i++) { ql[i] = (NodeImpl)nl.item(i); doc = (DocumentImpl)ql[i].getOwnerDocument(); ! doc.setBroker(broker); } return ql; *************** *** 178,186 **** */ protected void unlockDocuments() { ! Lock lock; ! for(int i = 0; i < activeLocks.size(); i++) { ! lock = (Lock)activeLocks.get(i); ! lock.release(); ! } } --- 196,200 ---- */ protected void unlockDocuments() { ! lockedDocuments.unlock(true); } |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:45
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/storage Modified Files: NativeTextEngine.java NativeElementIndex.java DBBroker.java NativeBroker.java Log Message: Improved locking to handle concurrent XUpdates. Index: NativeBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeBroker.java,v retrieving revision 1.76 retrieving revision 1.77 diff -C2 -d -r1.76 -r1.77 *** NativeBroker.java 28 May 2004 10:54:18 -0000 1.76 --- NativeBroker.java 2 Jun 2004 11:34:35 -0000 1.77 *************** *** 49,52 **** --- 49,53 ---- import org.exist.EXistException; import org.exist.collections.Collection; + import org.exist.collections.triggers.TriggerException; import org.exist.dom.ArraySet; import org.exist.dom.AttrImpl; *************** *** 415,476 **** final Lock lock = elementsDb.getLock(); for (Iterator i = docs.getCollectionIterator(); i.hasNext();) { ! collection = (Collection) i.next(); ! collectionId = collection.getId(); ! if (type == ElementValue.ATTRIBUTE_ID) { ! ref = new ElementValue((byte) type, collectionId, qname.getLocalName()); ! } else { ! sym = getSymbols().getSymbol(qname.getLocalName()); ! nsSym = getSymbols().getNSSymbol(qname.getNamespaceURI()); ! ref = new ElementValue((byte) type, collectionId, sym, nsSym); ! } ! boolean exceptionOcurred = false; ! try { ! lock.acquire(Lock.READ_LOCK); ! is = elementsDb.getAsStream(ref); ! } catch (LockException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "failed to acquire lock", ! e); ! // jmv: dis = null; ! exceptionOcurred = true; ! } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "io exception while reading elements for " ! + qname, ! e); ! // jmv: dis = null; ! exceptionOcurred = true; ! } finally { ! lock.release(); ! } ! // jmv: if (dis == null) ! // wolf: dis == null if no matching element has been found in the index ! if (is == null || exceptionOcurred) ! continue; ! try { ! while (is.available() > 0) { ! docId = is.readInt(); ! len = is.readInt(); ! if ((doc = docs.getDoc(docId)) == null) { ! is.skip(len * 4); ! continue; ! } ! gid = 0; ! for (int k = 0; k < len; k++) { ! gid = gid + is.readLong(); ! p = new NodeProxy(doc, gid, nodeType, StorageAddress.read(is)); ! if(selector == null || selector.match(p)) ! result.add(p, len); ! } ! } ! } catch (EOFException e) { ! } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "unexpected io error", ! e); ! } } // result.sort(); --- 416,477 ---- final Lock lock = elementsDb.getLock(); for (Iterator i = docs.getCollectionIterator(); i.hasNext();) { ! collection = (Collection) i.next(); ! collectionId = collection.getId(); ! if (type == ElementValue.ATTRIBUTE_ID) { ! ref = new ElementValue((byte) type, collectionId, qname.getLocalName()); ! } else { ! sym = getSymbols().getSymbol(qname.getLocalName()); ! nsSym = getSymbols().getNSSymbol(qname.getNamespaceURI()); ! ref = new ElementValue((byte) type, collectionId, sym, nsSym); ! } ! boolean exceptionOcurred = false; ! try { ! lock.acquire(Lock.READ_LOCK); ! is = elementsDb.getAsStream(ref); ! } catch (LockException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "failed to acquire lock", ! e); ! // jmv: dis = null; ! exceptionOcurred = true; ! } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "io exception while reading elements for " ! + qname, ! e); ! // jmv: dis = null; ! exceptionOcurred = true; ! } finally { ! lock.release(); ! } ! // jmv: if (dis == null) ! // wolf: dis == null if no matching element has been found in the index ! if (is == null || exceptionOcurred) ! continue; ! try { ! while (is.available() > 0) { ! docId = is.readInt(); ! len = is.readInt(); ! if ((doc = docs.getDoc(docId)) == null) { ! is.skip(len * 4); ! continue; ! } ! gid = 0; ! for (int k = 0; k < len; k++) { ! gid = gid + is.readLong(); ! p = new NodeProxy(doc, gid, nodeType, StorageAddress.read(is)); ! if(selector == null || selector.match(p)) ! result.add(p, len); ! } ! } ! } catch (EOFException e) { ! } catch (IOException e) { ! LOG.warn( ! "findElementsByTagName(byte, DocumentSet, QName, NodeSelector) - " ! + "unexpected io error", ! e); ! } } // result.sort(); *************** *** 1377,1381 **** */ public NodeList getRange(final Document doc, final long first, final long last) { ! NodeListImpl result = new NodeListImpl((int) (last - first)); for (long gid = first; gid <= last; gid++) { result.add(objectWith(doc, gid)); --- 1378,1382 ---- */ public NodeList getRange(final Document doc, final long first, final long last) { ! NodeListImpl result = new NodeListImpl((int) (last - first + 1)); for (long gid = first; gid <= last; gid++) { result.add(objectWith(doc, gid)); *************** *** 1642,1723 **** } ! // drop element-index ! short collectionId = doc.getCollection().getId(); ! Value ref = new ElementValue(collectionId); ! IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); ! Lock lock = elementsDb.getLock(); ! try { ! lock.acquire(Lock.WRITE_LOCK); ! ArrayList elements = elementsDb.findKeys(query); ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + "found " ! + elements.size() ! + " elements."); ! } ! ! Value key; ! Value value; ! byte[] data; ! // byte[] ndata; ! VariableByteArrayInput is; ! VariableByteOutputStream os; ! int len; ! int docId; ! long delta; ! long address; ! boolean changed; ! for (int i = 0; i < elements.size(); i++) { ! key = (Value) elements.get(i); ! value = elementsDb.get(key); ! data = value.getData(); ! is = new VariableByteArrayInput(data); ! os = new VariableByteOutputStream(); ! changed = false; ! try { ! while (is.available() > 0) { ! docId = is.readInt(); ! len = is.readInt(); ! if (docId != doc.getDocId()) { ! // copy data to new buffer ! os.writeInt(docId); ! os.writeInt(len); ! for (int j = 0; j < len; j++) { ! delta = is.readLong(); ! address = StorageAddress.read(is); ! os.writeLong(delta); ! StorageAddress.write(address, os); ! } ! } else { ! changed = true; ! // skip ! is.skip(len * 4); ! } ! } ! } catch (EOFException e) { ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument(String) - " ! + "eof: " ! + is.available(), e); ! } ! } ! if (changed) { ! if (elementsDb.put(key, os.data()) < 0) ! if (LOG.isDebugEnabled()) { ! LOG.debug("removeDocument() - " ! + "could not save element"); ! } ! } ! } ! } catch (LockException e) { ! LOG.warn("removeDocument(String) - " ! + "could not acquire lock on elements", e); ! } catch (TerminatedException e) { ! LOG.warn("method terminated", e); ! } finally { ! lock.release(); ! } ! ! ((NativeTextEngine) textEngine).removeDocument(doc); if (LOG.isDebugEnabled()) { LOG.debug("removeDocument() - " + "removing dom"); --- 1643,1648 ---- } ! elementIndex.dropIndex(doc); ! textEngine.removeDocument(doc); if (LOG.isDebugEnabled()) { LOG.debug("removeDocument() - " + "removing dom"); *************** *** 1732,1736 **** .run(); ! ref = new NodeRef(doc.getDocId()); final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); new DOMTransaction(this, domDb) { --- 1657,1661 ---- .run(); ! NodeRef ref = new NodeRef(doc.getDocId()); final IndexQuery idx = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); new DOMTransaction(this, domDb) { *************** *** 1753,1762 **** .run(); freeDocument(doc.getDocId()); - } catch (IOException ioe) { - ioe.printStackTrace(); - LOG.warn("removeDocument(String) - " + ioe); - } catch (BTreeException bte) { - bte.printStackTrace(); - LOG.warn("removeDocument(String) - " + bte); } catch (ReadOnlyException e) { LOG.warn("removeDocument(String) - " + DATABASE_IS_READ_ONLY); --- 1678,1681 ---- *************** *** 1898,1901 **** --- 1817,1873 ---- } + public void moveResource(DocumentImpl doc, Collection destination, String newName) + throws PermissionDeniedException, LockException { + if (readOnly) + throw new PermissionDeniedException(DATABASE_IS_READ_ONLY); + Collection collection = doc.getCollection(); + if(!collection.getPermissions().validate(user, Permission.WRITE)) + throw new PermissionDeniedException("Insufficient privileges to move resource " + + doc.getFileName()); + if(newName == null) { + int p = doc.getFileName().lastIndexOf('/'); + newName = doc.getFileName().substring(p + 1); + } + Lock lock = null; + try { + lock = collectionsDb.getLock(); + lock.acquire(Lock.WRITE_LOCK); + // check if the move would overwrite a collection + if(getCollection(destination.getName() + '/' + newName) != null) + throw new PermissionDeniedException("A resource can not replace an existing collection"); + DocumentImpl oldDoc = destination.getDocument(newName); + if(oldDoc != null) { + if(!destination.getPermissions().validate(user, Permission.UPDATE)) + throw new PermissionDeniedException("Resource with same name exists in target " + + "collection and update is denied"); + if(!oldDoc.getPermissions().validate(user, Permission.UPDATE)) + throw new PermissionDeniedException("Resource with same name exists in target " + + "collection and update is denied"); + collection.removeDocument(this, oldDoc.getFileName()); + } else + if(!destination.getPermissions().validate(user, Permission.WRITE)) + throw new PermissionDeniedException("Insufficient privileges on target collection " + + destination.getName()); + collection.unlinkDocument(doc); + elementIndex.dropIndex(doc); + textEngine.removeDocument(doc); + saveCollection(collection); + + doc.setFileName(destination.getName() + '/' + newName); + destination.addDocument(this, doc); + doc.setCollection(destination); + + // reindexing + reindex(doc); + saveCollection(destination); + } catch (TriggerException e) { + throw new PermissionDeniedException(e.getMessage()); + } catch (ReadOnlyException e) { + throw new PermissionDeniedException(e.getMessage()); + } finally { + lock.release(); + } + } + public void moveCollection(Collection collection, Collection destination, String newName) throws PermissionDeniedException, LockException { *************** *** 1910,1917 **** --- 1882,1900 ---- throw new PermissionDeniedException("Insufficient privileges on target collection " + destination.getName()); + if(newName == null) { + int p = collection.getName().lastIndexOf('/'); + newName = collection.getName().substring(p + 1); + } + if(newName.indexOf('/') > -1) + throw new PermissionDeniedException("New collection name is illegal (may not contain a '/')"); Lock lock = null; try { lock = collectionsDb.getLock(); lock.acquire(Lock.WRITE_LOCK); + // check if another collection with the same name exists at the destination + Collection old = getCollection(destination.getName() + '/' + newName); + if(old != null) + removeCollection(old.getName()); + String name = collection.getName(); Collection parent = collection.getParent(this); Index: NativeElementIndex.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeElementIndex.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** NativeElementIndex.java 28 May 2004 10:54:18 -0000 1.26 --- NativeElementIndex.java 2 Jun 2004 11:34:35 -0000 1.27 *************** *** 50,53 **** --- 50,54 ---- import org.exist.util.ProgressIndicator; import org.exist.util.ReadOnlyException; + import org.exist.xquery.TerminatedException; public class NativeElementIndex extends ElementIndex { *************** *** 95,98 **** --- 96,182 ---- } + public void dropIndex(DocumentImpl doc) throws ReadOnlyException { + // drop element-index + short collectionId = doc.getCollection().getId(); + Value ref = new ElementValue(collectionId); + IndexQuery query = new IndexQuery(IndexQuery.TRUNC_RIGHT, ref); + Lock lock = dbElement.getLock(); + try { + lock.acquire(Lock.WRITE_LOCK); + ArrayList elements = dbElement.findKeys(query); + if (LOG.isDebugEnabled()) { + LOG.debug("removeDocument() - " + + "found " + + elements.size() + + " elements."); + } + + Value key; + Value value; + byte[] data; + // byte[] ndata; + VariableByteArrayInput is; + VariableByteOutputStream os; + int len; + int docId; + long delta; + long address; + boolean changed; + for (int i = 0; i < elements.size(); i++) { + key = (Value) elements.get(i); + value = dbElement.get(key); + data = value.getData(); + is = new VariableByteArrayInput(data); + os = new VariableByteOutputStream(); + changed = false; + try { + while (is.available() > 0) { + docId = is.readInt(); + len = is.readInt(); + if (docId != doc.getDocId()) { + // copy data to new buffer + os.writeInt(docId); + os.writeInt(len); + for (int j = 0; j < len; j++) { + delta = is.readLong(); + address = StorageAddress.read(is); + os.writeLong(delta); + StorageAddress.write(address, os); + } + } else { + changed = true; + // skip + is.skip(len * 4); + } + } + } catch (EOFException e) { + if (LOG.isDebugEnabled()) { + LOG.debug("removeDocument(String) - eof", e); + } + } catch (IOException e) { + LOG.warn("removeDocument(String) " + e.getMessage(), e); + } + if (changed) { + if (dbElement.put(key, os.data()) < 0) + if (LOG.isDebugEnabled()) { + LOG.debug("removeDocument() - " + + "could not save element"); + } + } + } + } catch (LockException e) { + LOG.warn("removeDocument(String) - " + + "could not acquire lock on elements", e); + } catch (TerminatedException e) { + LOG.warn("method terminated", e); + } catch (BTreeException e) { + LOG.warn(e.getMessage(), e); + } catch (IOException e) { + LOG.warn(e.getMessage(), e); + } finally { + lock.release(); + } + } + public void reindex(DocumentImpl oldDoc, NodeImpl node) { if (elementIds.size() == 0) Index: DBBroker.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/DBBroker.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** DBBroker.java 28 May 2004 10:54:18 -0000 1.30 --- DBBroker.java 2 Jun 2004 11:34:35 -0000 1.31 *************** *** 445,448 **** --- 445,451 ---- throws PermissionDeniedException, LockException; + public abstract void moveResource(DocumentImpl doc, Collection destination, String newName) + throws PermissionDeniedException, LockException; + public void sync() { /* Index: NativeTextEngine.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/NativeTextEngine.java,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** NativeTextEngine.java 28 May 2004 10:54:18 -0000 1.52 --- NativeTextEngine.java 2 Jun 2004 11:34:35 -0000 1.53 *************** *** 660,666 **** } } catch (EOFException e) { ! LOG.debug(e.getMessage(), e); } catch (IOException e) { ! LOG.debug(e.getMessage(), e); } if (changed) { --- 660,666 ---- } } catch (EOFException e) { ! // LOG.debug(e.getMessage(), e); } catch (IOException e) { ! // LOG.debug(e.getMessage(), e); } if (changed) { |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:45
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/store In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/storage/store Modified Files: BFile.java Log Message: Improved locking to handle concurrent XUpdates. Index: BFile.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/BFile.java,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** BFile.java 28 May 2004 10:54:20 -0000 1.23 --- BFile.java 2 Jun 2004 11:34:36 -0000 1.24 *************** *** 401,405 **** final long p = findValue(key); if (p == KEY_NOT_FOUND) { - LOG.debug("key not found"); return null; } --- 401,404 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:45
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/xquery/functions Modified Files: FunDoc.java ExtCollection.java ExtDocument.java Log Message: Improved locking to handle concurrent XUpdates. Index: ExtDocument.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/ExtDocument.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExtDocument.java 28 May 2004 10:54:09 -0000 1.3 --- ExtDocument.java 2 Jun 2004 11:34:36 -0000 1.4 *************** *** 31,43 **** import org.exist.dom.ExtArrayNodeSet; import org.exist.dom.NodeProxy; - import org.exist.dom.NodeSet; import org.exist.dom.QName; import org.exist.security.PermissionDeniedException; import org.exist.xquery.Cardinality; import org.exist.xquery.Dependency; import org.exist.xquery.Function; import org.exist.xquery.FunctionSignature; - import org.exist.xquery.XQueryContext; import org.exist.xquery.XPathException; import org.exist.xquery.value.Item; import org.exist.xquery.value.Sequence; --- 31,43 ---- import org.exist.dom.ExtArrayNodeSet; import org.exist.dom.NodeProxy; import org.exist.dom.QName; import org.exist.security.PermissionDeniedException; + import org.exist.util.LockException; import org.exist.xquery.Cardinality; import org.exist.xquery.Dependency; 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; *************** *** 96,104 **** throws XPathException { DocumentSet docs = null; if (getArgumentCount() == 0) { ! if(cached != null) ! return cached; ! docs = new DocumentSet(); ! context.getBroker().getAllDocuments(docs); } else { List args = getParameterValues(contextSequence, contextItem); --- 96,108 ---- throws XPathException { DocumentSet docs = null; + Sequence result = null; if (getArgumentCount() == 0) { ! if(cached != null) { ! result = cached; ! docs = cached.getDocumentSet(); ! } else { ! docs = new DocumentSet(); ! context.getBroker().getAllDocuments(docs); ! } } else { List args = getParameterValues(contextSequence, contextItem); *************** *** 106,132 **** if(cachedArgs != null) cacheIsValid = compareArguments(cachedArgs, args); ! if(cacheIsValid) ! return cached; ! docs = new DocumentSet(); ! for(int i = 0; i < args.size(); i++) { ! String next = (String)args.get(i); ! if(next.length() == 0) ! throw new XPathException("Invalid argument to fn:doc function: empty string is not allowed here."); ! if(next.charAt(0) != '/') ! next = context.getBaseURI() + '/' + next; ! try { ! DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(next); ! if(doc != null) ! docs.add(doc); ! } catch (PermissionDeniedException e) { ! throw new XPathException("Permission denied: unable to load document " + next); } } - cachedArgs = args; } ! NodeSet result = new ExtArrayNodeSet(docs.getLength(), 1); ! for (Iterator i = docs.iterator(); i.hasNext();) { ! result.add(new NodeProxy((DocumentImpl) i.next(), -1)); ! } cached = result; return result; --- 110,150 ---- if(cachedArgs != null) cacheIsValid = compareArguments(cachedArgs, args); ! if(cacheIsValid) { ! result = cached; ! docs = cached.getDocumentSet(); ! } else { ! docs = new DocumentSet(); ! for(int i = 0; i < args.size(); i++) { ! String next = (String)args.get(i); ! if(next.length() == 0) ! throw new XPathException("Invalid argument to fn:doc function: empty string is not allowed here."); ! if(next.charAt(0) != '/') ! next = context.getBaseURI() + '/' + next; ! try { ! DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(next); ! if(doc != null) { ! docs.add(doc); ! } ! } catch (PermissionDeniedException e) { ! throw new XPathException("Permission denied: unable to load document " + next); ! } } + cachedArgs = args; } } ! try { ! docs.lock(false); ! // wait for pending updates ! if(result == null) { ! result = new ExtArrayNodeSet(docs.getLength(), 1); ! for (Iterator i = docs.iterator(); i.hasNext();) { ! result.add(new NodeProxy((DocumentImpl) i.next(), -1)); ! } ! } ! } catch (LockException e) { ! throw new XPathException(getASTNode(), "Could not acquire lock on document set."); ! } finally { ! docs.unlock(false); ! } cached = result; return result; Index: FunDoc.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/FunDoc.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** FunDoc.java 28 May 2004 10:54:09 -0000 1.3 --- FunDoc.java 2 Jun 2004 11:34:36 -0000 1.4 *************** *** 27,30 **** --- 27,32 ---- import org.exist.dom.QName; import org.exist.security.PermissionDeniedException; + import org.exist.util.Lock; + import org.exist.util.LockException; import org.exist.xquery.Cardinality; import org.exist.xquery.Dependency; *************** *** 90,100 **** if (path.charAt(0) != '/') path = context.getBaseURI() + '/' + path; ! if(path.equals(cachedPath) && cachedNode != null) ! return cachedNode; try { ! DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(path); cachedPath = path; - if(doc == null) - return Sequence.EMPTY_SEQUENCE; cachedNode = new NodeProxy(doc, -1); return cachedNode; --- 92,117 ---- if (path.charAt(0) != '/') path = context.getBaseURI() + '/' + path; ! Lock dlock = null; ! if(path.equals(cachedPath) && cachedNode != null) { ! dlock = cachedNode.doc.getUpdateLock(); ! try { ! // wait for pending updates ! dlock.acquire(Lock.READ_LOCK); ! return cachedNode; ! } catch (LockException e) { ! throw new XPathException(getASTNode(), "Failed to acquire lock on document " + path); ! } finally { ! dlock.release(Lock.READ_LOCK); ! } ! } ! try { ! DocumentImpl doc = (DocumentImpl) context.getBroker().getDocument(path); ! if(doc == null) ! return Sequence.EMPTY_SEQUENCE; ! // wait for currently pending updates ! dlock = doc.getUpdateLock(); ! dlock.acquire(Lock.READ_LOCK); cachedPath = path; cachedNode = new NodeProxy(doc, -1); return cachedNode; *************** *** 102,105 **** --- 119,126 ---- throw new XPathException( "Permission denied: unable to load document " + path); + } catch (LockException e) { + throw new XPathException(getASTNode(), "Failed to acquire read lock on document " + path); + } finally { + if(dlock != null) dlock.release(Lock.READ_LOCK); } } Index: ExtCollection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/ExtCollection.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExtCollection.java 28 May 2004 10:54:09 -0000 1.3 --- ExtCollection.java 2 Jun 2004 11:34:36 -0000 1.4 *************** *** 34,37 **** --- 34,39 ---- import org.exist.dom.QName; import org.exist.security.PermissionDeniedException; + import org.exist.util.Lock; + import org.exist.util.LockException; import org.exist.xquery.Cardinality; import org.exist.xquery.Function; *************** *** 106,111 **** } NodeSet result = new ExtArrayNodeSet(docs.getLength(), 1); for (Iterator i = docs.iterator(); i.hasNext();) { ! result.add(new NodeProxy((DocumentImpl) i.next(), -1)); } cached = result; --- 108,124 ---- } NodeSet result = new ExtArrayNodeSet(docs.getLength(), 1); + Lock dlock; + DocumentImpl doc; for (Iterator i = docs.iterator(); i.hasNext();) { ! doc = (DocumentImpl)i.next(); ! dlock = doc.getUpdateLock(); ! try { ! dlock.acquire(Lock.READ_LOCK); ! result.add(new NodeProxy(doc, -1)); ! } catch (LockException e) { ! LOG.info("Could not acquire read lock on document " + doc.getFileName()); ! } finally { ! dlock.release(Lock.READ_LOCK); ! } } cached = result; |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:34:44
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/collections In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3696/src/org/exist/collections Modified Files: Collection.java Log Message: Improved locking to handle concurrent XUpdates. Index: Collection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/collections/Collection.java,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** Collection.java 25 May 2004 12:52:00 -0000 1.25 --- Collection.java 2 Jun 2004 11:34:35 -0000 1.26 *************** *** 175,178 **** --- 175,182 ---- } + public void unlinkDocument(DocumentImpl doc) { + documents.remove(doc.getFileName()); + } + /** * Return an iterator over all subcollections. *************** *** 542,546 **** } } ! /** * Remove the specified document from the collection. --- 546,550 ---- } } ! /** * Remove the specified document from the collection. *************** *** 663,666 **** --- 667,674 ---- throw new PermissionDeniedException( "Document exists and update is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 758,763 **** document.setFileName(oldDoc.getFileName()); } addDocument(broker, document); - document.setWriteLock(true); indexer.setValidating(false); if (trigger != null) --- 766,771 ---- document.setFileName(oldDoc.getFileName()); } + document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); indexer.setValidating(false); if (trigger != null) *************** *** 795,799 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 803,807 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 835,838 **** --- 843,850 ---- throw new PermissionDeniedException( "Document exists and update is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 930,934 **** document.setFileName(oldDoc.getFileName()); } ! document.setWriteLock(true); addDocument(broker, document); --- 942,946 ---- document.setFileName(oldDoc.getFileName()); } ! document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); *************** *** 980,984 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 992,996 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 1018,1021 **** --- 1030,1037 ---- throw new PermissionDeniedException( "document exists and update " + "is not allowed"); + if (!(getPermissions().validate(broker.getUser(), Permission.UPDATE) || + getPermissions().validate(broker.getUser(), Permission.WRITE))) + throw new PermissionDeniedException( + "Document exists and update is not allowed for the collection"); // no: do we have write permissions? } else if (!getPermissions().validate(broker.getUser(), *************** *** 1098,1102 **** document.setFileName(oldDoc.getFileName()); } ! document.setWriteLock(true); addDocument(broker, document); --- 1114,1118 ---- document.setFileName(oldDoc.getFileName()); } ! document.getUpdateLock().acquire(Lock.WRITE_LOCK); addDocument(broker, document); *************** *** 1129,1133 **** } } finally { ! document.setWriteLock(false); } broker.deleteObservers(); --- 1145,1149 ---- } } finally { ! document.getUpdateLock().release(Lock.WRITE_LOCK); } broker.deleteObservers(); *************** *** 1189,1194 **** return blob; } finally { - if(blob != null) - blob.setWriteLock(false); lock.release(); } --- 1205,1208 ---- *************** *** 1278,1282 **** path = path.substring(path.lastIndexOf('/') + 1); childDoc.setFileName(getName() + '/' + path); - LOG.debug("Moved " + childDoc.getFileName()); newMap.put(childDoc.getFileName(), childDoc); } --- 1292,1295 ---- |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:33:42
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3520/src/org/exist/xquery/functions/util Modified Files: ModuleImpl.java Added Files: LockFunction.java SharedLockFunction.java ExclusiveLockFunction.java Log Message: Added new functions exclusive-lock and shared-lock. --- NEW FILE: LockFunction.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * 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. * * $Id: LockFunction.java,v 1.1 2004/06/02 11:33:30 wolfgang_m Exp $ */ package org.exist.xquery.functions.util; import org.exist.dom.DocumentSet; import org.exist.util.LockException; 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; public abstract class LockFunction extends Function { protected boolean exclusive = false; protected LockFunction(XQueryContext context, FunctionSignature signature, boolean exclusive) { super(context, signature); this.exclusive = exclusive; } /* (non-Javadoc) * @see org.exist.xquery.Function#eval(org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) */ public Sequence eval(Sequence contextSequence, Item contextItem) throws XPathException { Sequence docsArg = getArgument(0).eval(contextSequence, contextItem); DocumentSet docs = docsArg.getDocumentSet(); try { docs.lock(exclusive); return getArgument(1).eval(contextSequence, contextItem); } catch (LockException e) { throw new XPathException(getASTNode(), "Could not lock document set", e); } finally { docs.unlock(exclusive); } } /* (non-Javadoc) * @see org.exist.xquery.Function#getCardinality() */ public int getCardinality() { return getArgument(1).getCardinality(); } /* (non-Javadoc) * @see org.exist.xquery.Function#returnsType() */ public int returnsType() { return getArgument(1).returnsType(); } } Index: ModuleImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/ModuleImpl.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ModuleImpl.java 28 May 2004 10:54:21 -0000 1.6 --- ModuleImpl.java 2 Jun 2004 11:33:30 -0000 1.7 *************** *** 44,48 **** new FunctionDef(CollectionName.signature, CollectionName.class), new FunctionDef(LogFunction.signature, LogFunction.class), ! new FunctionDef(CatchFunction.signature, CatchFunction.class) }; --- 44,50 ---- new FunctionDef(CollectionName.signature, CollectionName.class), new FunctionDef(LogFunction.signature, LogFunction.class), ! new FunctionDef(CatchFunction.signature, CatchFunction.class), ! new FunctionDef(ExclusiveLockFunction.signature, ExclusiveLockFunction.class), ! new FunctionDef(SharedLockFunction.signature, SharedLockFunction.class) }; --- NEW FILE: ExclusiveLockFunction.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * 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. * * $Id: ExclusiveLockFunction.java,v 1.1 2004/06/02 11:33:30 wolfgang_m Exp $ */ package org.exist.xquery.functions.util; import org.exist.dom.QName; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; public class ExclusiveLockFunction extends LockFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("exclusive-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts an exclusive lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + "its completition.", new SequenceType[] { new SequenceType(Type.NODE, Cardinality.ONE_OR_MORE), new SequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE) }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public ExclusiveLockFunction(XQueryContext context) { super(context, signature, true); } } --- NEW FILE: SharedLockFunction.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * 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. * * $Id: SharedLockFunction.java,v 1.1 2004/06/02 11:33:30 wolfgang_m Exp $ */ package org.exist.xquery.functions.util; import org.exist.dom.QName; import org.exist.xquery.Cardinality; import org.exist.xquery.FunctionSignature; import org.exist.xquery.XQueryContext; import org.exist.xquery.value.SequenceType; import org.exist.xquery.value.Type; public class SharedLockFunction extends LockFunction { public final static FunctionSignature signature = new FunctionSignature( new QName("shared-lock", ModuleImpl.NAMESPACE_URI, ModuleImpl.PREFIX), "Puts a shared lock on the owner documents of all nodes in the first argument, $a. " + "Then calls the expression in the second argument, $b and releases the acquired locks after" + "its completition.", new SequenceType[] { new SequenceType(Type.NODE, Cardinality.ONE_OR_MORE), new SequenceType(Type.ITEM, Cardinality.ZERO_OR_MORE) }, new SequenceType(Type.ITEM, Cardinality.EMPTY)); public SharedLockFunction(XQueryContext context) { super(context, signature, false); } } |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:31:30
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3160/src/org/exist/http/webdav/methods Modified Files: Move.java Log Message: Added move method for resources. Index: Move.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/http/webdav/methods/Move.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Move.java 25 May 2004 12:52:02 -0000 1.1 --- Move.java 2 Jun 2004 11:31:20 -0000 1.2 *************** *** 59,65 **** HttpServletResponse response, Collection collection, DocumentImpl resource) throws ServletException, IOException { ! if(resource != null) { ! response.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED, ! "Move is not yet implemented for resources"); return; } --- 59,64 ---- HttpServletResponse response, Collection collection, DocumentImpl resource) throws ServletException, IOException { ! if(collection == null) { ! response.sendError(HttpServletResponse.SC_NOT_FOUND, "Resource or collection not found"); return; } *************** *** 83,91 **** response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); } ! LOG.debug("Moving " + collection.getName() + " to " + path); ! moveCollection(user, response, collection, path); } ! private void moveCollection(User user, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { if(collection.getName().equals(destination)) { --- 82,92 ---- response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Malformed URL in destination header"); } ! if(resource != null) ! moveResource(user, request, response, resource, path); ! else ! moveCollection(user, request, response, collection, path); } ! private void moveCollection(User user, HttpServletRequest request, HttpServletResponse response, Collection collection, String destination) throws ServletException, IOException { if(collection.getName().equals(destination)) { *************** *** 97,105 **** try { broker = pool.get(user); Collection destCollection = broker.getCollection(destination); if(destCollection != null) { ! response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, "Destination collection exists"); ! return; } int p = destination.lastIndexOf('/'); --- 98,112 ---- try { broker = pool.get(user); + boolean replaced = false; Collection destCollection = broker.getCollection(destination); if(destCollection != null) { ! boolean overwrite = overwrite(request); ! if(!overwrite) { ! response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, "Destination collection exists"); ! return; ! } ! broker.removeCollection(destCollection.getName()); ! replaced = true; } int p = destination.lastIndexOf('/'); *************** *** 119,123 **** } broker.moveCollection(collection, parent, newCollectionName); ! response.setStatus(HttpServletResponse.SC_CREATED); } catch (EXistException e) { throw new ServletException(e.getMessage(), e); --- 126,180 ---- } broker.moveCollection(collection, parent, newCollectionName); ! if(replaced) ! response.setStatus(HttpServletResponse.SC_NO_CONTENT); ! else ! response.setStatus(HttpServletResponse.SC_CREATED); ! } catch (EXistException e) { ! throw new ServletException(e.getMessage(), e); ! } catch (PermissionDeniedException e) { ! response.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage()); ! } catch (LockException e) { ! response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage()); ! } finally { ! pool.release(broker); ! } ! } ! ! private void moveResource(User user, HttpServletRequest request, HttpServletResponse response, DocumentImpl resource, ! String destination) ! throws ServletException, IOException { ! int p = destination.lastIndexOf('/'); ! if(p < 0) { ! response.sendError(HttpServletResponse.SC_BAD_REQUEST, ! "Bad destination: " + destination); ! return; ! } ! String newResourceName = destination.substring(p + 1); ! destination = destination.substring(0, p); ! boolean replaced = false; ! DBBroker broker = null; ! try { ! broker = pool.get(user); ! Collection destCollection = broker.getCollection(destination); ! if(destCollection == null) { ! response.sendError(HttpServletResponse.SC_CONFLICT, ! "Destination collection not found"); ! return; ! } ! DocumentImpl oldDoc = destCollection.getDocument(newResourceName); ! if(oldDoc != null) { ! boolean overwrite = overwrite(request); ! if(!overwrite) { ! response.sendError(HttpServletResponse.SC_PRECONDITION_FAILED, ! "Destination resource exists and overwrite is not allowed"); ! return; ! } ! replaced = true; ! } ! broker.moveResource(resource, destCollection, newResourceName); ! if(replaced) ! response.setStatus(HttpServletResponse.SC_NO_CONTENT); ! else ! response.setStatus(HttpServletResponse.SC_CREATED); } catch (EXistException e) { throw new ServletException(e.getMessage(), e); *************** *** 130,132 **** --- 187,196 ---- } } + + private boolean overwrite(HttpServletRequest request) { + String header = request.getHeader("Overwrite"); + if(header == null) + return false; + return header.equals("T"); + } } |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:30:35
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2956/src/org/exist/client Modified Files: ClientFrame.java Log Message: Added support for moving collections or resources, and reindexing collections. Index: ClientFrame.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/client/ClientFrame.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ClientFrame.java 3 May 2004 13:05:04 -0000 1.18 --- ClientFrame.java 2 Jun 2004 11:30:24 -0000 1.19 *************** *** 52,55 **** --- 52,56 ---- import java.util.Enumeration; import java.util.Properties; + import java.util.Vector; import javax.swing.BorderFactory; *************** *** 97,101 **** --- 98,104 ---- import org.exist.storage.serializers.EXistOutputKeys; import org.exist.xmldb.CollectionImpl; + import org.exist.xmldb.CollectionManagementServiceImpl; import org.exist.xmldb.EXistResource; + import org.exist.xmldb.IndexQueryService; import org.exist.xmldb.UserManagementService; import org.gnu.readline.Readline; *************** *** 169,172 **** --- 172,176 ---- setJMenuBar(createMenuBar()); + // create the toolbar JToolBar toolbar = new JToolBar(); URL url = getClass().getResource("icons/Up24.gif"); *************** *** 276,279 **** --- 280,284 ---- toolbar.add(button); + // the split pane separates the resource view table from the shell JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT); split.setResizeWeight(0.5); *************** *** 308,311 **** --- 313,317 ---- statusbar = new JLabel(); + statusbar.setMinimumSize(new Dimension(400, 15)); statusbar.setBorder(BorderFactory .createBevelBorder(BevelBorder.LOWERED)); *************** *** 350,353 **** --- 356,377 ---- fileMenu.add(item); + item = new JMenuItem("Move", KeyEvent.VK_M); + item.setAccelerator(KeyStroke.getKeyStroke("control M")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + moveAction(e); + } + }); + fileMenu.add(item); + + item = new JMenuItem("Reindex collection", KeyEvent.VK_R); + item.setAccelerator(KeyStroke.getKeyStroke("control R")); + item.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + reindexAction(e); + } + }); + fileMenu.add(item); + item = new JMenuItem("Resource properties"); item.setAccelerator(KeyStroke.getKeyStroke("control P")); *************** *** 693,700 **** "Are you sure you want to remove the selected " + "resources?", "Confirm deletion", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { - final JFrame parent = this; Runnable removeTask = new Runnable() { public void run() { ! ProgressMonitor monitor = new ProgressMonitor(parent, "Remove Progress", "", 1, rows.length); monitor.setMillisToDecideToPopup(500); --- 717,723 ---- "Are you sure you want to remove the selected " + "resources?", "Confirm deletion", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { Runnable removeTask = new Runnable() { public void run() { ! ProgressMonitor monitor = new ProgressMonitor(ClientFrame.this, "Remove Progress", "", 1, rows.length); monitor.setMillisToDecideToPopup(500); *************** *** 737,740 **** --- 760,862 ---- } + private void moveAction(ActionEvent ev) { + final int[] rows = fileman.getSelectedRows(); + final Object[] res = new Object[rows.length]; + for (int i = 0; i < rows.length; i++) { + res[i] = resources.getValueAt(rows[i], 3); + } + String[] collections = null; + try { + Collection root = client.getCollection("/db"); + Vector collectionsVec = getCollections(root, new Vector()); + collections = new String[collectionsVec.size()]; + collectionsVec.toArray(collections); + } catch (XMLDBException e) { + showErrorMessage(e.getMessage(), e); + return; + } + Object val = JOptionPane.showInputDialog(this, "Select target collection", "Move", JOptionPane.QUESTION_MESSAGE, + null, collections, collections[0]); + if(val == null) + return; + final String destinationPath = (String)val; + Runnable moveTask = new Runnable() { + public void run() { + try { + CollectionManagementServiceImpl service = (CollectionManagementServiceImpl) + client.current.getService("CollectionManagementService", "1.0"); + for(int i = 0; i < res.length; i++) { + setStatus("Moving " + res[i].toString() + " to " + destinationPath + "..."); + if(res[i] instanceof InteractiveClient.CollectionName) + service.move(res[i].toString(), destinationPath, null); + else + service.moveResource(res[i].toString(), destinationPath, null); + } + client.reloadCollection(); + } catch (XMLDBException e) { + showErrorMessage(e.getMessage(), e); + } + setStatus("Move completed."); + } + }; + new Thread(moveTask).start(); + } + + private Vector getCollections(Collection root, Vector collectionsList) + throws XMLDBException { + collectionsList.addElement(root.getName()); + String[] childCollections= root.listChildCollections(); + Collection child; + for (int i= 0; i < childCollections.length; i++) { + child= root.getChildCollection(childCollections[i]); + getCollections(child, collectionsList); + } + return collectionsList; + } + + private void reindexAction(ActionEvent ev) { + final int[] rows = fileman.getSelectedRows(); + Object[] res; + if(rows.length == 0) { + res = new Object[1]; + res[0] = new InteractiveClient.CollectionName(client.path); + } else { + res = new Object[rows.length]; + for (int i = 0; i < rows.length; i++) { + res[i] = resources.getValueAt(rows[i], 3); + if(!(res[i] instanceof InteractiveClient.CollectionName)) { + JOptionPane.showMessageDialog(this, "Only collections can be reindexed.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + } + } + + if (JOptionPane.showConfirmDialog(this, + "Are you sure you want to reindex the selected collections \nand all resources below them?", + "Confirm reindex", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) { + final Object collections[] = res; + Runnable reindexThread = new Runnable() { + public void run() { + ClientFrame.this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); + IndexQueryService service; + try { + service = (IndexQueryService) + client.current.getService("IndexQueryService", "1.0"); + for(int i = 0; i < collections.length; i++) { + InteractiveClient.CollectionName next = (InteractiveClient.CollectionName)collections[i]; + setStatus("Reindexing collection " + next + "..."); + service.reindexCollection(next.toString()); + } + setStatus("Reindex completed."); + } catch (XMLDBException e) { + showErrorMessage(e.getMessage(), e); + } + ClientFrame.this.setCursor(Cursor.getDefaultCursor()); + } + }; + new Thread(reindexThread).start(); + } + } + private void uploadAction(ActionEvent ev) { String dir = properties.getProperty("working-dir", System |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:30:13
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2800/src/org/exist/dom Modified Files: ElementImpl.java Log Message: Added patch for appendChild (provided by Piotr Kaminski) Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ElementImpl.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** ElementImpl.java 28 May 2004 10:54:14 -0000 1.34 --- ElementImpl.java 2 Jun 2004 11:29:56 -0000 1.35 *************** *** 226,241 **** public Node appendChild(Node child) throws DOMException { DocumentImpl prevDoc = new DocumentImpl(ownerDocument); ! Node node = null; ! if (children == 0) ! node = appendChild(firstChildID(), this, child, true); ! else { ! long last = lastChildID(); ! node = ! appendChild( ! last + 1, ! (NodeImpl) ownerDocument.getNode(last), ! child, ! true); } ownerDocument.broker.update(this); ownerDocument.broker.reindex(prevDoc, ownerDocument, null); --- 226,247 ---- public Node appendChild(Node child) throws DOMException { DocumentImpl prevDoc = new DocumentImpl(ownerDocument); ! long childGid; ! NodeImpl lastNode; ! if (children == 0) { ! childGid = firstChildID(); ! lastNode = this; ! } else { ! childGid = lastChildID() + 1; ! lastNode = getLastNode((NodeImpl)ownerDocument.getNode(childGid - 1)); ! } ! try { ! checkTree(1); ! } catch(EXistException e) { ! throw new DOMException( ! DOMException.INVALID_MODIFICATION_ERR, ! "max. document size exceeded"); } + children++; + Node node = appendChild(childGid, lastNode, child, true); ownerDocument.broker.update(this); ownerDocument.broker.reindex(prevDoc, ownerDocument, null); *************** *** 386,393 **** ns= attr.getNamespaceURI(); prefix = (ns != null && ns.equals("http://www.w3.org/XML/1998/namespace") ? "xml" : attr.getPrefix()); QName attrName = ! new QName( ! attr.getLocalName(), ! ns, prefix); final AttrImpl attrib = new AttrImpl(attrName, attr.getValue()); attrib.setGID(gid); --- 392,399 ---- ns= attr.getNamespaceURI(); prefix = (ns != null && ns.equals("http://www.w3.org/XML/1998/namespace") ? "xml" : attr.getPrefix()); + String name = attr.getLocalName(); + if(name == null) name = attr.getName(); QName attrName = ! new QName(name, ns, prefix); final AttrImpl attrib = new AttrImpl(attrName, attr.getValue()); attrib.setGID(gid); *************** *** 914,921 **** namespace = (String) entry.getValue(); if (prefix.length() == 0) { ! buf.append("xmlns=\""); buf.append(namespace); } else { ! buf.append("xmlns:"); buf.append(prefix); buf.append("=\""); --- 920,927 ---- namespace = (String) entry.getValue(); if (prefix.length() == 0) { ! buf.append(" xmlns=\""); buf.append(namespace); } else { ! buf.append(" xmlns:"); buf.append(prefix); buf.append("=\""); *************** *** 928,932 **** if (nodeName.getNamespaceURI().length() > 0 && (!namespaces.contains(nodeName.getNamespaceURI()))) { ! buf.append("\" xmlns:").append(nodeName.getPrefix()).append("=\""); buf.append(nodeName.getNamespaceURI()); buf.append("\" "); --- 934,938 ---- if (nodeName.getNamespaceURI().length() > 0 && (!namespaces.contains(nodeName.getNamespaceURI()))) { ! buf.append(" xmlns:").append(nodeName.getPrefix()).append("=\""); buf.append(nodeName.getNamespaceURI()); buf.append("\" "); |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:28:53
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2591/src/org/exist/xmldb Modified Files: IndexQueryService.java RemoteIndexQueryService.java CollectionImpl.java RemoteCollectionManagementService.java LocalIndexQueryService.java LocalCollectionManagementService.java Added Files: CollectionManagementServiceImpl.java Log Message: Added support for moving collections or resources, and reindexing collections. Index: LocalCollectionManagementService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollectionManagementService.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** LocalCollectionManagementService.java 5 May 2004 11:14:46 -0000 1.9 --- LocalCollectionManagementService.java 2 Jun 2004 11:28:42 -0000 1.10 *************** *** 1,16 **** ! package org.exist.xmldb; import org.exist.EXistException; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; import org.w3c.dom.Document; ! import org.apache.log4j.Category; ! import org.xmldb.api.base.*; ! import org.xmldb.api.modules.CollectionManagementService; ! public class LocalCollectionManagementService implements CollectionManagementService { protected BrokerPool brokerPool; --- 1,40 ---- ! /* ! * eXist Open Source Native XML Database ! * ! * Copyright (C) 2001-04 Wolfgang M. Meier wol...@ex... ! * ! * This program is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2 of the License, or (at your ! * option) any later version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! * ! * You should have received a copy of the GNU Lesser General Public License ! * along with this program; if not, write to the Free Software Foundation, ! * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! * ! * $Id$ ! */ package org.exist.xmldb; + import org.apache.log4j.Logger; import org.exist.EXistException; + import org.exist.dom.DocumentImpl; import org.exist.security.PermissionDeniedException; import org.exist.security.User; import org.exist.storage.BrokerPool; import org.exist.storage.DBBroker; + import org.exist.util.LockException; import org.w3c.dom.Document; ! import org.xmldb.api.base.Collection; ! import org.xmldb.api.base.ErrorCodes; ! import org.xmldb.api.base.XMLDBException; ! public class LocalCollectionManagementService implements CollectionManagementServiceImpl { ! protected BrokerPool brokerPool; *************** *** 18,23 **** protected User user; ! private static Category LOG = ! Category.getInstance( LocalCollection.class.getName() ); public LocalCollectionManagementService( User user, BrokerPool pool, --- 42,47 ---- protected User user; ! private static Logger LOG = ! Logger.getLogger( LocalCollectionManagementService.class ); public LocalCollectionManagementService( User user, BrokerPool pool, *************** *** 100,103 **** --- 124,191 ---- } + /* (non-Javadoc) + * @see org.exist.xmldb.CollectionManagementServiceImpl#move(org.xmldb.api.base.Collection, org.xmldb.api.base.Collection, java.lang.String) + */ + public void move(String collectionPath, String destinationPath, + String newName) throws XMLDBException { + if(!collectionPath.startsWith("/db")) + collectionPath = parent.getPath() + '/' + collectionPath; + if(!destinationPath.startsWith("/db")) + destinationPath = parent.getPath() + '/' + destinationPath; + DBBroker broker = null; + try { + broker = brokerPool.get(user); + org.exist.collections.Collection collection = broker.getCollection(collectionPath); + if(collection == null) + throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, "Collection " + collectionPath + " not found"); + org.exist.collections.Collection destination = broker.getCollection(destinationPath); + if(destination == null) + throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, "Collection " + destinationPath + " not found"); + broker.moveCollection(collection, destination, newName); + } catch ( EXistException e ) { + e.printStackTrace(); + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + "failed to move collection " + collectionPath, e ); + } catch ( PermissionDeniedException e ) { + throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, + e.getMessage(), e ); + } catch (LockException e) { + throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, + e.getMessage(), e ); + } finally { + brokerPool.release( broker ); + } + } + + public void moveResource(String resourcePath, String destinationPath, + String newName) throws XMLDBException { + if(!resourcePath.startsWith("/db")) + resourcePath = parent.getPath() + '/' + resourcePath; + if(!destinationPath.startsWith("/db")) + destinationPath = parent.getPath() + '/' + destinationPath; + DBBroker broker = null; + try { + broker = brokerPool.get(user); + DocumentImpl doc = (DocumentImpl)broker.getDocument(resourcePath); + if(doc == null) + throw new XMLDBException(ErrorCodes.NO_SUCH_RESOURCE, "Resource " + resourcePath + " not found"); + org.exist.collections.Collection destination = broker.getCollection(destinationPath); + if(destination == null) + throw new XMLDBException(ErrorCodes.NO_SUCH_COLLECTION, "Collection " + destinationPath + " not found"); + broker.moveResource(doc, destination, newName); + } catch ( EXistException e ) { + e.printStackTrace(); + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + "failed to move resource " + resourcePath, e ); + } catch ( PermissionDeniedException e ) { + throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, + e.getMessage(), e ); + } catch (LockException e) { + throw new XMLDBException( ErrorCodes.PERMISSION_DENIED, + e.getMessage(), e ); + } finally { + brokerPool.release( broker ); + } + } public void setCollection( Collection parent ) throws XMLDBException { this.parent = (LocalCollection) parent; --- NEW FILE: CollectionManagementServiceImpl.java --- /* * eXist Open Source Native XML Database * Copyright (C) 2001-04 Wolfgang M. Meier * wol...@ex... * 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. * * $Id: CollectionManagementServiceImpl.java,v 1.5 2004/06/02 11:28:42 wolfgang_m Exp $ */ package org.exist.xmldb; import org.xmldb.api.base.XMLDBException; import org.xmldb.api.modules.CollectionManagementService; /** * Extends the {@link org.xmldb.api.modules.CollectionManagementService} * interface with extensions specific to eXist, in particular moving and copying * collections and resources. * * @author wolf */ public interface CollectionManagementServiceImpl extends CollectionManagementService { public void move(String collection, String destination, String newName) throws XMLDBException; public void moveResource(String resourcePath, String destinationPath, String newName) throws XMLDBException; } Index: IndexQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/IndexQueryService.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** IndexQueryService.java 28 May 2004 10:54:13 -0000 1.2 --- IndexQueryService.java 2 Jun 2004 11:28:42 -0000 1.3 *************** *** 1,2 **** --- 1,23 ---- + /* + * eXist Open Source Native XML Database + * + * Copyright (C) 2001-04 Wolfgang M. Meier wol...@ex... + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ package org.exist.xmldb; *************** *** 5,12 **** --- 26,53 ---- import org.xmldb.api.base.XMLDBException; + /** + * Provides additional methods related to eXist's indexing system. + * + * @author wolf + * + */ public interface IndexQueryService extends Service { + /** + * Reindex the current collection, i.e. the collection from which + * this service has been retrieved. + * + * @throws XMLDBException + */ public void reindexCollection() throws XMLDBException; + /** + * Reindex the collection specified by its path. + * + * @param collectionPath + * @throws XMLDBException + */ + public void reindexCollection(String collectionPath) throws XMLDBException; + public Occurrences[] getIndexedElements(boolean inclusive) throws XMLDBException; Index: RemoteCollectionManagementService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteCollectionManagementService.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RemoteCollectionManagementService.java 21 May 2004 08:32:14 -0000 1.3 --- RemoteCollectionManagementService.java 2 Jun 2004 11:28:42 -0000 1.4 *************** *** 3,14 **** import java.io.IOException; import java.util.Vector; - import org.apache.xmlrpc.*; - import org.w3c.dom.Document; ! import org.xmldb.api.base.*; ! import org.xmldb.api.modules.CollectionManagementService; ! public class RemoteCollectionManagementService implements CollectionManagementService { protected XmlRpcClient client; --- 3,16 ---- import java.io.IOException; import java.util.Vector; ! import org.apache.xmlrpc.XmlRpcClient; ! import org.apache.xmlrpc.XmlRpcException; ! import org.w3c.dom.Document; ! import org.xmldb.api.base.Collection; ! import org.xmldb.api.base.ErrorCodes; ! import org.xmldb.api.base.XMLDBException; ! public class RemoteCollectionManagementService implements CollectionManagementServiceImpl { protected XmlRpcClient client; *************** *** 100,103 **** --- 102,163 ---- } + /* (non-Javadoc) + * @see org.exist.xmldb.CollectionManagementServiceImpl#move(java.lang.String, java.lang.String, java.lang.String) + */ + public void move(String collectionPath, String destinationPath, String newName) throws XMLDBException { + if(!collectionPath.startsWith("/db")) + collectionPath = parent.getPath() + '/' + collectionPath; + if(!destinationPath.startsWith("/db")) + destinationPath = parent.getPath() + '/' + destinationPath; + if(newName == null) { + int p = collectionPath.lastIndexOf(('/')); + newName = collectionPath.substring(p + 1); + } + Vector params = new Vector(); + params.addElement( collectionPath ); + params.addElement( destinationPath ); + params.addElement( newName ); + try { + client.execute( "moveCollection", params ); + } catch ( XmlRpcException xre ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + xre.getMessage(), + xre ); + } catch ( IOException ioe ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + ioe.getMessage(), + ioe); + } + } + + /* (non-Javadoc) + * @see org.exist.xmldb.CollectionManagementServiceImpl#moveResource(java.lang.String, java.lang.String, java.lang.String) + */ + public void moveResource(String resourcePath, String destinationPath, String newName) throws XMLDBException { + if(!resourcePath.startsWith("/db")) + resourcePath = parent.getPath() + '/' + resourcePath; + if(!destinationPath.startsWith("/db")) + destinationPath = parent.getPath() + '/' + destinationPath; + if(newName == null) { + int p = resourcePath.lastIndexOf(('/')); + newName = resourcePath.substring(p + 1); + } + Vector params = new Vector(); + params.addElement( resourcePath ); + params.addElement( destinationPath ); + params.addElement( newName ); + try { + client.execute( "moveResource", params ); + } catch ( XmlRpcException xre ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + xre.getMessage(), + xre ); + } catch ( IOException ioe ) { + throw new XMLDBException( ErrorCodes.VENDOR_ERROR, + ioe.getMessage(), + ioe); + } + } + } Index: LocalIndexQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalIndexQueryService.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LocalIndexQueryService.java 28 May 2004 10:54:13 -0000 1.6 --- LocalIndexQueryService.java 2 Jun 2004 11:28:42 -0000 1.7 *************** *** 1,2 **** --- 1,23 ---- + /* + * eXist Open Source Native XML Database + * + * Copyright (C) 2001-04 Wolfgang M. Meier wol...@ex... + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ package org.exist.xmldb; *************** *** 45,48 **** --- 66,90 ---- } + + /* (non-Javadoc) + * @see org.exist.xmldb.IndexQueryService#reindexCollection(java.lang.String) + */ + public void reindexCollection(String collectionPath) throws XMLDBException { + String path = (collectionPath.startsWith("/db") ? collectionPath : + parent.getPath() + '/' + collectionPath); + DBBroker broker = null; + try { + broker = pool.get(user); + broker.reindex(path); + broker.sync(); + } catch (PermissionDeniedException e) { + throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, e.getMessage(), e); + } catch (EXistException e) { + throw new XMLDBException(ErrorCodes.VENDOR_ERROR, e.getMessage(), e); + } finally { + pool.release(broker); + } + } + /* (non-Javadoc) * @see org.exist.xmldb.IndexQueryService#getIndexedElements(boolean) Index: RemoteIndexQueryService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteIndexQueryService.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RemoteIndexQueryService.java 28 May 2004 10:54:13 -0000 1.5 --- RemoteIndexQueryService.java 2 Jun 2004 11:28:42 -0000 1.6 *************** *** 1,6 **** /* ! * RemoteIndexQueryService.java - Mar 28, 2003 * ! * @author wolf */ package org.exist.xmldb; --- 1,22 ---- /* ! * eXist Open Source Native XML Database ! * ! * Copyright (C) 2001-04 Wolfgang M. Meier wol...@ex... * ! * This program is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2 of the License, or (at your ! * option) any later version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! * ! * You should have received a copy of the GNU Lesser General Public License ! * along with this program; if not, write to the Free Software Foundation, ! * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! * ! * $Id$ */ package org.exist.xmldb; *************** *** 17,26 **** import org.xmldb.api.base.XMLDBException; - /** - * @author wolf - * - * To change this generated comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ public class RemoteIndexQueryService implements IndexQueryService { --- 33,36 ---- *************** *** 41,44 **** --- 51,62 ---- } + + /* (non-Javadoc) + * @see org.exist.xmldb.IndexQueryService#reindexCollection(java.lang.String) + */ + public void reindexCollection(String collectionPath) throws XMLDBException { + throw new XMLDBException(ErrorCodes.NOT_IMPLEMENTED); + } + /* (non-Javadoc) * @see org.exist.xmldb.IndexQueryService#getIndexedElements(boolean) Index: CollectionImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/CollectionImpl.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** CollectionImpl.java 15 Apr 2004 09:24:16 -0000 1.12 --- CollectionImpl.java 2 Jun 2004 11:28:42 -0000 1.13 *************** *** 1,6 **** /* ! * CollectionImpl.java - Aug 4, 2003 * ! * @author wolf */ package org.exist.xmldb; --- 1,22 ---- /* ! * eXist Open Source Native XML Database ! * ! * Copyright (C) 2001-04 Wolfgang M. Meier wol...@ex... * ! * This program is free software; you can redistribute it and/or modify it ! * under the terms of the GNU Lesser General Public License as published by the ! * Free Software Foundation; either version 2 of the License, or (at your ! * option) any later version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ! * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License ! * for more details. ! * ! * You should have received a copy of the GNU Lesser General Public License ! * along with this program; if not, write to the Free Software Foundation, ! * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ! * ! * $Id$ */ package org.exist.xmldb; |
From: Wolfgang M. M. <wol...@us...> - 2004-06-02 11:28:51
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2591/src/org/exist/xmlrpc Modified Files: RpcServer.java RpcAPI.java RpcConnection.java Log Message: Added support for moving collections or resources, and reindexing collections. Index: RpcServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcServer.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** RpcServer.java 1 Jun 2004 12:08:06 -0000 1.36 --- RpcServer.java 2 Jun 2004 11:28:41 -0000 1.37 *************** *** 1,5 **** - /* <<<<<<< RpcServer.java * eXist Open Source Native XML Database Copyright (C) 2001-03, Wolfgang M. * Meier (me...@if...) --- 1,6 ---- /* <<<<<<< RpcServer.java + ======= + <<<<<<< RpcServer.java * eXist Open Source Native XML Database Copyright (C) 2001-03, Wolfgang M. * Meier (me...@if...) *************** *** 21,24 **** --- 22,26 ---- * $Id$ ======= + >>>>>>> 1.36 * eXist Open Source Native XML Database * Copyright (C) 2001-03, Wolfgang M. Meier (me...@if...) *************** *** 38,43 **** --- 40,49 ---- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + <<<<<<< RpcServer.java + * $Id$ + ======= * $Id$ >>>>>>> 1.33 + >>>>>>> 1.36 */ package org.exist.xmlrpc; *************** *** 938,941 **** --- 944,985 ---- } + + /* (non-Javadoc) + * @see org.exist.xmlrpc.RpcAPI#moveCollection(org.exist.security.User, java.lang.String, java.lang.String, java.lang.String) + */ + public boolean moveCollection(User user, String collectionPath, + String destinationPath, String newName) throws EXistException, + PermissionDeniedException { + RpcConnection con = pool.get(); + try { + return con.moveCollection(user, collectionPath, destinationPath, newName); + } catch (Exception e) { + handleException(e); + return false; + } finally { + con.synchronize(); + pool.release(con); + } + } + + + /* (non-Javadoc) + * @see org.exist.xmlrpc.RpcAPI#moveResource(org.exist.security.User, java.lang.String, java.lang.String, java.lang.String) + */ + public boolean moveResource(User user, String docPath, + String destinationPath, String newName) throws EXistException, + PermissionDeniedException { + RpcConnection con = pool.get(); + try { + return con.moveResource(user, docPath, destinationPath, newName); + } catch (Exception e) { + handleException(e); + return false; + } finally { + con.synchronize(); + pool.release(con); + } + } + public boolean removeCollection(User user, String name) throws EXistException, PermissionDeniedException { *************** *** 1568,1581 **** public boolean reindexCollection(User user, String name) throws EXistException, PermissionDeniedException { ! RpcConnection con = pool.get(); ! try { ! con.reindexCollection(user, name); ! return true; ! } catch (Exception e) { ! handleException(e); ! return false; ! } finally { ! pool.release(con); ! } ! } } --- 1612,1625 ---- public boolean reindexCollection(User user, String name) throws EXistException, PermissionDeniedException { ! RpcConnection con = pool.get(); ! try { ! con.reindexCollection(user, name); ! return true; ! } catch (Exception e) { ! handleException(e); ! return false; ! } finally { ! pool.release(con); ! } ! } } Index: RpcAPI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcAPI.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** RpcAPI.java 1 Jun 2004 12:08:06 -0000 1.28 --- RpcAPI.java 2 Jun 2004 11:28:41 -0000 1.29 *************** *** 21,28 **** */ package org.exist.xmlrpc; import java.util.Date; import java.util.Hashtable; import java.util.Vector; - import java.io.IOException; import org.exist.EXistException; --- 21,28 ---- */ package org.exist.xmlrpc; + import java.io.IOException; import java.util.Date; import java.util.Hashtable; import java.util.Vector; import org.exist.EXistException; *************** *** 35,39 **** * *@author Wolfgang Meier <me...@if...> - *@created 21. Juni 2002 */ public interface RpcAPI { --- 35,38 ---- *************** *** 700,706 **** throws EXistException, PermissionDeniedException, IOException; boolean reindexCollection(User user, String name) throws EXistException, PermissionDeniedException; - } --- 699,710 ---- throws EXistException, PermissionDeniedException, IOException; + boolean moveCollection(User user, String collectionPath, String destinationPath, String newName) + throws EXistException, PermissionDeniedException; + + boolean moveResource(User user, String docPath, String destinationPath, String newName) + throws EXistException, PermissionDeniedException; + boolean reindexCollection(User user, String name) throws EXistException, PermissionDeniedException; } Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.59 retrieving revision 1.60 diff -C2 -d -r1.59 -r1.60 *** RpcConnection.java 1 Jun 2004 12:08:06 -0000 1.59 --- RpcConnection.java 2 Jun 2004 11:28:41 -0000 1.60 *************** *** 1,2 **** --- 1,24 ---- + /* + * eXist Open Source Native XML Database + * Copyright (C) 2001-03 Wolfgang M. Meier + * wol...@ex... + * http://exist.sourceforge.net + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * $Id$ + */ package org.exist.xmlrpc; *************** *** 531,535 **** throw new EXistException("collection " + collectionName + " not found"); ! DocumentSet docs = collection.allDocs(broker, new DocumentSet(true), true); XUpdateProcessor processor = new XUpdateProcessor(broker, docs); --- 553,557 ---- throw new EXistException("collection " + collectionName + " not found"); ! DocumentSet docs = collection.allDocs(broker, new DocumentSet(), true); XUpdateProcessor processor = new XUpdateProcessor(broker, docs); *************** *** 560,564 **** if (doc == null) throw new EXistException("document " + resource + " not found"); ! DocumentSet docs = new DocumentSet(true); docs.add(doc); XUpdateProcessor processor = new XUpdateProcessor(broker, docs); --- 582,586 ---- if (doc == null) throw new EXistException("document " + resource + " not found"); ! DocumentSet docs = new DocumentSet(); docs.add(doc); XUpdateProcessor processor = new XUpdateProcessor(broker, docs); *************** *** 1895,1898 **** --- 1917,1977 ---- } + public boolean moveResource(User user, String docPath, String destinationPath, String newName) + throws EXistException, PermissionDeniedException { + DBBroker broker = null; + try { + broker = brokerPool.get(user); + // get source document + int p = docPath.lastIndexOf('/'); + if (p < 0 || p == docPath.length() - 1) + throw new EXistException("Illegal document path"); + String collectionName = docPath.substring(0, p); + Collection collection = broker.getCollection(collectionName); + if (collection == null) + throw new EXistException("Collection " + collectionName + + " not found"); + DocumentImpl doc = collection.getDocument(docPath); + if(doc == null) + throw new EXistException("Document " + docPath + " not found"); + + // get destination collection + Collection destination = broker.getCollection(destinationPath); + if(destination == null) + throw new EXistException("Destination collection " + destinationPath + " not found"); + broker.moveResource(doc, destination, newName); + documentCache.clear(); + return true; + } catch (LockException e) { + throw new PermissionDeniedException("Could not acquire lock on document " + docPath); + } finally { + brokerPool.release(broker); + } + } + + public boolean moveCollection(User user, String collectionPath, String destinationPath, String newName) + throws EXistException, PermissionDeniedException { + DBBroker broker = null; + try { + broker = brokerPool.get(user); + // get source document + Collection collection = broker.getCollection(collectionPath); + if (collection == null) + throw new EXistException("Collection " + collectionPath + + " not found"); + + // get destination collection + Collection destination = broker.getCollection(destinationPath); + if(destination == null) + throw new EXistException("Destination collection " + destinationPath + " not found"); + broker.moveCollection(collection, destination, newName); + documentCache.clear(); + return true; + } catch (LockException e) { + throw new PermissionDeniedException(e.getMessage()); + } finally { + brokerPool.release(broker); + } + } + public void reindexCollection(User user, String name) throws Exception, PermissionDeniedException { |
From: Giulio V. <gva...@us...> - 2004-06-01 12:08:15
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31396/src/org/exist/xmlrpc Modified Files: RpcAPI.java RpcConnection.java RpcServer.java Log Message: add reindexCollection method Index: RpcServer.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcServer.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** RpcServer.java 25 May 2004 09:26:10 -0000 1.35 --- RpcServer.java 1 Jun 2004 12:08:06 -0000 1.36 *************** *** 1565,1567 **** --- 1565,1581 ---- } } + + public boolean reindexCollection(User user, String name) + throws EXistException, PermissionDeniedException { + RpcConnection con = pool.get(); + try { + con.reindexCollection(user, name); + return true; + } catch (Exception e) { + handleException(e); + return false; + } finally { + pool.release(con); + } + } } Index: RpcAPI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcAPI.java,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** RpcAPI.java 21 May 2004 08:32:15 -0000 1.27 --- RpcAPI.java 1 Jun 2004 12:08:06 -0000 1.28 *************** *** 699,701 **** --- 699,706 ---- byte[] getDocumentChunk(User user, String name, int start, int stop) throws EXistException, PermissionDeniedException, IOException; + + boolean reindexCollection(User user, String name) + throws EXistException, PermissionDeniedException; + + } Index: RpcConnection.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmlrpc/RpcConnection.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** RpcConnection.java 25 May 2004 09:26:09 -0000 1.58 --- RpcConnection.java 1 Jun 2004 12:08:06 -0000 1.59 *************** *** 1894,1896 **** --- 1894,1911 ---- return buffer; } + + public void reindexCollection(User user, String name) throws Exception, + PermissionDeniedException { + DBBroker broker = null; + try { + broker = brokerPool.get(user); + broker.reindex(name); + LOG.debug("collection " + name + " and sub collection reindexed"); + } catch (Exception e) { + LOG.debug(e); + throw e; + } finally { + brokerPool.release(broker); + } + } } |
From: Wolfgang M. <sb...@we...> - 2004-05-29 08:51:05
|
Hi, please check http://wiki.exist-db.org:80/space/XQuery This explains how to return only a distinct subset of the query results. User sessions can be supported by storing the result set to the HTTP session object. Please have a look at the supplied examples in webapp/xquery, especially biblio.xq. Wolfgang On Friday 28 May 2004 15:08, Hicham BOUSRAOU wrote: > Hi: > > I have many files in database eXist -1200 XML files-. > > I want to create a xquery request witch bring me only > the ten first results. In the next research i want get > only the ten next response,etc. I mean the system of > pagination. > Any suggestions please > Regards;) |
From: Hicham B. <h.b...@or...> - 2004-05-28 13:04:17
|
Hi: I have many files in database eXist -1200 XML files-. I want to= create a xquery request witch bring me only the ten first results. In t= he next research i want get only the ten next response,etc. I mean the = system of pagination. Any suggestions please Regards;) |
From: Wolfgang M. M. <wol...@us...> - 2004-05-28 10:55:04
|
Update of /cvsroot/exist/eXist-1.0/.externalToolBuilders In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24065/.externalToolBuilders Modified Files: Ant builder.launch Log Message: Removing a document did not correctly remove all text tokens, so some index entries remained in the index. Fixed. Index: Ant builder.launch =================================================================== RCS file: /cvsroot/exist/eXist-1.0/.externalToolBuilders/Ant builder.launch,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Ant builder.launch 1 Apr 2004 14:12:44 -0000 1.1 --- Ant builder.launch 28 May 2004 10:54:22 -0000 1.2 *************** *** 4,12 **** <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> - <stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.ant.internal.ui.antsupport.InternalAntRunner"/> - <stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_TYPE_ID" value="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType"/> - <stringAttribute key="org.eclipse.jdt.launching.VM_INSTALL_NAME" value="j2sdk1.4.2"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx128M"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/eXist-1.0/build.xml}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/wolf/Devel/eXist/eXist-1.0"/> --- 4,10 ---- <booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> <booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx128M"/> + <stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/eXist-1.0}"/> <stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/eXist-1.0/build.xml}"/> <stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="/home/wolf/Devel/eXist/eXist-1.0"/> |
From: Wolfgang M. M. <wol...@us...> - 2004-05-28 10:55:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24065/src/org/exist/xquery/functions/request Modified Files: RequestParameterNames.java RequestModule.java SetSessionAttribute.java RedirectTo.java CreateSession.java SessionAttributes.java EncodeURL.java GetSessionAttribute.java RequestURI.java Log Message: Removing a document did not correctly remove all text tokens, so some index entries remained in the index. Fixed. Index: RedirectTo.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/RedirectTo.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RedirectTo.java 29 Jan 2004 15:06:45 -0000 1.1 --- RedirectTo.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 60,64 **** /* (non-Javadoc) ! * @see org.exist.xpath.BasicFunction#eval(org.exist.xpath.value.Sequence[], org.exist.xpath.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) --- 60,64 ---- /* (non-Javadoc) ! * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) Index: RequestParameterNames.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/RequestParameterNames.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RequestParameterNames.java 29 Jan 2004 15:06:45 -0000 1.1 --- RequestParameterNames.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 64,68 **** /* (non-Javadoc) ! * @see org.exist.xpath.BasicFunction#eval(org.exist.xpath.value.Sequence[], org.exist.xpath.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) --- 64,68 ---- /* (non-Javadoc) ! * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) Index: SetSessionAttribute.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/SetSessionAttribute.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SetSessionAttribute.java 29 Jan 2004 15:06:45 -0000 1.1 --- SetSessionAttribute.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 57,61 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 57,61 ---- /* (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( Index: EncodeURL.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/EncodeURL.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** EncodeURL.java 29 Jan 2004 15:06:45 -0000 1.1 --- EncodeURL.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 56,60 **** /* (non-Javadoc) ! * @see org.exist.xpath.Function#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 56,60 ---- /* (non-Javadoc) ! * @see org.exist.xquery.Function#eval(org.exist.dom.DocumentSet, org.exist.xquery.value.Sequence, org.exist.xquery.value.Item) */ public Sequence eval( Index: RequestModule.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/RequestModule.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** RequestModule.java 13 May 2004 12:33:08 -0000 1.3 --- RequestModule.java 28 May 2004 10:54:20 -0000 1.4 *************** *** 59,63 **** /* (non-Javadoc) ! * @see org.exist.xpath.Module#getNamespaceURI() */ public String getNamespaceURI() { --- 59,63 ---- /* (non-Javadoc) ! * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { *************** *** 66,70 **** /* (non-Javadoc) ! * @see org.exist.xpath.Module#getDefaultPrefix() */ public String getDefaultPrefix() { --- 66,70 ---- /* (non-Javadoc) ! * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { Index: RequestURI.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/RequestURI.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RequestURI.java 29 Jan 2004 15:06:45 -0000 1.1 --- RequestURI.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 58,62 **** /* (non-Javadoc) ! * @see org.exist.xpath.BasicFunction#eval(org.exist.xpath.value.Sequence[], org.exist.xpath.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) --- 58,62 ---- /* (non-Javadoc) ! * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) Index: CreateSession.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/CreateSession.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** CreateSession.java 29 Jan 2004 15:06:45 -0000 1.1 --- CreateSession.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 58,62 **** /* (non-Javadoc) ! * @see org.exist.xpath.BasicFunction#eval(org.exist.xpath.value.Sequence[], org.exist.xpath.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) --- 58,62 ---- /* (non-Javadoc) ! * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) Index: SessionAttributes.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/SessionAttributes.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SessionAttributes.java 29 Jan 2004 15:06:45 -0000 1.1 --- SessionAttributes.java 28 May 2004 10:54:20 -0000 1.2 *************** *** 65,69 **** /* (non-Javadoc) ! * @see org.exist.xpath.BasicFunction#eval(org.exist.xpath.value.Sequence[], org.exist.xpath.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) --- 65,69 ---- /* (non-Javadoc) ! * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence) */ public Sequence eval(Sequence[] args, Sequence contextSequence) Index: GetSessionAttribute.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/request/GetSessionAttribute.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** GetSessionAttribute.java 16 Feb 2004 13:02:35 -0000 1.2 --- GetSessionAttribute.java 28 May 2004 10:54:20 -0000 1.3 *************** *** 61,65 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 61,65 ---- /* (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( |
From: Wolfgang M. M. <wol...@us...> - 2004-05-28 10:55:03
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24065/src/org/exist/xquery/functions/util Modified Files: EvalFunction.java BuiltinFunctions.java ModuleImpl.java DescribeFunction.java MD5.java Log Message: Removing a document did not correctly remove all text tokens, so some index entries remained in the index. Fixed. Index: MD5.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/MD5.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** MD5.java 29 Jan 2004 15:06:46 -0000 1.1 --- MD5.java 28 May 2004 10:54:21 -0000 1.2 *************** *** 56,60 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 56,60 ---- /* (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( Index: BuiltinFunctions.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/BuiltinFunctions.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BuiltinFunctions.java 29 Jan 2004 15:06:46 -0000 1.1 --- BuiltinFunctions.java 28 May 2004 10:54:21 -0000 1.2 *************** *** 60,64 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 60,64 ---- /* (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( Index: EvalFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/EvalFunction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** EvalFunction.java 17 May 2004 09:52:00 -0000 1.3 --- EvalFunction.java 28 May 2004 10:54:21 -0000 1.4 *************** *** 79,83 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 79,83 ---- /* (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( Index: DescribeFunction.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/DescribeFunction.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DescribeFunction.java 16 Feb 2004 15:59:37 -0000 1.2 --- DescribeFunction.java 28 May 2004 10:54:21 -0000 1.3 *************** *** 61,65 **** /* (non-Javadoc) ! * @see org.exist.xpath.Expression#eval(org.exist.dom.DocumentSet, org.exist.xpath.value.Sequence, org.exist.xpath.value.Item) */ public Sequence eval( --- 61,65 ---- /* (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( Index: ModuleImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xquery/functions/util/ModuleImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ModuleImpl.java 17 May 2004 09:52:00 -0000 1.5 --- ModuleImpl.java 28 May 2004 10:54:21 -0000 1.6 *************** *** 52,56 **** /* (non-Javadoc) ! * @see org.exist.xpath.Module#getNamespaceURI() */ public String getNamespaceURI() { --- 52,56 ---- /* (non-Javadoc) ! * @see org.exist.xquery.Module#getNamespaceURI() */ public String getNamespaceURI() { *************** *** 59,63 **** /* (non-Javadoc) ! * @see org.exist.xpath.Module#getDefaultPrefix() */ public String getDefaultPrefix() { --- 59,63 ---- /* (non-Javadoc) ! * @see org.exist.xquery.Module#getDefaultPrefix() */ public String getDefaultPrefix() { |
From: Wolfgang M. M. <wol...@us...> - 2004-05-28 10:55:01
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/storage/store In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24065/src/org/exist/storage/store Modified Files: BFile.java Log Message: Removing a document did not correctly remove all text tokens, so some index entries remained in the index. Fixed. Index: BFile.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/storage/store/BFile.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** BFile.java 17 May 2004 09:54:41 -0000 1.22 --- BFile.java 28 May 2004 10:54:20 -0000 1.23 *************** *** 400,404 **** try { final long p = findValue(key); ! if (p == KEY_NOT_FOUND) return null; final long pnum = StorageAddress.pageFromPointer(p); final DataPage page = getDataPage(pnum); --- 400,407 ---- try { final long p = findValue(key); ! if (p == KEY_NOT_FOUND) { ! LOG.debug("key not found"); ! return null; ! } final long pnum = StorageAddress.pageFromPointer(p); final DataPage page = getDataPage(pnum); |
From: Wolfgang M. M. <wol...@us...> - 2004-05-28 10:54:58
|
Update of /cvsroot/exist/eXist-1.0/src/org/exist/dom In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24065/src/org/exist/dom Modified Files: AVLTreeNodeSet.java TextSearchResult.java ArraySet.java SortedNodeSet.java ElementImpl.java NodeProxy.java ExtArrayNodeSet.java AbstractNodeSet.java Log Message: Removing a document did not correctly remove all text tokens, so some index entries remained in the index. Fixed. Index: AbstractNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AbstractNodeSet.java,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** AbstractNodeSet.java 10 May 2004 11:22:39 -0000 1.15 --- AbstractNodeSet.java 28 May 2004 10:54:15 -0000 1.16 *************** *** 35,39 **** /** * Abstract base class for all node set implementations. A node set is a special type of sequence, ! * which contains only nodes. Class NodeSet thus implements the {@link org.exist.xpath.value.Sequence} * as well as the DOM {@link org.w3c.dom.NodeList} interfaces. * --- 35,39 ---- /** * Abstract base class for all node set implementations. A node set is a special type of sequence, ! * which contains only nodes. Class NodeSet thus implements the {@link org.exist.xquery.value.Sequence} * as well as the DOM {@link org.w3c.dom.NodeList} interfaces. * *************** *** 58,72 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#iterate() */ public abstract SequenceIterator iterate(); /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#unorderedIterator() */ public abstract SequenceIterator unorderedIterator(); /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#getItemType() */ public int getItemType() { --- 58,72 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#iterate() */ public abstract SequenceIterator iterate(); /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#unorderedIterator() */ public abstract SequenceIterator unorderedIterator(); /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#getItemType() */ public int getItemType() { Index: ArraySet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ArraySet.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** ArraySet.java 8 Mar 2004 11:21:21 -0000 1.30 --- ArraySet.java 28 May 2004 10:54:14 -0000 1.31 *************** *** 721,725 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.SequenceIterator#nextItem() */ public Item nextItem() { --- 721,725 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { Index: NodeProxy.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/NodeProxy.java,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** NodeProxy.java 10 May 2004 11:22:39 -0000 1.29 --- NodeProxy.java 28 May 2004 10:54:15 -0000 1.30 *************** *** 51,55 **** * * All sets of type NodeSet operate on NodeProxys. A node set is a special type of ! * sequence, so NodeProxy does also implement {@link org.exist.xpath.value.Item} and * can thus be an item in a sequence. Since, according to XPath 2, a single node is also * a sequence, NodeProxy does itself extend NodeSet. It thus represents a node set containing --- 51,55 ---- * * All sets of type NodeSet operate on NodeProxys. A node set is a special type of ! * sequence, so NodeProxy does also implement {@link org.exist.xquery.value.Item} and * can thus be an item in a sequence. Since, according to XPath 2, a single node is also * a sequence, NodeProxy does itself extend NodeSet. It thus represents a node set containing *************** *** 142,146 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.NodeValue#getImplementation() */ public int getImplementationType() { --- 142,146 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.NodeValue#getImplementation() */ public int getImplementationType() { *************** *** 437,441 **** * information is preserved through all following steps. * ! * To process the predicate expression, {@link org.exist.xpath.Predicate} will take the * context nodes returned by the filter expression and compare them to its context * node set. --- 437,441 ---- * information is preserved through all following steps. * ! * To process the predicate expression, {@link org.exist.xquery.Predicate} will take the * context nodes returned by the filter expression and compare them to its context * node set. *************** *** 485,489 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#getType() */ public int getType() { --- 485,489 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#getType() */ public int getType() { *************** *** 505,509 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#toSequence() */ public Sequence toSequence() { --- 505,509 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#toSequence() */ public Sequence toSequence() { *************** *** 512,516 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#getStringValue() */ public String getStringValue() { --- 512,516 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#getStringValue() */ public String getStringValue() { *************** *** 519,523 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#convertTo(int) */ public AtomicValue convertTo(int requiredType) throws XPathException { --- 519,523 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#convertTo(int) */ public AtomicValue convertTo(int requiredType) throws XPathException { *************** *** 526,530 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#atomize() */ public AtomicValue atomize() throws XPathException { --- 526,530 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#atomize() */ public AtomicValue atomize() throws XPathException { *************** *** 551,555 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#unorderedIterator() */ public SequenceIterator unorderedIterator() { --- 551,555 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#unorderedIterator() */ public SequenceIterator unorderedIterator() { *************** *** 598,602 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { --- 598,602 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { *************** *** 644,648 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#conversionPreference(java.lang.Class) */ public int conversionPreference(Class javaClass) { --- 644,648 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#conversionPreference(java.lang.Class) */ public int conversionPreference(Class javaClass) { *************** *** 676,680 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Item#toJavaObject(java.lang.Class) */ public Object toJavaObject(Class target) throws XPathException { --- 676,680 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Item#toJavaObject(java.lang.Class) */ public Object toJavaObject(Class target) throws XPathException { *************** *** 717,721 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.SequenceIterator#nextItem() */ public Item nextItem() { --- 717,721 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { Index: TextSearchResult.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/TextSearchResult.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TextSearchResult.java 29 Jan 2004 15:06:46 -0000 1.3 --- TextSearchResult.java 28 May 2004 10:54:14 -0000 1.4 *************** *** 214,218 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { --- 214,218 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { Index: ElementImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ElementImpl.java,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** ElementImpl.java 10 May 2004 11:22:39 -0000 1.33 --- ElementImpl.java 28 May 2004 10:54:14 -0000 1.34 *************** *** 787,790 **** --- 787,794 ---- } + public int getPrefixCount() { + return namespaceMappings.size(); + } + public void toSAX( ContentHandler contentHandler, Index: AVLTreeNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/AVLTreeNodeSet.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AVLTreeNodeSet.java 29 Jan 2004 15:06:46 -0000 1.5 --- AVLTreeNodeSet.java 28 May 2004 10:54:14 -0000 1.6 *************** *** 66,70 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { --- 66,70 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { *************** *** 417,421 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.SequenceIterator#nextItem() */ public Item nextItem() { --- 417,421 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { Index: ExtArrayNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/ExtArrayNodeSet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ExtArrayNodeSet.java 25 May 2004 09:26:12 -0000 1.18 --- ExtArrayNodeSet.java 28 May 2004 10:54:15 -0000 1.19 *************** *** 151,155 **** * (non-Javadoc) * ! * @see org.exist.xpath.value.Sequence#iterate() */ public SequenceIterator iterate() { --- 151,155 ---- * (non-Javadoc) * ! * @see org.exist.xquery.value.Sequence#iterate() */ public SequenceIterator iterate() { *************** *** 211,215 **** * (non-Javadoc) * ! * @see org.exist.xpath.value.Sequence#getLength() */ public int getLength() { --- 211,215 ---- * (non-Javadoc) * ! * @see org.exist.xquery.value.Sequence#getLength() */ public int getLength() { *************** *** 270,274 **** * (non-Javadoc) * ! * @see org.exist.xpath.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { --- 270,274 ---- * (non-Javadoc) * ! * @see org.exist.xquery.value.Sequence#itemAt(int) */ public Item itemAt(int pos) { *************** *** 342,346 **** * (non-Javadoc) * ! * @see org.exist.xpath.value.AbstractSequence#setSelfAsContext() */ public void setSelfAsContext() { --- 342,346 ---- * (non-Javadoc) * ! * @see org.exist.xquery.value.AbstractSequence#setSelfAsContext() */ public void setSelfAsContext() { *************** *** 701,705 **** * (non-Javadoc) * ! * @see org.exist.xpath.value.SequenceIterator#nextItem() */ public Item nextItem() { --- 701,705 ---- * (non-Javadoc) * ! * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { Index: SortedNodeSet.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/dom/SortedNodeSet.java,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** SortedNodeSet.java 29 Jan 2004 15:06:46 -0000 1.18 --- SortedNodeSet.java 28 May 2004 10:54:14 -0000 1.19 *************** *** 194,198 **** /* (non-Javadoc) ! * @see org.exist.xpath.value.SequenceIterator#nextItem() */ public Item nextItem() { --- 194,198 ---- /* (non-Javadoc) ! * @see org.exist.xquery.value.SequenceIterator#nextItem() */ public Item nextItem() { |