Package org.exist

Examples of org.exist.EXistException


           
            final PathExpr expr = new PathExpr(context);
            treeParser.xpath(ast, expr);
            if (treeParser.foundErrors()) {
                LOG.debug(treeParser.getErrorMessage());
                throw new EXistException(treeParser.getErrorMessage());
            }
            LOG.info("query: " + ExpressionDumper.dump(expr));
            final long start = System.currentTimeMillis();
            expr.analyze(new AnalyzeContextInfo());
            final Sequence seq= expr.eval(null, null);
View Full Code Here


                if (LOG.isDebugEnabled()) {
                    LOG.debug(String.format("No resource found for path: %s", xmldbUri));
                }
                //return null; // throw exception?
                throw new EXistException("No resource found.");
            }

            // Get current userlock
            Account userLock = document.getUserLock();

            // Check if Resource is already locked. @@ToDo
            if (userLock != null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Resource was already locked, ignored.");
                }
            }

            if ( userLock != null && userLock.getName() != null
                    && !userLock.getName().equals(subject.getName())
                    && !subject.hasDbaRole() ) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(String.format("Resource is locked by user %s.", userLock.getName()));
                }
                throw new PermissionDeniedException(userLock.getName());
            }

            // Check for request for shared lock. @@TODO
            if (inputToken.getScope() == LockToken.LOCK_SCOPE_SHARED) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Shared locks are not implemented.");
                }
                throw new EXistException("Shared locks are not implemented.");
            }

            // Update locktoken
            inputToken.setOwner(subject.getName());
            inputToken.createOpaqueLockToken();
            //inputToken.setTimeOut(inputToken.getTimeOut());
            inputToken.setTimeOut(LockToken.LOCK_TIMEOUT_INFINITE);

            // Update document
            document.getMetadata().setLockToken(inputToken);
            document.setUserLock(subject);

            // Make token persistant
            txnManager = brokerPool.getTransactionManager();
            txn = txnManager.beginTransaction();
            broker.storeMetadata(txn, document);
            txnManager.commit(txn);

            if (LOG.isDebugEnabled()) {
                LOG.debug("Successfully retrieved token");
            }
           
            return inputToken;


        } catch (EXistException | PermissionDeniedException e) {
            LOG.error(e);
            if (txnManager != null) {
                txnManager.abort(txn);
            }
            throw e;

        } catch (TriggerException e) {
            LOG.error(e);
            //dead code, remove?
            if (txnManager != null) {
                txnManager.abort(txn);
            }
            //-----------------------
            throw new EXistException(e);

    } finally {

            // TODO: check if can be done earlier
            if (document != null) {
View Full Code Here

            document = broker.getXMLResource(xmldbUri, Lock.WRITE_LOCK);

            if (document == null) {
                final String msg = String.format("No resource found for path: %s", xmldbUri);
                LOG.debug(msg);
                throw new EXistException(msg);
            }

            // Get current userlock
            Account lock = document.getUserLock();

            // Check if Resource is already locked.
            if (lock == null) {
                LOG.debug(String.format("Resource %s is not locked.", xmldbUri));
                throw new DocumentNotLockedException("" + xmldbUri);
            }

            // Check if Resource is from subject
            if (!lock.getName().equals(subject.getName()) && !subject.hasDbaRole() ) {
                LOG.debug(String.format("Resource lock is from user %s", lock.getName()));
                throw new PermissionDeniedException(lock.getName());
            }

            // Update document
            document.setUserLock(null);
            document.getMetadata().setLockToken(null);

            // Make it persistant
            broker.storeMetadata(txn, document);
            txnManager.commit(txn);

        } catch (EXistException | PermissionDeniedException e) {
            txnManager.abort(txn);
            LOG.error(e);
            throw e;

        } catch (TriggerException e) {
            txnManager.abort(txn);
            LOG.error(e);
            throw new EXistException(e);

    } finally {

            if (document != null) {
                document.getUpdateLock().release(Lock.WRITE_LOCK);
View Full Code Here

        XmldbURI newNameUri = null;
        try {
            newNameUri = XmldbURI.xmldbUriFor(newName);
        } catch (URISyntaxException ex) {
            LOG.error(ex);
            throw new EXistException(ex.getMessage());
        }

        DBBroker broker = null;
        Collection srcCollection = null;
        DocumentImpl srcDocument = null;

        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
            XmldbURI srcCollectionUri = xmldbUri.removeLastSegment();
            XmldbURI srdDocumentUri = xmldbUri.lastSegment();

            // Open collection if possible, else abort
            srcCollection = broker.openCollection(srcCollectionUri, Lock.WRITE_LOCK);
            if (srcCollection == null) {
                txnManager.abort(txn);
                return; // TODO throw
            }

            // Open document if possible, else abort
            srcDocument = srcCollection.getDocument(broker, srdDocumentUri);
            if (srcDocument == null) {
                LOG.debug(String.format("No resource found for path: %s", xmldbUri));
                txnManager.abort(txn);
                return;
            }

            // Open collection if possible, else abort
            destCollection = broker.openCollection(destCollectionUri, Lock.WRITE_LOCK);
            if (destCollection == null) {
                LOG.debug(String.format("Destination collection %s does not exist.", xmldbUri));
                txnManager.abort(txn);
                return;
            }


            // Perform actial move/copy
            if (mode == Mode.COPY) {
                broker.copyResource(txn, srcDocument, destCollection, newNameUri);

            } else {
                broker.moveResource(txn, srcDocument, destCollection, newNameUri);
            }


            // Commit change
            txnManager.commit(txn);

            if (LOG.isDebugEnabled()) {
                LOG.debug(String.format("Document %sd sucessfully", mode));
            }

        } catch (LockException e) {
            LOG.error("Resource is locked.", e);
            txnManager.abort(txn);
            throw new EXistException(e.getMessage());

        } catch (EXistException e) {
            LOG.error(e);
            txnManager.abort(txn);
            throw e;

        } catch (IOException | PermissionDeniedException | TriggerException e) {
            LOG.error(e);
            txnManager.abort(txn);
            throw new EXistException(e.getMessage());

        } finally {

            // TODO: check if can be done earlier
            if (destCollection != null) {
View Full Code Here

        if (token == null) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("token is null");
            }
            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?)
            document = broker.getXMLResource(xmldbUri, Lock.WRITE_LOCK);

            if (document == null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug(String.format("No resource found for path: %s", xmldbUri));
                }
                //return null; // throw exception?
                throw new EXistException("No resource found.");
            }

            // Get current userlock
            Account userLock = document.getUserLock();
View Full Code Here

            txnManager.abort(txn);

        } catch (Throwable e) {
            LOG.error(e);
            txnManager.abort(txn);
            throw new EXistException(e);

        } finally {

            // TODO: check if can be done earlier
            if (collection != null) {
View Full Code Here

        try {
            newNameUri = XmldbURI.xmldbUriFor(newName);
           
        } catch (URISyntaxException ex) {
            LOG.error(ex);
            throw new EXistException(ex.getMessage());
        }

        DBBroker broker = null;
        Collection srcCollection = null;
        Collection destCollection = null;


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

        try {
            broker = brokerPool.get(subject);

            // This class contains already the URI of the resource that shall be moved/copied
            XmldbURI srcCollectionUri = xmldbUri;

            // Open collection if possible, else abort
            srcCollection = broker.openCollection(srcCollectionUri, Lock.WRITE_LOCK);
            if (srcCollection == null) {
                txnManager.abort(txn);
                return; // TODO throw
            }


            // Open collection if possible, else abort
            destCollection = broker.openCollection(destCollectionUri, Lock.WRITE_LOCK);
            if (destCollection == null) {
                LOG.debug(String.format("Destination collection %s does not exist.", xmldbUri));
                txnManager.abort(txn);
                return; // TODO throw?
            }

            // Perform actial move/copy
            if (mode == Mode.COPY) {
                broker.copyCollection(txn, srcCollection, destCollection, newNameUri);

            } else {
                broker.moveCollection(txn, srcCollection, destCollection, newNameUri);
            }

            // Commit change
            txnManager.commit(txn);

            if(LOG.isDebugEnabled())
                LOG.debug(String.format("Collection %sd sucessfully", mode));

        } catch (LockException e) {
            LOG.error("Resource is locked.", e);
            txnManager.abort(txn);
            throw new EXistException(e.getMessage());

        } catch (EXistException e) {
            LOG.error(e);
            txnManager.abort(txn);
            throw e;

        } catch (IOException | PermissionDeniedException | TriggerException e) {
            LOG.error(e);
            txnManager.abort(txn);
            throw new EXistException(e.getMessage());

        } finally {

            if (destCollection != null) {
                destCollection.release(Lock.WRITE_LOCK);
View Full Code Here

 
  public DBBroker getBroker() throws EXistException {
    if (pool != null)
      return pool.get(null);
   
    throw new EXistException("that shouldn't happend. internal error.");
  }
View Full Code Here

    throw new EXistException("that shouldn't happend. internal error.");
  }

  public void releaseBroker(DBBroker broker) throws EXistException {
    if (pool == null)
      throw new EXistException("Database wan't set properly.");

    pool.release(broker);
  }
View Full Code Here

                        try {
                            Field fld = account.getClass().getSuperclass().getDeclaredField("groups");
                            fld.setAccessible(true);
                            fld.set(account, memberOf_groups);
                        } catch(NoSuchFieldException nsfe) {
                            throw new EXistException(nsfe.getMessage(), nsfe);
                        } catch(IllegalAccessException iae) {
                            throw new EXistException(iae.getMessage(), iae);
                        }
                    }
                   
                    //update the metdata?
                    if((update & UPDATE_METADATA) == UPDATE_METADATA) {
View Full Code Here

TOP

Related Classes of org.exist.EXistException

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.