Ejemplo n.º 1
0
  private void inheritParentPI() {
    // inherit parent PI's if customer has privilege
    try {
      List<String> privileges =
          mobBasePage.getDefaultPrivileges(
              customer.getCustomerTypeId(), customer.getRiskCategoryId());
      if (PortalUtils.exists(privileges) && privileges.contains(Constants.PRIV_AUTO_INHERIT_PIS)) {
        List<WalletEntry> weList =
            mobBasePage.getWalletEntryList(customer.getParentId(), null, null);
        if (PortalUtils.exists(weList)) {
          for (WalletEntry we : weList) {
            LOG.debug(
                "# add sva["
                    + we.getPaymentInstrumentId()
                    + "] to the wallet of customer["
                    + customer.getId()
                    + "]");

            mobBasePage.createAgentWalletEntry(
                customer.getId(), we.getPaymentInstrumentId(), we.getAlias());
          }
        }
      }
    } catch (Exception e) {
      error(getLocalizer().getString("ERROR.CREATE_AGENT_FAILURE", this));

      LOG.error("# An error occurred while creating new customer's wallet Entry", e);
    }
  }
Ejemplo n.º 2
0
  protected List<KeyValue<Long, String>> getLimitSets(Long limitSetId) {
    List<KeyValue<Long, String>> limitSetKeyValueList = new ArrayList<KeyValue<Long, String>>();
    List<LimitSet> limitSetList;
    try {
      limitSetList = mobBasePage.findLimitSet(null);
      KeyValue<Long, String> keyValue;
      boolean isGlobalLimitSet = false;
      if (PortalUtils.exists(limitSetList)) {
        for (LimitSet limitSet : limitSetList) {
          keyValue =
              new KeyValue<Long, String>(new Long(limitSet.getId().intValue()), limitSet.getName());
          limitSetKeyValueList.add(keyValue);
          if (!PortalUtils.exists(limitSetId)
              || limitSet.getId().longValue() == limitSetId.longValue()) isGlobalLimitSet = true;
        }
      }

      if (PortalUtils.exists(limitSetId) && limitSetId.longValue() != 0 && !isGlobalLimitSet) {
        keyValue =
            new KeyValue<Long, String>(
                new Long(limitSetId.longValue()),
                getLocalizer().getString("cst.customercare.limitset.individual", mobBasePage));
        limitSetKeyValueList.add(keyValue);
      }
    } catch (Exception e) {
      LOG.error("# An error occurred while fetching limit sets" + e);
    }
    return limitSetKeyValueList;
  }
Ejemplo n.º 3
0
  private void checkResponse(AjaxRequestTarget target) {
    // Show cancel
    if (response.isCancelVisible()) {
      cancelDiv.setVisible(true);
      target.addComponent(cancelDiv);
    }
    // Show retry
    if (response.isRetryVisible()) {
      retryDiv.setVisible(true);
      target.addComponent(retryDiv);
    }

    // Show error Text
    if (PortalUtils.exists(response.getErrorMessage())) {
      errorMsg.setVisible(true);
      target.addComponent(errorMsg);
    }

    // Return to URL
    if (PortalUtils.exists(response.getReturnUrl()) && response.isRedirect())
      try {
        getWebRequestCycle()
            .getWebResponse()
            .getHttpServletResponse()
            .sendRedirect(response.getReturnUrl());
        isRedirected = true;
      } catch (IOException e) {
        LOG.error(
            "#An error occurred while redirecting to the return url["
                + response.getReturnUrl()
                + "]",
            e);
        return;
      }
  }
 public NotificationMessagePanel(
     String id, MobiliserBasePage mobBasePage, MessageTemplate message) {
   super(id);
   this.basePage = mobBasePage;
   this.message = message;
   if (message == null) {
     isAttachmentContainerVisible = false;
     isCreateMode = true;
   } else {
     getAttachments();
     isCreateMode = false;
     localeStr = basePage.convertLocale(message.getLocale());
     if (PortalUtils.exists(message)
         && Constants.TEMPLATE_TYPE_EMAIL_KEY.equals(message.getTemplateType())) {
       isEmail = true;
       isAttachmentContainerVisible = true;
       if (PortalUtils.exists(message.getContent()))
         setPlainText(message.getContent().getContent());
       if (PortalUtils.exists(message.getAlternativeContent()))
         setHtmlText(message.getAlternativeContent().getContent());
     } else {
       if (PortalUtils.exists(message.getContent())) setSmsText(message.getContent().getContent());
       isEmail = false;
       isAttachmentContainerVisible = false;
     }
   }
   constructPanel();
 }
