Пример #1
0
  @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());
  }
Пример #2
0
  protected MocamResult endSuccessProcess(LocalTransaction localTransaction) {
    CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo());
    ApplicationVersion applicationVersion =
        applicationVersionManager.getByAidAndVersionNo(
            localTransaction.getAid(), localTransaction.getAppVersion());

    if (null != applicationVersion
        && (null == applicationVersion.getApplication().getNeedSubscribe()
            || !applicationVersion
                .getApplication()
                .getNeedSubscribe())) { // 如果应用不需要单独订购/退订,则删除使用即为退订,添加退订记录
      subscribeHistoryManager.unsubscribeApplication(card, applicationVersion);
    }

    // 删除终端上客户端记录
    List<CardClient> cardClients =
        cardClientManager.getByCardAndApplication(card, applicationVersion.getApplication());
    if (null != cardClients) {
      for (CardClient cardClient : cardClients) {
        cardClientManager.remove(cardClient);
      }
    }

    return super.endSuccessProcess(localTransaction);
  }
Пример #3
0
  protected String calcLoadPercent(LocalTransaction localTransaction) {
    ApplicationVersion applicationVersion =
        applicationVersionManager.getAidAndVersionNo(
            localTransaction.getAid(), localTransaction.getAppVersion());
    int totalCount = applicationVersion.getApplicationLoadFiles().size();
    int currentIndex = localTransaction.getCurrentLoadFileIndex();

    Integer percent = 5 + (int) (((new Double(currentIndex - 1) / totalCount) * 0.85) * 100);

    return percent.toString();
  }
Пример #4
0
  protected MocamResult synCardSpace(LocalTransaction localTransaction) {
    Application application = applicationManager.getByAid(localTransaction.getAid());
    SecurityDomain sd = application.getSd();
    CardSecurityDomain cardSecurityDomain =
        cardSecurityDomainManager.getByCardNoAid(
            localTransaction.getCardNo(), application.getSd().getAid());

    if (CardSecurityDomain.STATUS_PERSO
        == cardSecurityDomain.getStatus().intValue()) { // 如果应用所属安全域没有被自动删除,同步应用所属安全域空间
      return launchSelectSdForSynCardSpace(
          localTransaction, sd, SessionStatus.SYNC_CARD_SELECT_ISD_CMD);
    } else {
      localTransaction.setSessionStatus(SessionStatus.OPERATE_NOTIFY);
      return processTrans(localTransaction);
    }
  }
Пример #5
0
  protected MocamResult launchDealNextLoadFile(LocalTransaction localTransaction) {
    // 当前处理的加载文件索引值+1
    localTransaction.increaseCurrentLoadFileIndex();
    localTransactionManager.saveOrUpdate(localTransaction);

    // 处理当前的加载文件
    return startDelApp(localTransaction);
  }
Пример #6
0
 protected MocamResult startDelApp(LocalTransaction localTransaction) {
   MocamResult result = new MocamResult();
   if (isAllLoadFileDelete(localTransaction)) { // 所有文件都删除,进入后续流程
     localTransaction.setSessionStatus(SessionStatus.DELETE_APP_END_DELETE_LOAD_FILE);
     result = processTrans(localTransaction);
   } else {
     CardInfo card = cardInfoManager.getByCardNo(localTransaction.getCardNo());
     LoadFileVersion loadFileVersion =
         transactionHelper.getCurrentLoadFileVersionToDelete(localTransaction);
     if (transactionHelper.isLoadFileVersionExistOnCard(card, loadFileVersion)) { // 当前加载文件在卡上
       return launchDealCurrentLoadFile(localTransaction);
     } else { // 当前加载文件没在卡上,删除下一个文件
       return launchDealNextLoadFile(localTransaction);
     }
   }
   return result;
 }
