Remove dead code
[clamp.git] / src / main / java / org / onap / clamp / clds / client / GuardPolicyDeleteDelegate.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP CLAMP
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Modifications Copyright (c) 2019 Samsung
9  * ================================================================================
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  * ============LICENSE_END============================================
22  * ===================================================================
23  *
24  */
25
26 package org.onap.clamp.clds.client;
27
28 import com.att.eelf.configuration.EELFLogger;
29 import com.att.eelf.configuration.EELFManager;
30
31 import org.apache.camel.Exchange;
32 import org.apache.camel.Handler;
33 import org.onap.clamp.clds.client.req.policy.GuardPolicyAttributesConstructor;
34 import org.onap.clamp.clds.client.req.policy.PolicyClient;
35 import org.onap.clamp.clds.model.CldsEvent;
36 import org.onap.clamp.clds.model.properties.ModelProperties;
37 import org.onap.clamp.clds.model.properties.Policy;
38 import org.onap.clamp.clds.model.properties.PolicyChain;
39 import org.onap.clamp.clds.model.properties.PolicyItem;
40 import org.springframework.beans.factory.annotation.Autowired;
41 import org.springframework.stereotype.Component;
42
43 /**
44  * Delete Operational Policy via policy api.
45  */
46 @Component
47 public class GuardPolicyDeleteDelegate {
48
49     protected static final EELFLogger logger = EELFManager.getInstance()
50             .getLogger(GuardPolicyDeleteDelegate.class);
51     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
52     private final PolicyClient policyClient;
53
54     @Autowired
55     public GuardPolicyDeleteDelegate(PolicyClient policyClient) {
56         this.policyClient = policyClient;
57     }
58
59     /**
60      * Perform activity. Delete Operational Policy via policy api.
61      *
62      * @param camelExchange The Camel Exchange object containing the properties
63      */
64     @Handler
65     public void execute(Exchange camelExchange) {
66         ModelProperties prop = ModelProperties.create(camelExchange);
67         Policy policy = prop.getType(Policy.class);
68
69         String eventAction = (String) camelExchange.getProperty("eventAction");
70         if (!eventAction.equalsIgnoreCase(CldsEvent.ACTION_CREATE) && policy.isFound()) {
71             for (PolicyChain policyChain : prop.getType(Policy.class).getPolicyChains()) {
72                 for (PolicyItem policyItem : GuardPolicyAttributesConstructor
73                         .getAllPolicyGuardsFromPolicyChain(policyChain)) {
74                     prop.setCurrentModelElementId(policy.getId());
75                     prop.setPolicyUniqueId(policyChain.getPolicyId());
76                     prop.setGuardUniqueId(policyItem.getId());
77                     policyClient.deleteGuard(prop);
78                 }
79             }
80         }
81     }
82 }