Ejemplo n.º 5
0
 protected void detachFeeSetFromCustomer(Long oldFeeSetId, Long newFeeSetId) {
   List<FeeSet> feeSetsList = null;
   try {
     feeSetsList = mobBasePage.getFeeSetsList(null);
     for (FeeSet feeSet : feeSetsList) {
       if (feeSet.getId().longValue() == oldFeeSetId.longValue()) {
         if (feeSet.isIndividual()) {
           try {
             mobBasePage.removeFeeSet(feeSet);
           } catch (Exception e) {
             error(getLocalizer().getString("feeSets.remove.error", mobBasePage));
             LOG.error("# An error occurred while deleting the fee set");
           }
           // break;
         }
       } else if (feeSet.getId().longValue() == newFeeSetId.longValue()) {
         if (feeSet.isIndividual()) {
           mobBasePage.getMobiliserWebSession().getCustomer().setIsIndividualFeeSet(Boolean.TRUE);
         } else {
           mobBasePage.getMobiliserWebSession().getCustomer().setIsIndividualFeeSet(Boolean.FALSE);
         }
       }
     }
     if (PortalUtils.exists(newFeeSetId) && newFeeSetId.longValue() == 0) {
       mobBasePage.getMobiliserWebSession().getCustomer().setIsIndividualFeeSet(Boolean.FALSE);
     }
   } catch (DataProviderLoadException dpe) {
     LOG.error("#An error occurred while fetching fee sets");
   }
   ((StandingDataPage) (mobBasePage)).buildLeftMenu();
   setResponsePage(new StandingDataPage(getCustomer()));
 }
  private void handleRemove() {
    if (!PortalUtils.exists(getSelectedAttachments())) {
      error(getLocalizer().getString("msgAttachment.nothing.selected.remove", this));
      return;
    }

    try {
      Iterator<Long> iterator = message.getAttachments().iterator();

      while (iterator.hasNext()) {
        Long attId = iterator.next();
        for (MessageAttachment removeId : getSelectedAttachments()) {
          if (attId.equals(removeId.getId())) {
            iterator.remove();
          }
        }
      }
      if (updateMessage()) {
        info(getLocalizer().getString("remove.attachment.success", this));
        getAttachments();
      }
    } catch (Exception e) {
      error(getLocalizer().getString("remove.attachment.error", this));
      LOG.error("Error in removing attachment", e);
    }
  };
  public void loadList(Long customerId, boolean forcedReload) throws DataProviderLoadException {

    if (invoiceConfigurationEntries == null || forcedReload) {

      List<InvoiceConfiguration> allEntries =
          getMobiliserBasePage().getInvoiceConfigurationCustomerAllowedList(customerId);

      if (PortalUtils.exists(allEntries)) {
        invoiceConfigurationEntries = allEntries;
      }
    }
  }
Ejemplo n.º 8
0
    @Override
    public void validate(Form<?> form) {
      FormComponent[] components = getDependentFormComponents();
      String strFromAmount = String.valueOf(components[0].getInput());
      String strToAmount = String.valueOf(components[1].getInput());
      String strRate = String.valueOf(components[2].getInput());
      String fromCurrency = null;
      String toCurrency = null;
      if (components.length > 3) {
        fromCurrency = String.valueOf(components[3].getInput());
        toCurrency = String.valueOf(components[4].getInput());
      }
      if ((fromCurrency != null && toCurrency != null) && fromCurrency.equals(toCurrency))
        form.error(
            getLocalizer()
                .getString(
                    "forex.error.fromSameAsTo", this.getDependentFormComponents()[0].getPage()));
      // check if percentage from amount and/or percentage to amount equal
      // "0"
      if (PortalUtils.exists(strFromAmount) && "0".equals(strFromAmount))
        form.error(
            getLocalizer()
                .getString(
                    "forex.fromAmount.zero", this.getDependentFormComponents()[0].getPage()));
      if (PortalUtils.exists(strToAmount) && "0".equals(strToAmount))
        form.error(
            getLocalizer()
                .getString("forex.toAmount.zero", this.getDependentFormComponents()[0].getPage()));

      if (form.hasError()) return;
      // if (!PortalUtils.exists(strFromAmount)) {
      // components[0].setModelObject((new Long(1)));
      // }
      // if (!PortalUtils.exists(strToAmount))
      // components[1].setModelObject(new Long(1));

    }
