}
}
@Override
public void doFreemarkerGenerate() throws IOException, TemplateException {
EnunciateFreemarkerModel model = getModel();
Map<String, SchemaInfo> ns2schema = model.getNamespacesToSchemas();
Map<String, WsdlInfo> ns2wsdl = model.getNamespacesToWSDLs();
model.put("prefix", new PrefixMethod());
model.put("isDefinedGlobally", new IsDefinedGloballyMethod());
model.setVariable("uniqueContentTypes", new UniqueContentTypesMethod());
model.put("wadlStylesheetUri", this.wadlStylesheetUri);
model.put("accessorOverridesAnother", new AccessorOverridesAnotherMethod());
model.put("qnameForType", new QNameForTypeMethod());
File artifactDir = getGenerateDir();
model.setFileOutputDirectory(artifactDir);
boolean upToDate = isUpToDate(artifactDir);
if (!upToDate) {
processTemplate(getTemplateURL(), model);
}
else {
info("Skipping generation of XML files since everything appears up-to-date...");
}
for (WsdlInfo wsdl : ns2wsdl.values()) {
File wsdlFile = (File) wsdl.getProperty("file");
if (wsdlFile == null) {
String file = (String) wsdl.getProperty("filename");
wsdlFile = new File(artifactDir, file);
wsdl.setProperty("file", wsdlFile);
if (!upToDate && prettyPrint) {
prettyPrint(wsdlFile);
}
}
FileArtifact wsdlArtifact = new FileArtifact(getName(), wsdl.getId() + ".wsdl", wsdlFile);
wsdlArtifact.setDescription("WSDL file for namespace " + wsdl.getTargetNamespace());
getEnunciate().addArtifact(wsdlArtifact);
}
for (SchemaInfo schemaInfo : ns2schema.values()) {
File schemaFile = (File) schemaInfo.getProperty("file");
if (schemaFile == null) {
String file = (String) schemaInfo.getProperty("filename");
schemaFile = new File(artifactDir, file);
schemaInfo.setProperty("file", schemaFile);
if (!upToDate && prettyPrint) {
prettyPrint(schemaFile);
}
if (!upToDate && validateSchemas) {
//todo: write some logic to validate the schemas.
}
}
FileArtifact schemaArtifact = new FileArtifact(getName(), schemaInfo.getId() + ".xsd", schemaFile);
schemaArtifact.setDescription("Schema file for namespace " + schemaInfo.getNamespace());
getEnunciate().addArtifact(schemaArtifact);
}
if (!isDisableWadl()) {
File wadl = new File(artifactDir, "application.wadl");
if (wadl.exists()) {
FileArtifact wadlArtifact = new FileArtifact(getName(), "application.wadl", wadl);
wadlArtifact.setDescription("WADL document");
getEnunciate().addArtifact(wadlArtifact);
prettyPrint(wadl);
model.setWadlFile(wadl);
}
}
}