Search in sources :

Example 1 with UpdateManager

use of de.janrufmonitor.service.update.UpdateManager in project janrufmonitor by tbrandt77.

the class ConsoleSearchUpdates method execute.

public void execute() {
    System.out.println("Available updates for jAnrufmonitor:");
    System.out.println("------------------------------------");
    System.out.println("");
    List updates = new UpdateManager().getUpdates();
    this.checkConsoleEnabled(updates);
    if (updates.size() > 0) {
        System.out.println("Modules to be updated available on update server: ");
        Properties p = null;
        for (int i = 0; i < updates.size(); i++) {
            p = (Properties) updates.get(i);
            System.out.print(PIMRuntime.getInstance().getI18nManagerFactory().getI18nManager().getString(p.getProperty(InstallerConst.DESCRIPTOR_NAMESPACE, "-"), "title", "label", PIMRuntime.getInstance().getConfigManagerFactory().getConfigManager().getProperty(IJAMConst.GLOBAL_NAMESPACE, IJAMConst.GLOBAL_LANGUAGE)));
            System.out.print(", ");
            System.out.print(p.getProperty(InstallerConst.DESCRIPTOR_VERSION));
            System.out.print(" -> [ UPDATE ");
            System.out.print(p.getProperty(InstallerConst.DESCRIPTOR_NAME));
            System.out.println(" ]");
        }
    } else {
        System.out.println("No module updates available on update server.");
    }
    System.out.println("");
}
Also used : UpdateManager(de.janrufmonitor.service.update.UpdateManager) List(java.util.List) Properties(java.util.Properties)

Example 2 with UpdateManager

use of de.janrufmonitor.service.update.UpdateManager in project janrufmonitor by tbrandt77.

the class ConsoleUpdate method execute.

public void execute() {
    this.isExecuting = true;
    if (this.getExecuteParams().length != 1) {
        System.out.println("ERROR: Parameters are invalid. Please specify a valid module for update.");
        this.isExecuting = false;
        return;
    }
    String modname = this.getExecuteParams()[0];
    List updates = new UpdateManager().getUpdates();
    if (updates.size() > 0) {
        Properties p, f = null;
        for (int i = 0; i < updates.size(); i++) {
            p = (Properties) updates.get(i);
            if (p.getProperty(InstallerConst.DESCRIPTOR_NAME).equalsIgnoreCase(modname)) {
                f = p;
            }
        }
        if (f == null) {
            System.out.println("No updates found for module [ " + modname + " ].");
        } else {
            System.out.println("Installing update for module [ " + modname + " ]...");
            String url = f.getProperty(InstallerConst.DESCRIPTOR_UPDATE);
            String name = f.getProperty(InstallerConst.DESCRIPTOR_NAME) + "." + f.getProperty(InstallerConst.DESCRIPTOR_VERSION) + InstallerConst.EXTENSION_ARCHIVE;
            if (url != null && url.length() > 6) {
                StreamRequester sr = new StreamRequester(url);
                System.out.println("Downloading update for module [ " + modname + " ] from " + url);
                sr.go();
                try {
                    InstallerEngine.getInstance().install(name, sr.getInputStream(), false);
                    System.out.println("Installation of update for module [ " + modname + " ] successfully finished.");
                    boolean b = Boolean.parseBoolean(f.getProperty(InstallerConst.DESCRIPTOR_RESTART, "false"));
                    if (b) {
                        System.out.println("Module can be used after restarting jAnrufmonitor.");
                    }
                } catch (InstallerException e) {
                    System.out.println("ERROR during installing update for module [ " + modname + " ]: " + e.getMessage());
                }
            } else {
                System.out.println("ERROR: Downloading update for module [ " + modname + " ] from " + url + " failed.");
            }
        }
    } else {
        System.out.println("No update required all modules are up to date...");
    }
    System.out.println();
    this.isExecuting = false;
}
Also used : UpdateManager(de.janrufmonitor.service.update.UpdateManager) List(java.util.List) InstallerException(de.janrufmonitor.framework.installer.InstallerException) Properties(java.util.Properties)

Aggregations

UpdateManager (de.janrufmonitor.service.update.UpdateManager)2 List (java.util.List)2 Properties (java.util.Properties)2 InstallerException (de.janrufmonitor.framework.installer.InstallerException)1