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