001/*
002 * (C) Copyright 2012-2015 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     mguillaume
016 */
017
018package org.nuxeo.launcher.info;
019
020import java.io.File;
021import java.io.FileInputStream;
022import java.io.IOException;
023import java.util.Properties;
024
025import javax.xml.bind.annotation.XmlAccessType;
026import javax.xml.bind.annotation.XmlAccessorType;
027import javax.xml.bind.annotation.XmlElement;
028import javax.xml.bind.annotation.XmlRootElement;
029
030import org.nuxeo.common.Environment;
031
032@XmlAccessorType(XmlAccessType.NONE)
033@XmlRootElement(name = "distribution")
034public class DistributionInfo {
035
036    public DistributionInfo() {
037    }
038
039    public DistributionInfo(File distFile) throws IOException {
040        Properties distProps = new Properties();
041        distProps.load(new FileInputStream(distFile));
042        name = distProps.getProperty(Environment.DISTRIBUTION_NAME, "unknown");
043        server = distProps.getProperty(Environment.DISTRIBUTION_SERVER, "unknown");
044        version = distProps.getProperty(Environment.DISTRIBUTION_VERSION, "unknown");
045        date = distProps.getProperty(Environment.DISTRIBUTION_DATE, "unknown");
046        packaging = distProps.getProperty(Environment.DISTRIBUTION_PACKAGE, "unknown");
047    }
048
049    @XmlElement()
050    public String name = "unknown";
051
052    @XmlElement()
053    public String server = "unknown";
054
055    @XmlElement()
056    public String version = "unknown";
057
058    @XmlElement()
059    public String date = "unknown";
060
061    @XmlElement()
062    public String packaging = "unknown";
063
064}