2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2016-2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.plugins.event.protocol.yaml;
26 import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextTokenDelimitedParameters;
29 * Event protocol parameters for YAML as an event protocol.
31 * <p>The parameters for this plugin are:
33 * <li>nameAlias: The field in a YAML event to use as an alias for the event name. This parameter is
35 * <li>versionAlias: The field in a YAML event to use as an alias for the event version. This
36 * parameter is optional.
37 * <li>nameSpaceAlias: The field in a YAML event to use as an alias for the event name space. This
38 * parameter is optional.
39 * <li>sourceAlias: The field in a YAML event to use as an alias for the event source. This
40 * parameter is optional.
41 * <li>targetAlias: The field in a YAML event to use as an alias for the event target. This
42 * parameter is optional.
43 * <li>yamlFieldName: The name of the field in the APEX event that will contain the unmarshaled YAML object. The
44 * parameter is optional and defaults to the value "yaml_field".
47 * @author Liam Fallon (liam.fallon@ericsson.com)
51 public class YamlEventProtocolParameters extends EventProtocolTextTokenDelimitedParameters {
52 /** The label of this event protocol. */
53 public static final String YAML_EVENT_PROTOCOL_LABEL = "YAML";
55 // Constants for text block delimiters
56 private static final String YAML_START_TEXT_DELIMITER_TOKEN = "---";
57 private static final String YAML_END_TEXT_DELIMITER_TOKEN = "...";
59 // Default parameter values
60 private static final String DEFAULT_YAML_FIELD_NAME = "yaml_field";
62 // Aliases for Apex event header fields
64 private String nameAlias = null;
65 private String versionAlias = null;
66 private String nameSpaceAlias = null;
67 private String sourceAlias = null;
68 private String targetAlias = null;
69 private String yamlFieldName = DEFAULT_YAML_FIELD_NAME;
73 * Constructor to create a YAML event protocol parameter instance and register the instance with
74 * the parameter service.
76 public YamlEventProtocolParameters() {
77 this(YAML_EVENT_PROTOCOL_LABEL);
81 * Constructor to create an event protocol parameters instance with the name of a sub class of
84 * @param eventProtocolLabel the name of the event protocol for this plugin
86 public YamlEventProtocolParameters(final String eventProtocolLabel) {
89 // Set the event protocol properties for the YAML event protocol
90 this.setLabel(eventProtocolLabel);
92 // Set the delimiter token for text blocks of YAML events
93 this.setStartDelimiterToken(YAML_START_TEXT_DELIMITER_TOKEN);
94 this.setEndDelimiterToken(YAML_END_TEXT_DELIMITER_TOKEN);
96 // Set the event protocol plugin class
97 this.setEventProtocolPluginClass(Apex2YamlEventConverter.class.getName());