Пример #7
0
 @RequestMapping
 public @ResponseBody JsonMessage get(@RequestParam("id") Long id) {
   JsonMessage message = new JsonMessage();
   try {
     LocalTransaction lt = localTransactionManager.load(id);
     Map<String, Object> map = lt.toMap(null, null);
     message.setMessage(map);
   } catch (PlatformException e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   } catch (Exception e) {
     e.printStackTrace();
     message.setSuccess(Boolean.FALSE);
     message.setMessage(e.getMessage());
   }
   return message;
 }
Пример #8
0
  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;
  }
Пример #9
0
  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);
  }
Пример #10
0
 protected boolean isAllLoadFileDelete(LocalTransaction localTransaction) {
   List<ApplicationLoadFile> deleteOrder = transactionHelper.getDeleteOrder(localTransaction);
   return localTransaction.getCurrentLoadFileIndex() == deleteOrder.size() + 1;
 }
Пример #11
0
 protected MocamResult startupDelete(LocalTransaction localTransaction) {
   check(localTransaction);
   localTransaction.setSessionStatus(SessionStatus.OPEN_RW_WAIT_OPEN_REQ);
   localTransactionManager.saveOrUpdate(localTransaction);
   return processTrans(localTransaction);
 }
Пример #12
0
 protected MocamResult launchOperationNotify(LocalTransaction localTransaction) {
   localTransaction.setSessionStatus(SessionStatus.OPERATE_NOTIFY);
   return processTrans(localTransaction);
 }
Пример #13
0
 private List<Map<String, Object>> localTransactionResult(List<LocalTransaction> requistionList) {
   List<Map<String, Object>> mappedApplications =
       new ArrayList<Map<String, Object>>(requistionList.size());
   List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();
   List<Application> apps = new ArrayList<Application>();
   List<SecurityDomain> sds = new ArrayList<SecurityDomain>();
   for (LocalTransaction localTransaction : requistionList) {
     propertyFilters.clear();
     apps.clear();
     sds.clear();
     Map<String, Object> mappedLocalTransaction = localTransaction.toMap(null, null);
     String formatValue = "";
     if (localTransaction.getBeginTime() != null) {
       formatValue =
           DateFormatUtils.format(
               (Calendar) localTransaction.getBeginTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("beginTime", formatValue);
     formatValue = "";
     if (localTransaction.getEndTime() != null) {
       formatValue =
           DateFormatUtils.format((Calendar) localTransaction.getEndTime(), "yyyy-MM-dd HH:mm:ss");
     }
     mappedLocalTransaction.put("endTime", formatValue);
     mappedLocalTransaction.put(
         "failMessage",
         localTransaction.getFailMessage() == null ? "" : localTransaction.getFailMessage());
     // propertyFilters.add(new PropertyFilter("aid", MatchType.EQ,
     // PropertyType.S, localTransaction.getAid()));
     if (localTransaction.getProcedureName().equals(Operation.CREATE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.DELETE_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.LOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UNLOCK_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.SYNC_CARD_SD.toString())
         || localTransaction.getProcedureName().equals(Operation.UPDATE_KEY.toString())) {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       sds = securityDomainManager.find(propertyFilters);
       if (sds != null && sds.size() != 0) {
         mappedLocalTransaction.put("appName", sds.get(0).getSdName());
         mappedLocalTransaction.put("showType", "sd");
       }
     } else if (localTransaction.getProcedureName().equals("LOCK_CARD")
         || localTransaction.getProcedureName().equals("UNLOCK_CARD")) {
       propertyFilters.add(
           new PropertyFilter(
               "mobileNo", MatchType.EQ, PropertyType.S, localTransaction.getMobileNo()));
       List<CustomerCardInfo> ccis = this.customerCardInfoManager.find(propertyFilters);
       CustomerCardInfo cci = null;
       for (CustomerCardInfo _cci : ccis) {
         if (_cci.getCard()
             .getCardNo()
             .equals(localTransaction.getCardNo())) { // 根据卡号和手机号查找CustomerCardInfo,并且列出最新的终端名
           if (cci == null || cci.getId() < _cci.getId()) {
             cci = _cci;
           }
         }
       }
       if (null != cci) {
         mappedLocalTransaction.put("appName", cci.getName());
         mappedLocalTransaction.put("cciIconId", cci.getMobileType().getId());
         mappedLocalTransaction.put("showType", "termial");
       }
     } else {
       propertyFilters.add(
           new PropertyFilter("aid", MatchType.EQ, PropertyType.S, localTransaction.getAid()));
       apps = applicationManager.find(propertyFilters);
       if (apps != null && apps.size() != 0) {
         mappedLocalTransaction.put("appName", apps.get(0).getName());
         mappedLocalTransaction.put("application_id", apps.get(0).getId());
         mappedLocalTransaction.put("showType", "app");
       }
     }
     if (PlatformMessage.SUCCESS.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.SUCCESS.getMessage());
     } else if (PlatformMessage.TRANS_EXCESSIVING.getCode().equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCESSIVING.getMessage());
     } else if (PlatformMessage.TRANS_EXCEPTION_CLOSED
         .getCode()
         .equals(localTransaction.getResult())) {
       mappedLocalTransaction.put("result", PlatformMessage.TRANS_EXCEPTION_CLOSED.getMessage());
     } else {
       //				for (PlatformErrorCode pe : PlatformErrorCode.values()) {
       //					if (pe.getErrorCode().equals(localTransaction.getResult())) {
       //						mappedLocalTransaction.put("result", pe.getDefaultMessage());
       //					}
       //				}
       mappedLocalTransaction.put("result", localTransaction.getFailMessage());
     }
     mappedApplications.add(mappedLocalTransaction);
   }
   return mappedApplications;
 }
