Search in sources :

Example 6 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class IdentityRequestWrapper method processRequestFilter.

@Override
public Navajo processRequestFilter(HttpServletRequest request) throws IOException, ServletException {
    Navajo in = null;
    // String sendEncoding = request.getHeader("Accept-Encoding");
    String recvEncoding = request.getHeader("Content-Encoding");
    // boolean useSendCompression = ((sendEncoding != null) &&
    // (sendEncoding.indexOf("zip") != -1));
    boolean useRecvCompression = ((recvEncoding != null) && (recvEncoding.indexOf("zip") != -1));
    BufferedInputStream is = null;
    if (useRecvCompression) {
        java.util.zip.GZIPInputStream unzip = new java.util.zip.GZIPInputStream(request.getInputStream());
        is = new BufferedInputStream(unzip);
        in = NavajoFactory.getInstance().createNavajo(is);
    } else {
        is = new BufferedInputStream(request.getInputStream());
        in = NavajoFactory.getInstance().createNavajo(is);
    }
    if (in == null) {
        throw new ServletException("Invalid request.");
    }
    return in;
}
Also used : ServletException(javax.servlet.ServletException) BufferedInputStream(java.io.BufferedInputStream) Navajo(com.dexels.navajo.document.Navajo)

Example 7 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class LaszloRequestWrapper method processRequestFilter.

@Override
public Navajo processRequestFilter(HttpServletRequest request) throws IOException, ServletException {
    Navajo in = null;
    // String sendEncoding = request.getHeader("Accept-Encoding");
    String recvEncoding = request.getHeader("Content-Encoding");
    // boolean useSendCompression = ((sendEncoding != null) &&
    // (sendEncoding.indexOf("zip") != -1));
    boolean useRecvCompression = ((recvEncoding != null) && (recvEncoding.indexOf("zip") != -1));
    BufferedInputStream is = null;
    if (useRecvCompression) {
        java.util.zip.GZIPInputStream unzip = new java.util.zip.GZIPInputStream(request.getInputStream());
        is = new BufferedInputStream(unzip);
        in = NavajoLaszloConverter.createNavajoFromLaszlo(is);
    } else {
        is = new BufferedInputStream(request.getInputStream());
        in = NavajoLaszloConverter.createNavajoFromLaszlo(is);
    }
    return in;
}
Also used : BufferedInputStream(java.io.BufferedInputStream) Navajo(com.dexels.navajo.document.Navajo)

Example 8 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class BirtHandler method doService.

@Override
public final Navajo doService(Access a) {
    Navajo inDoc = getInDoc(a);
    inDoc.removeInternalMessages();
    Binary birtBinary = getBirtBinary(inDoc);
    Navajo navajoBirt = makeNavajoBirt(birtBinary);
    return navajoBirt;
}
Also used : Navajo(com.dexels.navajo.document.Navajo) Binary(com.dexels.navajo.document.types.Binary)

Example 9 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class Switch method testWithPropertyAndSingleValueParameter.

@Test
public void testWithPropertyAndSingleValueParameter() throws Exception {
    FunctionInterface fi = fff.getInstance(cl, "Switch");
    fi.reset();
    Navajo n = createTestNavajo();
    fi.setInMessage(n);
    fi.insertOperand(Expression.evaluate("[/Single/Vuur]", n));
    fi.insertIntegerOperand(0);
    try {
        Object result = fi.evaluate();
    } catch (TMLExpressionException tmle) {
        assertTrue(tmle.getMessage().indexOf("Not enough") != -1);
    }
}
Also used : FunctionInterface(com.dexels.navajo.expression.api.FunctionInterface) Navajo(com.dexels.navajo.document.Navajo) TMLExpressionException(com.dexels.navajo.expression.api.TMLExpressionException) Test(org.junit.Test)

Example 10 with Navajo

use of com.dexels.navajo.document.Navajo in project navajo by Dexels.

the class Switch method createTestNavajo.

@Override
protected Navajo createTestNavajo() throws Exception {
    Navajo doc = NavajoFactory.getInstance().createNavajo();
    Message array = NavajoFactory.getInstance().createMessage(doc, "Aap");
    array.setType(Message.MSG_TYPE_ARRAY);
    Message array1 = NavajoFactory.getInstance().createMessage(doc, "Aap");
    array.addElement(array1);
    doc.addMessage(array);
    Property p = NavajoFactory.getInstance().createProperty(doc, "Noot", Property.INTEGER_PROPERTY, "10", 10, "", "in");
    p.setValue(10);
    array1.addProperty(p);
    Message single = NavajoFactory.getInstance().createMessage(doc, "Single");
    doc.addMessage(single);
    Property p2 = NavajoFactory.getInstance().createProperty(doc, "Selectie", "1", "", "in");
    p2.addSelection(NavajoFactory.getInstance().createSelection(doc, "key", "value", true));
    single.addProperty(p2);
    Property p3 = NavajoFactory.getInstance().createProperty(doc, "Vuur", Property.INTEGER_PROPERTY, "10", 10, "", "out");
    p3.setValue(10);
    single.addProperty(p3);
    return doc;
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Aggregations

Navajo (com.dexels.navajo.document.Navajo)258 Message (com.dexels.navajo.document.Message)131 Test (org.junit.Test)109 Property (com.dexels.navajo.document.Property)86 NavajoException (com.dexels.navajo.document.NavajoException)31 Access (com.dexels.navajo.script.api.Access)30 IOException (java.io.IOException)28 StringWriter (java.io.StringWriter)27 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)26 FunctionInterface (com.dexels.navajo.expression.api.FunctionInterface)25 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)22 Selection (com.dexels.navajo.document.Selection)22 Header (com.dexels.navajo.document.Header)20 Operand (com.dexels.navajo.document.Operand)20 InputStream (java.io.InputStream)17 UserException (com.dexels.navajo.script.api.UserException)16 Optional (java.util.Optional)16 FatalException (com.dexels.navajo.script.api.FatalException)14 SystemException (com.dexels.navajo.script.api.SystemException)14 ContextExpression (com.dexels.navajo.expression.api.ContextExpression)13