}
String lensesPath = lensesPathProperty.getStringValue();
String rootPath = rootPathProperty.getStringValue();
Augeas augeas = new Augeas(rootPath, lensesPath, Augeas.NONE);
// Find out where to look for the apt sources tree
PropertySimple augeasTreeNodeProperty = pluginConfiguration.getSimple("augeas-apt-sources-path");
if (augeasTreeNodeProperty == null) {
throw new Exception("Augeas tree node not specified for apt sources, cannot retrive configuration");
}
String sourcesTreeNode = augeasTreeNodeProperty.getStringValue();
// Request data from augeas
List<String> matches = augeas.match(sourcesTreeNode);
if (matches.size() == 0) {
throw new Exception("Unable to load apt sources data from augeas");
}
// Parse out the properties
Configuration configuration = new Configuration();
configuration.setNotes("Loaded from Augeas at " + new Date());
PropertyList entriesList = new PropertyList("aptEntries");
configuration.put(entriesList);
for (String entryNode : matches) {
String type = augeas.get(entryNode + "/type");
String uri = augeas.get(entryNode + "/uri");
String distribution = augeas.get(entryNode + "/distribution");
PropertyMap entry = new PropertyMap("aptEntry");
entry.put(new PropertySimple("type", type));
entry.put(new PropertySimple("uri", uri));
entry.put(new PropertySimple("distribution", distribution));