/*
 * Copyright 2008-2012 LinkedIn, Inc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */

package voldemort.utils;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * A utility class that abstract out fields from manifest file
 * 
 */
public class ManifestFileReader {

    protected static final Logger logger = Logger.getLogger(ManifestFileReader.class);

    private static String MANIFEST_FILE = "META-INF/MANIFEST.MF";
    private static String RELEASE_VERSION_KEY = "Implementation-Version";

    public static String getReleaseVersion() {
        String version = null;
        Properties properties = new Properties();
        try {
            properties.load(new FileInputStream(MANIFEST_FILE));
            version = properties.getProperty(RELEASE_VERSION_KEY);
        } catch(IOException e) {
            logger.warn("Unable to load voldemort release version due to the following error:", e);
        }
        return version;
    }
}
