Package org.exist.storage.txn

Examples of org.exist.storage.txn.Txn


        final Subject currentUser = getSubject();
        //elevate getUser() to DBA_USER
        setSubject(pool.getSecurityManager().getSystemSubject());
        //start a transaction
        final TransactionManager transact = pool.getTransactionManager();
        final Txn transaction = transact.beginTransaction();
        //create a name for the temporary document
        final XmldbURI docName = XmldbURI.create(MessageDigester.md5(Thread.currentThread().getName() + Long.toString(System.currentTimeMillis()), false) + ".xml");

        //get the temp collection
        Collection temp = openCollection(XmldbURI.TEMP_COLLECTION_URI, Lock.WRITE_LOCK);
        boolean created = false;
        try {
            //if no temp collection
            if(temp == null) {
                //creates temp collection (with write lock)
                temp = createTempCollection(transaction);
                if(temp == null) {
                    LOG.warn("Failed to create temporary collection");
                    //TODO : emergency exit?
                }
                created = true;
            }
            //create a temporary document
            final DocumentImpl targetDoc = new DocumentImpl(pool, temp, docName);
            targetDoc.getPermissions().setMode(Permission.DEFAULT_TEMPORARY_DOCUMENT_PERM);
            final long now = System.currentTimeMillis();
            final DocumentMetadata metadata = new DocumentMetadata();
            metadata.setLastModified(now);
            metadata.setCreated(now);
            targetDoc.setMetadata(metadata);
            targetDoc.setDocId(getNextResourceId(transaction, temp));
            //index the temporary document
            final DOMIndexer indexer = new DOMIndexer(this, transaction, doc, targetDoc); //NULL transaction, so temporary fragment is not journalled - AR
            indexer.scan();
            indexer.store();
            //store the temporary document
            temp.addDocument(transaction, this, targetDoc); //NULL transaction, so temporary fragment is not journalled - AR
            // unlock the temp collection
            if(transaction == null) {
                temp.getLock().release(Lock.WRITE_LOCK);
            } else if(!created) {
                transaction.registerLock(temp.getLock(), Lock.WRITE_LOCK);
            }
            //NULL transaction, so temporary fragment is not journalled - AR
            storeXMLResource(transaction, targetDoc);
            flush();
            closeDocument();
View Full Code Here


          } finally {
              is.close();
          }
        } else {
          TransactionManager txManager = db.getTransactionManager();
          Txn txn = txManager.beginTransaction();

            try {
                FileInputStream is = new FileInputStream(file);
                try {
                    col.addBinaryResource(txn, broker,
View Full Code Here

        final Collection temp = getCollection(XmldbURI.TEMP_COLLECTION_URI);
        if(temp == null) {
            return;
        }
        final TransactionManager transact = pool.getTransactionManager();
        final Txn transaction = transact.beginTransaction();
        try {
            removeCollection(transaction, temp);
            transact.commit(transaction);
        } catch(final Exception e) {
            transact.abort(transaction);
View Full Code Here

        DBBroker broker = null;
        Collection collection = null;
        DocumentImpl resource = null;

        TransactionManager txnManager = brokerPool.getTransactionManager();
        Txn txn = txnManager.beginTransaction();

        try {
            broker = brokerPool.get(subject);

            // Need to split path into collection and document name
View Full Code Here

        }

        DBBroker broker = null;
        DocumentImpl document = null;
        TransactionManager txnManager = null;
        Txn txn = null;

        try {
            broker = brokerPool.get(subject);

            // Try to get document (add catch?)
View Full Code Here

        DBBroker broker = null;
        DocumentImpl document = null;

        TransactionManager txnManager = brokerPool.getTransactionManager();
        Txn txn = txnManager.beginTransaction();

        try {
            broker = brokerPool.get(subject);

View Full Code Here

        Collection destCollection = null;


        TransactionManager txnManager = brokerPool.getTransactionManager();
        Txn txn = txnManager.beginTransaction();

        try {
            broker = brokerPool.get(subject);

            // Need to split path into collection and document name
View Full Code Here

            throw new EXistException("token is null");
        }

        // Prepare transaction
        TransactionManager txnManager = null;
        Txn txn = null;

        try {
            broker = brokerPool.get(subject);

            // Try to get document (add catch?)
View Full Code Here

 
    public static void cleanupDB() {
        BrokerPool pool = null;
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
        try {
            pool = BrokerPool.getInstance();
            assertNotNull(pool);
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
View Full Code Here

    @BeforeClass
    public static void startDB() {
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
        try {
            File confFile = ConfigurationHelper.lookup("conf.xml");
            Configuration config = new Configuration(confFile.getAbsolutePath());
            BrokerPool.configure(1, 5, config);
            pool = BrokerPool.getInstance();
View Full Code Here

TOP

Related Classes of org.exist.storage.txn.Txn

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.