Exemplo n.º 1
0
  protected void approveCustomer(boolean bApprove) {
    ContinuePendingCustomerResponse response = null;

    try {
      ContinuePendingCustomerRequest request =
          mobBasePage.getNewMobiliserRequest(ContinuePendingCustomerRequest.class);
      request.setTaskId(getCustomer().getTaskId());
      request.setApprove(bApprove);
      response = mobBasePage.wsCustomerClient.continuePendingCustomer(request);
      if (!mobBasePage.evaluateMobiliserResponse(response)) {
        if (bApprove) {
          LOG.warn("# An error occurred while approving customer");
        } else {
          LOG.warn("# An error occurred while rejecting customer");
        }
        return;
      }

    } catch (Exception e) {
      if (bApprove) {

        LOG.error("# An error occurred while approving customer");
        error(getLocalizer().getString("customer.approval.error", mobBasePage));
      } else {
        LOG.error("# An error occurred while rejecting customer");
        error(getLocalizer().getString("customer.rejection.error", mobBasePage));
      }
    }

    // Create SVA for customer after approval
    if (bApprove) {

      boolean isSvaCreated = false;
      try {
        // the customer object at this point does not contain
        // customer id value from DB so set the id obtained from
        // response
        customer.setId(response.getCustomerId());
        isSvaCreated = mobBasePage.createSvaWalletWithPI(customer);
      } catch (Exception e1) {
        LOG.error(
            "# An error occured while creating SVA for customer[" + customer.getId() + "]", e1);

      } finally {
        if (!isSvaCreated
            && PortalUtils.exists(response)
            && PortalUtils.exists(response.getCustomerId())) {
          try {
            mobBasePage.deleteCustomer(customer.getId());
          } catch (Exception e1) {
            LOG.error(
                "# An error occured while deleting the customer[" + customer.getId() + "]", e1);
          }
        }
      }

      // DPP agent related processing
      Integer custType = customer.getCustomerTypeId();
      if (custType == Constants.CUSTOMER_ROLE_MONEY_MERCHANT
          || custType == Constants.CUSTOMER_ROLE_MONEY_MERCHANT_AGENT
          || custType == Constants.CUSTOMER_ROLE_MONEY_MERCHANT_DEALER) {
        inheritParentPI();
        // createBalanceAlerts();
        // saveAgentLimitSettings();
      }
    } // End of SVA Creation and DPP agent processing

    if (bApprove) {
      LOG.info("Customer approved successfully");
      mobBasePage
          .getMobiliserWebSession()
          .info(getLocalizer().getString("customer.approved.successfull", mobBasePage));

    } else {
      LOG.info("Customer rejected successfully");
      mobBasePage
          .getMobiliserWebSession()
          .info(getLocalizer().getString("customer.rejected.successfull", mobBasePage));
    }

    setResponsePage(ApproveCustomersPage.class);
  }
