Package org.exist

Examples of org.exist.EXistException


        try {
            broker = factory.getBrokerPool().get(user);
            doc = broker.getXMLResource(name, Lock.READ_LOCK);
           
            if(doc == null) {
                throw new EXistException("Resource " + name + " not found");
            }
           
            if(doc.getResourceType() != DocumentImpl.BINARY_FILE) {
                throw new EXistException("Document " + name + " is not a binary resource");
            }
           
            if(!doc.getPermissions().validate(user, requiredPermissions)) {
                throw new PermissionDeniedException("Insufficient privileges to access resource");
            }
           
            try {
                final InputStream is = broker.getBinaryResource((BinaryDocument)doc);
    final long resourceSize = broker.getBinaryResourceSize((BinaryDocument)doc);
    if(resourceSize > (long)Integer.MAX_VALUE) {
                    throw new EXistException("Resource too big to be read using this method.");
    }
                final byte[] data = new byte[(int)resourceSize];
                is.read(data);
                is.close();
                return data;
            } catch(final IOException ex) {
               throw new EXistException("I/O error while reading resource.",ex);
            }
        } finally {
            if(doc != null) {
                doc.getUpdateLock().release(Lock.READ_LOCK);
            }
View Full Code Here


        try {
            broker = factory.getBrokerPool().get(user);
            final Collection collection = broker.getCollection(collUri);
            if (collection == null) {
                transact.abort(transaction);
                throw new EXistException("collection " + collUri + " not found");
            }
            //TODO : register a lock (which one ?) in the transaction ?
            final DocumentSet docs = collection.allDocs(broker, new DefaultDocumentSet(), true);
            final XUpdateProcessor processor = new XUpdateProcessor(broker, docs, AccessContext.XMLRPC);
            final Modification modifications[] = processor.parse(new InputSource(new StringReader(xupdate)));
            long mods = 0;
            for (int i = 0; i < modifications.length; i++) {
                mods += modifications[i].process(transaction);
                broker.flush();
            }
            transact.commit(transaction);
            return (int) mods;
        } catch (final ParserConfigurationException e) {
            transact.abort(transaction);
            throw new EXistException(e.getMessage());
        } catch (final IOException e) {
            transact.abort(transaction);
            throw new EXistException(e.getMessage());
        } finally {
            transact.close(transaction);
            factory.getBrokerPool().release(broker);
        }
    }
View Full Code Here

        try {
            broker = factory.getBrokerPool().get(user);
            final DocumentImpl doc = broker.getResource(docUri, Permission.READ);
            if (doc == null) {
                transact.abort(transaction);
                throw new EXistException("document " + docUri + " not found");
            }
            //TODO : register a lock (which one ?) within the transaction ?
            final MutableDocumentSet docs = new DefaultDocumentSet();
            docs.add(doc);
            final XUpdateProcessor processor = new XUpdateProcessor(broker, docs, AccessContext.XMLRPC);
            final Modification modifications[] = processor.parse(new InputSource(
                    new StringReader(xupdate)));
            long mods = 0;
            for (int i = 0; i < modifications.length; i++) {
                mods += modifications[i].process(transaction);
                broker.flush();
            }
            transact.commit(transaction);
            return (int) mods;
        } catch (final ParserConfigurationException e) {
            transact.abort(transaction);
            throw new EXistException(e.getMessage());
        } catch (final IOException e) {
            transact.abort(transaction);
            throw new EXistException(e.getMessage());
        } finally {
            transact.close(transaction);
            factory.getBrokerPool().release(broker);
        }
    }
View Full Code Here

     */
    @Override
    public int getHits(int resultId) throws EXistException {
        final QueryResult qr = factory.resultSets.getResult(resultId);
        if (qr == null)
            {throw new EXistException("result set unknown or timed out");}
        qr.touch();
        if (qr.result == null)
            {return 0;}
        return qr.result.getItemCount();
    }
View Full Code Here

            if(collection == null) {
                DocumentImpl doc = null;
                try {
                    doc = broker.getXMLResource(uri, Lock.READ_LOCK);
                    if(doc == null) {
                        throw new EXistException("document or collection " + uri + " not found");
                    }
                    perm = doc.getPermissions();
                } finally {
                    if(doc != null) {
                        doc.getUpdateLock().release(Lock.READ_LOCK);
View Full Code Here

        try {
            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(uri, Lock.READ_LOCK);
            Permission perm = null;
            if(collection == null) {
                throw new EXistException("collection " + uri + " not found");
            } else {
                perm = collection.getSubCollectionEntry(broker, name).getPermissions();
            }

            final HashMap<String, Object> result = new HashMap<String, Object>();
View Full Code Here

        try {
            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(uri, Lock.READ_LOCK);
            Permission perm = null;
            if(collection == null) {
                throw new EXistException("collection " + uri + " not found");
            } else {
                perm = collection.getResourceEntry(broker, name).getPermissions();
            }

            final HashMap<String, Object> result = new HashMap<String, Object>();
View Full Code Here

        try {
            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(uri, Lock.READ_LOCK);
            if(collection == null) {
                throw new EXistException("collection " + uri + " not found");
            } else {
                return collection.getSubCollectionEntry(broker, name).getCreated();
            }

        } finally {
View Full Code Here

        Collection collection = null;
        try {
            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(collUri, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + collUri + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException(
                        "not allowed to read collection " + collUri);}
            final HashMap<String, List<Object>> result = new HashMap<String, List<Object>>(collection.getDocumentCount(broker));
View Full Code Here

        Collection collection = null;
        try {
            broker = factory.getBrokerPool().get(user);
            collection = broker.openCollection(collUri, Lock.READ_LOCK);
            if (collection == null)
                {throw new EXistException("Collection " + collUri + " not found");}
            if (!collection.getPermissionsNoLock().validate(user, Permission.READ))
                {throw new PermissionDeniedException("not allowed to read collection " + collUri);}
            final HashMap<XmldbURI, List<Object>> result = new HashMap<XmldbURI, List<Object>>(collection.getChildCollectionCount(broker));
            for (final Iterator<XmldbURI> i = collection.collectionIterator(broker); i.hasNext(); ) {
              final XmldbURI child = i.next();
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.