void PersistenceModule::instructionDrop ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); if ( item.hasAttr ( xem_pers.branchRevId() ) ) { String branchRevStr = item.getEvaledAttr ( getXProcessor(), xem_pers.branchRevId() ); BranchRevId branchRevId = BranchManager::parseBranchRevId ( branchRevStr.c_str() ); if ( ! branchRevId.branchId || ! branchRevId.revisionId ) { throwException ( Exception, "Invalid branch and revision id '%s'\n", branchRevStr.c_str() ); } Log_Pers ( "[XEM:BRANCH] Dropping alter revision [%llu:%llu]\n", _brid(doc.getBranchRevId()) ); NotImplemented ( "We shall schedule revision removal here !\n" ); #if 0 // store.dropRevisions ( branchRevId.branchId, branchRevId.revisionId, branchRevId.revisionId ); persistentDocument = store.createPersistentDocument ( branchRevId.branchId, branchRevId.revisionId, Document_Read ); persistentDocument->scheduleRevisionForRemoval (); persistentDocument->release (); #endif return; } Log_Pers ( "[XEM:BRANCH] Dropping current revision [%llu:%llu]\n", _brid(doc.getBranchRevId()) ); doc.scheduleRevisionForRemoval (); }
void PersistenceModule::instructionReopen ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); if ( doc.isWritable() ) { throwException ( Exception, "Current Revision is writable, you should commit it before reopen.\n" ); } doc.reopen ( getXProcessor() ); }
void PersistenceModule::instructionFork ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); if ( doc.isWritable() ) { throwException ( Exception, "Current Revision is writable, you should commit it before forking.\n" ); } String branchName = item.getEvaledAttr ( getXProcessor(), xem_pers.name() ); doc.fork ( getXProcessor(), branchName, BranchFlags_MayIndexNameIfDuplicate ); }
void PersistenceModule::instructionRenameBranch ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); BranchId branchId = doc.getBranchRevId().branchId; String branchName = item.getEvaledAttr ( getXProcessor(), xem_pers.name() ); Log_Pers ( "[XEM-BRANCH] Rename branch %llu to '%s'\n", branchId, branchName.c_str() ); getXProcessor().getStore().getBranchManager().renameBranch ( branchId, branchName.c_str() ); }
void PersistenceModule::instructionCommit ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); if ( !doc.isWritable() ) { AssertBug ( !doc.isLockedWrite(), "Document not writable, but locked write ?\n" ); Warn ( "Document '%s' (%llx:%llx) not writable !\n", doc.getRole().c_str(), _brid(doc.getBranchRevId()) ); return; throwException ( Exception, "Document not writable !\n" ); } if ( !doc.isLockedWrite() ) { doc.lockWrite(); } doc.commit ( getXProcessor() ); }
void PersistenceModule::instructionMerge ( __XProcHandlerArgs__ ) { XPath selectXPath ( getXProcessor(), item, xem_pers.select() ); Document& doc = selectXPath.evalElement().getDocument(); bool keepBranch = false; try { doc.merge ( getXProcessor(), keepBranch ); } catch ( Exception* e ) { detailException ( e, "xem:merge : could not merge branch.\n" ); throw ( e); } doc.scheduleBranchForRemoval (); }
void XPath::evalFunctionKeyGet ( __XPath_Functor_Args ) { KeyId keyNameId = evalStepAsKeyId ( node, step->functionArguments[0] ); __evalArgNodeSet(1); Log_EvalKey ( "xsl:key : expression '%s'\n", expression ); XPath matchXPath ( xproc ); XPath useXPath ( xproc ); XPath scopeXPath(xproc); getXProcessor().getXPathKeyExpressions(keyNameId, matchXPath,useXPath); ElementMultiMapRef map = node.getDocument().getKeyMapping ( keyNameId ); if ( ! map ) { map = node.getDocument().createKeyMapping ( keyNameId ); AssertBug ( map, "Could not create SKMultiMapRef !\n" ); Log_EvalKey ( "Building for key '%x'\n", keyNameId ); ElementRef baseElement = node.getRootElement (); #if 0 if ( instructKey.findAttr ( __builtinKey(xsl.base) ) ) { throwXPathException ( "Invalid xsl:base attribute set !\n" ); XPath baseXPath ( instructKey, __builtinKey(xsl.base) ); Log_EvalKey ( "xsl:base : expression '%s'\n", baseXPath.expression ); Log_EvalKey ( "xsl:base - before : base : %llx:%s\n", baseElement.getElementId(), baseElement.getKey().c_str() ); baseElement = baseXPath.evalElement ( baseElement ); Log_EvalKey ( "xsl:base - after : base : %llx:%s\n", baseElement.getElementId(), baseElement.getKey().c_str() ); } #endif evalFunctionKeyBuild ( baseElement, map, matchXPath, useXPath, scopeXPath, 0 ); } evalFunctionKeyGet ( map, useXPath, result, res1 ); }