/*******************************************************************************
*
* Copyright 2011-2014 Spiffy UI Team
*
* 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 org.spiffyui.spsample.server;
import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* This servlet shows version information.
*/
public class VersionInfoServlet extends HttpServlet
{
private static final long serialVersionUID = -1L;
private static final ResourceBundle BUILD_BUNDLE =
ResourceBundle.getBundle("org/spiffyui/spsample/server/buildnum", Locale.getDefault());
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("application/json");
ServletOutputStream out = response.getOutputStream();
StringBuffer buildinfo = new StringBuffer();
buildinfo.append("{");
/*
These values are defined in the buildnum.properties file which is generated by the build
*/
buildinfo.append("\"version\":\"" + BUILD_BUNDLE.getString("build.version") + "\",");
buildinfo.append("\"user\":\"" + BUILD_BUNDLE.getString("build.user") + "\",");
buildinfo.append("\"date\":\"" + BUILD_BUNDLE.getString("build.date") + "\",");
buildinfo.append("\"rev\":\"" + BUILD_BUNDLE.getString("build.revision") + "\",");
buildinfo.append("\"revdate\":\"" + BUILD_BUNDLE.getString("build.revision.date") + "\"");
buildinfo.append("}");
out.println(buildinfo.toString());
}
}