in lib/tools_api/src/main/java/com/google/appengine/tools/admin/Application.java [223:345]
private Application(String explodedPath, String appId, String module, String appVersion) {
this.baseDir = new File(explodedPath);
// Normalize the exploded path.
explodedPath = buildNormalizedPath(baseDir);
File webinf = new File(baseDir, "WEB-INF");
if (!webinf.getName().equals("WEB-INF")) {
// On OSes with case-insensitive file systems, it is possible to
// create a directory with different case. Some of our handling
// code is case-sensitive so we disallow this.
throw new AppEngineConfigException("WEB-INF directory must be capitalized.");
}
// Should initialize correctly the appengine.use.EE10 or 8 system properties.
new AppEngineWebXmlInitialParse(explodedPath + "/WEB-INF/appengine-web.xml")
.handleRuntimeProperties();
AppengineSdk.resetSdk();
String webinfPath = webinf.getPath();
AppEngineWebXmlReader aewebReader = new AppEngineWebXmlReader(explodedPath);
WebXmlReader webXmlReader = new WebXmlReader(explodedPath);
AppYamlProcessor.convert(webinf, aewebReader.getFilename(), webXmlReader.getFilename());
File webXmlFile = new File(webinfPath, "web.xml");
if (!webXmlFile.exists()) {
writeDefaultWebXml(webXmlFile);
}
if (new File(aewebReader.getFilename()).exists()) {
XmlUtils.validateXml(
aewebReader.getFilename(), new File(getSdkDocsDir(), "appengine-web.xsd"));
}
appEngineWebXml = aewebReader.readAppEngineWebXml();
appEngineWebXml.setSourcePrefix(explodedPath);
if (appId != null) {
appEngineWebXml.setAppId(appId);
}
if (appVersion != null) {
appEngineWebXml.setMajorVersionId(appVersion);
}
if (module != null) {
appEngineWebXml.setModule(module);
}
webXml = webXmlReader.readWebXml();
// TODO: validateXml(webXml.getFilename(), new File(SDKDOCS, "servlet.xsd"));
webXml.validate();
servletVersion = webXmlReader.getServletVersion();
validateFilterClasses();
validateRuntime();
CronXmlReader cronReader = new CronXmlReader(explodedPath);
if (new File(cronReader.getFilename()).exists()) {
XmlUtils.validateXml(cronReader.getFilename(), new File(getSdkDocsDir(), "cron.xsd"));
}
CronXml parsedCronXml = cronReader.readCronXml();
if (parsedCronXml == null) {
CronYamlReader cronYaml = new CronYamlReader(webinfPath);
parsedCronXml = cronYaml.parse();
}
this.cronXml = parsedCronXml;
QueueXmlReader queueReader = new QueueXmlReader(explodedPath);
if (new File(queueReader.getFilename()).exists()) {
XmlUtils.validateXml(queueReader.getFilename(), new File(getSdkDocsDir(), "queue.xsd"));
}
QueueXml parsedQueueXml = queueReader.readQueueXml();
if (parsedQueueXml == null) {
QueueYamlReader queueYaml = new QueueYamlReader(webinfPath);
parsedQueueXml = queueYaml.parse();
}
this.queueXml = parsedQueueXml;
DispatchXmlReader dispatchXmlReader =
new DispatchXmlReader(explodedPath, DispatchXmlReader.DEFAULT_RELATIVE_FILENAME);
if (new File(dispatchXmlReader.getFilename()).exists()) {
XmlUtils.validateXml(
dispatchXmlReader.getFilename(), new File(getSdkDocsDir(), "dispatch.xsd"));
}
DispatchXml parsedDispatchXml = dispatchXmlReader.readDispatchXml();
if (parsedDispatchXml == null) {
DispatchYamlReader dispatchYamlReader = new DispatchYamlReader(webinfPath);
parsedDispatchXml = dispatchYamlReader.parse();
}
this.dispatchXml = parsedDispatchXml;
DosXmlReader dosReader = new DosXmlReader(explodedPath);
if (new File(dosReader.getFilename()).exists()) {
XmlUtils.validateXml(dosReader.getFilename(), new File(getSdkDocsDir(), "dos.xsd"));
}
DosXml parsedDosXml = dosReader.readDosXml();
if (parsedDosXml == null) {
DosYamlReader dosYaml = new DosYamlReader(webinfPath);
parsedDosXml = dosYaml.parse();
}
this.dosXml = parsedDosXml;
IndexesXmlReader indexReader = new IndexesXmlReader(explodedPath);
File datastoreSchema = new File(getSdkDocsDir(), "datastore-indexes.xsd");
if (new File(indexReader.getFilename()).exists()) {
XmlUtils.validateXml(indexReader.getFilename(), datastoreSchema);
}
// TODO: consider validating the auto-generated file too, in case
// someone edited it by hand. However, note that the "autoGenerate" attribute
// of the datastore-indexes XML element is currently required by the XML Schema;
// so check whether the dev server actually does include it (or consider
// changing it to optional, since it kinda doesn't really make sense in the
// case of the auto-generated file.
//
// validateXml(indexReader.getAutoFilename(), datastoreSchema);
indexesXml = indexReader.readIndexesXml();
BackendsXmlReader backendsReader = new BackendsXmlReader(explodedPath);
if (new File(backendsReader.getFilename()).exists()) {
XmlUtils.validateXml(backendsReader.getFilename(), new File(getSdkDocsDir(), "backends.xsd"));
}
BackendsXml parsedBackendsXml = backendsReader.readBackendsXml();
if (parsedBackendsXml == null) {
BackendsYamlReader backendsYaml = new BackendsYamlReader(webinfPath);
parsedBackendsXml = backendsYaml.parse();
}
this.backendsXml = parsedBackendsXml;
}