Пример #14
0
 private List<Map<String, Object>> desiredOperationResult(
     List<DesiredOperation> requistionList, String executionStatus) {
   List<Map<String, Object>> mappedApplications =
       new ArrayList<Map<String, Object>>(requistionList.size());
   List<PropertyFilter> propertyFilters = new ArrayList<PropertyFilter>();
   List<Application> apps = new ArrayList<Application>();
   List<SecurityDomain> sds = new ArrayList<SecurityDomain>();
   Task task = null;
   for (DesiredOperation desiredOperation : requistionList) {
     if (desiredOperation.getPreProcess().intValue() == DesiredOperation.PREPROCESS_TURE
         && desiredOperation.getIsExcuted().intValue() == DesiredOperation.NOT_EXCUTED) {
       continue;
     }
     if (desiredOperation.getTaskId() != null) {
       task = taskManager.load(desiredOperation.getTaskId());
     } else {
       task = new Task();
     }
     CustomerCardInfo customerCardInfo = null;
     if (null != desiredOperation.getCustomerCardId()
         && 0 != desiredOperation.getCustomerCardId()) {
       customerCardInfo = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
     }
     propertyFilters.clear();
     apps.clear();
     sds.clear();
     Map<String, Object> mappedDesiredOperation = desiredOperation.toMap(null, null);
     mappedDesiredOperation.put("cardNo", "");
     Long cciId;
     if (null != (cciId = desiredOperation.getCustomerCardId())) {
       CustomerCardInfo cci = customerCardInfoManager.load(cciId);
       mappedDesiredOperation.put("cardNo", cci.getCard().getCardNo());
     }
     mappedDesiredOperation.put("idStr", String.valueOf(desiredOperation.getId()));
     mappedDesiredOperation.put(
         "beginTime",
         CalendarUtils.parsefomatCalendar(task.getBeginTime(), CalendarUtils.LONG_FORMAT_LINE));
     if (null != customerCardInfo) {
       mappedDesiredOperation.put("cciName", customerCardInfo.getName());
     } else {
       mappedDesiredOperation.put("cciName", "");
     }
     mappedDesiredOperation.put(
         "endTime",
         CalendarUtils.parsefomatCalendar(task.getEndTime(), CalendarUtils.LONG_FORMAT_LINE));
     String result = desiredOperation.getResult();
     if (StringUtils.isBlank(result)) {
       LocalTransaction localTransaction =
           localTransactionManager.getBySessionId(desiredOperation.getSessionId());
       if (localTransaction != null) {
         mappedDesiredOperation.put("failMessage", localTransaction.getFailMessage());
       }
     } else {
       mappedDesiredOperation.put("failMessage", result);
     }
     // if (executionStatus != null && Integer.parseInt(executionStatus)
     // == DesiredOperation.NOT_FINISH_EXCUTED){
     // List<LocalTransaction> localTransactions =
     // task.getLocalTransactions();
     // for (LocalTransaction lt : localTransactions){
     // if(!StringUtils.isEmpty(lt.getFailMessage())){
     // mappedDesiredOperation.put("failMessage", lt.getFailMessage());
     // break;
     // }
     // }
     // }
     propertyFilters.add(
         new PropertyFilter("aid", MatchType.EQ, PropertyType.S, desiredOperation.getAid()));
     if (desiredOperation.getProcedureName().equals(Operation.CREATE_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.DELETE_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.LOCK_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.UNLOCK_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.SYNC_CARD_SD.toString())
         || desiredOperation.getProcedureName().equals(Operation.UPDATE_KEY.toString())) {
       sds = securityDomainManager.find(propertyFilters);
       if (sds != null && sds.size() != 0) {
         mappedDesiredOperation.put("appName", sds.get(0).getSdName());
         mappedDesiredOperation.put("hasIcon", "sd");
       }
     } else if (desiredOperation.getProcedureName().equals("LOCK_CARD")) {
       CustomerCardInfo cci = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
       mappedDesiredOperation.put("appName", "");
       if (null != cci) {
         mappedDesiredOperation.put("cciIconId", cci.getMobileType().getId());
         mappedDesiredOperation.put("hasIcon", "LOCK_CARD");
       }
     } else if (desiredOperation.getProcedureName().equals("UNLOCK_CARD")) {
       CustomerCardInfo cci = customerCardInfoManager.load(desiredOperation.getCustomerCardId());
       mappedDesiredOperation.put("appName", "");
       if (null != cci) {
         mappedDesiredOperation.put("cciIconId", cci.getMobileType().getId());
         mappedDesiredOperation.put("hasIcon", "UNLOCK_CARD");
       }
     } else {
       apps = applicationManager.find(propertyFilters);
       if (apps != null && apps.size() != 0) {
         mappedDesiredOperation.put("appName", apps.get(0).getName());
         mappedDesiredOperation.put("application_id", apps.get(0).getId());
         mappedDesiredOperation.put("hasIcon", apps.get(0).getPcIcon() != null);
         boolean hasClient = false;
         List<ApplicationVersion> versions = apps.get(0).getVersions();
         for (ApplicationVersion av : versions) {
           if (av.getClients().size() != 0) {
             hasClient = true;
             break;
           }
         }
         mappedDesiredOperation.put("hasClient", hasClient);
       }
     }
     mappedApplications.add(mappedDesiredOperation);
     final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     if (Integer.valueOf(executionStatus) != 0) {
       Collections.sort(
           mappedApplications,
           new Comparator<Map<String, Object>>() {
             @Override
             public int compare(Map<String, Object> m1, Map<String, Object> m2) {
               if (StringUtils.isNotBlank((String) m1.get("beginTime"))
                   && StringUtils.isNotBlank((String) m2.get("beginTime"))) {
                 try {
                   Date date1 = sdf.parse((String) m1.get("beginTime"));
                   Date date2 = sdf.parse((String) m2.get("beginTime"));
                   return 0 - date1.compareTo(date2);
                 } catch (ParseException e) {
                   e.printStackTrace();
                 }
                 return 0;
               } else {
                 return 0;
               }
             }
           });
     }
   }
   return mappedApplications;
 }