package com.mozu.base.controllers;

import java.io.InputStream;
import java.util.jar.Attributes;
import java.util.jar.Manifest;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.context.ServletContextAware;

import com.mozu.base.models.AppInfo;
import com.mozu.base.utils.ApplicationUtils;

@Controller
@RequestMapping("/version")
public class VersionController implements ServletContextAware {

    private ServletContext context;
    
    @Override
    public void setServletContext(ServletContext servletContext) {
        this.context = servletContext;
    }

    @RequestMapping(method = RequestMethod.GET)
    public @ResponseBody AppInfo getversion(final HttpServletRequest request ) throws Exception {
        InputStream manifestStream = context.getResourceAsStream("/META-INF/MANIFEST.MF");
        AppInfo appInfo = ApplicationUtils.getAppInfo();
        if (manifestStream== null) {
            appInfo.setBuildVersion("Unknown version");
        }
        Manifest manifest = new Manifest(manifestStream);
        Attributes attributes = manifest.getMainAttributes();
        appInfo.setBuildVersion(attributes.getValue("Implementation-Version"));
        
        return appInfo;
    }
    
    
}

@@ -1251,25 +1251,33 @@
 );%0A        %7D
-%0A
+ else %7B%0A%09
         Mani
@@ -1322,16 +1322,17 @@
 tream);%0A
+%09
         
@@ -1381,24 +1381,25 @@
 tributes();%0A
+%09
         appI
@@ -1470,24 +1470,25 @@
 ));%0A        
+%7D
 %0A        ret

Fix version controller