5f2b74204dbf752a467b916a310ef7b91f5a3a6f
[policy/apex-pdp.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  *  Copyright (C) 2016-2018 Ericsson. All rights reserved.
4  * ================================================================================
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * 
9  *      http://www.apache.org/licenses/LICENSE-2.0
10  * 
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  * 
17  * SPDX-License-Identifier: Apache-2.0
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin;
22
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCharDelimitedParameters;
24
25 /**
26  * Event protocol parameters for JSON as an event protocol.
27  *
28  * The parameters for this plugin are:
29  * <ol>
30  * <li>nameAlias: The field in a JSON event to use as an alias for the event name. This parameter is
31  * optional.
32  * <li>versionAlias: The field in a JSON event to use as an alias for the event version. This
33  * parameter is optional.
34  * <li>nameSpaceAlias: The field in a JSON event to use as an alias for the event name space. This
35  * parameter is optional.
36  * <li>sourceAlias: The field in a JSON event to use as an alias for the event source. This
37  * parameter is optional.
38  * <li>targetAlias: The field in a JSON event to use as an alias for the event target. This
39  * parameter is optional.
40  * </ol>
41  * 
42  * @author Liam Fallon (liam.fallon@ericsson.com)
43  */
44 public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedParameters {
45     /** The label of this event protocol. */
46     public static final String JSON_EVENT_PROTOCOL_LABEL = "JSON";
47
48     // Constants for text block delimiters
49     private static final char JSON_TEXT_BLOCK_START_DELIMITER = '{';
50     private static final char JSON_TEXT_BLOCK_END_DELIMITER = '}';
51
52     // Aliases for Apex event header fields
53     // @formatter:off
54     private String nameAlias      = null;
55     private String versionAlias   = null;
56     private String nameSpaceAlias = null;
57     private String sourceAlias    = null;
58     private String targetAlias    = null;
59     // @formatter:on
60
61     /**
62      * Constructor to create a JSON event protocol parameter instance and register the instance with
63      * the parameter service.
64      */
65     public JSONEventProtocolParameters() {
66         this(JSONEventProtocolParameters.class.getCanonicalName(), JSON_EVENT_PROTOCOL_LABEL);
67     }
68
69     /**
70      * Constructor to create an event protocol parameters instance with the name of a sub class of
71      * this class.
72      *
73      * @param parameterClassName the class name of a sub class of this class
74      * @param eventProtocolLabel the name of the event protocol for this plugin
75      */
76     public JSONEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) {
77         super(parameterClassName);
78
79         // Set the event protocol properties for the JSON event protocol
80         this.setLabel(eventProtocolLabel);
81
82         // Set the starting and ending delimiters for text blocks of JSON events
83         this.setStartChar(JSON_TEXT_BLOCK_START_DELIMITER);
84         this.setEndChar(JSON_TEXT_BLOCK_END_DELIMITER);
85
86         // Set the event protocol plugin class
87         this.setEventProtocolPluginClass(Apex2JSONEventConverter.class.getCanonicalName());
88     }
89
90     /**
91      * Gets the name alias.
92      *
93      * @return the name alias
94      */
95     public String getNameAlias() {
96         return nameAlias;
97     }
98
99     /**
100      * Gets the version alias.
101      *
102      * @return the version alias
103      */
104     public String getVersionAlias() {
105         return versionAlias;
106     }
107
108     /**
109      * Gets the name space alias.
110      *
111      * @return the name space alias
112      */
113     public String getNameSpaceAlias() {
114         return nameSpaceAlias;
115     }
116
117     /**
118      * Gets the source alias.
119      *
120      * @return the source alias
121      */
122     public String getSourceAlias() {
123         return sourceAlias;
124     }
125
126     /**
127      * Gets the target alias.
128      *
129      * @return the target alias
130      */
131     public String getTargetAlias() {
132         return targetAlias;
133     }
134     
135     /**
136      * Sets the name alias.
137      *
138      * @param nameAlias the new name alias
139      */
140     public void setNameAlias(String nameAlias) {
141         this.nameAlias = nameAlias;
142     }
143
144     /**
145      * Sets the version alias.
146      *
147      * @param versionAlias the new version alias
148      */
149     public void setVersionAlias(String versionAlias) {
150         this.versionAlias = versionAlias;
151     }
152
153     /**
154      * Sets the name space alias.
155      *
156      * @param nameSpaceAlias the new name space alias
157      */
158     public void setNameSpaceAlias(String nameSpaceAlias) {
159         this.nameSpaceAlias = nameSpaceAlias;
160     }
161
162     /**
163      * Sets the source alias.
164      *
165      * @param sourceAlias the new source alias
166      */
167     public void setSourceAlias(String sourceAlias) {
168         this.sourceAlias = sourceAlias;
169     }
170
171     /**
172      * Sets the target alias.
173      *
174      * @param targetAlias the new target alias
175      */
176     public void setTargetAlias(String targetAlias) {
177         this.targetAlias = targetAlias;
178     }
179 }