in core/cocoon-cli/src/main/java/org/apache/cocoon/bean/helpers/BeanConfigurator.java [99:223]
public static String configure(Document xconf, CocoonBean cocoon, String destDir, String uriGroup, OutputStreamListener listener)
throws IllegalArgumentException {
Node root = xconf.getDocumentElement();
if (!NODE_ROOT.equals(root.getNodeName())) {
throw new IllegalArgumentException("Expected root node of "+ NODE_ROOT);
}
if (hasAttribute(root, ATTR_FOLLOW_LINKS)) {
cocoon.setFollowLinks(getBooleanAttributeValue(root, ATTR_FOLLOW_LINKS));
}
if (hasAttribute(root, ATTR_PRECOMPILE_ONLY)) {
cocoon.setPrecompileOnly(getBooleanAttributeValue(root, ATTR_PRECOMPILE_ONLY));
}
if (hasAttribute(root, ATTR_CONFIRM_EXTENSIONS)) {
cocoon.setConfirmExtensions(getBooleanAttributeValue(root, ATTR_CONFIRM_EXTENSIONS));
}
if (hasAttribute(root, ATTR_CONTEXT_DIR)) {
cocoon.setContextDir(getAttributeValue(root, ATTR_CONTEXT_DIR));
}
if (hasAttribute(root, ATTR_DEST_DIR)) {
destDir = getAttributeValue(root, ATTR_DEST_DIR);
}
if (hasAttribute(root, ATTR_WORK_DIR)) {
cocoon.setWorkDir(getAttributeValue(root, ATTR_WORK_DIR));
}
if (hasAttribute(root, ATTR_CONFIG_FILE)) {
cocoon.setConfigFile(getAttributeValue(root, ATTR_CONFIG_FILE));
}
if (hasAttribute(root, ATTR_URI_FILE)) {
cocoon.addTargets(processURIFile(getAttributeValue(root, ATTR_URI_FILE)), destDir);
}
if (hasAttribute(root, ATTR_CHECKSUMS_URI)) {
cocoon.setChecksumURI(getAttributeValue(root, ATTR_CHECKSUMS_URI));
}
if (hasAttribute(root, ATTR_AGENT)) {
cocoon.setAgentOptions(getAttributeValue(root, ATTR_AGENT));
}
if (hasAttribute(root, ATTR_ACCEPT)) {
cocoon.setAcceptOptions(getAttributeValue(root, ATTR_ACCEPT));
}
if (hasAttribute(root, ATTR_DEFAULT_FILENAME)) {
cocoon.setDefaultFilename(getAttributeValue(root, ATTR_DEFAULT_FILENAME));
}
if (destDir == null || destDir.length() == 0) {
destDir = getNodeValue(root, NODE_DEST_DIR);
}
NodeList nodes = root.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType()== Node.ELEMENT_NODE) {
String nodeName = node.getNodeName();
if (nodeName.equals(NODE_BROKEN_LINKS)) {
parseBrokenLinkNode(cocoon, node, listener);
} else if (nodeName.equals(NODE_LOAD_CLASS)) {
cocoon.addLoadedClass(getNodeValue(node));
} else if (nodeName.equals(NODE_LOGGING)) {
parseLoggingNode(cocoon, node);
} else if (nodeName.equals(NODE_CONTEXT_DIR)) {
if (hasAttribute(root, ATTR_CONTEXT_DIR)) {
throw new IllegalArgumentException("Cannot have "+NODE_CONTEXT_DIR+" as both element and attribute");
}
cocoon.setContextDir(getNodeValue(node));
} else if (nodeName.equals(NODE_CONFIG_FILE)) {
if (hasAttribute(root, ATTR_CONFIG_FILE)) {
throw new IllegalArgumentException("Cannot have "+NODE_CONFIG_FILE+" as both element and attribute");
}
cocoon.setConfigFile(getNodeValue(node));
} else if (nodeName.equals(NODE_DEST_DIR)) {
// Ignore
} else if (nodeName.equals(NODE_WORK_DIR)) {
if (hasAttribute(root, ATTR_WORK_DIR)) {
throw new IllegalArgumentException("Cannot have "+NODE_WORK_DIR+" as both element and attribute");
}
cocoon.setWorkDir(getNodeValue(node));
} else if (nodeName.equals(NODE_CHECKSUMS_URI)) {
if (hasAttribute(root, ATTR_CHECKSUMS_URI)) {
throw new IllegalArgumentException("Cannot have "+NODE_CHECKSUMS_URI+" as both element and attribute");
}
cocoon.setChecksumURI(getNodeValue(node));
} else if (nodeName.equals(NODE_AGENT)) {
cocoon.setAgentOptions(getNodeValue(node));
} else if (nodeName.equals(NODE_ACCEPT)) {
cocoon.setAcceptOptions(getNodeValue(node));
} else if (nodeName.equals(NODE_DEFAULT_FILENAME)) {
cocoon.setDefaultFilename(getNodeValue(node));
} else if (nodeName.equals(NODE_INCLUDE)) {
String pattern = parseIncludeExcludeNode(cocoon, node, NODE_INCLUDE);
cocoon.addIncludePattern(pattern);
} else if (nodeName.equals(NODE_EXCLUDE)) {
String pattern = parseIncludeExcludeNode(cocoon, node, NODE_EXCLUDE);
cocoon.addExcludePattern(pattern);
} else if (nodeName.equals(NODE_INCLUDE_LINKS)) {
parseIncludeLinksNode(cocoon, node);
} else if (nodeName.equals(NODE_URI)) {
parseURINode(cocoon, node, destDir);
} else if (nodeName.equals(NODE_URIS)) {
parseURIsNode(cocoon, node, destDir, uriGroup);
} else if (nodeName.equals(NODE_URI_FILE)) {
if (hasAttribute(root, ATTR_URI_FILE)) {
throw new IllegalArgumentException("Cannot have "+NODE_URI_FILE+" as both element and attribute");
}
cocoon.addTargets(processURIFile(getNodeValue(node)), destDir);
} else {
throw new IllegalArgumentException("Unknown element: <" + nodeName + ">");
}
}
}
return destDir;
}