• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java XmldbURI类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.exist.xmldb.XmldbURI的典型用法代码示例。如果您正苦于以下问题:Java XmldbURI类的具体用法?Java XmldbURI怎么用?Java XmldbURI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



XmldbURI类属于org.exist.xmldb包,在下文中一共展示了XmldbURI类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: dropSingleDocument

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Test
public void dropSingleDocument() {
    final BrokerPool pool = existEmbeddedServer.getBrokerPool();
    final TransactionManager transact = pool.getTransactionManager();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
         final Txn transaction = transact.beginTransaction()) {

        TDBIndexWorker worker = (TDBIndexWorker) broker.getIndexController().getWorkerByIndexId(TDBRDFIndex.ID);

        DocumentSet docs = configureAndStore(COLLECTION_CONFIG, XML, "dropDocument.xml");
        DocumentImpl doc = docs.getDocumentIterator().next();

        assertTrue(worker.isDocumentIndexed(doc));

        root.removeXMLResource(transaction, broker, XmldbURI.create("dropDocument.xml"));

        transact.commit(transaction);

        assertFalse(worker.isDocumentIndexed(doc));

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:ljo,项目名称:exist-sparql,代码行数:26,代码来源:RDFIndexTest.java


示例2: configureAndStore

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
private DocumentSet configureAndStore(String configuration, String data, String docName) {
    MutableDocumentSet docs = new DefaultDocumentSet();
    final BrokerPool pool = existEmbeddedServer.getBrokerPool();
    final TransactionManager transact = pool.getTransactionManager();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
         final Txn transaction = transact.beginTransaction()) {

        if (configuration != null) {
            CollectionConfigurationManager mgr = pool.getConfigurationManager();
            mgr.addConfiguration(transaction, broker, root, configuration);
        }

        IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(docName), data);
        assertNotNull(info);
        root.store(transaction, broker, info, data);

        docs.add(info.getDocument());
        transact.commit(transaction);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    return docs;
}
 
开发者ID:ljo,项目名称:exist-sparql,代码行数:25,代码来源:RDFIndexTest.java


示例3: cleanup

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@After
    public void cleanup() throws EXistException {
        final BrokerPool pool = existEmbeddedServer.getBrokerPool();
        final TransactionManager transact = pool.getTransactionManager();
        try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
             final Txn transaction = transact.beginTransaction()) {

            Collection collConfig = broker.getOrCreateCollection(transaction,
                    XmldbURI.create(XmldbURI.CONFIG_COLLECTION + "/db"));
            assertNotNull(collConfig);
            broker.removeCollection(transaction, collConfig);

            if (root != null) {
                assertNotNull(root);
                broker.removeCollection(transaction, root);
            }
            transact.commit(transaction);

//            Configuration config = BrokerPool.getInstance().getConfiguration();
//            config.setProperty(Indexer.PROPERTY_PRESERVE_WS_MIXED_CONTENT, savedConfig);
        } catch (Exception e) {
            e.printStackTrace();
            fail(e.getMessage());
        }
    }
 
开发者ID:ljo,项目名称:exist-sparql,代码行数:26,代码来源:RDFIndexTest.java


