Package org.exist.dom

Examples of org.exist.dom.BinaryDocument


            Txn transaction = transact.beginTransaction();
            System.out.println("Transaction started ...");
           
            XmldbURI docPath = TestConstants.TEST_COLLECTION_URI.append(DOCUMENT_NAME_URI);
           
            BinaryDocument binDoc = (BinaryDocument) broker
                    .getXMLResource(docPath, Lock.READ_LOCK);
           
            // if document is not present, null is returned
            if(binDoc == null){
                fail("Binary document '" + docPath + " does not exist.");
            } else {
               InputStream is = broker.getBinaryResource(binDoc);
               data = new byte[(int)broker.getBinaryResourceSize(binDoc)];
               is.read(data);
               is.close();
                binDoc.getUpdateLock().release(Lock.READ_LOCK);
            }
           
            Collection collection = broker.getCollection(TestConstants.TEST_COLLECTION_URI);
            broker.removeCollection(transaction, collection);
           
View Full Code Here


            {
                return defaultReturn;
            }
            else if(isCalledAs("binary-doc"))
            {
                final BinaryDocument bin = (BinaryDocument) doc;
                final InputStream is = context.getBroker().getBinaryResource(bin);

                /*
                long binaryLength = context.getBroker().getBinaryResourceSize(bin);

View Full Code Here

    if(inputSource!=null)
      {return inputSource;}

    final Subject preserveSubject = pool.getSubject();
    DBBroker broker = null;
    BinaryDocument blob = null;
    InputStream rawDataStream = null;
    try {
      broker = pool.get(user);
      blob = (BinaryDocument)getDocument(broker, Lock.READ_LOCK);
      if(!blob.getPermissions().validate(user, Permission.READ))
          {throw new XMLDBException(ErrorCodes.PERMISSION_DENIED,
            "Permission denied to read resource");}
     
      rawDataStream = broker.getBinaryResource(blob);
    } catch(final EXistException e) {
View Full Code Here

    } else if(rawData!=null) {
      retval=new ByteArrayInputStream(rawData);
    } else {
      final Subject preserveSubject = pool.getSubject();
      DBBroker broker = null;
      BinaryDocument blob = null;
      try {
        broker = pool.get(user);
        blob = (BinaryDocument)getDocument(broker, Lock.READ_LOCK);
        if(!blob.getPermissions().validate(user, Permission.READ))
            {throw new XMLDBException(ErrorCodes.PERMISSION_DENIED,
              "Permission denied to read resource");}
       
        retval = broker.getBinaryResource(blob);
      } catch(final EXistException e) {
View Full Code Here

  }
 
  public void getContentIntoAStream(OutputStream os) throws XMLDBException {
    final Subject preserveSubject = pool.getSubject();
    DBBroker broker = null;
    BinaryDocument blob = null;
    boolean doClose=false;
    try {
      broker = pool.get(user);
      blob = (BinaryDocument)getDocument(broker, Lock.READ_LOCK);
      if(!blob.getPermissions().validate(user, Permission.READ))
        {throw new XMLDBException(ErrorCodes.PERMISSION_DENIED,
          "Permission denied to read resource");}
     
      // Improving the performance a bit for files!
      if(os instanceof FileOutputStream) {
View Full Code Here

    } else if(rawData!=null) {
      retval=rawData.length;
    } else {
      final Subject preserveSubject = pool.getSubject();
      DBBroker broker = null;
      BinaryDocument blob = null;
      try {
        broker = pool.get(user);
        blob = (BinaryDocument)getDocument(broker, Lock.READ_LOCK);
        retval=blob.getContentLength();
      } catch(final EXistException e) {
        throw new XMLDBException(ErrorCodes.VENDOR_ERROR,
          "error while loading binary resource " + getId(), e);
      } finally {
        if(blob!=null)
View Full Code Here

            {throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored");}
    final Subject preserveSubject = pool.getSubject();
    DBBroker broker = null;
    try {
      broker = pool.get(user);
      final BinaryDocument blob = (BinaryDocument)getDocument(broker, Lock.NO_LOCK);
      return new Date(blob.getMetadata().getCreated());
    } catch (final EXistException e) {
      throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e);
    } finally {
      pool.release(broker);
      pool.setSubject(preserveSubject);
View Full Code Here

            {throw new XMLDBException(ErrorCodes.INVALID_RESOURCE, "The resource has not yet been stored");}
    final Subject preserveSubject = pool.getSubject();
    DBBroker broker = null;
    try {
      broker = pool.get(user);
      final BinaryDocument blob = (BinaryDocument)getDocument(broker, Lock.NO_LOCK);
      return new Date(blob.getMetadata().getLastModified());
    } catch (final EXistException e) {
      throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e);
    } finally {
      pool.release(broker);
      pool.setSubject(preserveSubject);
View Full Code Here

            {return mimeType;}
    final Subject preserveSubject = pool.getSubject();
        DBBroker broker = null;
        try {
            broker = pool.get(user);
            final BinaryDocument blob = (BinaryDocument)getDocument(broker, Lock.NO_LOCK);
            mimeType = blob.getMetadata().getMimeType();
            return mimeType;
        } catch (final EXistException e) {
            throw new XMLDBException(ErrorCodes.UNKNOWN_ERROR, e.getMessage(), e);
        } finally {
            pool.release(broker);
View Full Code Here

       *
       * @return true if the description is valid, false otherwise
       */
      public boolean isValid()
      {
        BinaryDocument docXQWS = null;
       
        try
        {
          docXQWS = getXQWS(broker, XQWSPath);
          return (docXQWS.getMetadata().getLastModified() == lastModifiedXQWS);
        }
        catch(final PermissionDeniedException e)
        {
          LOG.debug(e.getMessage());
          return false;
        }
        finally
        {
          if(docXQWS != null)
          {
            docXQWS.getUpdateLock().release(Lock.READ_LOCK);
          }
        }
      }
View Full Code Here

TOP

Related Classes of org.exist.dom.BinaryDocument

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.