Examples of MessageBuilder


Examples of org.springframework.binding.message.MessageBuilder

            String base = param.getType().getBase();
            if ("integer".equals(base)) {
              try {
                Integer.parseInt(paramValue);
              } catch (NumberFormatException e) {
                context.addMessage(new MessageBuilder().error().source(paramPath)
                    .code("errors.channelDefinition.param.int")
                    .defaultText("Value must be an integer").build());
              }
            } else if ("float".equals(base)) {
              try {
                Float.parseFloat(paramValue);
              } catch (NumberFormatException e) {
                context.addMessage(new MessageBuilder().error().source(paramPath)
                    .code("errors.channelDefinition.param.float")
                    .defaultText("Value must be a number").build());
              }
            }
           
            // if this parameter has a restriction in the CPD,
            // check it against the restriction
            if (param.getType().getRestriction() != null
                && def.getParameters().containsKey(param.getName())) {
             
              CPDParameterTypeRestriction restriction = param.getType().getRestriction();
              if ("range".equals(restriction.getType())) {
                // For now, lets just not do anything.  It doesn't
                // look like the existing channel manager logic
                // actually uses this restriction for validation
              } else if ("enumeration".equals(restriction.getType())) {
                // if this restriction is an enumeration of allowed values, check to
                // make sure the entered value is in the enumerated list
                if (!restriction.getValues().contains(paramValue)) {
                  context.addMessage(new MessageBuilder().error().source(paramPath)
                      .code("errors.channelDefinition.param.enum")
                      .defaultText("Invalid selection").build());
                }
              }
            }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

  }
 
  public void validateChooseCategory(ChannelDefinitionForm def, MessageContext context) {
    // make sure the user has picked at least one category
    if (def.getCategories().size() == 0) {
      context.addMessage(new MessageBuilder().error().source("categories")
          .code("errors.channelDefinition.param.categories.empty")
          .defaultText("Please choose at least one category").build());
    }
  }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

  }
 
  public void validateChooseGroup(ChannelDefinitionForm def, MessageContext context) {
    // make sure the user has picked at least one group
    if (def.getGroups().size() == 0) {
      context.addMessage(new MessageBuilder().error().source("groups")
          .code("errors.channelDefinition.groups.empty")
          .defaultText("Please choose at least one group").build());
    }
  }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

 
  public void validateLifecycle(ChannelDefinitionForm def, ValidationContext context) {
    MessageContext messageContext = context.getMessageContext();
   
    if (def.getLifecycleState() == null) {
      messageContext.addMessage(new MessageBuilder().error().source("lifecycle")
          .code("lifecycle.error.selectLifecycle")
          .defaultText("Please select a lifecycle stage").build());
    }
    Date now = new Date();
    if (def.getPublishDate() != null) {
      if (def.getPublishDateTime().before(now)) {
        messageContext.addMessage(new MessageBuilder().error().source("publishDate")
            .code("lifecycle.error.invalidPublishDate")
            .defaultText("The auto-publishing date must be in the future").build());
      }
    }
    if (def.getExpirationDate() != null) {
      if (def.getExpirationDateTime().before(now)) {
        messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
            .code("lifecycle.error.invalidExpirationDate")
            .defaultText("The auto-expiration date must be in the future").build());
      }
    }
    if (def.getPublishDate() != null && def.getExpirationDate() != null) {
      if (def.getExpirationDateTime().before(def.getPublishDateTime())) {
        messageContext.addMessage(new MessageBuilder().error().source("expirationDate")
            .code("lifecycle.error.invalidPublishAndExpirationDate")
            .defaultText("The auto-expiration date must be after the auto-publish date").build());
      }
    }
  }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

        final Set<String> queryAttributes = personLookupHelper.getQueryAttributes(externalContext);
       
        final Map<String, Attribute> attributes = personQuery.getAttributes();
        for (final String attribute : attributes.keySet()) {
            if (!queryAttributes.contains(attribute)) {
                final MessageBuilder messageBuilder = new MessageBuilder();
                messageBuilder.error();
                messageBuilder.source("attributes[" + attribute + "].value");
                messageBuilder.code("personLookup.invalidQueryAttribute");
                messageBuilder.arg(attribute);

                final MessageResolver errorMessage = messageBuilder.build();
                context.addMessage(errorMessage);
            }
        }
    }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

     * Checks the keys in the Map on the model against a Set to ensure there are no values in the Map that aren't also in the Set
     */
    protected void checkAttributesMap(MessageContext context, String basePath, Set<String> swappableAttributes, Map<String, Attribute> attributesToCopy) {
        for (final String attribute : attributesToCopy.keySet()) {
            if (!swappableAttributes.contains(attribute)) {
                final MessageBuilder messageBuilder = new MessageBuilder();
                messageBuilder.error();
                messageBuilder.source(basePath + "[" + attribute + "].value");
                messageBuilder.code("attributesForm.invalidSwapAttribute");
                messageBuilder.arg(attribute);

                final MessageResolver errorMessage = messageBuilder.build();
                context.addMessage(errorMessage);
            }
        }
    }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder


    private void populateErrorsInstance(final TicketException e, final MessageContext messageContext) {

        try {
            messageContext.addMessage(new MessageBuilder().error().code(e.getCode()).defaultText(e.getCode()).build());
        } catch (final Exception fe) {
            logger.error(fe.getMessage(), fe);
        }
    }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

  private MessageResolver createMessageResolver(MappingResult error) {
    String field = error.getMapping().getTargetExpression().getExpressionString();
    String errorCode = error.getCode();
    String propertyErrorCode = new StringBuffer().append(getModelExpression().getExpressionString()).append('.')
        .append(field).append('.').append(errorCode).toString();
    return new MessageBuilder().error().source(field).code(propertyErrorCode).code(errorCode).resolvableArg(field)
        .defaultText(errorCode + " on " + field).build();
  }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

    {
       
        if (this.isEmpty())
        {
            MessageContext messages = context.getMessageContext();
            messages.addMessage(new MessageBuilder().error().defaultText(
                "At least one of the Search criteria should not be empty.")
                    .build());
           
        }
        else if (lastName.startsWith("*") || firstName.startsWith("*")
                || bookingId.startsWith("*") || activityDate.startsWith("*"))
        {
            MessageContext messages = context.getMessageContext();
            messages.addMessage(new MessageBuilder().error().defaultText(
                "Search criterion can not start with '*'.").build());
        }
    }
View Full Code Here

Examples of org.springframework.binding.message.MessageBuilder

    public void validateRecordretrieval(ValidationContext context)
    {
        MessageContext messages = context.getMessageContext();
        if (StringUtils.isEmpty(recordURI))
        {
            messages.addMessage(new MessageBuilder().error().source("recordURI").
            defaultText("Record URI can not be blank").build());
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.