Added oparent to sdc main
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / auditing / impl / resourceadmin / AuditResourceAdminEventFactory.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.resourceadmin;
22
23 import org.openecomp.sdc.be.auditing.impl.AuditBaseEventFactory;
24 import org.openecomp.sdc.be.model.User;
25 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
26 import org.openecomp.sdc.be.resources.data.auditing.AuditingGenericEvent;
27 import org.openecomp.sdc.be.resources.data.auditing.ResourceAdminEvent;
28 import org.openecomp.sdc.be.resources.data.auditing.model.CommonAuditData;
29 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
30 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
31
32 public abstract class AuditResourceAdminEventFactory extends AuditBaseEventFactory {
33
34     protected final ResourceAdminEvent event;
35
36     AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams,
37                                           ResourceVersionInfo currParams, String invariantUuid,
38                                           User modifier, String artifactData, String comment, String did, String toscaNodeType) {
39         this(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, AuditBaseEventFactory.buildUserName(modifier),
40                 artifactData, AuditBaseEventFactory.replaceNullNameWithEmpty(comment), did, toscaNodeType);
41     }
42
43     AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
44                                           ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid,
45                                           String modifier, String artifactData, String comment, String did,
46                                           String toscaNodeType, String timestamp) {
47         this(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier,
48                 artifactData, comment, did, toscaNodeType);
49         this.event.setTimestamp1(timestamp);
50     }
51
52     private AuditResourceAdminEventFactory(AuditingActionEnum action, CommonAuditData commonFields, ResourceCommonInfo resourceCommonInfo,
53                                           ResourceVersionInfo prevParams, ResourceVersionInfo currParams, String invariantUuid,
54                                           String modifier, String artifactData, String comment, String did,
55                                           String toscaNodeType) {
56         super(action);
57         this.event = new ResourceAdminEvent(getAction().getName(), commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier,
58                 artifactData, comment, did, toscaNodeType);
59     }
60
61     @Override
62     public AuditingGenericEvent getDbEvent() {
63         return event;
64     }
65
66 }