Examples of DBBroker


Examples of org.exist.storage.DBBroker

            {previous = getLastNode(previous);}
        final NodePath oldPath = oldNode.getPath();
        StreamListener listener = null;
        //May help getReindexRoot() to make some useful things
        Node newNode = null;
        DBBroker broker = null;
        try {
            broker = ownerDocument.getBrokerPool().get(null);
            broker.getIndexController().setDocument(ownerDocument);
            final StoredNode reindexRoot = broker.getIndexController().getReindexRoot(oldNode, oldPath, false);
            broker.getIndexController().setMode(StreamListener.REMOVE_SOME_NODES);
            if (reindexRoot == null) {
                listener = broker.getIndexController().getStreamListener();
            } else {
                broker.getIndexController().reindex(transaction, reindexRoot,
                    StreamListener.REMOVE_SOME_NODES);
            }
            broker.removeAllNodes(transaction, oldNode, oldPath, listener);
            broker.endRemove(transaction);
            broker.flush();
            broker.getIndexController().setMode(StreamListener.STORE);
            listener = broker.getIndexController().getStreamListener();
            newNode = appendChild(transaction, oldNode.nodeId, new NodeImplRef(previous),
                getPath(), newChild, listener);
            //Reindex if required
            final DocumentImpl owner = (DocumentImpl)getOwnerDocument();
            broker.storeXMLResource(transaction, owner);
            broker.updateNode(transaction, this, false);
            broker.getIndexController().reindex(transaction, reindexRoot, StreamListener.STORE);
            broker.flush();
        } catch (final EXistException e) {
            LOG.warn("Exception while inserting node: " + e.getMessage(), e);
        } finally {
          if (broker != null)
            broker.release();
        }
        //return oldChild;  // method is spec'd to return the old child, even though that's probably useless in this case
        return newNode; //returning the newNode is more sensible than returning the oldNode
    }
View Full Code Here

Examples of org.exist.storage.DBBroker

        return enabled;
    }

    public final boolean isLogEnabled() {
        try {
            final DBBroker broker = db.getActiveBroker();
            final Boolean globalProp = (Boolean) broker.getConfiguration().getProperty(CONFIG_PROPERTY_TRACELOG);
            return logEnabled || (globalProp != null && globalProp.booleanValue());
        } catch (Throwable t) {
            log.debug("Ignored exception: " + t.getMessage());
            return logEnabled;
        }
View Full Code Here

Examples of org.exist.storage.DBBroker

  }

    public void restore(RestoreListener listener, String username, Object credentials, String newCredentials, File f, String uri) throws XMLDBException, FileNotFoundException, IOException, SAXException, ParserConfigurationException, URISyntaxException, AuthenticationException, ConfigurationException, PermissionDeniedException {
       
        //login
        final DBBroker broker = db.authenticate(username, credentials);
        try {
          //set the new password
          setAdminCredentials(broker, newCredentials);
 
          //get the backup descriptors, can be more than one if it was an incremental backup
View Full Code Here

Examples of org.exist.storage.DBBroker

 
    public String[] list() {
     
      if (isDirectory()) {
       
          DBBroker broker = null;
        BrokerPool db = null;

        try {
          try {
            db = BrokerPool.getInstance();
View Full Code Here

Examples of org.exist.storage.DBBroker

        {return null;}
     
      if (collection == null)
        {return null;}
     
      DBBroker broker = null;
    BrokerPool db = null;

    try {
      try {
        db = BrokerPool.getInstance();
View Full Code Here

Examples of org.exist.storage.DBBroker

      doc = getDocument();
    } catch (final IOException e) {
      throw new FileNotFoundException(e.getMessage());
    }
   
      DBBroker broker = null;
    BrokerPool db = null;

    try {
      try {
        db = BrokerPool.getInstance();
        broker = db.get(null);
      } catch (final EXistException e) {
        throw new FileNotFoundException(e.getMessage());
      }
 
      if (doc instanceof BinaryDocument) {
        return broker.getBinaryFile(((BinaryDocument)doc));
       
      } else {
        return serialize(broker, doc);
      }
View Full Code Here

Examples of org.exist.storage.DBBroker

    }
   
    private void modifyMetadata(ModifyMetadata method) throws IOException {
//      if (initialized) {return;}
     
    DBBroker broker = null;
    BrokerPool db = null;

    try {
      try {
        db = BrokerPool.getInstance();
        broker = db.get(null);
      } catch (final EXistException e) {
        throw new IOException(e);
      }
 
      final TransactionManager tm = db.getTransactionManager();
      Txn txn = null;
     
      try {
        //collection
        if (uri.endsWith("/")) {
          collection = broker.getCollection(uri);
          if (collection == null)
            {throw new IOException("Resource not found: "+uri);}
         
        //resource
        } else {
          resource = broker.getXMLResource(uri, Lock.READ_LOCK);
          if (resource == null) {
            //may be, it's collection ... checking ...
            collection = broker.getCollection(uri);
            if (collection == null) {
              throw new IOException("Resource not found: "+uri);
            }
           
            txn = tm.beginTransaction();

            method.modify(collection);
            broker.saveCollection(txn, collection);
           
            tm.commit(txn);

          } else {
            collection = resource.getCollection();

            txn = tm.beginTransaction();
           
            method.modify(resource);
                  broker.storeMetadata(txn, resource);
           
            tm.commit(txn);
          }
        }
      } catch (final IOException e) {
View Full Code Here

Examples of org.exist.storage.DBBroker

  public DocumentImpl getDocument(String uuid) throws EXistException, PermissionDeniedException {
    MetasImpl ms = docByUUID.get(uuid);
    if (ms == null) return null;
   
    BrokerPool db = null;
    DBBroker broker = null;
    try {
      db = BrokerPool.getInstance();
      broker = db.get(null);
     
      XmldbURI uri = XmldbURI.create(ms.uri);
      Collection col = broker.getCollection(uri.removeLastSegment());
      if (col != null) {
        return col.getDocument(broker, uri.lastSegment());
      }
     
      return null;
View Full Code Here

Examples of org.exist.storage.DBBroker

  public Collection getCollection(String uuid) throws EXistException, PermissionDeniedException {
    MetasImpl ms = docByUUID.get(uuid);
    if (ms == null) return null;
   
    BrokerPool db = null;
    DBBroker broker = null;
    try {
      db = BrokerPool.getInstance();
      broker = db.get(null);
     
      XmldbURI uri = XmldbURI.create(ms.uri);
      return broker.getCollection(uri);
    } finally {
      if (db != null)
        db.release(broker);
    }
  }
View Full Code Here

Examples of org.exist.storage.DBBroker

     * The method <code>getNodeValue</code>
     *
     * @return a <code>String</code> value
     */
    public String getNodeValue() {
        DBBroker broker = null;
        try {
            broker = doc.getBrokerPool().get(null);
            if (isDocument()) {
                final Element e = doc.getDocumentElement();
                if (e instanceof NodeProxy) {
                    return broker.getNodeValue(new StoredNode((NodeProxy)e), false);
                } else if (e != null) {
                    return broker.getNodeValue((ElementImpl)e, false);
                } else
                    // probably a binary resource
                    {return "";}
            } else {
                return broker.getNodeValue(new StoredNode(this), false);
            }
        } catch (final EXistException e) {
            //TODO : raise an exception here ! -pb
        } finally {
            doc.getBrokerPool().release(broker);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.