Package org.exist.storage

Examples of org.exist.storage.DBBroker


      } catch(final URISyntaxException e) {
        throw new RemoteException("Invalid collection URI",e);
      }
    }
    public org.exist.soap.EntityPermissionsList listCollectionPermissions(java.lang.String sessionId, XmldbURI name) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        Collection collection = null;
        try {
            broker = pool.get(user);
            collection = broker.openCollection(name, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + name + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException(
                        "not allowed to read collection " + name);}
            final EntityPermissions[] result = new EntityPermissions[collection.getChildCollectionCount(broker)];
            XmldbURI child, path;
            Collection childColl;
            Permission perm;
            int cnt = 0;
            for (final Iterator<XmldbURI> i = collection.collectionIterator(broker); i.hasNext(); ) {
                child = i.next();
                path = name.append(child);
                childColl = broker.getCollection(path);
                perm = childColl.getPermissionsNoLock();
                result[cnt] = new EntityPermissions();
                result[cnt].setName(child.toString());
                result[cnt].setOwner(perm.getOwner().getName());
                result[cnt].setGroup(perm.getGroup().getName());
View Full Code Here


      } catch(final URISyntaxException e) {
        throw new RemoteException("Invalid collection URI",e);
      }
    }
    public org.exist.soap.EntityPermissionsList listDocumentPermissions(java.lang.String sessionId, XmldbURI name) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        Collection collection = null;
        try {
            broker = pool.get(user);
            collection = broker.openCollection(name, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + name + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException(
                        "not allowed to read collection " + name);}
View Full Code Here

      } catch(final URISyntaxException e) {
        throw new RemoteException("Invalid collection URI",e);
      }
    }
    public org.exist.soap.IndexedElements getIndexedElements(java.lang.String sessionId, XmldbURI collectionName, boolean inclusive) throws java.rmi.RemoteException {
        DBBroker broker = null;
        final Session session = getSession(sessionId);
        final Subject user = session.getUser();
        Collection collection = null;
        try {
            broker = pool.get(user);
            collection = broker.openCollection(collectionName, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("collection " + collectionName
                        + " not found");}
            final Occurrences occurrences[] = broker.getElementIndex().scanIndexedElements(collection,
                    inclusive);
            final IndexedElement[] result = new IndexedElement[occurrences.length];
            for (int i = 0; i < occurrences.length; i++) {
                final QName qname = (QName)occurrences[i].getTerm();
                result[i] = new IndexedElement(qname.getLocalName(),qname.getNamespaceURI(),
View Full Code Here

     * Set the owner of this resource for purposes of permission management.
     *
     * @param owner the new owner of this resource
     */
    public void owner(String owner) {
                    DBBroker broker = null;
                    try {
                        broker = db.acquireBroker();
                        permissions.setOwner(owner);
                    } catch(PermissionDeniedException pde) {
                        throw new DatabaseException(pde.getMessage(), pde);
View Full Code Here

     * Set the group that will have privileged access to this resource for purposes of permission management.
     *
     * @param group the new owning group of this resource
     */
    public void group(String group) {
                    DBBroker broker = null;
                    try {
                        broker = db.acquireBroker();
                        permissions.setGroup(group);
                    } catch(PermissionDeniedException pde) {
                        throw new DatabaseException(pde.getMessage(), pde);
View Full Code Here

   *
   * @param writer destination writer
   */
  public void write(Writer writer) {
    staleMarker.check();
    DBBroker broker = null;
    try {
      broker = db.acquireBroker();
      broker.getSerializer().serialize(doc, writer);
    } catch (SAXException e) {
      throw new DatabaseException(e);
    } finally {
      db.releaseBroker(broker);
    }
View Full Code Here

    @Test
    public void simpleQueries() {
        System.out.println("Test simple queries ...");
        DocumentSet docs = configureAndStore(COLLECTION_CONFIG1, XML1, "test.xml");
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);

            checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1);
            Occurrences[] o = checkIndex(docs, broker, new QName[]{new QName("p", "")}, "with", 1);
            assertEquals(2, o[0].getOccurrences());
            checkIndex(docs, broker, new QName[] { new QName("hi", "") }, "just", 1);
            checkIndex(docs, broker, null, "in", 1);

            QName attrQN = new QName("rend", "");
            attrQN.setNameType(ElementValue.ATTRIBUTE);
            checkIndex(docs, broker, new QName[] { attrQN }, null, 2);
            checkIndex(docs, broker, new QName[] { attrQN }, "center", 1);
            checkIndex(docs, broker, new QName[] { attrQN }, "right", 1);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("/section[ft:query(p, 'content')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());
View Full Code Here

    }

    @Test
    public void configuration() {
        DocumentSet docs = configureAndStore(COLLECTION_CONFIG4, XML4, "test.xml");
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);

            checkIndex(docs, broker, new QName[] { new QName("a", "") }, "x", 1);
            checkIndex(docs, broker, new QName[] { new QName("c", "") }, "x", 1);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("/test[ft:query(a, 'x')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());
View Full Code Here

    @Test
    public void inlineAndIgnore() {
        System.out.println("Test simple queries ...");
        DocumentSet docs = configureAndStore(COLLECTION_CONFIG5, XML5, "test.xml");
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);

            checkIndex(docs, broker, new QName[] { new QName("head", "") }, "title", 1);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "simple", 1);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "mixed", 1);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "dangerous", 1);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "note", 0);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "ignore", 0);
            checkIndex(docs, broker, new QName[] { new QName("p", "") }, "warnings", 1);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("/article[ft:query(head, 'title')]", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(1, seq.getItemCount());
View Full Code Here

    }

    @Test
    public void boosts() {
        configureAndStore(COLLECTION_CONFIG6, XML6, "test.xml");
        DBBroker broker = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);

            XQuery xquery = broker.getXQueryService();
            assertNotNull(xquery);
            Sequence seq = xquery.execute("for $a in ft:query((//b|//c), 'AAA') " +
                    "order by ft:score($a) descending return $a/local-name(.)", null, AccessContext.TEST);
            assertNotNull(seq);
            assertEquals(3, seq.getItemCount());
View Full Code Here

TOP

Related Classes of org.exist.storage.DBBroker

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.