Ejemplo n.º 9
0
  private void saveExchnageRate(
      final WebMarkupContainer addExchangerateContainer,
      final WebMarkupContainer updateExchangerateContainer) {

    NumberFormat format = NumberFormat.getInstance(getMobiliserWebSession().getLocale());

    try {
      if (PortalUtils.exists(getStrFromAmount())) {
        getExchangeRate().setFromAmount(format.parse(getStrFromAmount()).longValue());
      } else {
        getExchangeRate().setFromAmount(1);
      }
      if (PortalUtils.exists(getStrToAmount())) {
        getExchangeRate().setToAmount(format.parse(getStrToAmount()).longValue());
      } else {
        getExchangeRate().setToAmount(1);
      }

      getExchangeRate().setRate(BigDecimal.valueOf(format.parse(getStrRate()).doubleValue()));
      SetExchangeRateRequest request;
      request = getNewMobiliserRequest(SetExchangeRateRequest.class);
      request.setExchangeRate(getExchangeRate());
      SetExchangeRateResponse response = wsSystemConfClient.setExchangeRate(request);
      if (!evaluateMobiliserResponse(response)) return;
      this.forceReload = true;
      createExchangeRateDataView(updateExchangerateContainer, addExchangerateContainer);
      addExchangerateContainer.setVisible(false);
      updateExchangerateContainer.setVisible(false);
      setExchangeRate(null);
      setStrFromAmount(null);
      setStrToAmount(null);
      LOG.info("# Exchange rate saved successfully.");
    } catch (Exception e) {
      LOG.error("# An error occurred while saving Exchange rate", e);
      error(getLocalizer().getString("save.exchangerate.error", this));
    }
  }
  protected void createMessage() {
    message.setLocale(basePage.convertLocale(localeStr));
    if (Constants.TEMPLATE_TYPE_SMS_KEY.equals(message.getTemplateType())) {
      MessageStringContent content = new MessageStringContent();
      content.setContentType("text/plain");
      content.setContent(getSmsText());
      message.setContent(content);
    } else {
      MessageStringContent content = new MessageStringContent();
      content.setContentType("text/plain");
      content.setContent(getPlainText());
      message.setContent(content);
      if (PortalUtils.exists(getHtmlText())) {
        MessageStringContent altContent = new MessageStringContent();
        altContent.setContentType("text/html");
        altContent.setContent(getHtmlText());
        message.setAlternativeContent(altContent);
      }
    }
    if (message.getId() == null) {
      try {
        CreateTemplateRequest request =
            basePage.getNewMobiliserRequest(CreateTemplateRequest.class);
        request.setTemplate(message);
        CreateTemplateResponse response = basePage.wsTemplateClient.createTemplate(request);
        if (!basePage.evaluateMobiliserResponse(response)) {
          return;
        }
        LOG.debug("message created successfully");
        message.setId(response.getTemplateId());
        info(getLocalizer().getString("create.message.success", this));

        setResponsePage(new EditMessagePage(message));
      } catch (Exception e) {
        LOG.error("Error in creating message. ", e);
        error(getLocalizer().getString("create.message.error", this));
      }
    } else {
      try {
        if (updateMessage()) {
          info(getLocalizer().getString("update.message.success", this));
        }
      } catch (Exception e) {
        error(getLocalizer().getString("update.message.error", this));
        LOG.error("Error in updating message", e);
      }
    }
  }
 public List<ApproveFeeDetailsBean> getFeeDetails() {
   if (!PortalUtils.exists(feeDetails)) {
     feeDetails = new ArrayList<ApproveFeeDetailsBean>();
   }
   return feeDetails;
 }
