Search in sources :

Example 1 with SieveToSoap

use of com.zimbra.cs.filter.SieveToSoap in project zm-mailbox by Zimbra.

the class TestFilter method normalize.

/**
     * Converts the script to XML and back again.
     */
private String normalize(String script) throws ParseException, ServiceException {
    List<String> ruleNames = RuleManager.getRuleNames(script);
    Node node = RuleManager.getSieveFactory().parse(new ByteArrayInputStream(script.getBytes()));
    // Convert from Sieve to SOAP and back again.
    SieveToSoap sieveToSoap = new SieveToSoap(ruleNames);
    sieveToSoap.accept(node);
    SoapToSieve soapToSieve = new SoapToSieve(sieveToSoap.toFilterRules());
    return soapToSieve.getSieveScript();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Node(org.apache.jsieve.parser.generated.Node) SieveToSoap(com.zimbra.cs.filter.SieveToSoap) SoapToSieve(com.zimbra.cs.filter.SoapToSieve)

Aggregations

SieveToSoap (com.zimbra.cs.filter.SieveToSoap)1 SoapToSieve (com.zimbra.cs.filter.SoapToSieve)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 Node (org.apache.jsieve.parser.generated.Node)1