示例4: configure

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Override
public void configure(final DBBroker broker, final Collection collection, final Map<String, List<? extends Object>> parameters) throws TriggerException {

    //extract the black list parameter value from the parameters
    final List<String> lst = (List<String>)parameters.get(BLACKLIST_PARAM);
    if(lst == null) {
        throw new TriggerException("The parameter '" + blacklist + "' has not been provided in the collection configuration of '" + collection.getURI() + "' for '" + getClass().getName() + "'.");
    }

    for(final String blacklisted : lst) {
        try {
            this.blacklist.add(XmldbURI.create(blacklisted));
        } catch(final IllegalArgumentException iae) {
            LOG.warn("Skipping... collection uri '" + blacklisted + "' provided in the black list is invalid: " + iae.getMessage());
        }
    }

    //extract the optional protectMode parameter value from the parameters
    final List<String> protect = (List<String>)parameters.get(PROTECT_MOVE_PARAM);
    if(protect != null && protect.size() == 1) {
        this.protectMove = Boolean.parseBoolean(protect.get(0));
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:24,代码来源:NoDeleteCollectionTrigger.java


示例5: beforeMoveCollection

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Override
public void beforeMoveCollection(final DBBroker broker, final Txn txn, final Collection collection, final XmldbURI newUri) throws TriggerException {
    /**
     * If we are protecting moves (as a form
     * of delete) and the collection is on
     * the blacklist, we throw a TriggerException
     * to abort the operation which is attempting
     * to move the collection.
     *
     * After all a Move would remove the
     * original location of the collection!
     */
    if(protectMove && blacklist.contains(collection.getURI())) {
        LOG.info("Preventing move of blacklisted collection '" + collection.getURI() + "'.");
        throw new TriggerException("The collection '" + collection.getURI().lastSegment() + "' is black-listed by the NoDeleteCollectionTrigger and may not be moved, consider a copy instead!");
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:18,代码来源:NoDeleteCollectionTrigger.java


示例6: getPipelineArgument

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
private Either<XmldbURI, InputStream> getPipelineArgument(final Sequence[] args) throws IOException, XPathException, SAXException {
    final Sequence pipe = args[0];
    if (Type.subTypeOf(pipe.getItemType(), Type.DOCUMENT) || Type.subTypeOf(pipe.getItemType(), Type.ELEMENT)) {
        try (final StringWriter writer = new StringWriter()) {
            final XQuerySerializer xqSerializer = new XQuerySerializer(context.getBroker(), new Properties(), writer);
            xqSerializer.serialize(pipe);
            return Either.Right(new ByteArrayInputStream(writer.toString().getBytes(UTF_8)));
        }
    } else if(Type.subTypeOf(pipe.getItemType(), Type.ANY_URI)) {
        return Either.Left(((AnyURIValue)pipe.itemAt(0).convertTo(Type.ANY_URI)).toXmldbURI());
    } else if(Type.subTypeOf(pipe.getItemType(), Type.STRING)) {
        return Either.Left(XmldbURI.create(pipe.itemAt(0).getStringValue()));
    } else {
        throw new XPathException(this, "$pipeline must be either document(), element() or xs:anyURI (or xs:anyURI as xs:string)");
    }
}
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:17,代码来源:ProcessFunction.java


示例7: configureAndStore

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
private DocumentSet configureAndStore(final String configuration, final String data, final String docName) throws EXistException, CollectionConfigurationException, LockException, SAXException, PermissionDeniedException, IOException {
    final MutableDocumentSet docs = new DefaultDocumentSet();
    final TransactionManager transact = pool.getTransactionManager();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
         final Txn transaction = transact.beginTransaction()) {

        if (configuration != null) {
            final CollectionConfigurationManager mgr = pool.getConfigurationManager();
            mgr.addConfiguration(transaction, broker, root, configuration);
        }

        final IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(docName), data);
        assertNotNull(info);
        root.store(transaction, broker, info, data);

        docs.add(info.getDocument());
        transact.commit(transaction);
    }
    return docs;
}
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:21,代码来源:Simplest.java


示例8: setup

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Before
public void setup() throws EXistException, PermissionDeniedException, IOException, TriggerException {
    final TransactionManager transact = pool.getTransactionManager();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
         final Txn transaction = transact.beginTransaction()) {

        root = broker.getOrCreateCollection(transaction, XmldbURI.ROOT_COLLECTION_URI.append("test"));
        assertNotNull(root);

        //root.setPermissions(0770);

        broker.saveCollection(transaction, root);

        transact.commit(transaction);

    }
}
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:18,代码来源:Simplest.java


示例9: cleanup

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@After
    public void cleanup() throws EXistException, PermissionDeniedException, IOException, TriggerException {
        final BrokerPool pool = BrokerPool.getInstance();
        final TransactionManager transact = pool.getTransactionManager();
        try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
             final Txn transaction = transact.beginTransaction()) {

            final Collection collConfig = broker.getOrCreateCollection(transaction, XmldbURI.CONFIG_COLLECTION_URI.append("db"));
            assertNotNull(collConfig);
            broker.removeCollection(transaction, collConfig);

//            if (root != null) {
//                assertNotNull(root);
//                broker.removeCollection(transaction, root);
//            }
            transact.commit(transaction);

        }
    }
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:20,代码来源:Simplest.java


