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.client.rest;
019    
020    import java.util.Properties;
021    
022    import org.apache.oozie.client.JMSConnectionInfoWrapper;
023    import org.apache.oozie.client.rest.JsonTags;
024    import org.json.simple.JSONObject;
025    import org.json.simple.JSONValue;
026    /**
027     * JMS connection info bean representing the JMS related information for a job
028     *
029     */
030    public class JMSConnectionInfoBean implements JsonBean, JMSConnectionInfoWrapper {
031    
032        private Properties JNDIProperties;
033        private String topicPrefix;
034        private Properties topicProperties;
035    
036    
037        @Override
038        public JSONObject toJSONObject() {
039            return toJSONObject("GMT");
040        }
041    
042        /**
043         * Set the JNDI properties for jms connection
044         * @param JNDIProperties
045         */
046        public void setJNDIProperties(Properties JNDIProperties) {
047            this.JNDIProperties = JNDIProperties;
048        }
049    
050        public Properties getJNDIProperties() {
051            return JNDIProperties;
052        }
053    
054        @SuppressWarnings("unchecked")
055        @Override
056        public JSONObject toJSONObject(String timeZoneId) {
057            JSONObject json = new JSONObject();
058            json.put(JsonTags.JMS_JNDI_PROPERTIES, JSONValue.toJSONString(JNDIProperties));
059            json.put(JsonTags.JMS_TOPIC_PATTERN, JSONValue.toJSONString(topicProperties));
060            json.put(JsonTags.JMS_TOPIC_PREFIX, topicPrefix);
061            return json;
062        }
063    
064        @Override
065        public String getTopicPrefix() {
066           return topicPrefix;
067        }
068    
069        /**
070         * Sets the topic prefix
071         * @param topicPrefix
072         */
073        public void setTopicPrefix(String topicPrefix) {
074            this.topicPrefix = topicPrefix;
075        }
076    
077        /**
078         * Set the topic pattern properties
079         * @param topicProperties
080         */
081        public void setTopicPatternProperties(Properties topicProperties) {
082            this.topicProperties = topicProperties;
083        }
084    
085        @Override
086        public Properties getTopicPatternProperties() {
087            return topicProperties;
088        }
089    
090    }