Search in sources :

Example 11 with MessageBuilder

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);
        }
    }
}
Also used : MessageResolver(org.springframework.binding.message.MessageResolver) MessageBuilder(org.springframework.binding.message.MessageBuilder) Attribute(org.apereo.portal.portlets.Attribute) ExternalContext(org.springframework.webflow.context.ExternalContext) RequestContext(org.springframework.webflow.execution.RequestContext)

Example 12 with MessageBuilder

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);
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) MessageContext(org.springframework.binding.message.MessageContext)

Example 13 with MessageBuilder

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();
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder) PasswordChangeBean(org.apereo.cas.pm.PasswordChangeBean) UsernamePasswordCredential(org.apereo.cas.authentication.UsernamePasswordCredential) EventFactorySupport(org.springframework.webflow.action.EventFactorySupport)

Example 14 with MessageBuilder

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());
}
Also used : MessageBuilder(org.springframework.binding.message.MessageBuilder)

Example 15 with MessageBuilder

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);
}
Also used : MessageResolver(org.springframework.binding.message.MessageResolver) MessageBuilder(org.springframework.binding.message.MessageBuilder)

Aggregations

MessageBuilder (org.springframework.binding.message.MessageBuilder)24 MessageContext (org.springframework.binding.message.MessageContext)6 MessageResolver (org.springframework.binding.message.MessageResolver)6 BigDecimal (java.math.BigDecimal)4 DateTime (org.joda.time.DateTime)3 ArrayList (java.util.ArrayList)2 ErrorEntry (org.mifos.platform.validations.ErrorEntry)2 BusinessRuleException (org.mifos.service.BusinessRuleException)2 ReportServiceLocatorException (org.opennms.reporting.core.svclayer.ReportServiceLocatorException)2 SchedulerException (org.quartz.SchedulerException)2 EventFactorySupport (org.springframework.webflow.action.EventFactorySupport)2 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 CentralAuthenticationService (org.apereo.cas.CentralAuthenticationService)1 AuthenticationException (org.apereo.cas.authentication.AuthenticationException)1 AuthenticationResultBuilder (org.apereo.cas.authentication.AuthenticationResultBuilder)1 Credential (org.apereo.cas.authentication.Credential)1 UsernamePasswordCredential (org.apereo.cas.authentication.UsernamePasswordCredential)1 Service (org.apereo.cas.authentication.principal.Service)1