Ejemplo n.º 12
0
  private void sendMoneyNext() {
    LOG.debug("#SendMoneyPage.sendMoneyNext()");

    if (getTxnText().length() > Integer.valueOf(Constants.MAX_LENGTH_SEND_MONEY_TXN_TEXT)) {
      error(getLocalizer().getString("sendMoney.text.length.error", this));
      return;
    }

    PhoneNumber pn = new PhoneNumber(getRecipient(), getConfiguration().getCountryCode());

    com.sybase365.mobiliser.util.tools.wicketutils.security.Customer loggedInCustomer =
        getMobiliserWebSession().getLoggedInCustomer();

    convertAmount();
    TransactionBean tab = new TransactionBean();
    VatAmount vatAmnt = new VatAmount();
    SVA sva = null;
    try {
      WalletEntry wallet = getSvaPI(getMobiliserWebSession().getLoggedInCustomer().getCustomerId());
      if (PortalUtils.exists(wallet)) sva = wallet.getSva();
      if (PortalUtils.exists(sva)) {
        vatAmnt.setCurrency(
            PortalUtils.exists(sva.getCurrency())
                ? sva.getCurrency()
                : getConfiguration().getCurrency());
      } else {
        vatAmnt.setCurrency(getConfiguration().getCurrency());
      }

    } catch (Exception e1) {
      LOG.error("# Error while getting SVA's payment instrument", e1);
    }

    vatAmnt.setValue(amount);

    tab.setAmount(vatAmnt);
    tab.setAutoCapture(true);
    tab.setUsecase(Integer.valueOf(Constants.USE_CASE_SEND_MONEY));
    tab.setText(txnText);

    TransactionParticipant payer = new TransactionParticipant();
    Identifier payerId = new Identifier();
    payerId.setType(Constants.IDENT_TYPE_CUST_ID);
    payerId.setValue(String.valueOf(loggedInCustomer.getCustomerId()));
    payer.setIdentifier(payerId);
    tab.setPayer(payer);

    TransactionParticipant payee = new TransactionParticipant();
    Identifier payeeId = new Identifier();
    payeeId.setType(Constants.IDENT_TYPE_MSISDN);
    payeeId.setValue(pn.getInternationalFormat());
    payee.setIdentifier(payeeId);
    tab.setPayee(payee);
    tab.setModule(Constants.MODULE_SEND_MONEY);

    Customer payeeCustomer =
        getCustomerByIdentification(Constants.IDENT_TYPE_MSISDN, pn.getInternationalFormat());

    try {
      if (PortalUtils.exists(payeeCustomer)) {
        if (handleTransaction(tab)) setResponsePage(new SendMoneyFriendConfirmPage(tab, false));
      } else {
        if (startVoucher(tab)) setResponsePage(new SendMoneyFriendConfirmPage(tab, true));
      }
    } catch (Exception e) {
      LOG.error("# An error occurred during Preauthorization", e);
      error(getLocalizer().getString("preauthorization.error", this));
      return;
    }
  }