示例10: run

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
public Sequence run(final BinaryDocument xq) throws Exception {
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()))) {
        assertNotNull(broker);

        final XQuery xquery = pool.getXQueryService();
        assertNotNull(xquery);

        final DBSource source = new DBSource(broker, xq, true);
        final XQueryContext context = new XQueryContext(pool);
        context.setModuleLoadPath(XmldbURI.EMBEDDED_SERVER_URI.append(xq.getCollection().getURI()).toString());
        context.setStaticallyKnownDocuments(new XmldbURI[]{
                xq.getCollection().getURI()
        });

        final CompiledXQuery compiled = xquery.compile(broker, context, source);
        return xquery.execute(broker, compiled, null);

    }
}
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:20,代码来源:ExternalTests.java


示例11: configureAndStore

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
private DocumentSet configureAndStore(final String configuration, final String data, final String docName) throws EXistException, CollectionConfigurationException, LockException, SAXException, PermissionDeniedException, IOException {
    final TransactionManager transact = pool.getTransactionManager();
    final MutableDocumentSet docs = new DefaultDocumentSet();
    try (final DBBroker broker = pool.get(Optional.of(pool.getSecurityManager().getSystemSubject()));
         final Txn transaction = transact.beginTransaction()) {

        if (configuration != null) {
            final CollectionConfigurationManager mgr = pool.getConfigurationManager();
            mgr.addConfiguration(transaction, broker, root, configuration);
        }

        final IndexInfo info = root.validateXMLResource(transaction, broker, XmldbURI.create(docName), data);
        assertNotNull(info);
        root.store(transaction, broker, info, data);

        docs.add(info.getDocument());
        transact.commit(transaction);
    }
    return docs;
}
 
开发者ID:eXist-db,项目名称:xquery-xproc-xmlcalabash-module,代码行数:21,代码来源:ExternalTests.java


示例12: start

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
public void start() throws Exception {
    synchronized (started) {
        if (database == null) {
            database = new DatabaseImpl();
            database.setProperty("create-database", "true");

            if (configuration != null && configuration.length() > 0) {
                database.setProperty("configuration", configuration);
            }

            current = database.getCollection(XmldbURI.EMBEDDED_SERVER_URI, null, null);
            DatabaseManager.registerDatabase(database);
            started  = true;
        }
    }
}
 
开发者ID:vgoldin,项目名称:camel-existdb,代码行数:17,代码来源:DatabaseFactory.java


示例13: getCollectionPath

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
private String getCollectionPath(final String aCollectionPath) {
    final StringBuilder builder = new StringBuilder();

    if (!aCollectionPath.startsWith(XmldbURI.ROOT_COLLECTION)) {
        builder.append(XmldbURI.ROOT_COLLECTION);

        if (!aCollectionPath.startsWith("/")) {
            builder.append('/');
        }
    }

    return builder.append(aCollectionPath).toString();
}
 
开发者ID:ksclarke,项目名称:freelib-marc4j-exist,代码行数:14,代码来源:ReadFromFile.java


示例14: getCollectionManagementService

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
/**
 * Gets the correct CollectionManagementService for internal use
 * @return
 * @throws Exception
 */
private CollectionManagementService getCollectionManagementService() throws Exception 
{
	
	Collection root = DatabaseManager.getCollection(_uri+XmldbURI.ROOT_COLLECTION+"/RootCollection", _user, _pass);
       return (CollectionManagementService)root.getService("CollectionManagementService", "1.0");
}
 
