public XmlObject convertToSpecificPlan(XmlObject plan) throws DeploymentException {
XmlCursor rawCursor = plan.newCursor();
try {
if (SchemaConversionUtils.findNestedElement(rawCursor, "web-app")) {
XmlCursor temp = rawCursor.newCursor();
String namespace = temp.getName().getNamespaceURI();
temp.dispose();
if(!namespace.equals(GENERIC_NAMESPACE) && !namespace.equals(this.namespace) && !namespace.equals(OLD_GENERIC_NAMESPACE)) {
throw new DeploymentException("Cannot handle web plan with namespace "+namespace+" -- expecting "+GENERIC_NAMESPACE+" or "+this.namespace);
}
XmlObject webPlan = rawCursor.getObject().copy();
XmlCursor cursor = webPlan.newCursor();
XmlCursor end = cursor.newCursor();
try {
cursor.push();
if (cursor.toChild(GENERIC_CONFIG_QNAME) || cursor.toChild(OLD_GENERIC_CONFIG_QNAME)) {
XmlCursor source = cursor.newCursor();
cursor.push();
cursor.toEndToken();
cursor.toNextToken();
try {
if (source.toChild(configNamespace, element)) {
source.copyXmlContents(cursor);
}
} finally {
source.dispose();
}
cursor.pop();
cursor.removeXml();
}
cursor.pop();
cursor.push();
while (cursor.hasNextToken()) {
if (cursor.isStart()) {
if (!SchemaConversionUtils.convertSingleElementToGeronimoSubSchemas(cursor, end)
&& !this.namespace.equals(cursor.getName().getNamespaceURI())
&& !excludedNamespaces.contains(cursor.getName().getNamespaceURI())) {
cursor.setName(new QName(this.namespace, cursor.getName().getLocalPart()));
}
}
cursor.toNextToken();
}
cursor.pop();
cursor.push();
Map< Object, List< XmlCursor > > map = createElementMap(cursor);
cursor.pop();
moveToBottom(cursor, map.get("security-realm-name"));
moveToBottom(cursor, map.get("authentication"));
moveToBottom(cursor, map.get("security"));
moveToBottom(cursor, map.get("gbean"));
moveToBottom(cursor, map.get("persistence"));
clearElementMap(map);
return webPlan;
} finally {
cursor.dispose();
end.dispose();
}
} else {
throw new DeploymentException("No web-app element");
}
} finally {
rawCursor.dispose();
}
}
|