protected MailMessage composeMessage(MailMessage message) {

    MailMessage mm = new MailMessage();

    // If realNotificationsEnabled is false, mails will be sent to
    // nonProductionNotificationMailingList
    if (!isRealNotificationsEnabled()) {
      getNonProductionMessage(message);
    }

    String app =
        CoreApiServiceLocator.getKualiConfigurationService()
            .getPropertyValueAsString(CoreConstants.Config.APPLICATION_ID);
    String env =
        CoreApiServiceLocator.getKualiConfigurationService()
            .getPropertyValueAsString(KRADConstants.ENVIRONMENT_KEY);

    mm.setToAddresses(message.getToAddresses());
    mm.setBccAddresses(message.getBccAddresses());
    mm.setCcAddresses(message.getCcAddresses());
    mm.setSubject(app + " " + env + ": " + message.getSubject());
    mm.setMessage(message.getMessage());
    mm.setFromAddress(message.getFromAddress());
    return mm;
  }
  /**
   * Retrieves validation errors from GlobalVariables MessageMap and appends to the given list of
   * RemotableAttributeError
   *
   * @param validationErrors list to append validation errors
   */
  protected void retrieveValidationErrorsFromGlobalVariables(
      List<RemotableAttributeError> validationErrors) {
    // can we use KualiConfigurationService?  It seemed to be used elsewhere...
    ConfigurationService configurationService =
        CoreApiServiceLocator.getKualiConfigurationService();

    if (GlobalVariables.getMessageMap().hasErrors()) {
      MessageMap deepCopy =
          (MessageMap) SerializationUtils.deepCopy(GlobalVariables.getMessageMap());
      for (String errorKey : deepCopy.getErrorMessages().keySet()) {
        List<ErrorMessage> errorMessages = deepCopy.getErrorMessages().get(errorKey);
        if (CollectionUtils.isNotEmpty(errorMessages)) {
          List<String> errors = new ArrayList<String>();
          for (ErrorMessage errorMessage : errorMessages) {
            // need to materialize the message from it's parameters so we can send it back to the
            // framework
            String error =
                MessageFormat.format(
                    configurationService.getPropertyValueAsString(errorMessage.getErrorKey()),
                    errorMessage.getMessageParameters());
            errors.add(error);
          }
          RemotableAttributeError remotableAttributeError =
              RemotableAttributeError.Builder.create(errorKey, errors).build();
          validationErrors.add(remotableAttributeError);
        }
      }
      // we should now strip the error messages from the map because they have moved to
      // validationErrors
      GlobalVariables.getMessageMap().clearErrorMessages();
    }
  }
