This project has retired. For details please refer to its
Attic page.
001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018 package org.apache.oozie.servlet;
019
020 import java.io.IOException;
021 import java.util.Properties;
022
023 import javax.servlet.http.HttpServletRequest;
024 import javax.servlet.http.HttpServletResponse;
025
026 import org.apache.hadoop.conf.Configuration;
027 import org.apache.oozie.ErrorCode;
028 import org.apache.oozie.client.rest.JMSConnectionInfoBean;
029 import org.apache.oozie.client.rest.JsonBean;
030 import org.apache.oozie.jms.JMSConnectionInfo;
031 import org.apache.oozie.jms.JMSJobEventListener;
032 import org.apache.oozie.service.JMSTopicService;
033 import org.apache.oozie.service.Services;
034
035 /**
036 * V2 admin servlet
037 *
038 */
039 public class V2AdminServlet extends V1AdminServlet {
040
041 private static final long serialVersionUID = 1L;
042 private static final String INSTRUMENTATION_NAME = "v2admin";
043
044 public V2AdminServlet() {
045 super(INSTRUMENTATION_NAME);
046 }
047
048 @Override
049 protected JsonBean getJMSConnectionInfo(HttpServletRequest request, HttpServletResponse response)
050 throws XServletException, IOException {
051 Configuration conf = Services.get().getConf();
052 JMSTopicService jmsTopicService = Services.get().get(JMSTopicService.class);
053 String connectionProperties = conf.get(JMSJobEventListener.JMS_CONNECTION_PROPERTIES);
054 if (connectionProperties == null) {
055 throw new XServletException(HttpServletResponse.SC_BAD_REQUEST, ErrorCode.E1601,
056 "JMS connection property is not defined");
057 }
058 JMSConnectionInfoBean jmsBean = new JMSConnectionInfoBean();
059 JMSConnectionInfo jmsInfo = new JMSConnectionInfo(connectionProperties);
060 Properties jmsInfoProps = jmsInfo.getJNDIProperties();
061 jmsInfoProps.remove("java.naming.security.principal");
062 jmsBean.setJNDIProperties(jmsInfoProps);
063 if (jmsTopicService != null) {
064 jmsBean.setTopicPrefix(jmsTopicService.getTopicPrefix());
065 jmsBean.setTopicPatternProperties(jmsTopicService.getTopicPatternProperties());
066 }
067 else {
068 throw new XServletException(
069 HttpServletResponse.SC_BAD_REQUEST,
070 ErrorCode.E1601,
071 "JMSTopicService is not initialized. JMS notification"
072 + "may not be enabled");
073 }
074 return jmsBean;
075 }
076
077 }