//
// OrchardWebAppContextListener.java -- Java class OrchardWebAppContextListener
// Project Orchard
//
// Created by jthywiss on Feb 24, 2010.
//
// Copyright (c) 2016 The University of Texas at Austin. All rights reserved.
//
// Use and redistribution of this file is governed by the license terms in
// the LICENSE file found in the project's top-level directory and also found at
// URL: http://orc.csres.utexas.edu/license.shtml .
//

package orc.orchard;

import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.Enumeration;
import java.util.jar.Manifest;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

/**
 * Listens for initialized and destroyed events on the Orchard Web application
 * context. Currently, this just copies the Web app's initialization parameters
 * into the <code>OrchardProperties</code> map.
 *
 * @author jthywiss
 */
public class OrchardWebAppContextListener implements ServletContextListener {

    protected static Logger logger = Logger.getLogger("orc.orchard");

    @Override
    public void contextInitialized(final ServletContextEvent event) {
        final Enumeration<? extends String> entries = event.getServletContext().getInitParameterNames();
        for (final String parmName : Collections.list(entries)) {
            OrchardProperties.setProperty(parmName, event.getServletContext().getInitParameter(parmName));
        }
        try {
            final InputStream manifestStream = event.getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF");
            logger.log(Level.SEVERE, "manifestStream="+manifestStream);
            if (manifestStream != null) {
                final Manifest warManifest = new Manifest(manifestStream);
                for (final Object key : warManifest.getMainAttributes().keySet()) {
                    final String propName = "war.manifest." + key;
                    logger.log(Level.SEVERE, "propName="+propName);
                    OrchardProperties.setProperty(propName, warManifest.getMainAttributes().get(key).toString());
                }
            } else {
                logger.log(Level.SEVERE, "Orchard WAR manifest attributes read failed: ServletContext.getResourceAsStream(\"/META-INF/MANIFEST.MF\") returned null");
            }
        } catch (final IOException e) {
            logger.log(Level.SEVERE, "Orchard WAR manifest attributes read failed", e);
        }
        logger.config(getOrchardFullVersionString());
        logger.config(orc.Main.orcImplName() + " " + orc.Main.orcVersion());
    }

    private String getOrchardFullVersionString() {
        return OrchardProperties.getProperty("war.manifest.Implementation-Title") + " " + OrchardProperties.getProperty("war.manifest.Implementation-Version") + " rev. " + OrchardProperties.getProperty("war.manifest.SCM-Revision");
    }

    @Override
    public void contextDestroyed(final ServletContextEvent event) {
    }

}

@@ -1654,80 +1654,8 @@
 %22);%0A
-            logger.log(Level.SEVERE, %22manifestStream=%22+manifestStream);%0A
     
@@ -1922,76 +1922,8 @@
 ey;%0A
-                    logger.log(Level.SEVERE, %22propName=%22+propName);%0A
     

Remove debug output inadvertently left in 1a16a0f81775c80c8bdc4372bd643db833dc2eaf.