Beispiel #3
0
  /**
   * route the document using the document service
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  @Override
  public ActionForward route(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    AwardBudgetDocument awardBudgetDocument = ((AwardBudgetForm) form).getAwardBudgetDocument();
    Award currentAward =
        getAwardBudgetService()
            .getActiveOrNewestAward(
                ((AwardDocument) awardBudgetDocument.getBudget().getBudgetParent().getDocument())
                    .getAward()
                    .getAwardNumber());
    ScaleTwoDecimal newCostLimit = getAwardBudgetService().getTotalCostLimit(currentAward);
    if (!newCostLimit.equals(awardBudgetDocument.getBudget().getTotalCostLimit())
        || !getAwardBudgetService()
            .limitsMatch(
                currentAward.getAwardBudgetLimits(),
                awardBudgetDocument.getAwardBudget().getAwardBudgetLimits())) {
      Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
      Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
      String methodToCall = ((KualiForm) form).getMethodToCall();
      if (question == null) {
        ConfigurationService kualiConfiguration =
            CoreApiServiceLocator.getKualiConfigurationService();
        return confirm(
            buildParameterizedConfirmationQuestion(
                mapping,
                form,
                request,
                response,
                UPDATE_COST_LIMITS_QUESTION,
                KeyConstants.QUESTION_TOTALCOSTLIMIT_CHANGED),
            methodToCall,
            methodToCall);
      } else if (UPDATE_COST_LIMITS_QUESTION.equals(question)
          && ConfirmationQuestion.YES.equals(buttonClicked)) {
        getAwardBudgetService().setBudgetLimits(awardBudgetDocument, currentAward);
        return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
      } else {
        // do nothing and continue with route
      }
    }
    ((AwardBudgetForm) form).setAuditActivated(true);
    ValidationState state =
        KcServiceLocator.getService(AuditHelper.class)
            .isValidSubmission((AwardBudgetForm) form, true);
    if (state != ValidationState.ERROR) {
      getAwardBudgetService().processSubmision(awardBudgetDocument);
      return super.route(mapping, form, request, response);
    } else {
      GlobalVariables.getMessageMap().clearErrorMessages();
      GlobalVariables.getMessageMap()
          .putError("datavalidation", KeyConstants.ERROR_WORKFLOW_SUBMISSION, new String[] {});

      return mapping.findForward(Constants.MAPPING_AWARD_BASIC);
    }
  }
 public Map<String, String> getDefaultReplacementParameters() {
   Map<String, String> params = super.getDefaultReplacementParameters();
   params.put(
       ProtocolReplacementParameters.REASON,
       StringUtils.isNotBlank(reason)
           ? reason
           : CoreApiServiceLocator.getKualiConfigurationService()
               .getPropertyValueAsString(NO_REASON_GIVEN));
   return params;
 }
 /**
  * Uses the key returned by {@link #getPatternTypeKey()} to fetch the validationPattern's regex
  * string from the ConfigurationService which should not include the start(^) and end($) symbols
  *
  * @return String regex validation string
  */
 @Override
 protected String getRegexString() {
   if (StringUtils.isBlank(getPatternTypeKey())) {
     throw new IllegalArgumentException(
         "patternTypeKey is null, configuration of "
             + this.getClass().getName()
             + " is incomplete");
   }
   return CoreApiServiceLocator.getKualiConfigurationService()
       .getPropertyValueAsString(getPatternTypeKey());
 }
