use of org.apache.commons.configuration.XMLPropertiesConfiguration in project zaproxy by zaproxy.
the class ExtensionAutoUpdate method execute.
@Override
public void execute(CommandLineArgument[] args) {
if (arguments[ARG_CFU_UPDATE_IDX].isEnabled()) {
AddOnCollection aoc = getLatestVersionInfo();
// Create some temporary options with the settings we need
OptionsParamCheckForUpdates options = new OptionsParamCheckForUpdates();
options.load(new XMLPropertiesConfiguration());
options.setCheckOnStart(true);
options.setCheckAddonUpdates(true);
options.setInstallAddonUpdates(true);
checkForAddOnUpdates(aoc, options);
waitAndInstallDownloads();
CommandLine.info(Constant.messages.getString("cfu.cmdline.updated"));
}
if (arguments[ARG_CFU_INSTALL_ALL_IDX].isEnabled()) {
AddOnCollection aoc = getLatestVersionInfo();
if (aoc == null) {
CommandLine.error(Constant.messages.getString("cfu.cmdline.nocfu"));
} else {
AddOnDependencyChecker addOnDependencyChecker = new AddOnDependencyChecker(getLocalVersionInfo(), aoc);
AddOnDependencyChecker.AddOnChangesResult result;
AddOnDependencyChecker.AddOnChangesResult allResults = null;
Set<AddOn> allAddOns = new HashSet<>();
for (AddOn ao : aoc.getAddOns()) {
if (ao.getId().equals("coreLang") && (Constant.isDevBuild() || Constant.isDailyBuild())) {
// this may well be missing strings that are now necessary
continue;
}
// Check to see if its already installed
AddOn iao = getLocalVersionInfo().getAddOn(ao.getId());
if (iao != null) {
if (!ao.isUpdateTo(iao)) {
continue;
}
result = addOnDependencyChecker.calculateUpdateChanges(ao);
} else {
result = addOnDependencyChecker.calculateInstallChanges(ao);
}
if (result.getUninstalls().isEmpty()) {
allAddOns.addAll(result.getInstalls());
allAddOns.addAll(result.getNewVersions());
if (allResults == null) {
allResults = result;
} else {
allResults.addResults(result);
}
}
}
if (allAddOns.isEmpty()) {
// Nothing to do
return;
}
for (AddOn addOn : allAddOns) {
CommandLine.info(MessageFormat.format(Constant.messages.getString("cfu.cmdline.addonurl"), addOn.getUrl()));
}
processAddOnChanges(null, allResults);
waitAndInstallDownloads();
}
}
if (arguments[ARG_CFU_INSTALL_IDX].isEnabled()) {
Vector<String> params = arguments[ARG_CFU_INSTALL_IDX].getArguments();
installAddOns(params);
}
if (arguments[ARG_CFU_UNINSTALL_IDX].isEnabled()) {
Vector<String> params = arguments[ARG_CFU_UNINSTALL_IDX].getArguments();
uninstallAddOns(params);
}
if (arguments[ARG_CFU_LIST_IDX].isEnabled()) {
AddOnCollection aoc = this.getLocalVersionInfo();
List<AddOn> aolist = new ArrayList<AddOn>(aoc.getAddOns());
Collections.sort(aolist, new Comparator<AddOn>() {
@Override
public int compare(AddOn ao1, AddOn ao2) {
return ao1.getName().compareTo(ao2.getName());
}
});
for (AddOn addon : aolist) {
CommandLine.info(addon.getName() + "\t" + addon.getId() + "\tv" + addon.getFileVersion() + "\t" + addon.getStatus().name() + "\t" + addon.getDescription());
}
}
}
Aggregations