return null;
}
} finally {
cursor.dispose();
}
ModuleDocument moduleDoc;
if (xmlObject instanceof ModuleDocument) {
moduleDoc = (ModuleDocument) xmlObject;
} else {
moduleDoc = (ModuleDocument) xmlObject.changeType(ModuleDocument.type);
}
Collection errors = new ArrayList();
if (!moduleDoc.validate(XmlBeansUtil.createXmlOptions(errors))) {
throw new DeploymentException("Invalid deployment descriptor: " + errors + "\nDescriptor: " + moduleDoc.toString());
}
// If there's no artifact ID and we won't be able to figure one out later, use the plan file name. Bit of a hack.
if(jarFile == null && (moduleDoc.getModule().getEnvironment() == null ||
moduleDoc.getModule().getEnvironment().getModuleId() == null ||
moduleDoc.getModule().getEnvironment().getModuleId().getArtifactId() == null)) {
if(moduleDoc.getModule().getEnvironment() == null) {
moduleDoc.getModule().addNewEnvironment();
}
if(moduleDoc.getModule().getEnvironment().getModuleId() == null) {
moduleDoc.getModule().getEnvironment().addNewModuleId();
}
String name = planFile.getName();
int pos = name.lastIndexOf('.');
if(pos > -1) {
name = name.substring(0, pos);
}
moduleDoc.getModule().getEnvironment().getModuleId().setArtifactId(name);
}
return moduleDoc.getModule();
} catch (XmlException e) {
throw new DeploymentException("Could not parse xml in plan", e);
} catch (IOException e) {
throw new DeploymentException("no plan at " + planFile, e);
}