001 /**
002 * Copyright (c) 2010 Yahoo! Inc. All rights reserved.
003 * Licensed under the Apache License, Version 2.0 (the "License");
004 * you may not use this file except in compliance with the License.
005 * You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software
010 * distributed under the License is distributed on an "AS IS" BASIS,
011 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012 * See the License for the specific language governing permissions and
013 * limitations under the License. See accompanying LICENSE file.
014 */
015 package org.apache.oozie.servlet;
016
017 import org.apache.oozie.client.OozieClient;
018 import org.apache.oozie.servlet.JsonRestServlet;
019 import org.json.simple.JSONArray;
020
021 import javax.servlet.ServletException;
022 import javax.servlet.http.HttpServletRequest;
023 import javax.servlet.http.HttpServletResponse;
024 import java.io.IOException;
025 import java.util.Arrays;
026 import java.util.Collections;
027
028 public class VersionServlet extends JsonRestServlet {
029 private static final String INSTRUMENTATION_NAME = "version";
030
031 private static final ResourceInfo RESOURCE_INFO =
032 new ResourceInfo("", Arrays.asList("GET"), Collections.EMPTY_LIST);
033
034 // private static JSONArray versions = new JSONArray();
035
036 public VersionServlet() {
037 super(INSTRUMENTATION_NAME, RESOURCE_INFO);
038 // versions.add(OozieClient.WS_PROTOCOL_VERSION_0);
039 // versions.add(OozieClient.WS_PROTOCOL_VERSION);
040 }
041
042 protected void doGet(HttpServletRequest request, HttpServletResponse response)
043 throws ServletException, IOException {
044 JSONArray versions = new JSONArray();
045 versions.add(OozieClient.WS_PROTOCOL_VERSION_0);
046 versions.add(OozieClient.WS_PROTOCOL_VERSION);
047 sendJsonResponse(response, HttpServletResponse.SC_OK, versions);
048 }
049 }