Search in sources :

Example 6 with Header

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

the class Dispatcher method generateErrorMessage.

/**
 * Generate a Navajo error message and log the error to the Database.
 */
@Override
public final Navajo generateErrorMessage(Access access, String message, int code, int level, Throwable t) throws FatalException {
    if (message == null) {
        message = "Null pointer exception";
    }
    if (t != null) {
        logger.error("Generating error message for: ", t);
    }
    try {
        Navajo outMessage = NavajoFactory.getInstance().createNavajo();
        // Make sure empty Header is constructed
        Header h = NavajoFactory.getInstance().createHeader(outMessage, "", "", "", -1);
        outMessage.addHeader(h);
        Message errorMessage = NavajoFactory.getInstance().createMessage(outMessage, Constants.ERROR_MESSAGE);
        outMessage.addMessage(errorMessage);
        Property prop = NavajoFactory.getInstance().createProperty(outMessage, "message", Property.STRING_PROPERTY, message, 200, "Message", Property.DIR_OUT);
        errorMessage.addProperty(prop);
        prop = NavajoFactory.getInstance().createProperty(outMessage, "code", Property.INTEGER_PROPERTY, code + "", 100, "Code", Property.DIR_OUT);
        errorMessage.addProperty(prop);
        prop = NavajoFactory.getInstance().createProperty(outMessage, "level", Property.INTEGER_PROPERTY, level + "", 100, "Level", Property.DIR_OUT);
        errorMessage.addProperty(prop);
        if (access != null) {
            prop = NavajoFactory.getInstance().createProperty(outMessage, "access_id", Property.STRING_PROPERTY, access.accessID + "", 100, "Access id", Property.DIR_OUT);
            errorMessage.addProperty(prop);
            access.setException(t);
        }
        if (access != null) {
            access.setOutputDoc(outMessage);
        }
        return outMessage;
    } catch (Exception e) {
        throw new FatalException(e.getMessage(), e);
    }
}
Also used : Header(com.dexels.navajo.document.Header) Message(com.dexels.navajo.document.Message) FatalException(com.dexels.navajo.script.api.FatalException) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) FatalException(com.dexels.navajo.script.api.FatalException) NavajoException(com.dexels.navajo.document.NavajoException) AuthorizationException(com.dexels.navajo.script.api.AuthorizationException) UserException(com.dexels.navajo.script.api.UserException) TriggerException(com.dexels.navajo.server.enterprise.scheduler.TriggerException) IOException(java.io.IOException) SystemException(com.dexels.navajo.script.api.SystemException)

Example 7 with Header

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

the class HandlerFactory method createHandler.

public ServiceHandler createHandler(NavajoConfigInterface navajoConfig, Access access, Boolean simulationMode) {
    ServiceHandler sh = null;
    try {
        if (simulationMode) {
            sh = instances.getOrDefault("stress", getDefaultServiceHandler());
        } else {
            // check if birt is requested
            Header h = access.getInDoc().getHeader();
            if (h.getHeaderAttribute("GenerateBirt") != null && h.getHeaderAttribute("GenerateBirt").equals("true")) {
                sh = instances.getOrDefault("birt", getDefaultServiceHandler());
            } else {
                sh = instances.getOrDefault("default", getDefaultServiceHandler());
            }
        }
    } catch (Exception e) {
        logger.error("Problem finding handler, falling back on default: ", e);
        sh = getDefaultServiceHandler();
    }
    sh.setNavajoConfig(navajoConfig);
    return sh;
}
Also used : Header(com.dexels.navajo.document.Header)

Example 8 with Header

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

the class Dispatcher method generateScheduledMessage.

private final Navajo generateScheduledMessage(Header h, String taskId, boolean rejected) {
    try {
        Navajo outMessage = NavajoFactory.getInstance().createNavajo();
        Header hnew = NavajoFactory.getInstance().createHeader(outMessage, h.getRPCName(), h.getRPCUser(), "", -1);
        if (!rejected) {
            hnew.setSchedule(taskId);
        } else {
            Message msg = NavajoFactory.getInstance().createMessage(outMessage, "Warning");
            outMessage.addMessage(msg);
            Property prop = NavajoFactory.getInstance().createProperty(outMessage, "Status", Property.STRING_PROPERTY, "TimeExpired", 32, "Created by generateScheduledMessage", Property.DIR_OUT);
            msg.addProperty(prop);
        }
        outMessage.addHeader(hnew);
        return outMessage;
    } catch (Exception e) {
        logger.error("Error: ", e);
        return null;
    }
}
Also used : Header(com.dexels.navajo.document.Header) Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property) FatalException(com.dexels.navajo.script.api.FatalException) NavajoException(com.dexels.navajo.document.NavajoException) AuthorizationException(com.dexels.navajo.script.api.AuthorizationException) UserException(com.dexels.navajo.script.api.UserException) TriggerException(com.dexels.navajo.server.enterprise.scheduler.TriggerException) IOException(java.io.IOException) SystemException(com.dexels.navajo.script.api.SystemException)

Example 9 with Header

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

the class BaseHeaderImpl method copy.

@Override
public Header copy(Navajo n) {
    Header h = NavajoFactory.getInstance().createHeader(n, getRPCName(), getRPCUser(), getRPCPassword(), expiration);
    if (getAttributes() != null) {
        for (Iterator<String> iter = getAttributes().keySet().iterator(); iter.hasNext(); ) {
            String element = iter.next();
            h.setHeaderAttribute(element, getHeaderAttribute(element));
        }
    }
    return h;
}
Also used : Header(com.dexels.navajo.document.Header)

Example 10 with Header

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

the class BaseHeaderImpl method main.

public static void main(String[] args) {
    System.setProperty("com.dexels.navajo.DocumentImplementation", "com.dexels.navajo.document.nanoimpl.NavajoFactoryImpl");
    Navajo n = NavajoFactory.getInstance().createNavajo();
    Header h = NavajoFactory.getInstance().createHeader(n, "aap", "noot", "mies", -1);
    n.addHeader(h);
}
Also used : Header(com.dexels.navajo.document.Header) Navajo(com.dexels.navajo.document.Navajo)

Aggregations

Header (com.dexels.navajo.document.Header)29 Navajo (com.dexels.navajo.document.Navajo)19 NavajoException (com.dexels.navajo.document.NavajoException)9 IOException (java.io.IOException)9 FatalException (com.dexels.navajo.script.api.FatalException)7 UserException (com.dexels.navajo.script.api.UserException)7 Message (com.dexels.navajo.document.Message)6 SystemException (com.dexels.navajo.script.api.SystemException)6 AuthorizationException (com.dexels.navajo.script.api.AuthorizationException)5 Property (com.dexels.navajo.document.Property)4 TriggerException (com.dexels.navajo.server.enterprise.scheduler.TriggerException)4 ClientException (com.dexels.navajo.client.ClientException)3 Access (com.dexels.navajo.script.api.Access)3 NavajoResponseHandler (com.dexels.navajo.client.NavajoResponseHandler)2 MappableException (com.dexels.navajo.script.api.MappableException)2 BufferedReader (java.io.BufferedReader)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 InputStream (java.io.InputStream)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2