Ejemplo n.º 13
0
  protected void constructPanel() {

    final String chooseDtTxt = this.getLocalizer().getString("datepicker.chooseDate", mobBasePage);

    add(
        new HeaderContributor(
            new IHeaderContributor() {

              private static final long serialVersionUID = 1L;

              @Override
              public void renderHead(IHeaderResponse response) {

                // localize the jquery datepicker based on users locale setting
                // locale specific js includes for datepicker are available at
                // http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/
                String localeLang = getLocale().getLanguage().toLowerCase();

                LOG.debug("Using DatePicker for locale language: {}", localeLang);

                if (PortalUtils.exists(localeLang)) {
                  response.renderJavascriptReference(
                      "scripts/jquery/i18n/jquery.ui.datepicker-" + localeLang + ".js");
                }

                response.renderJavascript(
                    "\n"
                        + "jQuery(document).ready(function($) { \n"
                        + "  $('#birthDate').datepicker( { \n"
                        + "	'buttonText' : '"
                        + chooseDtTxt
                        + "', \n"
                        + "	'changeMonth' : true, \n"
                        + "	'changeYear' : true, \n"
                        + "       'yearRange' : '-100:+0', \n"
                        + "	'showOn': 'both', \n"
                        + "	'dateFormat' : '"
                        + Constants.DATE_FORMAT_PATTERN_PICKER
                        + "', \n"
                        + "	'buttonImage': 'images/calendar.gif', \n"
                        + "	'buttonOnlyImage': true} ); \n"
                        + "});\n",
                    "datePicker");
              }
            }));

    final Form<?> form =
        new Form("standingDataForm", new CompoundPropertyModel<StandingDataPanel>(this));

    if (!PortalUtils.exists(getCustomer().getTaskId()))
      mobBasePage.getMobiliserWebSession().setShowContact(true);
    form.add(new FeedbackPanel("errorMessages"));
    form.add(
            new RequiredTextField<String>("customer.address.firstName")
                .setRequired(true)
                .add(new PatternValidator(Constants.REGEX_FIRSTNAME))
                .add(Constants.mediumStringValidator)
                .add(Constants.mediumSimpleAttributeModifier))
        .add(new ErrorIndicator());

    form.add(
        new DateTextField(
                "birthDateField",
                new PropertyModel<Date>(this, "customer.birthDateString"),
                new PatternDateConverter(Constants.DATE_FORMAT_PATTERN_PARSE, false))
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.customerTypeId",
                Integer.class,
                Constants.RESOURCE_BUNDLE_CUSTOMER_TYPE,
                this,
                Boolean.FALSE,
                true)
            .setNullValid(false)
            .setRequired(true));

    form.add(
            new RequiredTextField<String>("customer.address.lastName")
                .setRequired(true)
                .add(new PatternValidator(Constants.REGEX_FIRSTNAME))
                .add(Constants.mediumStringValidator)
                .add(Constants.mediumSimpleAttributeModifier))
        .add(new ErrorIndicator());

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.language",
                String.class,
                Constants.RESOURCE_BUNDLE_LANGUAGES,
                this,
                false,
                true)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.timeZone",
                String.class,
                Constants.RESOURCE_BUNDLE_TIMEZONES,
                this,
                false,
                true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.street1")
            .add(new PatternValidator(Constants.REGEX_STREET1))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.houseNo")
            .add(StringValidator.lengthBetween(1, 20))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));
    form.add(
        new TextField<String>("customer.address.state")
            .add(new PatternValidator(Constants.REGEX_STATE))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.address.kvCountry", String.class, "countries", this, false, true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.street2")
            .add(new PatternValidator(Constants.REGEX_STREET1))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.city")
            .setRequired(false)
            .add(new PatternValidator(Constants.REGEX_CITY))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.zip")
            .add(new PatternValidator(Constants.REGEX_ZIP))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    TextField<String> msisdn = new TextField<String>("customer.msisdn");
    if (!mobBasePage.getConfiguration().isMsisdnOtpConfirmed()) {
      msisdn.add(new SimpleAttributeModifier("readonly", "readonly"));
      msisdn.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
    }
    form.add(
        msisdn
            .add(new PatternValidator(Constants.REGEX_PHONE_NUMBER))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.address.email")
            .setRequired(true)
            .add(EmailAddressValidator.getInstance())
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.kvInfoMode", Integer.class, "sendModes", this, Boolean.FALSE, true)
            .setNullValid(false)
            .setRequired(true));

    WebMarkupContainer networkProviderDiv = new WebMarkupContainer("networkProviderDiv");

    networkProviderDiv.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.networkProvider", String.class, "networkproviders", this, false, true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    // network provider selection to be made only for mbanking customer
    // types
    if (customer.getCustomerTypeId() != null
        && customer.getCustomerTypeId().intValue() == Constants.MBANKING_CUSTOMER_TYPE) {
      networkProviderDiv.setVisible(true);
    } else {
      networkProviderDiv.setVisible(false);
    }

    form.add(networkProviderDiv);

    form.add(
        new KeyValueDropDownChoice<Long, String>(
            "customer.feeSetId", mobBasePage.getFeeSets(getCustomer().getFeeSetId())) {
          private static final long serialVersionUID = 1L;

          @Override
          protected CharSequence getDefaultChoice(Object selected) {
            return null;
          };
        }.setNullValid(false));

    form.add(
        new KeyValueDropDownChoice<Long, String>(
            "customer.limitId", getLimitSets(getCustomer().getLimitId())) {

          private static final long serialVersionUID = 1L;
        }.setNullValid(true));

    Button feeSetConfButton =
        new Button("feeSetConf") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            setResponsePage(new IndividualFeeSetConfig(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    feeSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));
    form.add(feeSetConfButton);

    Button limitSetConfButton =
        new Button("limitSetConf") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            setResponsePage(new IndividualLimitSetConfig(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    limitSetConfButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));
    form.add(limitSetConfButton);

    form.add(
        new LocalizableLookupDropDownChoice<String>(
                "customer.securityQuestion",
                String.class,
                Constants.RESOURCE_BUNDLE_SEC_QUESTIONS,
                this,
                false,
                true)
            .setNullValid(false)
            .setRequired(true)
            .add(new ErrorIndicator()));

    form.add(
        new TextField<String>("customer.userName")
            .add(new PatternValidator(Constants.REGEX_USERNAME))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    form.add(
        new RequiredTextField<String>("customer.SecQuesAns")
            .add(new PatternValidator(Constants.REGEX_SECURITY_ANSWER))
            .add(Constants.mediumStringValidator)
            .add(Constants.mediumSimpleAttributeModifier)
            .add(new ErrorIndicator()));

    PrivilegedBehavior cancelReasonBehavior =
        new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_CANCEL);
    cancelReasonBehavior.setMissingPrivilegeHidesComponent(false);
    KeyValueDropDownChoice<Integer, String> custStatus =
        new KeyValueDropDownChoice<Integer, String>(
            "customer.active", mobBasePage.getCustomerStatus());
    custStatus.add(
        new SimpleAttributeModifier(
            "onchange",
            "confirmDeactivation('"
                + getLocalizer().getString("customer.deactivate.warning", mobBasePage)
                + "')"));
    form.add(custStatus.setNullValid(false).setRequired(true).add(cancelReasonBehavior));

    WebMarkupContainer blackListReasonDiv = new WebMarkupContainer("blackListReasonDiv");
    PrivilegedBehavior blackListBehavior =
        new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_BLACKLIST);
    blackListBehavior.setMissingPrivilegeHidesComponent(false);
    blackListReasonDiv.add(
        new LocalizableLookupDropDownChoice<Integer>(
                "customer.blackListReason",
                Integer.class,
                "blackListReasons",
                this,
                Boolean.FALSE,
                true)
            .setNullValid(false)
            .setRequired(true)
            .add(blackListBehavior));

    form.add(blackListReasonDiv);

    WebMarkupContainer cancelDivContainer = new WebMarkupContainer("cancelDivContainer");
    LocalizableLookupDropDownChoice<Integer> cancelationreason =
        new LocalizableLookupDropDownChoice<Integer>(
            "customer.cancelationReason", Integer.class, "cancellationReasons", this, false, true);
    cancelationreason.add(
        new SimpleAttributeModifier(
            "onchange",
            "confirmCancellation('"
                + getLocalizer().getString("customer.cancel.warning", mobBasePage)
                + "')"));
    cancelDivContainer.add(
        cancelationreason.setNullValid(false).setRequired(true).add(cancelReasonBehavior));
    // cancelDivContainer
    // .setVisible(getCustomer().getCustomerTypeId() ==
    // Constants.CONSUMER_IDTYPE
    // || getCustomer().getCustomerTypeId() ==
    // Constants.CUSTOMER_ROLE_MONEY_MERCHANT);
    form.add(cancelDivContainer);
    Button changenMsisdnButton =
        new Button("changeMsisdn") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Customer customer =
                mobBasePage.getCustomerByIdentification(
                    Constants.IDENT_TYPE_CUST_ID, String.valueOf(getCustomer().getId()));
            if (customer.getCancellationReasonId() != 0 || !customer.isActive()) {
              error(
                  getLocalizer()
                      .getString("customer.msisdn.change.error.customerinactive", mobBasePage));
              return;
            }
            mobBasePage.getMobiliserWebSession().setCustomerOtp(null);
            mobBasePage.getMobiliserWebSession().setCustomerOtpCount(0);
            mobBasePage.getMobiliserWebSession().setCustomerOtpLimitHit(false);
            setResponsePage(new ChangeMsisdnPage(getCustomer()));
          };
        }.setDefaultFormProcessing(false);
    changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed());
    changenMsisdnButton.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE));

    form.add(changenMsisdnButton);
    changenMsisdnButton.setVisible(!mobBasePage.getConfiguration().isMsisdnOtpConfirmed());

    form.add(
        new Button("resetPin") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Customer customer =
                mobBasePage.getCustomerByIdentification(
                    Constants.IDENT_TYPE_MSISDN, getCustomer().getMsisdn());
            if (!PortalUtils.exists(customer)) {
              error(getLocalizer().getString("customer.reset.password.noMsisdn", mobBasePage));
              return;
            }
            setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "pin"));
          };
        }.setDefaultFormProcessing(false)
            .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PINCALL)));

    form.add(
        new Button("resetPassword") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            Address address = mobBasePage.getAddressByCustomer(getCustomer().getId());
            if (address == null || !PortalUtils.exists(address.getEmail())) {
              error(getLocalizer().getString("customer.reset.password.noEmail", mobBasePage));
              return;
            }
            setResponsePage(new ResetCredentialPage(getCustomer(), this.getWebPage(), "password"));
          };
        }.setDefaultFormProcessing(false)
            .add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_PASSWORD)));

    form.add(
        new Button("update") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            if (updateCustomer()) {
              LOG.info(
                  "Data updated successfully for customer["
                      + mobBasePage.getMobiliserWebSession().getCustomer().getId()
                      + "]");
              getSession().info(getLocalizer().getString("data.update.successful", mobBasePage));
              setResponsePage(new StandingDataPage(getCustomer()));
            }
          };
        }.add(new PrivilegedBehavior(mobBasePage, Constants.PRIV_CUST_WRITE))
            .setVisible(!PortalUtils.exists(getCustomer().getTaskId())));

    form.add(
        new Button("approve") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            approveCustomer(true);
          };
        }.setDefaultFormProcessing(false)
            .setVisible(PortalUtils.exists(getCustomer().getTaskId())));

    form.add(
        new Button("reject") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            approveCustomer(false);
          };
        }.setDefaultFormProcessing(false)
            .setVisible(PortalUtils.exists(getCustomer().getTaskId())));

    if (PortalUtils.exists(getCustomer().getTaskId())) {
      Iterator iter = form.iterator();
      Component component;
      for (int i = 0; iter.hasNext(); i++) {
        component = (Component) iter.next();

        if (component.getId().equals("approve")
            || component.getId().equals("reject")
            || component instanceof FeedbackPanel) {
          continue;
        } else if (component instanceof Button) {
          component.setVisible(false);
        } else {

          if (component.getId().equals("blackListReasonDiv")
              || component.getId().equals("cancelDivContainer")) {
            Iterator iter1 = ((WebMarkupContainer) component).iterator();
            Component comp;
            for (int j = 0; iter1.hasNext(); j++) {
              comp = (Component) iter1.next();
              comp.setEnabled(false);
              comp.add(new SimpleAttributeModifier("readonly", "readonly"));
              comp.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
            }

          } else {
            component.setEnabled(false);
            component.add(new SimpleAttributeModifier("readonly", "readonly"));
            component.add(new SimpleAttributeModifier("style", "background-color: #E6E6E6;"));
          }
        }
      }
    }

    add(form);

    LOG.debug(
        "PatternDateConverter format: "
            + Constants.DATE_FORMAT_PATTERN_PARSE
            + " DatePicker format: "
            + Constants.DATE_FORMAT_PATTERN_PICKER);
  }
