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