Package org.exist.collections

Examples of org.exist.collections.Collection


        final DocumentImpl updatedXML = builder.getDocument();

        final TransactionManager mgr = broker.getBrokerPool().getTransactionManager();
        final Txn txn = mgr.beginTransaction();
        try {
            final Collection collection = broker.getOrCreateCollection(txn, targetCollection);
            final XmldbURI name = XmldbURI.createInternal("repo.xml");
            final IndexInfo info = collection.validateXMLResource(txn, broker, name, updatedXML);
            final Permission permission = info.getDocument().getPermissions();
            setPermissions(false, MimeType.XML_TYPE, permission);

            collection.store(txn, broker, info, updatedXML, false);

            mgr.commit(txn);
        } catch (final Exception e) {
            mgr.abort(txn);
        } finally {
View Full Code Here


     * @param target
     */
    private void scanDirectory(File directory, XmldbURI target, boolean inRootDir) {
        final TransactionManager mgr = broker.getBrokerPool().getTransactionManager();
        final Txn txn = mgr.beginTransaction();
        Collection collection = null;
        try {
            collection = broker.getOrCreateCollection(txn, target);
            setPermissions(true, null, collection.getPermissionsNoLock());
            broker.saveCollection(txn, collection);
            mgr.commit(txn);
        } catch (final Exception e) {
            mgr.abort(txn);
        } finally {
            mgr.close(txn);
        }

        try {
            // lock the collection while we store the files
            // TODO: could be released after each operation
            collection.getLock().acquire(Lock.WRITE_LOCK);
            storeFiles(directory, collection, inRootDir);
        } catch (final LockException e) {
            e.printStackTrace();
        } finally {
            collection.getLock().release(Lock.WRITE_LOCK);
        }

        // scan sub directories
        final File[] files = directory.listFiles();
        for (final File file : files) {
View Full Code Here

      this.pool = pool;
     
        final TransactionManager transaction = pool.getTransactionManager();
        Txn txn = null;
   
        Collection systemCollection = null;
        try {
          systemCollection = broker.getCollection(XmldbURI.SYSTEM_COLLECTION_URI);
                if(systemCollection == null) {
                    txn = transaction.beginTransaction();
                    systemCollection = broker.getOrCreateCollection(txn, XmldbURI.SYSTEM_COLLECTION_URI);
                    if (systemCollection == null)
                            {return;}
                    systemCollection.setPermissions(Permission.DEFAULT_SYSTEM_COLLECTION_PERM);
                    broker.saveCollection(txn, systemCollection);

                    transaction.commit(txn);
                }
        } catch (final Exception e) {
View Full Code Here

        public boolean hasNext() {
            return nextCollection != null;
        }

        public Collection next() {
            final Collection oldCollection = nextCollection;
            nextCollection = null;
            while (pos <= size) {
                if (Type.subTypeOf(values[pos].getType(), Type.NODE)) {
                    final NodeValue node = (NodeValue) values[pos];
                    if (node.getImplementationType() == NodeValue.PERSISTENT_NODE) {
View Full Code Here

    {
        AccountImpl.getSecurityProperties().enableCheckPasswords(false);

        try {
            final List<ErrorReport> errors = new ArrayList<ErrorReport>();
            final Collection        root   = broker.getCollection( XmldbURI.ROOT_COLLECTION_URI );
            checkCollection( root, errors, callback );
            return( errors );
        }
        finally {
            AccountImpl.getSecurityProperties().enableCheckPasswords(true);
View Full Code Here

        try {
            for(final Iterator<XmldbURI> i = collection.collectionIteratorNoLock(broker); i.hasNext(); ) {
                final XmldbURI childUri = i.next();

                try {
                    final Collection child = broker.getCollection( uri.append( childUri ) );

                    if( child == null ) {
                        final ErrorReport.CollectionError error = new org.exist.backup.ErrorReport.CollectionError( org.exist.backup.ErrorReport.CHILD_COLLECTION, "Child collection not found: " + childUri + ", parent is " + uri );
                        error.setCollectionId( collection.getId() );
                        error.setCollectionURI( childUri );
                        errors.add( error );
                        if (callback != null)
                            {callback.error( error );}
                        continue;
                    }
                    if (child.getId() != collection.getId())
                            {checkCollection( child, errors, callback );}
                }
                catch( final Exception e ) {
                    final ErrorReport.CollectionError error = new ErrorReport.CollectionError( org.exist.backup.ErrorReport.CHILD_COLLECTION, "Error while loading child collection: " + childUri + ", parent is " + uri );
                    error.setCollectionId( collection.getId() );
View Full Code Here

        final String type = atts.getValue("type");
       
        if("collection".equals(type)) {

          try {
            final Collection col = broker.getCollection(currentCollection.getURI().append(name));
            if(col != null) {
              //delete
              final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
              final Txn txn = txnManager.beginTransaction();
              try {
View Full Code Here

    private Collection mkcol(XmldbURI collPath, Date created) throws SAXException {
       
      final TransactionManager txnManager = broker.getDatabase().getTransactionManager();
      final Txn txn = txnManager.beginTransaction();
      try {
        final Collection col = broker.getOrCreateCollection(txn, collPath);
       
        txnManager.commit(txn);
       
        return col;
      } catch (final Exception e) {
View Full Code Here

        final int docId = doc.getDocId();
        if (checkDuplicates && contains(docId))
            {return;}
        docIds.set(docId);
        put(docId, doc);
        final Collection collection = doc.getCollection();
        if (collection != null) {
          if (!collectionIds.get(collection.getId())) {
            collectionIds.set(collection.getId());
              collections.add(collection);
          }
        }
    }
View Full Code Here

    try {
      db = BrokerPool.getInstance();
      broker = db.get(null);
     
      XmldbURI uri = XmldbURI.create(ms.uri);
      Collection col = broker.getCollection(uri.removeLastSegment());
      if (col != null) {
        return col.getDocument(broker, uri.lastSegment());
      }
     
      return null;
    } finally {
      if (db != null)
View Full Code Here

TOP

Related Classes of org.exist.collections.Collection

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.