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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.apex.service.engine.event.impl.jsonprotocolplugin;
23 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCharDelimitedParameters;
26 * Event protocol parameters for JSON as an event protocol.
28 * The parameters for this plugin are:
30 * <li>nameAlias: The field in a JSON event to use as an alias for the event name. This parameter is
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.
42 * @author Liam Fallon (liam.fallon@ericsson.com)
44 public class JSONEventProtocolParameters extends EventProtocolTextCharDelimitedParameters {
45 /** The label of this event protocol. */
46 public static final String JSON_EVENT_PROTOCOL_LABEL = "JSON";
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 = '}';
52 // Aliases for Apex event header fields
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;
62 * Constructor to create a JSON event protocol parameter instance and register the instance with
63 * the parameter service.
65 public JSONEventProtocolParameters() {
66 this(JSONEventProtocolParameters.class.getCanonicalName(), JSON_EVENT_PROTOCOL_LABEL);
70 * Constructor to create an event protocol parameters instance with the name of a sub class of
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
76 public JSONEventProtocolParameters(final String parameterClassName, final String eventProtocolLabel) {
77 super(parameterClassName);
79 // Set the event protocol properties for the JSON event protocol
80 this.setLabel(eventProtocolLabel);
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);
86 // Set the event protocol plugin class
87 this.setEventProtocolPluginClass(Apex2JSONEventConverter.class.getCanonicalName());
91 * Gets the name alias.
93 * @return the name alias
95 public String getNameAlias() {
100 * Gets the version alias.
102 * @return the version alias
104 public String getVersionAlias() {
109 * Gets the name space alias.
111 * @return the name space alias
113 public String getNameSpaceAlias() {
114 return nameSpaceAlias;
118 * Gets the source alias.
120 * @return the source alias
122 public String getSourceAlias() {
127 * Gets the target alias.
129 * @return the target alias
131 public String getTargetAlias() {
136 * Sets the name alias.
138 * @param nameAlias the new name alias
140 public void setNameAlias(String nameAlias) {
141 this.nameAlias = nameAlias;
145 * Sets the version alias.
147 * @param versionAlias the new version alias
149 public void setVersionAlias(String versionAlias) {
150 this.versionAlias = versionAlias;
154 * Sets the name space alias.
156 * @param nameSpaceAlias the new name space alias
158 public void setNameSpaceAlias(String nameSpaceAlias) {
159 this.nameSpaceAlias = nameSpaceAlias;
163 * Sets the source alias.
165 * @param sourceAlias the new source alias
167 public void setSourceAlias(String sourceAlias) {
168 this.sourceAlias = sourceAlias;
172 * Sets the target alias.
174 * @param targetAlias the new target alias
176 public void setTargetAlias(String targetAlias) {
177 this.targetAlias = targetAlias;