Added oparent to sdc main
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / auditing / impl / distribution / AuditDistributionEngineEventFactoryManager.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.auditing.impl.distribution;
22
23 import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
24 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
25 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
26 import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData;
27 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
28
29 public class AuditDistributionEngineEventFactoryManager {
30
31     public static AuditEventFactory createDistributionEngineEventFactory(AuditingActionEnum action, String environmentName,
32                                                                          DistributionTopicData distributionTopicData, String role, String apiKey, String status) {
33         AuditEventFactory factory;
34
35         switch (action) {
36             case CREATE_DISTRIBUTION_TOPIC:
37                 factory = new AuditCreateTopicDistributionEngineEventFactory(
38                         CommonAuditData.newBuilder()
39                                 .status(status)
40                                 .requestId(ThreadLocalsHolder.getUuid())
41                                 .build(),
42                         distributionTopicData, apiKey, environmentName, role);
43                 break;
44             case ADD_KEY_TO_TOPIC_ACL:
45             case REMOVE_KEY_FROM_TOPIC_ACL:
46                 factory = new AuditAddRemoveKeyDistributionEngineEventFactory(action,
47                         CommonAuditData.newBuilder()
48                                 .status(status)
49                                 .requestId(ThreadLocalsHolder.getUuid())
50                                 .build(),
51                         distributionTopicData, apiKey, environmentName, role);
52                 break;
53             default:
54                 throw new UnsupportedOperationException();
55
56         }
57         return factory;
58
59     }
60 }