use of org.springframework.binding.message.MessageBuilder in project cas by apereo.
the class AuthenticationExceptionHandler method handleAbstractTicketException.
/**
* Maps an {@link AbstractTicketException} onto a state name equal to the simple class name of the exception with
* highest precedence. Also sets an ERROR severity message in the message context with the error code found in
* {@link AbstractTicketException#getCode()}. If no match is found,
* {@value AuthenticationExceptionHandler#UNKNOWN} is returned.
*
* @param e Ticket exception to handle.
* @param messageContext the spring message context
* @return Name of next flow state to transition to or {@value AuthenticationExceptionHandler#UNKNOWN}
*/
protected String handleAbstractTicketException(final AbstractTicketException e, final MessageContext messageContext) {
// find the first error in the error list that matches the AbstractTicketException
final Optional<String> match = this.errors.stream().filter(c -> c.isInstance(e)).map(Class::getSimpleName).findFirst();
match.ifPresent(s -> messageContext.addMessage(new MessageBuilder().error().code(e.getCode()).build()));
return match.orElse(UNKNOWN);
}
use of org.springframework.binding.message.MessageBuilder in project cas by apereo.
the class AbstractCasWebflowEventResolver method handleAuthenticationTransactionAndGrantTicketGrantingTicket.
/**
* Handle authentication transaction and grant ticket granting ticket set.
*
* @param context the context
* @return the set
*/
protected Set<Event> handleAuthenticationTransactionAndGrantTicketGrantingTicket(final RequestContext context) {
try {
final Credential credential = getCredentialFromContext(context);
AuthenticationResultBuilder builder = WebUtils.getAuthenticationResultBuilder(context);
LOGGER.debug("Handling authentication transaction for credential [{}]", credential);
final Service service = WebUtils.getService(context);
builder = this.authenticationSystemSupport.handleAuthenticationTransaction(service, builder, credential);
LOGGER.debug("Issuing ticket-granting tickets for service [{}]", service);
return Collections.singleton(grantTicketGrantingTicketToAuthenticationResult(context, builder, service));
} catch (final Exception e) {
LOGGER.error(e.getMessage(), e);
final MessageContext messageContext = context.getMessageContext();
messageContext.addMessage(new MessageBuilder().error().code(DEFAULT_MESSAGE_BUNDLE_PREFIX.concat(e.getClass().getSimpleName())).build());
return Collections.singleton(new EventFactorySupport().error(this));
}
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class QuestionnaireController method constructErrorMessage.
protected void constructErrorMessage(String code, String message, MessageContext context, Object... args) {
MessageResolver messageResolver = new MessageBuilder().error().code(code).defaultText(message).args(args).build();
context.addMessage(messageResolver);
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class UserFormBean method bindDateField.
private void bindDateField(MessageContext messages, CustomFieldDto additionalField, DateFieldBean additionalDateField) {
try {
DateTime date = new DateTime().withDate(Integer.valueOf(additionalDateField.getYear()), additionalDateField.getMonth().intValue(), additionalDateField.getDay().intValue());
SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
additionalField.setFieldValue(format.format(date.toDate()));
} catch (Throwable e) {
messages.addMessage(new MessageBuilder().error().source("customFields").code("Valid.UserFormBean.additionaldatefield").defaultText("date not valid.").build());
}
}
use of org.springframework.binding.message.MessageBuilder in project head by mifos.
the class CashFlowValidator method constructErrorMessage.
void constructErrorMessage(String code, String message, MessageContext context, Object... args) {
MessageResolver messageResolver = new MessageBuilder().error().code(code).defaultText(message).args(args).build();
context.addMessage(messageResolver);
}
Aggregations