Пример #1
0
void DocID::fetchDocument(const ContainerBase *container, OperationContext &oc,
	u_int32_t flags, XmlDocument &doc, ReferenceMinder *minder) const
{
	// Look up the document in the cache
	if(minder != 0) {
		doc = minder->findDocument(container->getContainerID(), *this);
	}

	if(doc.isNull()) {
		// TBD GMF -- figure out how to avoid using Container * here
		Container *cont = const_cast<ContainerBase*>(container)->getContainer();
		if(cont == 0) return;

		// Fetch the document from the container
		int err = cont->getDocument(oc, *this, doc, flags);
		// The document should be found
		if(err != 0) {
			container->log(Log::C_QUERY, Log::L_ERROR,
				"Invalid index values found during query (document not found)");
			throw XmlException(XmlException::INTERNAL_ERROR, "Invalid indexes");
		}
		if(minder != 0) {
			// Store the document in the cache
			minder->addDocument(doc);
		}
	}
}
Пример #2
0
void DocID::fetchDocument(const ContainerBase *container, DbXmlConfiguration &conf,
			  XmlDocument &doc, ReferenceMinder *minder) const
{
	fetchDocument(container, conf.getOperationContext(),
		      conf.getFlags(), doc, minder);

	if(container->getContainerID() == 0 && doc.isNull()) {
		// Just make a new XmlDocument
		XmlManager &mgr = conf.getManager();
		doc = mgr.createDocument();

		// get the temp DB for construction (container id 0)
		CacheDatabase *cdb = conf.getDbMinder().findOrAllocate((Manager&)mgr, 0);

		// Tell the document to use this database, and that it's
		// content is "NsDom"
		// TBD GMF: at some point, Document and NsDocument objects will not
		// be required by DbXmlNodeImpl, so creation/init of Document
		// objects is not required.
		Document &tdoc = (Document&)doc;
		tdoc.setDbMinder(conf.getDbMinder());
		tdoc.setContentAsNsDom(*this, cdb);

		if(minder != 0) minder->addDocument(doc);
	}

	// tell the document to use the shared databases in
	// the DbXmlConfiguration's CacheDatabaseMinder
	// If necessary, initialize the configuration's minder
	// TBD GMF -- figure out how to avoid using Container * here
	Container *cont = const_cast<ContainerBase*>(container)->getContainer();
	if (cont != 0 && !cont->isNodeContainer()) {
		Manager &mgr = (Manager&)cont->getManager();
		CacheDatabaseMinder &dbminder = conf.getDbMinder();
		dbminder.init(mgr);
		((Document&)doc).setDbMinder(dbminder);
	}
}