开发者ID:rwth-acis,项目名称:LAS2peer-iStarMLModel-Service,代码行数:12,代码来源:Storage.java


示例15: storeDocument

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
/**
 * Stores a document into the weather collection
 *
 * @param broker The broker for accessing the database
 * @param targetCollection The collection to store the document into
 * @param document The document to store
 * @param lockCollection Should the collection be locked whilst storing the document?
 */
public static void storeDocument(final DBBroker broker, final String targetCollection, final Node document, final boolean lockCollection) throws StoreException {

    Collection collection = null;
    final TransactionManager transact = broker.getBrokerPool().getTransactionManager();
    final Txn txn = transact.beginTransaction();
    final IndexInfo indexInfo;
    try {

        //prepare to store
        try {

            //open the weather collection
            collection = broker.openCollection(XmldbURI.create(targetCollection), lockCollection ? Lock.WRITE_LOCK : Lock.NO_LOCK);
            if(collection == null) {
                transact.abort(txn);
                throw new JobException(JobException.JobExceptionAction.JOB_ABORT_THIS, "Collection: " + targetCollection + " not found!");
            }

            //generate a unique name for the document
            final String documentName = UUID.randomUUID().toString() + ".xml";

            //validate the document
            indexInfo = collection.validateXMLResource(txn, broker, XmldbURI.create(documentName), document);
        } finally {
            //release the lock on the weather collection
            if(collection != null && lockCollection) {
                collection.release(Lock.WRITE_LOCK);
            }
        }

        //store
        collection.store(txn, broker, indexInfo, document, false);
        transact.commit(txn);

    } catch(final Exception e) {
        transact.abort(txn);
        throw new StoreException(e);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:48,代码来源:CommonUtils.java


示例16: execute

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Override
public void execute(final DBBroker broker) throws EXistException {

    try {

        //setup an output document
        final MemTreeBuilder builder = new MemTreeBuilder();
        builder.startDocument();

        final DatatypeFactory datatypeFactory = DatatypeFactory.newInstance();
        final XMLGregorianCalendar xmlCal = datatypeFactory.newXMLGregorianCalendar(new GregorianCalendar());

        final AttributesImpl attribs = new AttributesImpl();
        attribs.addAttribute(null, "timestamp", "timestamp", "string", xmlCal.toXMLFormat());
        builder.startElement(new QName("stats"), attribs);

        //collect stats
        collectStats(broker, XmldbURI.DB, builder);

        //finalise output document
        builder.endElement();
        builder.endDocument();

        //store stats document
        storeDocument(broker, statsCollection, builder.getDocument(), false);

    } catch(final DatatypeConfigurationException dce) {
        final String msg = "Unable to configure XML DatatypeFactory: " + dce.getMessage();
        LOG.error(msg, dce);
        throw new EXistException(msg, dce);
    } catch(final PermissionDeniedException pde) {
        LOG.error(pde);
        throw new EXistException(pde);
    } catch(final StoreException se) {
        LOG.error(se);
        throw new EXistException(se);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:39,代码来源:StatsSystemTask.java


示例17: collectStats

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
/**
 * Collects statistics about a Collection and its documents and sub-collections recursively
 * writes the results to the builder
 *
 * @param broker The database broker to use to access the database
 * @param collUri The absolute database URI of the collection to generate statistics for
 * @param builder The builder to write the statistics output to
 */
private void collectStats(final DBBroker broker, final XmldbURI collUri, final MemTreeBuilder builder) throws PermissionDeniedException {

    final Collection collection = broker.getCollection(collUri);

    final AttributesImpl attribs = new AttributesImpl();
    attribs.addAttribute(null, "name", "name", "string", collection.getURI().lastSegment().toString());
    attribs.addAttribute(null, "uri", "uri", "string", collection.getURI().toString());
    attribs.addAttribute(null, "sub-collections", "sub-collections", "string", Integer.toString(collection.getChildCollectionCount(broker)));
    attribs.addAttribute(null, "documents", "documents", "string", Integer.toString(collection.getDocumentCountNoLock(broker)));

    builder.startElement(new QName("collection"), attribs);

    final Iterator<DocumentImpl> itDocs = collection.iteratorNoLock(broker);
    while(itDocs.hasNext()) {
        final DocumentImpl doc = itDocs.next();

        final AttributesImpl docAttribs = new AttributesImpl();
        docAttribs.addAttribute(null, "name", "name", "string", doc.getURI().lastSegment().toString());
        docAttribs.addAttribute(null, "uri", "uri", "string", doc.getURI().toString());
        docAttribs.addAttribute(null, "nodes", "nodes", "string", Long.toString(countNodes(doc)));

        builder.startElement(new QName("document"), docAttribs);
        builder.endElement();
    }

    final Iterator<XmldbURI> itColls = collection.collectionIteratorNoLock(broker);
    while(itColls.hasNext()) {
        final XmldbURI childCollUri = collUri.append(itColls.next());
        collectStats(broker, childCollUri, builder);
    }

    builder.endElement();
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:42,代码来源:StatsSystemTask.java


示例18: execute

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Override
public void execute(final DBBroker sysBroker, final Map<String, List<? extends Object>> params) {

    //get the target parameter for where to store the modules summary
    final List<? extends Object> maybeTarget = params.get("target");
    if(maybeTarget == null || maybeTarget.size() != 1) {
        LOG.error("Missing 'target' parameter which provides the database uri for storing the modules summary!");
        return;

    } else {
        final String target = (String)maybeTarget.get(0);

        //start a document
        final MemTreeBuilder builder = new MemTreeBuilder();
        builder.startDocument();
        builder.startElement(new QName("modules-summary"), null);

        //get java modules info into document
        final Configuration existConf = sysBroker.getConfiguration();
        buildModulesSummary(existConf, builder);

        //finish document
        builder.endElement();
        builder.endDocument();

        //store document
        storeDocument(sysBroker, XmldbURI.create(target), builder.getDocument());
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:30,代码来源:ConfiguredModulesStartupTrigger.java


示例19: storeDocument

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
/**
 * Stores a document into the database
 *
 * Does not need to use locking, as we have exclusive access
 * inside a Startup Task!
 *
 * @param broker The broker for accessing the database
 * @param target The uri of where the document is to be stored in the database
 * @param document The document to store
 */
public void storeDocument(final DBBroker broker, final XmldbURI target, final DocumentImpl document) {

    final TransactionManager transact = broker.getBrokerPool().getTransactionManager();
    final Txn txn = transact.beginTransaction();
    final IndexInfo indexInfo;
    try {
        //open the collection
        final XmldbURI targetCollection = target.removeLastSegment();
        final Collection collection = broker.openCollection(targetCollection, Lock.NO_LOCK);

        if(collection == null) {
            //no such collection
            transact.abort(txn);
            LOG.error("Collection: " + targetCollection.toString() + " not found!");
            return;

        } else {

            //get the name for the document
            final XmldbURI documentName = target.lastSegment();

            //validate the document
            indexInfo = collection.validateXMLResource(txn, broker, documentName, document);

            //store
            collection.store(txn, broker, indexInfo, document, false);
            transact.commit(txn);
        }
    } catch(final Exception e) {
        transact.abort(txn);
        LOG.error(e);
    }
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:44,代码来源:ConfiguredModulesStartupTrigger.java


示例20: afterDeleteCollection

import org.exist.xmldb.XmldbURI; //导入依赖的package包/类
@Override
public void afterDeleteCollection(final DBBroker broker, final Txn txn, final XmldbURI uri) throws TriggerException {
    /**
     * Do nothing! The beforeDeleteCollection
     * protects what we need
     */
}
 
开发者ID:eXist-book,项目名称:book-code,代码行数:8,代码来源:NoDeleteCollectionTrigger.java



注:本文中的org.exist.xmldb.XmldbURI类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ExchangeService类代码示例发布时间:2022-05-22
下一篇:
Java Path类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap