3fa8c8fe476bcf2ffe05414ea0a395309edf65a0
[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.externalapi;
21
22 import org.openecomp.sdc.be.auditing.impl.AuditBaseEventFactory;
23 import org.openecomp.sdc.be.model.User;
24 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
25 import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
26 import org.openecomp.sdc.be.resources.data.auditing.ExternalApiEvent;
27 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
28 import org.openecomp.sdc.be.resources.data.auditing.model.DistributionData;
29 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
30 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
31 import org.openecomp.sdc.common.util.ThreadLocalsHolder;
32
33 public abstract class AuditExternalApiEventFactory extends AuditBaseEventFactory {
34
35     protected final ExternalApiEvent event;
36
37     public AuditExternalApiEventFactory(AuditingActionEnum action, CommonAuditData commonAuditData, ResourceCommonInfo resourceCommonInfo,
38                                         DistributionData distributionData, ResourceVersionInfo prevParams, ResourceVersionInfo currParams,
39                                         String invariantUuid, User modifier, String artifactData) {
40         super(action);
41         if (commonAuditData.getRequestId() == null) {
42             commonAuditData.setRequestId(ThreadLocalsHolder.getUuid());
43         }
44         event = new ExternalApiEvent(getAction().getName(), commonAuditData, resourceCommonInfo, distributionData, prevParams, currParams,
45             AuditBaseEventFactory.buildUserName(modifier), invariantUuid, artifactData);
46     }
47
48     @Override
49     public AuditingGenericEvent getDbEvent() {
50         return event;
51     }
52 }