001/*
002 * (C) Copyright 2012-2015 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     mguillaume
018 */
019
020package org.nuxeo.launcher.info;
021
022import java.io.File;
023import java.io.FileInputStream;
024import java.io.IOException;
025import java.io.InputStream;
026import java.util.Properties;
027
028import javax.xml.bind.annotation.XmlAccessType;
029import javax.xml.bind.annotation.XmlAccessorType;
030import javax.xml.bind.annotation.XmlElement;
031import javax.xml.bind.annotation.XmlRootElement;
032
033import org.nuxeo.common.Environment;
034
035@XmlAccessorType(XmlAccessType.NONE)
036@XmlRootElement(name = "distribution")
037public class DistributionInfo {
038
039    public DistributionInfo() {
040    }
041
042    public DistributionInfo(File distFile) throws IOException {
043        Properties distProps = new Properties();
044        try (InputStream in = new FileInputStream(distFile)) {
045            distProps.load(in);
046        }
047        name = distProps.getProperty(Environment.DISTRIBUTION_NAME, "unknown");
048        server = distProps.getProperty(Environment.DISTRIBUTION_SERVER, "unknown");
049        version = distProps.getProperty(Environment.DISTRIBUTION_VERSION, "unknown");
050        date = distProps.getProperty(Environment.DISTRIBUTION_DATE, "unknown");
051        packaging = distProps.getProperty(Environment.DISTRIBUTION_PACKAGE, "unknown");
052    }
053
054    @XmlElement()
055    public String name = "unknown";
056
057    @XmlElement()
058    public String server = "unknown";
059
060    @XmlElement()
061    public String version = "unknown";
062
063    @XmlElement()
064    public String date = "unknown";
065
066    @XmlElement()
067    public String packaging = "unknown";
068
069}