Package org.exist.storage

Examples of org.exist.storage.DBBroker


        throw new RemoteException("Invalid collection URI",e);
      }
    }
    public org.exist.soap.Collection listCollection(java.lang.String sessionId, XmldbURI path) throws java.rmi.RemoteException {
        final Session session = getSession(sessionId);
        DBBroker broker = null;
        try {
            broker = pool.get(session.getUser());
            if (path == null)
                {path = XmldbURI.ROOT_COLLECTION_URI;}
            final org.exist.collections.Collection collection = broker.getCollection(path);
            if (collection == null)
                {throw new RemoteException("collection " + path + " not found");}
            if (!collection.getPermissionsNoLock().validate(session.getUser(), Permission.READ))
                {throw new RemoteException("permission denied");}
            final Collection c = new Collection();
View Full Code Here


    public org.exist.soap.QueryResponse query(java.lang.String sessionId, java.lang.String xpath) throws java.rmi.RemoteException {
        final Session session = getSession(sessionId);
       
        final QueryResponse resp = new QueryResponse();
        resp.setHits(0);
        DBBroker broker = null;
        try {
//            xpath = StringValue.expand(xpath);
            LOG.debug("query: " + xpath);
            broker = pool.get(session.getUser());
            final XQueryContext context = new XQueryContext(pool, AccessContext.SOAP);
View Full Code Here

        return new Base64BinaryArray(data);
    }
   
    public java.lang.String[] retrieve(java.lang.String sessionId, int start, int howmany, boolean indent, boolean xinclude, java.lang.String highlight) throws java.rmi.RemoteException {
        final Session session = getSession(sessionId);
        DBBroker broker = null;
        try {
            broker = pool.get(session.getUser());
            final QueryResult queryResult = session.getQueryResult();
            if (queryResult == null)
                {throw new RemoteException("result set unknown or timed out");}
            final Sequence seq = (Sequence) queryResult.result;
            if (start < 1 || start > seq.getItemCount())
                {throw new RuntimeException(
                        "index " + start + " out of bounds (" + seq.getItemCount() + ")");}
            if (start + howmany > seq.getItemCount() || howmany == 0)
                {howmany = seq.getItemCount() - start + 1;}
           
            final String xml[] = new String[howmany];
            final Serializer serializer = broker.getSerializer();
            serializer.reset();
            serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
            serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
           
View Full Code Here

        }
    }
   
    public java.lang.String[] retrieveByDocument(java.lang.String sessionId, int start, int howmany, java.lang.String path, boolean indent, boolean xinclude, java.lang.String highlight) throws java.rmi.RemoteException {
        final Session session = getSession(sessionId);
        DBBroker broker = null;
        try {
            broker = pool.get(session.getUser());
            final Sequence qr = (Sequence) session.getQueryResult().result;
            if (qr == null)
                {throw new RemoteException("result set unknown or timed out");}
            String xml[] = null;
            if (Type.subTypeOf(qr.getItemType(), Type.NODE)) {
                // Fix typecast exception RMT
//        NodeList resultSet = (NodeSet)qr;
                final ExtArrayNodeSet hitsByDoc = new ExtArrayNodeSet();
                NodeProxy p;
                String ppath;
                for (final SequenceIterator i = qr.iterate(); i.hasNext(); ) {
//        for (Iterator i = ((NodeSet) resultSet).iterator(); i.hasNext();) {
                    p = (NodeProxy) i.nextItem();
                    ///TODO : use dedicated function in XmldbURI
                    ppath = p.getDocument().getCollection().getURI().toString() + '/' + p.getDocument().getFileURI();
                    if (ppath.equals(path))
                        {hitsByDoc.add(p);}
                }
                --start;
                if (start < 0 || start > hitsByDoc.getLength())
                    {throw new RemoteException(
                            "index " + start + "out of bounds (" + hitsByDoc.getLength() + ")");}
                if (start + howmany >= hitsByDoc.getLength())
                    {howmany = hitsByDoc.getLength() - start;}
                final Serializer serializer = broker.getSerializer();
                serializer.reset();
                serializer.setProperty(OutputKeys.INDENT, indent ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.EXPAND_XINCLUDES, xinclude ? "yes" : "no");
                serializer.setProperty(EXistOutputKeys.HIGHLIGHT_MATCHES, highlight);
               
View Full Code Here

            convertor.release();
        }
    }

    private Sequence enviroment(String file) throws Exception {
        DBBroker broker = null;
        XQuery xquery = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "xmldb:document('" + file + "')";

            return xquery.execute(query, null, AccessContext.TEST);
View Full Code Here

    }

    private HashMap<String, Sequence> enviroments(String file) {
        HashMap<String, Sequence> enviroments = new HashMap<String, Sequence>();

        DBBroker broker = null;
        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            XQuery xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "declare namespace qt='" + QT_NS + "';\n" + "let $testCases := xmldb:document('/db/QT3/" + file + "')\n"
                    + "let $tc := $testCases//qt:environment\n" + "return $tc";

            Sequence result = xquery.execute(query, null, AccessContext.TEST);
View Full Code Here

    }

    private String getEnviroment(String file, String name) {
        String enviroment = null;

        DBBroker broker = null;
        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            XQuery xquery = broker.getXQueryService();

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "declare namespace qt='" + QT_NS + "';\n" + "let $testCases := xmldb:document('/db/QT3/" + file + "')\n"
                    + "let $tc := $testCases//qt:environment[@name eq '" + name + "']\n" + "let $catalog := xmldb:document('/db/QT3/catalog.xml')\n"
                    + "let $cat := $catalog//qt:environment[@name eq '" + name + "']\n" + "return ($tc, $cat)";
View Full Code Here

    }

    protected void testCase(String file, String tcName) {
        System.out.println("test " + tcName);

        DBBroker broker = null;
        Sequence result = null;
        XQuery xquery = null;

        // try {
        Set<String> extectedError = new HashSet<String>();
        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());
            xquery = broker.getXQueryService();

            final XQueryContext context = new XQueryContext(db, AccessContext.TEST);

            broker.getConfiguration().setProperty(XQueryContext.PROPERTY_XQUERY_RAISE_ERROR_ON_FAILED_RETRIEVAL, true);

            String query = "declare namespace qt='" + QT_NS + "';\n" + "let $testCases := xmldb:document('/db/QT3/" + file + "')\n"
                    + "let $tc := $testCases//qt:test-case[@name eq \"" + tcName + "\"]\n" + "return $tc";

            XQuery xqs = broker.getXQueryService();

            Sequence results = xqs.execute(query, null, AccessContext.TEST);

            Assert.assertFalse("", results.isEmpty());
View Full Code Here

        BrokerPool db = BrokerPool.getInstance();

        db.registerDocumentTrigger(AnotherTrigger.class);

        DBBroker broker = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());

            Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", "");

            Resource resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT1_CONTENT);
            root.storeResource(resource);

            assertEquals(3, AnotherTrigger.createDocumentEvents);

            assertEquals(26, AnotherTrigger.count);

            assertEquals(DOCUMENT1_CONTENT, AnotherTrigger.sb.toString());

        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
            if (broker != null)
                broker.release();
        }
    }
View Full Code Here

        BrokerPool db = BrokerPool.getInstance();

        db.registerDocumentTrigger(StoreTrigger.class);

        DBBroker broker = null;

        try {
            broker = db.get(db.getSecurityManager().getSystemSubject());

            Collection root = DatabaseManager.getCollection(BASE_URI + testCollection, "admin", "");

            Resource resource = root.createResource("data.xml", "XMLResource");
            resource.setContent(DOCUMENT2_CONTENT);
            root.storeResource(resource);

            resource = root.createResource("data.xml", "XMLResource");

            assertEquals(DOCUMENT3_CONTENT, resource.getContent().toString());

        } catch (XMLDBException e) {
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
            if (broker != null)
                broker.release();
        }
    }
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.