@Override protected void check(LocalTransaction localTransaction) { String cardNo = localTransaction.getCardNo(); String aid = localTransaction.getAid(); Application app = applicationManager.getByAid(aid); CardInfo card = cardInfoManager.getByCardNo(cardNo); validateCard(card); // 校验应用的状态 if (app == null) { throw new PlatformException(PlatformErrorCode.APPLICATION_AID_NOT_EXIST); } // 校验卡上应用状态 CardApplication cardApplication = cardApplicationManager.getByCardNoAid(cardNo, aid); if (cardApplication == null) { throw new PlatformException(PlatformErrorCode.INVALID_CARD_APP_STATUS); } if (cardApplication.getApplicationVersion().getApplication().needSubscribe() && CardApplication.STATUS_AVAILABLE.intValue() == cardApplication.getStatus().intValue()) { // 如果应用需要退订,但卡上应用状态为“可用”,抛出异常 throw new PlatformException(PlatformErrorCode.TRANS_DELETE_APP_UNSUBSCRIBE); } // 校验完成,设置卡上应用的版本号 localTransaction.setAppVersion(cardApplication.getApplicationVersion().getVersionNo()); }
protected MocamResult launchDeleteAppSdOrNext( LocalTransaction localTransaction, int sessionStatus) { CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo()); Application application = applicationManager.getByAid(localTransaction.getAid()); SecurityDomain sd = application.getSd(); CardApplication cardApplication = cardApplicationManager.getByCardNoAid( localTransaction.getCardNo(), localTransaction.getAid()); MocamResult result; Integer currentStatus = cardApplication.getStatus(); // 保存当前卡上应用状态 cardApplication.setStatus( CardApplication.STATUS_UNDOWNLOAD); // 将卡上应用状态设置为“未下载”,防止干扰判断应用所属安全域是否自动删除 if (transactionHelper.isSdNeedAutoDelete(card, sd)) { // 如果需要删除应用所属安全域,执行删除安全域子流程 buildSubTransaction(localTransaction, sd.getAid(), null, Operation.DELETE_SD); localTransaction.setSessionStatus(sessionStatus); result = process(localTransaction); cardApplication.setStatus(currentStatus); // 恢复卡上应用状态 } else { // 否则同步卡空间 cardApplication.setStatus(currentStatus); // 如果当前运行环境为cms2ac,同步安全域的空间信息 if (SystemConfigUtils.isCms2acRuntimeEnvironment()) { // localTransaction.setSessionStatus(SessionStatus.SYN_CAED_SPACE_START); result = processTrans(localTransaction); } else { // 如果当前运行环境不是cms2ac,通知业务平台操作结果 result = launchOperationNotify(localTransaction); } } return result; }
protected MocamResult launchReadPesoDataOrStartDeleteApp(LocalTransaction localTransaction) { localTransaction.setSessionStatus(SessionStatus.DELETE_APP_READ_PERSO_DATA); CardApplication cardApplication = cardApplicationManager.getByCardNoAid( localTransaction.getCardNo(), localTransaction.getAid()); if (CardApplication.STATUS_PERSO_DATA_READABLE.contains(cardApplication.getStatus()) && localTransaction.hasPersonalizationsToExecute()) { // 如果有个人化数据且业务平台需要读取,读取数据 LocalTransaction subTransaction = buildSubTransaction( localTransaction, localTransaction.getAid(), Operation.DELETE_APP_READ_PERSO_DATA); transactionHelper.buildSubPersonalizedAppTransaction(localTransaction, subTransaction); subTransaction.setSessionStatus(SessionStatus.PRE_OPERATION_SUCCESS); } return process(localTransaction); }