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);
}
}
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;
}
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);
}
}
}
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;
}
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;
}
}
Aggregations