Reformat catalog-be
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / auditing / impl / resourceadmin / AuditResourceEventFactoryManager.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 package org.openecomp.sdc.be.auditing.impl.resourceadmin;
21
22 import org.openecomp.sdc.be.auditing.api.AuditEventFactory;
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.model.CommonAuditData;
27 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceCommonInfo;
28 import org.openecomp.sdc.be.resources.data.auditing.model.ResourceVersionInfo;
29
30 public class AuditResourceEventFactoryManager {
31
32     public static AuditEventFactory createResourceEventFactory(AuditingActionEnum action, CommonAuditData commonFields,
33                                                                ResourceCommonInfo resourceCommonInfo, ResourceVersionInfo prevParams,
34                                                                ResourceVersionInfo currParams, String invariantUuid, User modifier,
35                                                                String artifactData, String comment, String did, String toscaNodeType) {
36         AuditBaseEventFactory factory = null;
37         switch (action) {
38             case IMPORT_RESOURCE:
39                 factory = new AuditImportResourceAdminEventFactory(commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid, modifier,
40                     artifactData, comment, did, toscaNodeType);
41                 break;
42             case CREATE_RESOURCE:
43             case CREATE_SERVICE:
44             case UPDATE_RESOURCE_METADATA:
45             case ARCHIVE_COMPONENT:
46             case RESTORE_COMPONENT:
47             case UPDATE_SERVICE_METADATA:
48                 factory = new AuditCreateUpdateResourceAdminEventFactory(action, commonFields, resourceCommonInfo, prevParams, currParams,
49                     invariantUuid, modifier, artifactData, comment, did, org.openecomp.sdc.common.api.Constants.EMPTY_STRING);
50                 break;
51             case CHECKIN_RESOURCE:
52             case CHECKOUT_RESOURCE:
53             case UNDO_CHECKOUT_RESOURCE:
54             case CERTIFICATION_REQUEST_RESOURCE:
55             case START_CERTIFICATION_RESOURCE:
56             case CERTIFICATION_SUCCESS_RESOURCE:
57             case FAIL_CERTIFICATION_RESOURCE:
58             case CANCEL_CERTIFICATION_RESOURCE:
59             case UPDATE_SERVICE_REFERENCE:
60             case VF_UPGRADE_SERVICES:
61                 factory = new AuditCertificationResourceAdminEventFactory(action, commonFields, resourceCommonInfo, prevParams, currParams,
62                     invariantUuid, modifier, artifactData, comment, did);
63                 break;
64             case ARTIFACT_UPLOAD:
65             case ARTIFACT_DELETE:
66             case ARTIFACT_METADATA_UPDATE:
67             case ARTIFACT_PAYLOAD_UPDATE:
68             case ARTIFACT_DOWNLOAD:
69                 factory = new AuditArtifactResourceAdminEventFactory(action, commonFields, resourceCommonInfo, prevParams, currParams, invariantUuid,
70                     modifier, artifactData, comment, did);
71                 break;
72             case DISTRIBUTION_STATE_CHANGE_REQUEST:
73                 factory = new AuditDistStateChangeRequestResourceAdminEventFactory(commonFields, resourceCommonInfo, prevParams, currParams,
74                     invariantUuid, modifier, artifactData, comment, did);
75                 break;
76             case DISTRIBUTION_STATE_CHANGE_APPROV:
77             case DISTRIBUTION_STATE_CHANGE_REJECT:
78                 factory = new AuditDistStateChangeResourceAdminEventFactory(action, commonFields, resourceCommonInfo, prevParams, currParams,
79                     invariantUuid, modifier, artifactData, comment, did);
80                 break;
81             default:
82                 throw new UnsupportedOperationException();
83         }
84         return factory;
85     }
86 }