Search in sources :

Example 41 with Property

use of com.dexels.navajo.document.Property 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 42 with Property

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

the class CachedDescriptionProvider method dumpCacheMessage.

public Message dumpCacheMessage(Navajo n) throws NavajoException {
    Message m = NavajoFactory.getInstance().createMessage(n, "Cache", Message.MSG_TYPE_ARRAY);
    for (Iterator<String> iter = cache.keySet().iterator(); iter.hasNext(); ) {
        String element = iter.next();
        String value = cache.get(element);
        Property keyProp = NavajoFactory.getInstance().createProperty(n, "Key", Property.STRING_PROPERTY, element, 521, "", Property.DIR_IN);
        Property valProp = NavajoFactory.getInstance().createProperty(n, "Value", Property.STRING_PROPERTY, value, 521, "", Property.DIR_IN);
        Message ii = NavajoFactory.getInstance().createMessage(n, "Cache", Message.MSG_TYPE_ARRAY_ELEMENT);
        m.addMessage(ii);
        ii.addProperty(keyProp);
        ii.addProperty(valProp);
    }
    return m;
}
Also used : Message(com.dexels.navajo.document.Message) Property(com.dexels.navajo.document.Property)

Example 43 with Property

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

the class NavajoConfigEmitter method addAllProperties.

/**
 * Dump all parameter properties into the fray:
 * @param message
 * @param data
 */
private void addAllProperties(Message message, Dictionary<String, Object> data) {
    List<Property> all = message.getAllProperties();
    for (Property property : all) {
        String name = property.getName();
        final Object old = data.get(name);
        final Object newValue = property.getTypedValue();
        if (old != null) {
            logger.warn("Will not append property: {} (with value: {}) to configuration, as it will overwrite the present value of: {}", name, newValue, old);
        } else {
            data.put(name, newValue);
        }
    }
}
Also used : Property(com.dexels.navajo.document.Property)

Example 44 with Property

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

the class Request method getThanksMessage.

/**
 * Generate a simple "feedback" message with only 1 property: "resultaat".
 */
public Navajo getThanksMessage(String what) throws NavajoException {
    // Create Navajo out message
    Navajo outMessage = NavajoFactory.getInstance().createNavajo();
    Message resultMessage = NavajoFactory.getInstance().createMessage(outMessage, "feedback");
    outMessage.addMessage(resultMessage);
    Property prop = NavajoFactory.getInstance().createProperty(outMessage, "resultaat", Property.STRING_PROPERTY, what, 1, "", Property.DIR_OUT);
    resultMessage.addProperty(prop);
    return outMessage;
}
Also used : Message(com.dexels.navajo.document.Message) Navajo(com.dexels.navajo.document.Navajo) Property(com.dexels.navajo.document.Property)

Example 45 with Property

use of com.dexels.navajo.document.Property 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)

Aggregations

Property (com.dexels.navajo.document.Property)253 Message (com.dexels.navajo.document.Message)148 Test (org.junit.Test)88 Navajo (com.dexels.navajo.document.Navajo)84 Selection (com.dexels.navajo.document.Selection)36 NavajoException (com.dexels.navajo.document.NavajoException)30 TMLExpressionException (com.dexels.navajo.expression.api.TMLExpressionException)17 ArrayList (java.util.ArrayList)17 ImmutableMessage (com.dexels.immutable.api.ImmutableMessage)16 Binary (com.dexels.navajo.document.types.Binary)16 UserException (com.dexels.navajo.script.api.UserException)16 Access (com.dexels.navajo.script.api.Access)15 StringWriter (java.io.StringWriter)13 List (java.util.List)11 Operand (com.dexels.navajo.document.Operand)10 MappableException (com.dexels.navajo.script.api.MappableException)9 IOException (java.io.IOException)9 Writer (java.io.Writer)9 StringTokenizer (java.util.StringTokenizer)9 JSONTML (com.dexels.navajo.document.json.JSONTML)8