* {@inheritDoc}
*/
@Override
public void validate(final ClientPrincipalActionContext inActionContext) throws ValidationException
{
SendPrebuiltNotificationRequest params = (SendPrebuiltNotificationRequest) inActionContext.getParams();
ValidationException ve = new ValidationException();
// insure valid recipient
PersonModelView recipient = personMapper.execute(params.getRecipientAccountId());
if (recipient == null)
{
ve.addError("recipientAccountId", "Unknown or missing recipient account id.");
}
else if (recipient.isAccountLocked())
{
ve.addError("recipientAccountId", "Cannot send notifications to locked users.");
}
else
{
inActionContext.getState().put("recipient", recipient);
}
// message
if (params.getMessage() == null || params.getMessage().isEmpty())
{
ve.addError("message", "Message must be provided.");
}
else if (params.getMessage().length() > maxMessageLength)
{
ve.addError("message", "Message must be no more than " + maxMessageLength + " characters.");
}
// TODO: Should we check content of message?
// URL
if (params.getUrl() != null && params.getUrl().length() > maxUrlLength)
{
ve.addError("url", "URL must be no more than " + maxUrlLength + " characters.");
}
// TODO: Should we check format of URL?