Package org.exist.collections.Collection

Examples of org.exist.collections.Collection.CollectionEntry


            final XmldbURI newUri = destCollection.getURI().append(child.getFileURI());
            trigger.beforeCopyDocument(this, transaction, child, newUri);

            //are we overwriting an existing document?
            final CollectionEntry oldDoc;
            if(destCollection.hasDocument(this, child.getFileURI())) {
                oldDoc = destCollection.getResourceEntry(this, child.getFileURI().toString());
            } else {
                oldDoc = null;
            }

            DocumentImpl createdDoc;
            if(child.getResourceType() == DocumentImpl.XML_FILE) {
                //TODO : put a lock on newDoc ?
                final DocumentImpl newDoc = new DocumentImpl(pool, destCollection, child.getFileURI());
                newDoc.copyOf(child, false);
                if(oldDoc != null) {
                    //preserve permissions from existing doc we are replacing
                    newDoc.setPermissions(oldDoc.getPermissions()); //TODO use newDoc.copyOf(oldDoc) ideally, but we cannot currently access oldDoc without READ access to it, which we may not have (and should not need for this)!
                }

                newDoc.setDocId(getNextResourceId(transaction, destination));
                copyXMLResource(transaction, child, newDoc);
                storeXMLResource(transaction, newDoc);
                destCollection.addDocument(transaction, this, newDoc);

                createdDoc = newDoc;
            } else {
                final BinaryDocument newDoc = new BinaryDocument(pool, destCollection, child.getFileURI());
                newDoc.copyOf(child, false);
                if(oldDoc != null) {
                    //preserve permissions from existing doc we are replacing
                    newDoc.setPermissions(oldDoc.getPermissions()); //TODO use newDoc.copyOf(oldDoc) ideally, but we cannot currently access oldDoc without READ access to it, which we may not have (and should not need for this)!
                }
                newDoc.setDocId(getNextResourceId(transaction, destination));

                InputStream is = null;
                try {
View Full Code Here

TOP

Related Classes of org.exist.collections.Collection.CollectionEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.