src/org/openstreetmap/josm/plugins/opendata/core/modules/ModuleHandler.java
public static List<ModuleInformation> updateModules(Component parent,
            List<ModuleInformation> modules, ProgressMonitor monitor)
                    throws IllegalArgumentException {
        CheckParameterUtil.ensureParameterNotNull(modules, "modules");
        if (monitor == null) {
            monitor = NullProgressMonitor.INSTANCE;
        }
        try {
            monitor.beginTask("");
            ExecutorService service = Executors.newSingleThreadExecutor();

            // try to download the module lists
            //
            ReadRemoteModuleInformationTask task1 = new ReadRemoteModuleInformationTask(
                    monitor.createSubTaskMonitor(1, false),
                    OdPreferenceSetting.getModuleSites()
                    );
            Future<?> future = service.submit(task1);
            try {
                future.get();
                modules = buildListOfModulesToLoad(parent);
            } catch (ExecutionException e) {
                Logging.warn(tr("Warning: failed to download module information list"));
                e.printStackTrace();
                // don't abort in case of error, continue with downloading modules below
            } catch (InterruptedException e) {
                Logging.warn(tr("Warning: failed to download module information list"));
                e.printStackTrace();
                // don't abort in case of error, continue with downloading modules below
            }

            // filter modules which actually have to be updated
            //
            Collection<ModuleInformation> modulesToUpdate = new ArrayList<>();
            for (ModuleInformation pi: modules) {
                if (pi.isUpdateRequired()) {
                    modulesToUpdate.add(pi);
                }
            }

            if (!modulesToUpdate.isEmpty()) {
                // try to update the locally installed modules
                //
                ModuleDownloadTask task2 = new ModuleDownloadTask(
                        monitor.createSubTaskMonitor(1, false),
                        modulesToUpdate,
                        tr("Update modules")
                        );

                future = service.submit(task2);
                try {
                    future.get();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                    alertFailedModuleUpdate(parent, modulesToUpdate);
                    return modules;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    alertFailedModuleUpdate(parent, modulesToUpdate);
                    return modules;
                }
                // notify user if downloading a locally installed module failed
                //
                if (!task2.getFailedModules().isEmpty()) {
                    alertFailedModuleUpdate(parent, task2.getFailedModules());
                    return modules;
                }
            }
        } finally {
            monitor.finishTask();
        }
        // remember the update because it was successful
        //
        Config.getPref().put("opendata.modulemanager.lastupdate", Long.toString(System.currentTimeMillis()));
        return modules;
    }
/**
     * Updates the modules in <code>modules</code>.
     *
     * @param parent the parent window for message boxes
     * @param modules the collection of modules to update. Must not be null.
     * @param monitor the progress monitor. Defaults to {@link NullProgressMonitor#INSTANCE} if null.
     * @return list of modules
     * @throws IllegalArgumentException thrown if modules is null
     */
Updates the modules in modules.

