Examples of DBBroker


Examples of org.exist.storage.DBBroker

     
      throw new IOException("this never should happen");
    }
   
    private Subject getBrokerUser() throws IOException {
      DBBroker broker = null;
    BrokerPool db = null;

    try {
      db = BrokerPool.getInstance();
      broker = db.get(null);
     
      return broker.getSubject();
    } catch (final EXistException e) {
      throw new IOException(e);
    } finally {
      if (db != null)
        {db.release(broker);}
View Full Code Here

Examples of org.exist.storage.DBBroker

    private URLConnection connection = null;
   
    private URLConnection getConnection() throws IOException {
      if (connection == null) {
      BrokerPool db = null;
      DBBroker broker = null;
      try {
        db = BrokerPool.getInstance();
        broker = db.get(null);
        final Subject subject = broker.getSubject();
       
        final URL url = new URL("xmldb:exist://jsessionid:"+subject.getSessionId()+"@"+ uri.toString());
        connection = url.openConnection();
      } catch (final IllegalArgumentException e) {
        throw new IOException(e);
View Full Code Here

Examples of org.exist.storage.DBBroker

    return resource;
  }

  public Collection getCollection() throws IOException {
    if (!initialized) {
        DBBroker broker = null;
      BrokerPool db = null;

      try {
        try {
          db = BrokerPool.getInstance();
          broker = db.get(null);
        } catch (final EXistException e) {
          throw new IOException(e);
        }
 
        try {
          if (uri.endsWith("/")) {
            collection = broker.getCollection(uri);
          } else {
            collection = broker.getCollection(uri);
            if (collection == null)
              {collection = broker.getCollection(uri.removeLastSegment());}
          }
          if (collection == null)
            {throw new IOException("Collection not found: "+uri);}
         
          return collection;
View Full Code Here

Examples of org.exist.storage.DBBroker

  }
 
  protected void runScript(Subject subject, String scriptURI, String script, QName functionName, List<Expression> args) {
       
    final Database db = getDatabase();
        DBBroker broker = null;
        try {
            broker = db.get(subject);

            final Source source = getQuerySource(broker, scriptURI, script);
            if(source == null) {return;}

            final XQuery xquery = broker.getXQueryService();
            final XQueryContext context = xquery.newContext(AccessContext.XMLDB);

            final CompiledXQuery compiled = xquery.compile(context, source);

//            Sequence result = xquery.execute(compiled, subject.getName());
View Full Code Here

Examples of org.exist.storage.DBBroker

                final AbstractAccount remove_account = (AbstractAccount)principalDb.get(account.getName());
                if(remove_account == null){
                    throw new IllegalArgumentException("No such account exists!");
                }

                DBBroker broker = null;
                try {
                    broker = getDatabase().get(null);
                    final Account user = broker.getSubject();

                    if(!(account.getName().equals(user.getName()) || user.hasDbaRole()) ) {
                        throw new PermissionDeniedException("You are not allowed to delete '" +account.getName() + "' user");
                    }
View Full Code Here

Examples of org.exist.storage.DBBroker

       
              final AbstractPrincipal remove_group = (AbstractPrincipal)principalDb.get(group.getName());
              if(remove_group == null)
                    {throw new IllegalArgumentException("Group does '"+group.getName()+"' not exist!");}
   
              final DBBroker broker = getDatabase().getActiveBroker();
                final Subject subject = broker.getSubject();
               
                ((Group)remove_group).assertCanModifyGroup(subject);
   
                remove_group.setRemoved(true);
                remove_group.setCollection(broker, collectionRemovedGroups, XmldbURI.create(UUIDGenerator.getUUID() + ".xml"));
View Full Code Here

Examples of org.exist.storage.DBBroker

        if (!configDir.isDirectory()) {
            if (!configDir.mkdirs()) {
                return;
            }
        }
      DBBroker broker = null;
      Subject subject = null;
      try {
        broker = BrokerPool.getInstance().getActiveBroker();
        subject = broker.getSubject();
        broker.setSubject(broker.getBrokerPool().getSecurityManager().getSystemSubject());

        Resource configFile = new Resource(configDir, "config");
        Resource serversFile = new Resource(configDir, "servers");
        Resource readmeFile = new Resource(configDir, "README.txt");
       
        writeFile("/org/tmatesoft/svn/core/internal/wc/config/config", configFile);
        writeFile("/org/tmatesoft/svn/core/internal/wc/config/servers", serversFile);
        writeFile("/org/tmatesoft/svn/core/internal/wc/config/README.txt", readmeFile);
      } catch (EXistException e) {
        LOG.debug(e);
    } finally {
      if (broker != null && subject != null)
        broker.setSubject(subject);
      }
    }
View Full Code Here

Examples of org.exist.storage.DBBroker

        configureDefaults();
        reset();
    }
   
    private void configureDefaults() {
      final DBBroker broker = context.getBroker();
        final Configuration conf = broker.getBrokerPool().getConfiguration();
        Object option = conf.getProperty(PROPERTY_QUERY_TIMEOUT);
        if(option != null)
            {timeout = ((Long)option).longValue();}
        if(timeout <= 0)
            {timeout = Long.MAX_VALUE;}
View Full Code Here

Examples of org.exist.storage.DBBroker

        case NodeImpl.NAMESPACE_NODE:
            receiver.addNamespaceNode(document.namespaceCode[nr]);
            break;
        case NodeImpl.REFERENCE_NODE:
            if (expandRefs) {
                DBBroker broker = null;
                try {
                    broker = getDatabase().get(null);
                    final Serializer serializer = broker.getSerializer();
                    serializer.reset();
                    serializer.setProperty(Serializer.GENERATE_DOC_EVENTS, "false");
                    serializer.setReceiver(receiver);
                    serializer.toReceiver(document.references[document.alpha[nr]], false, false);
                } catch (final EXistException e) {
View Full Code Here

Examples of org.exist.storage.DBBroker

        }
        return oldNode;
    }

    public void removeAppendAttributes(Txn transaction, NodeList removeList, NodeList appendList) {
        DBBroker broker = null;
        try {
            broker = ownerDocument.getBrokerPool().get(null);
            if (removeList != null) {
                try {
                    for (int i=0; i<removeList.getLength(); i++) {
                        final Node oldChild = removeList.item(i);
                        if (!(oldChild instanceof StoredNode))
                            {throw new DOMException(DOMException.WRONG_DOCUMENT_ERR, "Wrong node type");}
                        final StoredNode old = (StoredNode) oldChild;
                        if (!old.nodeId.isChildOf(nodeId))
                            {throw new DOMException(DOMException.NOT_FOUND_ERR, "node " +
                                old.nodeId.getParentId() +
                                " is not a child of element " + nodeId);}
                        final NodePath oldPath = old.getPath();
                        // remove old custom indexes
                        broker.getIndexController().reindex(transaction, old,
                            StreamListener.REMOVE_SOME_NODES);
                        broker.removeNode(transaction, old, oldPath, null);
                        children--;
                        attributes--;
                    }
                } finally {
                    broker.endRemove(transaction);
                }
            }
            final NodePath path = getPath();
            broker.getIndexController().setDocument(ownerDocument, StreamListener.STORE);
            final StreamListener listener = broker.getIndexController().getStreamListener();
            if (children == 0) {
                appendChildren(transaction, nodeId.newChild(), null,
                    new NodeImplRef(this), path, appendList, listener);
            } else {
                if (attributes == 0) {
                    final StoredNode firstChild = (StoredNode) getFirstChild();
                    final NodeId newNodeId = firstChild.nodeId.insertBefore();
                    appendChildren(transaction, newNodeId, firstChild.getNodeId(),
                        new NodeImplRef(this), path, appendList, listener);
                } else {
                    final AttribVisitor visitor = new AttribVisitor();
                    accept(visitor);
                    final NodeId firstChildId = visitor.firstChild == null ? null : visitor.firstChild.nodeId;
                    final NodeId newNodeId = visitor.lastAttrib.nodeId.insertNode(firstChildId);
                    appendChildren(transaction, newNodeId, firstChildId, new NodeImplRef(visitor.lastAttrib),
                            path, appendList, listener);
                }
                setDirty(true);
            }
            attributes += appendList.getLength();

            broker.updateNode(transaction, this, true);
            broker.flush();

        } catch (final EXistException e) {
            LOG.warn("Exception while inserting node: " + e.getMessage(), e);
        } finally {
            if (broker != null)
            broker.release();
        }
    }
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.