2 * ===============================LICENSE_START======================================
\r
4 * ================================================================================
\r
5 * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============================LICENSE_END===========================================
\r
21 package org.openecomp.dcae.apod.analytics.tca.processor;
\r
23 import org.openecomp.dcae.apod.analytics.model.domain.cef.Domain;
\r
24 import org.openecomp.dcae.apod.analytics.model.domain.cef.EventListener;
\r
28 * TCA Processor which acts like a filter to filter out messages which does not belong to TCA Policy Domain
\r
30 * Pre Conditions: CEF Event Listener must be present
\r
33 * @author Rajiv Singla . Creation Date: 11/7/2016.
\r
35 public class TCACEFPolicyDomainFilter extends AbstractTCAECEFPolicyProcessor {
\r
38 private static final long serialVersionUID = 1L;
\r
41 public String getProcessorDescription() {
\r
42 return "Filters out CEF Messages which does not match TCAPolicy Domain";
\r
46 public TCACEFProcessorContext processMessage(TCACEFProcessorContext processorContext) {
\r
48 // Safe to get event Listener here without null check as pre processor will validate if
\r
49 // event listener is indeed present
\r
50 final EventListener eventListener = processorContext.getCEFEventListener();
\r
52 Domain cefMessageDomain;
\r
54 // Extract CEF domain as it is must be present as per CEF Schema
\r
55 if (eventListener.getEvent() != null &&
\r
56 eventListener.getEvent().getCommonEventHeader() != null &&
\r
57 eventListener.getEvent().getCommonEventHeader().getDomain() != null) {
\r
58 cefMessageDomain = eventListener.getEvent().getCommonEventHeader().getDomain();
\r
61 final String terminatingMessage = "Invalid CEF Message.Common Event Header Domain not present.";
\r
62 setTerminatingProcessingMessage(terminatingMessage, processorContext);
\r
63 return processorContext;
\r
66 // Get Policy Domain. TCA Policy Validation must ensure that Domain is indeed present
\r
67 // no null check will be required here
\r
68 final String policyDomain = processorContext.getTCAPolicy().getDomain();
\r
70 // If Policy domain matches CEF message domain then continue processing
\r
71 if (cefMessageDomain.toString().equalsIgnoreCase(policyDomain)) {
\r
72 final String finishMessage = String.format("Policy Domain and CEF Message Domain match successful." +
\r
73 " Message Domain: %s, Policy Domain: %s", cefMessageDomain, policyDomain);
\r
74 setFinishedProcessingMessage(finishMessage, processorContext);
\r
76 // If policy domain does not match with CEF message terminate processing chain
\r
77 final String terminatingMessage = String.format("Policy Domain and CEF Message Domain match unsuccessful." +
\r
78 " Message Domain: %s, Policy Domain: %s", cefMessageDomain, policyDomain);
\r
79 setTerminatingProcessingMessage(terminatingMessage, processorContext);
\r
82 return processorContext;
\r