application/docRevoke.js
/**
 * Process the effective revocation over dataset about document.
 * @param {ChaincodeClientTx} chaincodeTxRevoke Transaction client to connect on ledger.
 * @param {BeanUser} revoker User as revoker role. 
 * @param {BeanDataBlock} blockData Data block with the set of process information.
 */
Process the effective revocation over dataset about document.
@param {ChaincodeClientTx} chaincodeTxRevoke Transaction client to connect on ledger.
@param {BeanUser} revoker User as revoker role.
@param {BeanDataBlock} blockData Data block with the set of process information.
Process the effective revocation over dataset about document . @param { ChaincodeClientTx } chaincodeTxRevoke Transaction client to connect on ledger . @param { BeanUser } revoker User as revoker role . @param { BeanDataBlock } blockData Data block with the set of process information .
async function revokeDocument(chaincodeTxRevoke, revoker, blockData){
    var blockDataRevoker = await processToAddRevoker(revoker, blockData);
    blockDataRevoker.configDateTimeLedger();
    logWrite('[revokeDocument] Data to submit in transaction = ' + JSON.stringify(blockDataRevoker));
    if (logActive) { fs.writeFileSync(JsonSubmitToRevoke, blockDataRevoker.serialize(), utf8); }
    var txResponse = await chaincodeTxRevoke.processBlockchainTransaction(blockDataRevoker);
    if (txResponse == null || txResponse == undefined) {
        let msgError = `The response from ledger is NULL or UNDEFINED`;
        logWrite(`[revokeDocument, A] Message: ${msgError}`);
        throw msgError;
    }
    var response = ResponseModel.translateLedgerResponse(txResponse);
    logWrite(`[revokeDocument] ResponseModel object =  ${response.serialize()}`);
    if (response.txStatus == ResponseModel.getTxStatusType().FAIL){
        logWrite(`[revokeDocument, B] Error message = ${response.txMessage}`);
        logWrite(`[revokeDocument] Error stack = ${response.txContent}`);
        throw response.txMessage;
    }
    logWrite(`[revokeDocument] Transaction Message = ${response.txMessage}`);
    if (response.txStatus == ResponseModel.getTxStatusType().EMPTY) {
        logWrite(`[revokeDocument, C] Message = ${response.txMessage}`);
        logWrite(`[revokeDocument] Content = ${response.txContent}`);
        throw response.txMessage;
    }
    var blockDataJSon = JSON.parse(response.txContent);
    logWrite('[revokeDocument] Bloco de dados = ' + JSON.stringify(blockDataJSon));
    var blockDataAfterRevoke = BeanDataBlock.createBeanDataBlock(blockDataJSon);
    var status = blockDataAfterRevoke.status;
    logWrite(`[revokeDocument] Document status = ${status}`);
    return blockDataAfterRevoke;
}
async function revokeDocument ( chaincodeTxRevoke , revoker , blockData ) { var blockDataRevoker = await processToAddRevoker ( revoker , blockData ) ; blockDataRevoker . configDateTimeLedger ( ) ; logWrite ( '[revokeDocument] Data to submit in transaction = ' + JSON . stringify ( blockDataRevoker ) ) ; if ( logActive ) { fs . writeFileSync ( JsonSubmitToRevoke , blockDataRevoker . serialize ( ) , utf8 ) ; } var txResponse = await chaincodeTxRevoke . processBlockchainTransaction ( blockDataRevoker ) ; if ( txResponse == null || txResponse == undefined ) { let msgError = ` ` ; logWrite ( ` ${ msgError } ` ) ; throw msgError ; } var response = ResponseModel . translateLedgerResponse ( txResponse ) ; logWrite ( ` ${ response . serialize ( ) } ` ) ; if ( response . txStatus == ResponseModel . getTxStatusType ( ) . FAIL ) { logWrite ( ` ${ response . txMessage } ` ) ; logWrite ( ` ${ response . txContent } ` ) ; throw response . txMessage ; } logWrite ( ` ${ response . txMessage } ` ) ; if ( response . txStatus == ResponseModel . getTxStatusType ( ) . EMPTY ) { logWrite ( ` ${ response . txMessage } ` ) ; logWrite ( ` ${ response . txContent } ` ) ; throw response . txMessage ; } var blockDataJSon = JSON . parse ( response . txContent ) ; logWrite ( '[revokeDocument] Bloco de dados = ' + JSON . stringify ( blockDataJSon ) ) ; var blockDataAfterRevoke = BeanDataBlock . createBeanDataBlock ( blockDataJSon ) ; var status = blockDataAfterRevoke . status ; logWrite ( ` ${ status } ` ) ; return blockDataAfterRevoke ; }
Process the effective revocation over dataset about document.
Process the effective revocation over dataset about document .
// Add revoker data to block // Save in file before to submit //---------------------------------------------------------------------------------- // Process transaction into Fabric ledger // Treatment about data received as response from Ledger // Validate the success of transaction // Validate the situation of transaction // Process the content of the transaction