/**
   * @see
   *     org.kuali.rice.kns.maintenance.KualiMaintainableImpl#processAfterEdit(org.kuali.rice.kns.document.MaintenanceDocument,
   *     java.util.Map)
   */
  @Override
  public void processAfterEdit(MaintenanceDocument document, Map<String, String[]> parameters) {
    List<ErrorMessage> errorMessages = null;
    AgencyStagingData agency =
        (AgencyStagingData) document.getNewMaintainableObject().getBusinessObject();

    if (TemConstants.ExpenseImportTypes.IMPORT_BY_TRIP.equals(agency.getImportBy())) {
      errorMessages = getExpenseImportByTripService().validateAgencyData(agency);
    } else if (TemConstants.ExpenseImportTypes.IMPORT_BY_TRAVELLER.equals(agency.getImportBy())) {
      errorMessages = getExpenseImportByTravelerService().validateAgencyData(agency);
    }

    if (errorMessages.isEmpty()) {
      agency.setErrorCode(AgencyStagingDataErrorCodes.AGENCY_NO_ERROR);
    }

    MessageMap messageMap = GlobalVariables.getMessageMap();
    for (ErrorMessage message : errorMessages) {
      messageMap.putError(
          KFSConstants.GLOBAL_ERRORS, message.getErrorKey(), message.getMessageParameters());
    }

    updateCreditCardAgency(
        (AgencyStagingData) document.getNewMaintainableObject().getBusinessObject());

    super.processAfterEdit(document, parameters);
  }
Esempio n. 2
0
 private ActionForward doEndDateConfirmation(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response,
     String questionId,
     String yesMethodName)
     throws Exception {
   List<ErrorMessage> errors =
       GlobalVariables.getMessageMap()
           .getErrorMessagesForProperty(ProposalHierarchyKeyConstants.FIELD_CHILD_NUMBER);
   List<String> proposalNumbers = new ArrayList<String>();
   for (ErrorMessage error : errors) {
     if (error
         .getErrorKey()
         .equals(ProposalHierarchyKeyConstants.QUESTION_EXTEND_PROJECT_DATE_CONFIRM)) {
       proposalNumbers.add(error.getMessageParameters()[0]);
     }
   }
   String proposalNumberList = StringUtils.join(proposalNumbers, ',');
   StrutsConfirmation question =
       buildParameterizedConfirmationQuestion(
           mapping,
           form,
           request,
           response,
           questionId,
           ProposalHierarchyKeyConstants.QUESTION_EXTEND_PROJECT_DATE_CONFIRM,
           proposalNumberList);
   GlobalVariables.getMessageMap().getErrorMessages().clear();
   GlobalVariables.getMessageMap().getWarningMessages().clear();
   GlobalVariables.getMessageMap().getInfoMessages().clear();
   return confirm(question, yesMethodName, "hierarchyActionCanceled");
 }
  /**
   * 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();
    }
  }
 /**
  * This method...
  *
  * @param map
  */
 protected void removeRestrictedFieldChangedErrors(MessageMap map, String propertyKey) {
   AutoPopulatingList<ErrorMessage> errorMessages = map.getErrorMessagesForProperty(propertyKey);
   if (errorMessages != null) {
     for (int i = 0; i < errorMessages.size(); i++) {
       ErrorMessage eMessage = (ErrorMessage) errorMessages.get(i);
       String errorKey = eMessage.getErrorKey();
       if (errorKey.equals(
           KFSKeyConstants.ERROR_DOCUMENT_AUTHORIZATION_RESTRICTED_FIELD_CHANGED)) {
         errorMessages.remove(i);
       }
     }
   }
 }
