Package org.exist.dom

Examples of org.exist.dom.DocumentImpl


        }
       
        /* xmldb: */
        else if(location.startsWith(XmldbURI.XMLDB_URI_PREFIX))
        {
          DocumentImpl resource = null;
          try
          {
        final XmldbURI pathUri = XmldbURI.create(location);
        resource = broker.getXMLResource(pathUri, Lock.READ_LOCK);
        if (resource != null)
          {source = new DBSource(broker, (BinaryDocument)resource, true);}
          }
      finally
      {
        //TODO: this is nasty!!! as we are unlocking the resource whilst there
        //is still a source
        if(resource != null)
          {resource.getUpdateLock().release(Lock.READ_LOCK);}
      }
        }
       
        /* resource: */
        else if(location.startsWith(ClassLoaderSource.PROTOCOL))
View Full Code Here


            final int             docId        = CollectionStore.DocumentKey.getDocumentId( key );

            try {
                final byte              type    = key.data()[key.start() + Collection.LENGTH_COLLECTION_ID + DocumentImpl.LENGTH_DOCUMENT_TYPE];
                final VariableByteInput istream = store.getAsStream( pointer );
                DocumentImpl      doc     = null;

                if( type == DocumentImpl.BINARY_FILE ) {
                    doc = new BinaryDocument( broker.getBrokerPool() );
                } else {
                    doc = new DocumentImpl( broker.getBrokerPool() );
                }
                doc.read( istream );
                docCount++;

                if( checkDocs ) {

                    if( progress != null ) {
                        progress.startDocument( doc.getFileURI().toString(), docCount, getDocumentCount() );
                    }
                    int percentage = 100 * ( docCount + 1 ) / ( getDocumentCount() + 1 );

                    if( ( jmxAgent != null ) && ( percentage != lastPercentage ) ) {
                        lastPercentage = percentage;
View Full Code Here

        /**
         * Sort the documents in the pending list by their storage page, then
         * check each of them.
         */
        public void checkDocs() {
            DocumentImpl documents[] = new DocumentImpl[docs.size()];
            docs.toArray(documents);
            Arrays.sort(documents, new Comparator<DocumentImpl>() {
                @Override
                public int compare(DocumentImpl d1, DocumentImpl d2) {
                    final long a1 = StorageAddress.pageFromPointer(d1.getFirstChildAddress());
View Full Code Here

            }

      final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
      final Txn txn = txnManager.beginTransaction();
 
      DocumentImpl resource = null;
      try {
        if ("XMLResource".equals(type)) {
          // store as xml resource
         
          final IndexInfo info = currentCollection.validateXMLResource(txn, broker, docUri, is);
         
          resource = info.getDocument();
          final DocumentMetadata meta = resource.getMetadata();
          meta.setMimeType(mimetype);
          meta.setCreated(date_created.getTime());
          meta.setLastModified(date_modified.getTime());
         
                  if((publicid != null) || (systemid != null)) {
View Full Code Here

        } else if("resource".equals(type)) {

          try {
            final XmldbURI uri = XmldbURI.create(name);
            final DocumentImpl doc = currentCollection.getDocument(broker, uri);
           
            if (doc != null) {
              final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
              final Txn txn = txnManager.beginTransaction();
                try {
                 
                  if (doc.getResourceType() == DocumentImpl.BINARY_FILE) {
                      currentCollection.removeBinaryResource(txn, broker, uri);
                  } else {
                    currentCollection.removeXMLResource(txn, broker, uri);
                  }
                  txnManager.commit(txn);
View Full Code Here

    return key;
  }

  public Object getValue() {
    try {
      DocumentImpl doc = MetaData.inst.getDocument(value);
      if (doc != null) return doc;
    } catch (Exception e) {
      //LOG
    }
    return value;
View Full Code Here

          assertNotNull(docMD);
         
          String uuid = docMD.getUUID();
          assertNotNull(uuid);
         
          DocumentImpl doc = MetaData.get().getDocument(uuid);
          assertNotNull(doc);
          assertTrue(doc1.equals(doc));
   
          //add first key-value
          docMD.put(KEY1, VALUE1);
View Full Code Here

        return tempFile;
    }

    public static void restore(DBBroker broker) throws IOException, PermissionDeniedException {
        final XmldbURI docPath = XmldbURI.createInternal(XmldbURI.ROOT_COLLECTION + "/" + REPO_ARCHIVE);
        DocumentImpl doc = null;
        try {
            doc = broker.getXMLResource(docPath, Lock.READ_LOCK);
            if (doc == null)
                {return;}
            if (doc.getResourceType() != DocumentImpl.BINARY_FILE)
                {throw new IOException(docPath + " is not a binary resource");}

            final File file = ((NativeBroker)broker).getCollectionBinaryFileFsPath(doc.getURI());
            final File directory = ExistRepository.getRepositoryDir(broker.getConfiguration());
            unzip(file, directory);
        } finally {
            if (doc != null)
                {doc.getUpdateLock().release(Lock.READ_LOCK);}
        }
    }
View Full Code Here

            if (collection == null) {
                transact.abort(txn);
                throw new EXistException(
                        "Collection " + collectionUri + " not found");
            }
            final DocumentImpl doc = collection.getDocument(broker, docUri);
            if(doc == null)
                {throw new EXistException("Document " + docUri + " not found");}
           
            if(doc.getResourceType() == DocumentImpl.BINARY_FILE)
                {collection.removeBinaryResource(txn, broker, doc);}
            else
                {collection.removeXMLResource(txn, broker, docUri);}
           
            transact.commit(txn);
View Full Code Here

            if (collection == null) {
                transact.abort(txn);
                throw new EXistException("Collection " + collectionUri + " not found");
            }
            if(!replace) {
                final DocumentImpl old = collection.getDocument(broker, docUri);
                if(old != null) {
                    transact.abort(txn);
                    throw new RemoteException("Document exists and overwrite is not allowed");
                }
            }
View Full Code Here

TOP

Related Classes of org.exist.dom.DocumentImpl

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.