Ejemplo n.º 14
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);
  }
  private void createAttachmentContainer(final Form form) {
    final WebMarkupContainer attachmentContainer = new WebMarkupContainer("attachmentContainer");
    attachmentContainer.setOutputMarkupPlaceholderTag(true);
    forceReload = true;
    isAttachmentContainerVisible =
        isAttachmentContainerVisible
            && (message.getAttachments().size() > 0 || PortalUtils.exists(attachmentsList));
    createAttachmentsListDataView(attachmentContainer, form);
    final WebMarkupContainer addAttachmentContainer =
        new WebMarkupContainer("addAttachmentContainer");
    final Form<?> addAttachmentForm =
        new Form("addAttachmentForm", new CompoundPropertyModel<NotificationMessagePanel>(this));

    addAttachmentForm.add(
        new KeyValueDropDownChoice<Long, String>("attachmentAdd", attachmentsList)
            .setVisible(PortalUtils.exists(attachmentsList)));
    addAttachmentForm.setOutputMarkupPlaceholderTag(true);
    addAttachmentForm.add(
        new Button("add") {
          private static final long serialVersionUID = 1L;

          @Override
          public void onSubmit() {
            message.getAttachments().add(attachmentAdd);
            try {
              if (updateMessage()) {
                info(getLocalizer().getString("add.attachment.success", this));
                forceReload = true;
                getAttachments();
                createAttachmentContainer(form);
              }
            } catch (Exception e) {
              error(getLocalizer().getString("add.attachment.error", this));
              LOG.error("Error in attaching attachment with message", e);
            }
          }
        });

    addAttachmentForm.add(
        new AjaxLink("cancel") {

          @Override
          public void onClick(AjaxRequestTarget target) {
            addAttachmentContainer.setVisible(false);
            target.addComponent(addAttachmentContainer);
          }
        });
    addAttachmentContainer.setVisible(false);
    addAttachmentContainer.add(addAttachmentForm);
    addAttachmentContainer.setOutputMarkupPlaceholderTag(true);
    attachmentContainer.addOrReplace(addAttachmentContainer);
    attachmentContainer.addOrReplace(
        new AjaxLink("addAttachment") {

          private static final long serialVersionUID = 1L;

          @Override
          public void onClick(AjaxRequestTarget target) {
            addAttachmentContainer.setVisible(true);
            target.addComponent(addAttachmentContainer);
          }
        }.setVisible(PortalUtils.exists(attachmentsList)));
    attachmentContainer.setVisible(isAttachmentContainerVisible);
    form.addOrReplace(attachmentContainer);
  }
