f4bb5bedf7477512ec3764bba9d36009996567a1
[sdc.git] /
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 package org.openecomp.sdc.be.auditing.impl.distribution;
21
22 import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
23 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
24 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
25 import org.openecomp.sdc.be.resources.data.auditing.model.DistributionTopicData;
26 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
27
28 public class AuditDistributionEngineEventFactoryManager {
29
30     public static AuditEventFactory createDistributionEngineEventFactory(AuditingActionEnum action, String environmentName,
31                                                                          DistributionTopicData distributionTopicData, String role, String apiKey,
32                                                                          String status) {
33         AuditEventFactory factory;
34         switch (action) {
35             case CREATE_DISTRIBUTION_TOPIC:
36                 factory = new AuditCreateTopicDistributionEngineEventFactory(
37                     CommonAuditData.newBuilder().status(status).requestId(ThreadLocalsHolder.getUuid()).build(), distributionTopicData, apiKey,
38                     environmentName, role);
39                 break;
40             case ADD_KEY_TO_TOPIC_ACL:
41             case REMOVE_KEY_FROM_TOPIC_ACL:
42                 factory = new AuditAddRemoveKeyDistributionEngineEventFactory(action,
43                     CommonAuditData.newBuilder().status(status).requestId(ThreadLocalsHolder.getUuid()).build(), distributionTopicData, apiKey,
44                     environmentName, role);
45                 break;
46             default:
47                 throw new UnsupportedOperationException();
48         }
49         return factory;
50     }
51 }