Beispiel #6
0
  /**
   * Close the document and take the user back to the index; only after asking the user if they want
   * to save the document first. Only users who have the "canSave()" permission are given this
   * option.
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return ActionForward
   * @throws Exception
   */
  @Override
  public ActionForward close(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    KualiDocumentFormBase docForm = (KualiDocumentFormBase) form;
    // only want to prompt them to save if they already can save
    if (docForm.getDocumentActions().containsKey(KRADConstants.KUALI_ACTION_CAN_SAVE)) {
      Object question = request.getParameter(KRADConstants.QUESTION_INST_ATTRIBUTE_NAME);
      ConfigurationService kualiConfiguration =
          CoreApiServiceLocator.getKualiConfigurationService();

      // logic for close question
      if (question == null) {
        // ask question if not already asked
        return this.performQuestionWithoutInput(
            mapping,
            form,
            request,
            response,
            KRADConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION,
            kualiConfiguration.getPropertyValueAsString(
                RiceKeyConstants.QUESTION_SAVE_BEFORE_CLOSE),
            KRADConstants.CONFIRMATION_QUESTION,
            KRADConstants.MAPPING_CLOSE,
            "");
      } else {
        BudgetForm budgetForm = (BudgetForm) form;
        Budget budget = budgetForm.getBudgetDocument().getBudget();

        Object buttonClicked = request.getParameter(KRADConstants.QUESTION_CLICKED_BUTTON);
        if ((KRADConstants.DOCUMENT_SAVE_BEFORE_CLOSE_QUESTION.equals(question))
            && ConfirmationQuestion.YES.equals(buttonClicked)) {
          // if yes button clicked - save the doc
          getBudgetJustificationService().preSave(budget, getBudgetJusticationWrapper(form));
        }
        // else go to close logic below
      }
    }

    return super.close(mapping, form, request, response);
  }
 protected ConfigurationService getKualiConfigurationService() {
   return CoreApiServiceLocator.getKualiConfigurationService();
 }
 private static ConfigurationService getKualiConfigurationService() {
   if (kualiConfigurationService == null) {
     kualiConfigurationService = CoreApiServiceLocator.getKualiConfigurationService();
   }
   return kualiConfigurationService;
 }
  @Override
  @RequestMapping(params = "methodToCall=docHandler")
  public ModelAndView docHandler(
      @ModelAttribute("KualiForm") DocumentFormBase formBase,
      BindingResult result,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // TODO getting double view if we call base, not sure how to handle
    // so pasting in superclass code
    // super.docHandler(formBase, request, response);
    // * begin copy/paste from the base
    MaintenanceDocumentForm form = (MaintenanceDocumentForm) formBase;

    // in all of the following cases we want to load the document
    if (ArrayUtils.contains(DOCUMENT_LOAD_COMMANDS, form.getCommand()) && form.getDocId() != null) {
      try {
        loadDocument(form);
        OlePersistableBusinessObjectBase olePersistableBusinessObjectBase =
            (OlePersistableBusinessObjectBase)
                form.getDocument().getNewMaintainableObject().getDataObject();
        olePersistableBusinessObjectBase.setAlertBoList(
            alertService.retrieveAlertList(form.getDocument().getDocumentNumber()));
      } catch (UnknownDocumentIdException udie) {
        ConfigurationService kualiConfigurationService =
            CoreApiServiceLocator.getKualiConfigurationService();
        StringBuffer sb = new StringBuffer();
        sb.append(kualiConfigurationService.getPropertyValueAsString(KRADConstants.KRAD_URL_KEY));
        sb.append(
            kualiConfigurationService.getPropertyValueAsString(
                KRADConstants.KRAD_INITIATED_DOCUMENT_URL_KEY));
        Properties props = new Properties();
        props.put(UifParameters.METHOD_TO_CALL, UifConstants.MethodToCallNames.START);
        GlobalVariables.getUifFormManager().removeSessionForm(form); // removeForm(form);
        return performRedirect(new InitiatedDocumentInfoForm(), sb.toString(), props);
      }
    } else if (KewApiConstants.INITIATE_COMMAND.equals(form.getCommand())) {
      createDocument(form);
    } else {
      LOG.error("docHandler called with invalid parameters");
      throw new IllegalArgumentException("docHandler called with invalid parameters");
    }
    // * end copy/paste from the base

    if (KewApiConstants.ACTIONLIST_COMMAND.equals(form.getCommand())
        || KewApiConstants.DOCSEARCH_COMMAND.equals(form.getCommand())
        || KewApiConstants.SUPERUSER_COMMAND.equals(form.getCommand())
        || KewApiConstants.HELPDESK_ACTIONLIST_COMMAND.equals(form.getCommand())
            && form.getDocId() != null) {
      // TODO: set state in view
      // form.setReadOnly(true);
      form.setMaintenanceAction(
          (form.getDocument()).getNewMaintainableObject().getMaintenanceAction());

      // Retrieving the FileName from BO table
      Maintainable tmpMaintainable = form.getDocument().getNewMaintainableObject();
      if (tmpMaintainable.getDataObject() instanceof PersistableAttachment) {
        PersistableAttachment bo =
            (PersistableAttachment)
                getBusinessObjectService()
                    .retrieve((PersistableBusinessObject) tmpMaintainable.getDataObject());
        if (bo != null) {
          request.setAttribute("fileName", bo.getFileName());
        }
      }
    } else if (KewApiConstants.INITIATE_COMMAND.equals(form.getCommand())) {
      // form.setReadOnly(false);
      setupMaintenance(form, request, KRADConstants.MAINTENANCE_NEW_ACTION);
    } else {
      LOG.error("We should never have gotten to here");
      throw new IllegalArgumentException("docHandler called with invalid parameters");
    }

    return getUIFModelAndView(form);
  }