Esempio n. 5
0
  public ActionMessages getRequestMessages() {
    ActionMessages requestErrors = new ActionMessages();
    for (Iterator<String> iter = getMessagePropertyNames().iterator(); iter.hasNext(); ) {
      String property = iter.next();
      List errorList = (List) getMessagesForProperty(property);

      for (Iterator iterator = errorList.iterator(); iterator.hasNext(); ) {
        ErrorMessage errorMessage = (ErrorMessage) iterator.next();

        // add ActionMessage with any parameters
        requestErrors.add(
            property,
            new ActionMessage(errorMessage.getErrorKey(), errorMessage.getMessageParameters()));
      }
    }
    return requestErrors;
  }
 @SuppressWarnings("unchecked")
 public List<AwardSyncLog> getLogsFromSaveErrors(AwardSyncStatus awardStatus) {
   List<AwardSyncLog> result = new ArrayList<AwardSyncLog>();
   Map<String, ? extends List<ErrorMessage>> errors =
       GlobalVariables.getMessageMap().getErrorMessages();
   for (Map.Entry<String, ? extends List<ErrorMessage>> entry : errors.entrySet()) {
     Iterator<ErrorMessage> iter = entry.getValue().iterator();
     while (iter.hasNext()) {
       ErrorMessage curMessage = iter.next();
       awardStatus.addValidationLog(
           expandErrorString(curMessage.getErrorKey(), curMessage.getMessageParameters()),
           false,
           curMessage.getErrorKey());
     }
   }
   errors.clear();
   return result;
 }
 @Test
 public void testMoveUnitOwnDescendant() throws Exception {
   Unit unit = new Unit();
   unit.setUnitName("IN-IN");
   unit.setUnitNumber("IN-IN");
   unit.setParentUnitNumber("IN-MED");
   unit.setOrganizationId("00001");
   MaintenanceDocument unitmaintenancedocument = newMaintDoc(unit);
   assertFalse(rule.processCustomRouteDocumentBusinessRules(unitmaintenancedocument));
   List errors =
       GlobalVariables.getMessageMap()
           .getMessages("ddocument.newMaintainableObject.parentUnitNumber");
   errors =
       GlobalVariables.getMessageMap()
           .getMessages("document.newMaintainableObject.parentUnitNumber");
   assertTrue(errors.size() == 1);
   ErrorMessage message = (ErrorMessage) errors.get(0);
   assertEquals(message.getErrorKey(), KeyConstants.MOVE_UNIT_OWN_DESCENDANTS);
 }
Esempio n. 8
0
  /**
   * This method build a string list of error message keys out of the error map in GlobalVariables
   *
   * @return a String representing the list of error message keys
   */
  private String buildErrorMesageKeyList() {
    MessageMap errorMap = GlobalVariables.getMessageMap();
    StringBuffer errorList = new StringBuffer();

    for (String errorKey : (List<String>) errorMap.getPropertiesWithErrors()) {
      for (ErrorMessage errorMessage : (List<ErrorMessage>) errorMap.getMessages(errorKey)) {

        errorList.append(errorMessage.getErrorKey());
        errorList.append(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR);
      }
    }
    if (errorList.length() > 0) {
      errorList.replace(
          errorList.lastIndexOf(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR),
          errorList.lastIndexOf(PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR)
              + PdpParameterConstants.ERROR_KEY_LIST_SEPARATOR.length(),
          "");
    }

    return errorList.toString();
  }
  /**
   * Deletes the asset locking error messages from the GlobalVariables.
   *
   * @return none
   */
  protected void deleteLockErrorMessages() {
    // Finding locking error messages
    List<ErrorMessage> el = new ArrayList<ErrorMessage>();

    if (GlobalVariables.getMessageMap().getMessages(KFSConstants.GLOBAL_ERRORS) == null) {
      return;
    }

    for (Iterator<ErrorMessage> iterator =
            GlobalVariables.getMessageMap().getMessages(KFSConstants.GLOBAL_ERRORS).iterator();
        iterator.hasNext(); ) {
      ErrorMessage errorMessage = iterator.next();
      if (errorMessage.getErrorKey().equals(KFSKeyConstants.ERROR_MAINTENANCE_LOCKED)) {
        el.add(errorMessage);
      }
    }

    // Deleting asset locked error messages from global variable.
    for (ErrorMessage em : el) {
      GlobalVariables.getMessageMap().getMessages(KFSConstants.GLOBAL_ERRORS).remove(em);
    }
  }