setTranslationType(transType);
addProperty("xmlDocumentValidation", configElement.getAttribute("xmlDocumentValidation").getValue());
boolean deferInitialization = false;
Attribute aDefer = configElement.getAttribute("deferInitialization");
if (aDefer != null) {
deferInitialization = new Boolean(aDefer.getValue()).booleanValue();
}
Document enterpriseObjectsDoc = null;
String messageObjectClassName = configElement.getChild("ObjectClass").getText();
String messageObjectName = messageObjectClassName.substring(messageObjectClassName.lastIndexOf('.') + 1);
String eoDocUri = null;
java.util.List props = configElement.getChildren();
boolean keepTrying = true;
while(keepTrying) {
int propsSize = props.size();
if (propsSize == 0) {
keepTrying = false;
}
for (int i=0; i<propsSize; i++) {
Element aProp = (Element)props.get(0);
props.remove(0);
if (aProp.getName().equals("Authentication")) {
// UserId, Signature
java.util.List auths = aProp.getChildren();
for (int j=0; j<auths.size(); j++) {
Element anAuthChild = (Element)auths.get(j);
String key = anAuthChild.getName();
String value = anAuthChild.getText();
logger.debug("Adding " + key + " - " + value);
addProperty(key, value);
}
}
else if (aProp.getName().equals("PrimedXmlDocuments")) {
java.util.List docs = aProp.getChildren();
for (int k=0; k<docs.size(); k++) {
Element aDoc = (Element)docs.get(k);
String key, value;
key = aDoc.getAttribute("type").getValue() + "-" + aDoc.getName();
value = aDoc.getText();
logger.debug("Adding " + key + " - " + value);
addProperty(key, value);
}
}
// NEW ENTERPRISEFIELDS CONFIGURATION START - 8/8
else if (aProp.getName().equals("EnterpriseObjectDocument")) {
eoDocUri = aProp.getAttribute("docUri").getValue();
// new 7/30/2002, changed config document to allow multiple EnterpriseObject.xml
// documents. This way, we can break them apart and make each "chunk" smaller
// this should decrease the time necessary to build an object and make AppConfig
// initilialization quicker.
if (enterpriseObjectsDoc == null) {
if (eoDocUri != null) {
try {
//TODO: check for deferInitialization flag. If True, don't parse the document yet.
if (deferInitialization == false) {
logger.debug("EF initialization is NOT deferred, parsing EO docs...");
XmlDocumentReader xmlReader = new XmlDocumentReader();
enterpriseObjectsDoc =
xmlReader.initializeDocument(eoDocUri,getValidation());
logger.debug("DONE parsing EO docs.");
}
else {
logger.debug("EnterpriseFields initialization has been deferred (not parsing EO doc).");
}
}
catch (XmlDocumentReaderException e) {
logger.fatal(e.getMessage(), e);
String msg = "Exception occurred initializing EnterpriseFields object. Exception: " + e.getMessage();
logger.fatal(msg);
throw new EnterpriseConfigurationObjectException(msg, e);
}
}
}
if (getEnterpriseFields() == null) {
EnterpriseFields fields = new EnterpriseFields();
fields.setEnterpriseObjectsUri(eoDocUri);
fields.setIgnoreMissingFields(new Boolean(aProp.getAttribute("ignoreMissingFields").getValue()).booleanValue());
fields.setIgnoreValidation(new Boolean(aProp.getAttribute("ignoreValidation").getValue()).booleanValue());
logger.debug("[MessageObjectConfig] ignoreValidation is " + fields.ignoreValidation());
fields.setTranslationType(getTranslationType());
fields.setAppName(getAppName());
// ObjectDefinitions.APP_NAME = getAppName();
try {
//TODO: check for deferInitialization flag. If true, don't do this yet.
if (deferInitialization == false) {
logger.debug("EnterpriseFields initialization is NOT deferred, initializing EF...");
fields.init(enterpriseObjectsDoc);
logger.debug("DONE with EnterpriseFields initialization.");
}
else {
logger.debug("EnterpriseFields initialization has been deferred (not initializing EnterpriseFields).");
}
}
catch (EnterpriseFieldException e) {
String msg = "Exception occurred initializing EnterpriseFields object. Exception: " + e.getMessage();
logger.fatal(msg);
throw new EnterpriseConfigurationObjectException(msg, e);
}
setEnterpriseFields(fields);
}
}
// NEW ENTERPRISEFIELDS CONFIGURATION END - 8/8
// NEW LAYOUT MANAGER CONFIGURATION START - 8/8
else if (aProp.getName().equals("LayoutManager")) {
// Build all of the layout manager objects...
logger.debug("MessageObjectName is " + messageObjectName);
//TODO: may have to check deferInitialization flag here also...
// if (enterpriseObjectsDoc == null && deferInitialization == false) {
if (eoDocUri == null) {
String msg = "[MessageObjectConfig] Cannot initialize LayoutManagers until the EnterpriseObjectDocument has been initialized, putting it back on the list";
logger.warn(msg);
props.add(aProp);
continue;
}
logger.debug("Initializing layout managers...");
java.util.List lInputLayouts = aProp.getChildren("InputLayout");
boolean hasXmlLayoutManager = false;
for (int im=0; im<lInputLayouts.size(); im++) {
Element eInLayout = (Element)lInputLayouts.get(im);
String inputLayoutType = eInLayout.getAttribute("type").getValue();
String inputLayoutName = "";
if (inputLayoutType.equals("xml")) {
hasXmlLayoutManager = true;
Attribute aInLayoutName = eInLayout.getAttribute("name");
if (aInLayoutName != null) {
inputLayoutName = aInLayoutName.getValue();
}
else {
String className = getClass().getName();
inputLayoutName = className.substring(className.lastIndexOf('.') + 1); // Our based element in the XML passed in
}
}
else {
Attribute aInLayoutName = eInLayout.getAttribute("name");
if (aInLayoutName != null) {
inputLayoutName = aInLayoutName.getValue();
}
else {
String msg = "[MessageObjectConfig] Non-XML input layouts must have a name associated with them.";
logger.fatal(msg);
throw new EnterpriseConfigurationObjectException(msg);
}
}
String inLayoutClass = eInLayout.getChild("ObjectClass").getText();
try {
logger.debug("Instantiating input layout manager: " + inLayoutClass + " for " + inputLayoutName);
java.lang.Class inLayoutObj = java.lang.Class.forName(inLayoutClass);
EnterpriseLayoutManager ainElm = (EnterpriseLayoutManager)inLayoutObj.newInstance();
//TODO: check deferInitialization flag.
// ainElm.init(messageObjectName, inputLayoutName, enterpriseObjectsDoc);
if (deferInitialization == false) {
logger.debug("Layout manager initialization is NOT deferred, initializing input layout manager...");
ainElm.init(inputLayoutName, enterpriseObjectsDoc);
logger.debug("DONE initializing input layout manager...");
}
else {
logger.debug("Layout manager initialization has been deferred (input)");
ainElm.setLayoutManagerName(inputLayoutName);
ainElm.setEnterpriseObjectsUri(eoDocUri);
}
addInputLayoutManager(inputLayoutType, ainElm);
// Set the default input layout manager to the first one in the list.
if (im == 0) {
setInputLayoutManager(ainElm);
}
}
catch (Exception e) {
String msg = "Error initializing Input Layout Manager. Exception: " + e.getMessage();
logger.fatal(msg, e);
throw new EnterpriseConfigurationObjectException(msg, e);
}
}
if (hasXmlLayoutManager == false) {
// throw an exception
String msg = "[MessageObjectConfig] Missing XML Input Layout manager.";
logger.fatal(msg);
throw new EnterpriseConfigurationObjectException(msg);
}
logger.debug("MessageObjectName is " + messageObjectName);
java.util.List lOutputLayouts = aProp.getChildren("OutputLayout");
hasXmlLayoutManager = false;
for (int om=0; om<lOutputLayouts.size(); om++) {
Element eOutLayout = (Element)lOutputLayouts.get(om);
String outputLayoutType = eOutLayout.getAttribute("type").getValue();
String outputLayoutName = "";
if (outputLayoutType.equals("xml")) {
hasXmlLayoutManager = true;
Attribute aOutLayoutName = eOutLayout.getAttribute("name");
if (aOutLayoutName != null) {
outputLayoutName = aOutLayoutName.getValue();
}
else {
String className = getClass().getName();
outputLayoutName =className.substring(className.lastIndexOf('.') + 1); // Our based element in the XML passed in
}
}
else {
Attribute aOutLayoutName = eOutLayout.getAttribute("name");
if (aOutLayoutName != null) {
outputLayoutName = aOutLayoutName.getValue();
}
else {
String msg = "[MessageObjectConfig] Non-XML output layouts must have a name associated with them.";
logger.fatal(msg);
throw new EnterpriseConfigurationObjectException(msg);