@param parent the parent window for message boxes
@param modules the collection of modules to update. Must not be null.
@param monitor the progress monitor. Defaults to  NullProgressMonitor#INSTANCE if null.
@return list of modules
@throws IllegalArgumentException thrown if modules is null
Updates the modules in modules . @param parent the parent window for message boxes @param modules the collection of modules to update . Must not be null . @param monitor the progress monitor . Defaults to NullProgressMonitor#INSTANCE if null . @return list of modules @throws IllegalArgumentException thrown if modules is null
public static List<ModuleInformation> updateModules(Component parent,
            List<ModuleInformation> modules, ProgressMonitor monitor)
                    throws IllegalArgumentException {
        CheckParameterUtil.ensureParameterNotNull(modules, "modules");
        if (monitor == null) {
            monitor = NullProgressMonitor.INSTANCE;
        }
        try {
            monitor.beginTask("");
            ExecutorService service = Executors.newSingleThreadExecutor();
            ReadRemoteModuleInformationTask task1 = new ReadRemoteModuleInformationTask(
                    monitor.createSubTaskMonitor(1, false),
                    OdPreferenceSetting.getModuleSites()
                    );
            Future<?> future = service.submit(task1);
            try {
                future.get();
                modules = buildListOfModulesToLoad(parent);
            } catch (ExecutionException e) {
                Logging.warn(tr("Warning: failed to download module information list"));
                e.printStackTrace();
            } catch (InterruptedException e) {
                Logging.warn(tr("Warning: failed to download module information list"));
                e.printStackTrace();
            }
            Collection<ModuleInformation> modulesToUpdate = new ArrayList<>();
            for (ModuleInformation pi: modules) {
                if (pi.isUpdateRequired()) {
                    modulesToUpdate.add(pi);
                }
            }
            if (!modulesToUpdate.isEmpty()) {
                ModuleDownloadTask task2 = new ModuleDownloadTask(
                        monitor.createSubTaskMonitor(1, false),
                        modulesToUpdate,
                        tr("Update modules")
                        );
                future = service.submit(task2);
                try {
                    future.get();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                    alertFailedModuleUpdate(parent, modulesToUpdate);
                    return modules;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                    alertFailedModuleUpdate(parent, modulesToUpdate);
                    return modules;
                }
                if (!task2.getFailedModules().isEmpty()) {
                    alertFailedModuleUpdate(parent, task2.getFailedModules());
                    return modules;
                }
            }
        } finally {
            monitor.finishTask();
        }
        Config.getPref().put("opendata.modulemanager.lastupdate", Long.toString(System.currentTimeMillis()));
        return modules;
    }
public static List < ModuleInformation > updateModules ( Component parent , List < ModuleInformation > modules , ProgressMonitor monitor ) throws IllegalArgumentException { CheckParameterUtil . ensureParameterNotNull ( modules , "modules" ) ; if ( monitor == null ) { monitor = NullProgressMonitor . INSTANCE ; } try { monitor . beginTask ( "" ) ; ExecutorService service = Executors . newSingleThreadExecutor ( ) ; ReadRemoteModuleInformationTask task1 = new ReadRemoteModuleInformationTask ( monitor . createSubTaskMonitor ( 1 , false ) , OdPreferenceSetting . getModuleSites ( ) ) ; Future < ? > future = service . submit ( task1 ) ; try { future . get ( ) ; modules = buildListOfModulesToLoad ( parent ) ; } catch ( ExecutionException e ) { Logging . warn ( tr ( "Warning: failed to download module information list" ) ) ; e . printStackTrace ( ) ; } catch ( InterruptedException e ) { Logging . warn ( tr ( "Warning: failed to download module information list" ) ) ; e . printStackTrace ( ) ; } Collection < ModuleInformation > modulesToUpdate = new ArrayList < > ( ) ; for ( ModuleInformation pi : modules ) { if ( pi . isUpdateRequired ( ) ) { modulesToUpdate . add ( pi ) ; } } if ( ! modulesToUpdate . isEmpty ( ) ) { ModuleDownloadTask task2 = new ModuleDownloadTask ( monitor . createSubTaskMonitor ( 1 , false ) , modulesToUpdate , tr ( "Update modules" ) ) ; future = service . submit ( task2 ) ; try { future . get ( ) ; } catch ( ExecutionException e ) { e . printStackTrace ( ) ; alertFailedModuleUpdate ( parent , modulesToUpdate ) ; return modules ; } catch ( InterruptedException e ) { e . printStackTrace ( ) ; alertFailedModuleUpdate ( parent , modulesToUpdate ) ; return modules ; } if ( ! task2 . getFailedModules ( ) . isEmpty ( ) ) { alertFailedModuleUpdate ( parent , task2 . getFailedModules ( ) ) ; return modules ; } } } finally { monitor . finishTask ( ) ; } Config . getPref ( ) . put ( "opendata.modulemanager.lastupdate" , Long . toString ( System . currentTimeMillis ( ) ) ) ; return modules ; }
Updates the modules in <code>modules</code>.
Updates the modules in <code > modules< / code > .
// try to download the module lists
 //
 // don't abort in case of error, continue with downloading modules below
 // don't abort in case of error, continue with downloading modules below
 // filter modules which actually have to be updated
 //
 // try to update the locally installed modules
 //
 // notify user if downloading a locally installed module failed
 //
 // remember the update because it was successful
 //