Ejemplo n.º 16
0
  protected void checkStatus(AjaxRequestTarget target) {
    if (PortalUtils.exists(response)) {
      checkResponse(target);
    }
    // get current Thread
    SmsAuthenticationThread t = getMobiliserWebSession().getSmsThread();

    // if technical problem...
    // Thread not started
    if (t == null) {
      prepairResponse(new AjaxResponse(9999, "Thread not started"), null);
      return;
    }

    // exception was thrown from thread
    if (t.getException() != null) {
      prepairResponse(new AjaxResponse(9999, "Exception: " + t.getException().getMessage()), null);
      return;
    }

    // Still processing request
    if (t.isActive()) {
      prepairResponse(new AjaxResponse(-1, ""), null);
      return;
    }

    // Thread is finished

    // no answer from Mobiliser. Technical error
    if (t.getResponse() == null) {
      prepairResponse(new AjaxResponse(9999, "No response from Mobiliser"), null);
      return;
    }

    Transaction txn = getMobiliserWebSession().getTransaction();

    // check if second try is exceeded. Cancel Transaction by second
    // retry
    if (txn.getContinueRetryCounter() >= 2 && t.getResponse().getStatus().getCode() == 2853) {

      if (LOG.isDebugEnabled()) LOG.debug("retry count exceeded. Canceling transaction");

      try {
        // Fail transaction
        txn.failTransaction(2853);

      } catch (Exception e) {
        LOG.error("#failTransaction: " + e, e);
      }

      // Kill Session
      getMobiliserWebSession().invalidate();

      prepairResponse(new AjaxResponse(9999, "Cancel Response"), txn);
      return;
    }

    // check status of mobiliser response
    if (t.getResponse().getStatus() != null && t.getResponse().getStatus().getCode() != 0) {
      // Mobiliser request failed with an error code

      AjaxResponse response =
          new AjaxResponse(
              t.getResponse().getStatus().getCode(), t.getResponse().getStatus().getValue());

      switch (t.getResponse().getStatus().getCode()) {
        case 2853: // Transaction timed out
          response.setRetryVisible(true);

        default:
          response.setRedirect(true);
      }

      prepairResponse(response, txn);
      return;
    }

    // everything was OK
    prepairResponse(new AjaxResponse(0, "OK"), txn);
  }
Ejemplo n.º 17
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;
    }
  }