Feature for micro service communication
[appc.git] / appc-sdc-listener / appc-sdc-listener-bundle / src / main / java / org / onap / appc / sdc / artifacts / impl / ArtifactProcessorFactory.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.appc.sdc.artifacts.impl;
24
25 import com.att.eelf.configuration.EELFLogger;
26 import com.att.eelf.configuration.EELFManager;
27 import org.onap.appc.adapter.message.EventSender;
28 import org.onap.appc.sdc.artifacts.ArtifactProcessor;
29 import org.onap.appc.sdc.artifacts.object.ArtifactType;
30 import org.onap.sdc.api.IDistributionClient;
31 import org.onap.sdc.api.notification.IArtifactInfo;
32 import org.onap.sdc.api.notification.INotificationData;
33 import org.onap.sdc.api.notification.IResourceInstance;
34
35 import java.net.URI;
36
37 /**
38  * Factory class for creating instance of Artifact Processor
39  */
40 public class ArtifactProcessorFactory {
41
42     private static final EELFLogger logger = EELFManager.getInstance().getLogger(ArtifactProcessorFactory.class);
43
44     public ArtifactProcessorFactory (){
45
46     }
47
48     /**
49      * Provides and instance of Artifact Processor
50      * @param client an instance of IDistributionClient
51      * @param eventSender an instance of EventSender
52      * @param notification an instance of INotificationData
53      * @param resource an instance of IResourceInstance
54      * @param artifact an instance of IArtifactInfo
55      * @param storeUri
56      * @return
57      */
58     public ArtifactProcessor getArtifactProcessor(IDistributionClient client, EventSender eventSender,
59                                                          INotificationData notification, IResourceInstance resource,
60                                                          IArtifactInfo artifact, URI storeUri) {
61
62         logger.debug("Creating artifact processor for artifact type = " + artifact.getArtifactType());
63         ArtifactType artifactType = ArtifactType.getArtifactType(artifact.getArtifactType());
64         if(artifactType == null){
65             return null;
66         }
67         ArtifactProcessor artifactProcessor = null;
68         switch (artifactType){
69             case APPC_CONFIG :
70                 artifactProcessor = new ConfigArtifactProcessor(client, eventSender, notification, resource,
71                         artifact, storeUri);
72                 break;
73             case VF_LICENSE:
74                 artifactProcessor = new LicenseArtifactProcessor(client,eventSender,notification,resource,
75                         artifact,storeUri);
76                 break;
77             default:
78                 break;
79         }
80         return artifactProcessor;
81     }
82
83 }