Package org.opengeo

Source Code of org.opengeo.GeoServerInfo$BuildInfo

package org.opengeo;

import org.geoserver.ManifestLoader;
import org.geoserver.ManifestLoader.AboutModel;
import org.geoserver.ManifestLoader.AboutModel.ManifestModel;
import org.geoserver.platform.GeoServerResourceLoader;

import java.util.Properties;

/**
* Class providing info about GeoServer.
*/
public class GeoServerInfo {

    public GeoServerInfo(GeoServerResourceLoader loader) throws Exception {
        new ManifestLoader(loader);
    }

    public BuildInfo suite() throws Exception {
        final Properties props = new Properties();
        props.load(getClass().getResourceAsStream("suite.properties"));
        return new BuildInfo() {
            @Override
            public String version() {
                return props.getProperty("version");
            }

            @Override
            public String revision() {
                return props.getProperty("rev");
            }
        };
    }

    public BuildInfo geoserver() throws Exception {
        AboutModel about = ManifestLoader.getVersions();
        about = about.filterNameByRegex("GeoServer");

        final AboutModel.ManifestModel manifest = about.getManifests().iterator().next();
        return new BuildInfo() {
            @Override
            public String version() {
                return manifest.getEntries().get("Version");
            }

            @Override
            public String revision() {
                return manifest.getEntries().get("Git-Version").substring(0,7);
            }
        };
    }

    public interface BuildInfo {

        String version();
        String revision();
    }
}
TOP

Related Classes of org.opengeo.GeoServerInfo$BuildInfo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.