All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.nuiton.updater.ApplicationUpdaterActionGetVersions Maven / Gradle / Ivy

package org.nuiton.updater;

/*
 * #%L
 * Nuiton Application Updater
 * $Id: ApplicationUpdaterActionGetVersions.java 2588 2013-07-20 14:25:42Z tchemit $
 * $HeadURL: https://nuiton.org/svn/nuiton-updater/tags/nuiton-updater-3.0-alpha-2/src/main/java/org/nuiton/updater/ApplicationUpdaterActionGetVersions.java $
 * %%
 * Copyright (C) 2013 CodeLutin, Tony Chemit
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as 
 * published by the Free Software Foundation, either version 3 of the 
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public 
 * License along with this program.  If not, see
 * .
 * #L%
 */

import com.google.common.collect.Maps;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.vfs2.FileSystemOptions;
import org.nuiton.config.ApplicationConfig;

import java.io.File;
import java.util.Map;

/**
 * Get version of updates.
 *
 * @author tchemit 
 * @since 2.6.12
 */
public class ApplicationUpdaterActionGetVersions extends AbstractApplicationUpdaterAction {

    /** Logger. */
    private static final Log log =
            LogFactory.getLog(ApplicationUpdaterActionGetVersions.class);

    protected Map updates;

    public ApplicationUpdaterActionGetVersions(ApplicationConfig config,
                                               String vfsPropertiesUrl,
                                               File currentDir) {
        super(config, vfsPropertiesUrl, currentDir);
    }

    public Map getUpdates() {
        return updates;
    }

    @Override
    public void run() {
        try {
            FileSystemOptions vfsConfig = getVFSConfig(config);
            ApplicationConfig releaseConfig = getUpdaterConfig(
                    vfsConfig, vfsPropertiesUrl);

            Map appToUpdate =
                    getVersions(releaseConfig, true, null);

            updates = Maps.newTreeMap();
            updates.putAll(appToUpdate);
        } catch (Exception eee) {
            log.warn("Can't update");
            log.info("Application update aborted because: ", eee);
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy