private void createRepository(String templateName)
throws IOException
{
try {
ConfigTemplate configTemplate = manager.getConfigTemplateManager().getTemplate(templateName);
if (configTemplate == null) {
writeError("No template called " + templateName + " found");
return;
}
List<ConfigProperty> properties = configTemplate.getProperties();
if (!properties.isEmpty()) {
writeln("Please specify values for the following variables:");
}
// prompt for repository ID
write("Repository ID [" + templateName + "]: ");
String repositoryID = in.readLine();
if (repositoryID == null) {
// EOF
return;
}
else if (repositoryID.trim().length() < 1) {
repositoryID = templateName;
}
// other properties
for (ConfigProperty property : properties) {
List<Literal> values = property.getPossibleLiterals();
Literal defaultLiteral = property.getDefaultLiteral();
write(property.getLabel());
if (values.size() > 1) {
write(" (");
for (int i = 0; i < values.size(); i++) {
if (i > 0) {
write("|");
}
write(values.get(i).stringValue());
}
write(")");
}
if (defaultLiteral != null) {
write(" [" + defaultLiteral.stringValue() + "]");
}
write(": ");
String value = in.readLine();
if (value == null) {
// EOF
return;
}
value = value.trim();
if (value.length() > 0) {
property.setValue(new LiteralImpl(value));
}
}
Model repConfig = configTemplate.createConfig(properties);
if (manager.hasRepositoryConfig(repositoryID)) {
boolean proceed = askProceed(
"WARNING: you are about to overwrite the configuration of an existing repository!", false);