Search in sources :

Example 6 with MessageResolver

use of org.springframework.binding.message.MessageResolver in project uPortal by Jasig.

the class AttributeSwapRequestValidator method checkAttributesMap.

/**
     * 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("x.is.not.a.valid.attribute");
            messageBuilder.arg(attribute);
            final MessageResolver errorMessage = messageBuilder.build();
            context.addMessage(errorMessage);
        }
    }
}
Also used : MessageResolver(org.springframework.binding.message.MessageResolver) MessageBuilder(org.springframework.binding.message.MessageBuilder)

Aggregations

MessageBuilder (org.springframework.binding.message.MessageBuilder)6 MessageResolver (org.springframework.binding.message.MessageResolver)6 Attribute (org.apereo.portal.portlets.Attribute)1 ExternalContext (org.springframework.webflow.context.ExternalContext)1 RequestContext (org.springframework.webflow.execution.RequestContext)1