use of org.springframework.binding.message.MessageBuilder in project uPortal by Jasig.
the class PersonQueryValidator method validatePersonLookup.
/** Ensures all passed attributes are part of the valid query attribute set. */
public void validatePersonLookup(PersonQuery personQuery, MessageContext context) {
final RequestContext requestContext = RequestContextHolder.getRequestContext();
final ExternalContext externalContext = requestContext.getExternalContext();
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);
}
}
}
use of org.springframework.binding.message.MessageBuilder in project cas by apereo.
the class ValidateCaptchaAction method getError.
private Event getError(final RequestContext requestContext) {
final MessageContext messageContext = requestContext.getMessageContext();
messageContext.addMessage(new MessageBuilder().error().code(CODE).build());
return getEventFactorySupport().event(this, CODE);
}
use of org.springframework.binding.message.MessageBuilder in project cas by apereo.
the class PasswordChangeAction method doExecute.
@Override
protected Event doExecute(final RequestContext requestContext) throws Exception {
try {
final UsernamePasswordCredential c = (UsernamePasswordCredential) WebUtils.getCredential(requestContext);
final PasswordChangeBean bean = requestContext.getFlowScope().get(PasswordManagementWebflowConfigurer.FLOW_VAR_ID_PASSWORD, PasswordChangeBean.class);
if (passwordManagementService.change(c, bean)) {
return new EventFactorySupport().event(this, PASSWORD_UPDATE_SUCCESS);
}
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
}
requestContext.getMessageContext().addMessage(new MessageBuilder().error().code("pm.updateFailure").defaultText("Could not update the account password").build());
return error();
}
use of org.springframework.binding.message.MessageBuilder in project cas by apereo.
the class AbstractCasWebflowEventResolver method addMessageDescriptorToMessageContext.
/**
* Adds a warning message to the message context.
*
* @param context Message context.
* @param warning Warning message.
*/
protected static void addMessageDescriptorToMessageContext(final MessageContext context, final MessageDescriptor warning) {
final MessageBuilder builder = new MessageBuilder().warning().code(warning.getCode()).defaultText(warning.getDefaultMessage()).args((Object[]) warning.getParams());
context.addMessage(builder.build());
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class ValidationExceptionMessageExtractor method constructErrorMessage.
private void constructErrorMessage(String code, String defaultMessage, MessageContext context, Object... args) {
MessageResolver messageResolver = new MessageBuilder().error().code(code).defaultText(defaultMessage).args(args).build();
context.addMessage(messageResolver);
}
Aggregations