Exemplo n.º 2
0
  protected boolean updateCustomer() {
    try {
      Identification existingMsisdn =
          mobBasePage.getIdentificationByCustomer(
              getCustomer().getId(), Constants.IDENT_TYPE_MSISDN);
      Identification existingUserName =
          mobBasePage.getIdentificationByCustomer(
              getCustomer().getId(), Constants.IDENT_TYPE_USERNAME);
      String existingMsisdnStr = null;
      if (PortalUtils.exists(existingMsisdn)) {
        existingMsisdnStr = existingMsisdn.getIdentification();
      }
      String existingUserNameStr = null;
      if (PortalUtils.exists(existingUserName)) {
        existingUserNameStr = existingUserName.getIdentification();
      }
      String existingNetworkProviderStr = null;
      if (PortalUtils.exists(existingMsisdn)) {
        existingNetworkProviderStr = existingMsisdn.getProvider();
      }
      // do the unique identification check only when msisdn is modified
      // OR when a new msisdn is given
      if ((PortalUtils.exists(existingMsisdnStr)
              && !existingMsisdnStr.equals(getCustomer().getMsisdn()))
          || (!PortalUtils.exists(existingMsisdnStr)
              && PortalUtils.exists(getCustomer().getMsisdn()))) {
        if (PortalUtils.exists(getCustomer().getMsisdn())
            && !mobBasePage.uniqueIdentificationCheck(
                getCustomer().getMsisdn(), Constants.IDENT_TYPE_MSISDN, getCustomer().getId())) {
          getCustomer().setMsisdn(existingMsisdnStr);
          return false;
        }
      }
      // do the unique identification check when user name is modified
      // OR when a new user name is given
      if ((PortalUtils.exists(existingUserNameStr)
              && !existingUserNameStr.equals(getCustomer().getUserName()))
          || (!PortalUtils.exists(existingUserNameStr)
              && PortalUtils.exists(getCustomer().getUserName()))) {
        if (PortalUtils.exists(getCustomer().getUserName())
            && !mobBasePage.uniqueIdentificationCheck(
                getCustomer().getUserName(),
                Constants.IDENT_TYPE_USERNAME,
                getCustomer().getId())) {
          getCustomer().setUserName(existingUserNameStr);
          return false;
        }
      }
      // check if customer status has been changed
      boolean isStatusChanged = false;
      if (!getCustomer().isActive()) {
        isStatusChanged = true;
        getCustomer().setActive(true);
      }

      if (PortalUtils.exists(getCustomer().getOriginalFeeSetId())) {
        if (getCustomer().getOriginalFeeSetId().longValue()
            != getCustomer().getFeeSetId().longValue()) {
          detachFeeSetFromCustomer(
              getCustomer().getOriginalFeeSetId(), getCustomer().getFeeSetId());
        }
      }
      getCustomer().setOriginalFeeSetId(getCustomer().getFeeSetId());
      // Check whether individual limit configuration changed

      if (PortalUtils.exists(getCustomer().getOriginalLimitSetId())) {
        if (!PortalUtils.exists(getCustomer().getLimitId())
            || getCustomer().getOriginalLimitSetId().longValue()
                != getCustomer().getLimitId().longValue()) {
          if (getCustomer().getIsIndividualLimitSet()) {
            List<LimitSetClass> limitSetClassList =
                mobBasePage.getLimitSetClassList(
                    getCustomer().getOriginalLimitSetId().longValue(),
                    Constants.LIMIT_LIMITSET_TYPE);
            if (PortalUtils.exists(limitSetClassList)) {
              for (LimitSetClass limitSetClass : limitSetClassList) {
                if (getCustomer().getOriginalLimitSetId().longValue()
                    == limitSetClass.getLimitSet().getId().longValue()) {
                  mobBasePage.removeLimitClass(
                      limitSetClass.getLimitClass().getId(),
                      limitSetClass.getLimitSet().getId(),
                      Integer.valueOf(Constants.LIMIT_LIMITSET_TYPE));

                  mobBasePage.removeLimitSet(getCustomer().getOriginalLimitSetId().longValue());

                  getCustomer().setIsIndividualLimitSet(Boolean.FALSE);
                }
              }
            }
          }

          if (PortalUtils.exists(getCustomer().getLimitId())
              && getCustomer().getLimitId().longValue() == 0) {
            getCustomer().setLimitId(null);
          }
          getCustomer().setOriginalLimitSetId(getCustomer().getLimitId());
        }
      }

      if (!mobBasePage.updateCustomerDetail(getCustomer())) return false;

      if (PortalUtils.exists(getCustomer().getAddress().getId())) {
        if (!mobBasePage.updateCustomerAddress(getCustomer())) return false;
      } else {
        if (mobBasePage.createCustomerAddress(getCustomer()) == null) return false;
      }
      if (isStatusChanged) {
        if (!mobBasePage.deleteCustomer(getCustomer().getId())) return false;
        getCustomer().setActive(false);
        setResponsePage(new ContactNotePage(new CstHomePage()));
        info(getLocalizer().getString("customer.deactivated.success", mobBasePage));
        LOG.info(
            "Customer["
                + mobBasePage.getMobiliserWebSession().getCustomer().getId()
                + "] has been succesfully deactivated");
        return false;
      }

      if (getCustomer().isActive()
          && (getCustomer().getBlackListReason() == null
              || getCustomer().getCancelationReason() == Constants.CANCELATION_REASON_OK)) {
        if (PortalUtils.exists(getCustomer().getMsisdn())) {
          if ((PortalUtils.exists(existingMsisdnStr)
                  && !existingMsisdnStr.equals(
                      getInternationalMsisdnFormat(getCustomer().getMsisdn())))
              || (PortalUtils.exists(existingNetworkProviderStr)
                  && !existingNetworkProviderStr.equals(getCustomer().getNetworkProvider()))) {
            if (mobBasePage.updateIdentificationByCustomer(
                getCustomer().getId(),
                Constants.IDENT_TYPE_MSISDN,
                existingMsisdn.getId(),
                getInternationalMsisdnFormat(getCustomer().getMsisdn()),
                getCustomer().getNetworkProvider())) {
              getCustomer().setMsisdn(getInternationalMsisdnFormat(getCustomer().getMsisdn()));
            } else {
              getCustomer().setMsisdn(existingMsisdn.getIdentification());
              return false;
            }
          } else if (!PortalUtils.exists(existingMsisdnStr)) {
            mobBasePage.createCustomerMsisdn(getCustomer());
            if (mobBasePage.isCreateStatus())
              getCustomer().setMsisdn(getInternationalMsisdnFormat(getCustomer().getMsisdn()));
            else {
              getCustomer().setMsisdn(null);
              return false;
            }
          }
        } else if (PortalUtils.exists(existingMsisdn)
            && PortalUtils.exists(existingMsisdn.getId())) {
          // remove identification
          DeleteIdentificationRequest req =
              mobBasePage.getNewMobiliserRequest(DeleteIdentificationRequest.class);
          req.setIdentificationId(existingMsisdn.getId());
          DeleteIdentificationResponse res = mobBasePage.wsIdentClient.deleteIdentification(req);
          if (!mobBasePage.evaluateMobiliserResponse(res)) {
            return false;
          }
        }
        // create or update user name
        if (PortalUtils.exists(getCustomer().getUserName())) {
          if (PortalUtils.exists(existingUserNameStr)
              && !existingUserNameStr.equals(getCustomer().getUserName())) {
            if (!mobBasePage.updateIdentificationByCustomer(
                getCustomer().getId(),
                Constants.IDENT_TYPE_USERNAME,
                existingUserName.getId(),
                getCustomer().getUserName(),
                null)) {
              getCustomer().setUserName(existingUserName.getIdentification());
              return false;
            }
          } else if (!PortalUtils.exists(existingUserNameStr)) {
            mobBasePage.createCustomerUserName(getCustomer());
            if (!mobBasePage.isCreateStatus()) {
              getCustomer().setUserName(null);
              return false;
            }
          }
        } else if (PortalUtils.exists(existingUserName)
            && PortalUtils.exists(existingUserName.getId())) {
          // remove identification
          DeleteIdentificationRequest req =
              mobBasePage.getNewMobiliserRequest(DeleteIdentificationRequest.class);
          req.setIdentificationId(existingUserName.getId());
          DeleteIdentificationResponse res = mobBasePage.wsIdentClient.deleteIdentification(req);
          if (!mobBasePage.evaluateMobiliserResponse(res)) {
            return false;
          }
        }
      }
      return true;

    } catch (Exception e) {
      LOG.error(
          "# An error occurred while updating details for customer[" + getCustomer().getId() + "]",
          e);
      error(getLocalizer().getString("customer.update.error", mobBasePage));
      return false;
    }
  }