Update of /cvsroot/exist/eXist-1.0/src/org/exist/xmldb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16641/src/org/exist/xmldb Modified Files: RemoteXMLResource.java LocalCollectionManagementService.java CollectionManagementServiceImpl.java RemoteBinaryResource.java RemoteResourceIterator.java Log Message: Added copyResource method to DBBroker. Index: LocalCollectionManagementService.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/LocalCollectionManagementService.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** LocalCollectionManagementService.java 2 Jun 2004 11:28:42 -0000 1.10 --- LocalCollectionManagementService.java 21 Jun 2004 15:27:36 -0000 1.11 *************** *** 188,191 **** --- 188,226 ---- } } + + /* (non-Javadoc) + * @see org.exist.xmldb.CollectionManagementServiceImpl#copyResource(java.lang.String, java.lang.String, java.lang.String) + */ + public void copyResource(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.copyResource(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; Index: RemoteResourceIterator.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteResourceIterator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RemoteResourceIterator.java 29 Jan 2004 15:06:43 -0000 1.1 --- RemoteResourceIterator.java 21 Jun 2004 15:27:36 -0000 1.2 *************** *** 32,36 **** protected RemoteCollection collection; protected Vector resources; ! protected int pos = 0, indentXML; protected String encoding = "UTF-8"; --- 32,37 ---- protected RemoteCollection collection; protected Vector resources; ! protected int pos = 0 ; ! protected int indentXML; protected String encoding = "UTF-8"; Index: CollectionManagementServiceImpl.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/CollectionManagementServiceImpl.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CollectionManagementServiceImpl.java 2 Jun 2004 11:28:42 -0000 1.5 --- CollectionManagementServiceImpl.java 21 Jun 2004 15:27:36 -0000 1.6 *************** *** 42,44 **** --- 42,47 ---- public void moveResource(String resourcePath, String destinationPath, String newName) throws XMLDBException; + + public void copyResource(String resourcePath, String destinationPath, String newName) + throws XMLDBException; } Index: RemoteBinaryResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteBinaryResource.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** RemoteBinaryResource.java 29 Jan 2004 15:06:43 -0000 1.1 --- RemoteBinaryResource.java 21 Jun 2004 15:27:36 -0000 1.2 *************** *** 45,49 **** public class RemoteBinaryResource implements BinaryResource, EXistResource { ! private String documentName, path; private RemoteCollection parent; private byte[] data = null; --- 45,50 ---- public class RemoteBinaryResource implements BinaryResource, EXistResource { ! private String documentName; ! private String path; private RemoteCollection parent; private byte[] data = null; Index: RemoteXMLResource.java =================================================================== RCS file: /cvsroot/exist/eXist-1.0/src/org/exist/xmldb/RemoteXMLResource.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** RemoteXMLResource.java 21 May 2004 08:32:14 -0000 1.13 --- RemoteXMLResource.java 21 Jun 2004 15:27:36 -0000 1.14 *************** *** 50,54 **** private org.apache.excalibur.xml.sax.SAXParser cocoonParser = null; ! protected String id, documentName, path = null; protected int handle = -1; protected int pos = -1; --- 50,56 ---- private org.apache.excalibur.xml.sax.SAXParser cocoonParser = null; ! protected String id; ! protected String documentName; ! protected String path = null ; protected int handle = -1; protected int pos = -1; |