Search in sources :

Example 26 with SyntaxException

use of org.apache.jsieve.exception.SyntaxException in project zm-mailbox by Zimbra.

the class DummyCustomTag method validateArguments.

@Override
protected void validateArguments(Arguments arguments, SieveContext context) throws SieveException {
    @SuppressWarnings("unchecked") List<Argument> args = arguments.getArgumentList();
    if (args.size() != 1)
        throw new SyntaxException("Exactly 1 argument permitted. Found " + args.size());
    Object argument = args.get(0);
    if (!(argument instanceof StringListArgument))
        throw new SyntaxException("Expecting a string-list");
    if (1 != ((StringListArgument) argument).getList().size())
        throw new SyntaxException("Expecting exactly one argument");
}
Also used : Argument(org.apache.jsieve.Argument) StringListArgument(org.apache.jsieve.StringListArgument) SyntaxException(org.apache.jsieve.exception.SyntaxException) StringListArgument(org.apache.jsieve.StringListArgument)

Aggregations

SyntaxException (org.apache.jsieve.exception.SyntaxException)26 Argument (org.apache.jsieve.Argument)20 StringListArgument (org.apache.jsieve.StringListArgument)19 TagArgument (org.apache.jsieve.TagArgument)13 ZimbraMailAdapter (com.zimbra.cs.filter.ZimbraMailAdapter)8 ServiceException (com.zimbra.common.service.ServiceException)4 DummyMailAdapter (com.zimbra.cs.filter.DummyMailAdapter)4 List (java.util.List)3 Test (org.junit.Test)3 ZimbraSieveException (com.zimbra.cs.filter.ZimbraSieveException)2 EditHeaderExtension (com.zimbra.cs.filter.jsieve.EditHeaderExtension)2 ParseException (java.text.ParseException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 TimeZone (java.util.TimeZone)2 NumberArgument (org.apache.jsieve.NumberArgument)2 Strings (com.google.common.base.Strings)1 Lists (com.google.common.collect.Lists)1 HeaderConstants (com.zimbra.common.soap.HeaderConstants)1 StringUtil (com.zimbra.common.util.StringUtil)1