5e5f78a53ae53f561a64b523cf99fbd25d8484a4
[appc.git] / appc-inbound / appc-design-services / provider / src / main / java / org / onap / appc / design / dbervices / DbResponseProcessor.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  * 
21  * ============LICENSE_END=========================================================
22  */
23
24 package org.onap.appc.design.dbervices;
25
26 import org.onap.appc.design.services.util.DesignServiceConstants;
27
28 import com.att.eelf.configuration.EELFLogger;
29 import com.att.eelf.configuration.EELFManager;
30
31 public class DbResponseProcessor {
32
33     private static final EELFLogger log = EELFManager.getInstance().getLogger(DbResponseProcessor.class);
34     public String parseResponse(String dbresposne, String action) throws Exception {
35         
36         log.info("Starting Parsing the response for action :[" + action +  "]\n data:[" + dbresposne +"]" );
37         String response ;         
38         switch (action) {
39         case DesignServiceConstants.GETDESIGNS:
40             response =  getDesignsResponse(dbresposne);
41             break;
42         case DesignServiceConstants.GETAPPCTIMESTAMPUTC:
43             response = getAppcTimestampResponse(dbresposne);
44             break;
45         case DesignServiceConstants.ADDINCART:
46             response =  getAddInCartResponse(dbresposne);
47             break ;
48         case DesignServiceConstants.GETARTIFACTREFERENCE:
49             response=  getArtifactReferenceResponse(dbresposne);
50             break;
51         case DesignServiceConstants.GETARTIFACT:
52             response=  getArtifactResponse(dbresposne);
53             break;
54         case DesignServiceConstants.GETGUIREFERENCE:
55             response=  getGuiReferenceResponse(dbresposne);
56             break;
57         case DesignServiceConstants.GETSTATUS:
58             response=  getStatusResponse(dbresposne);
59             break;
60         case DesignServiceConstants.UPLOADARTIFACT:
61             response=  getsetStatusResponse(dbresposne);
62             break;    
63         case DesignServiceConstants.SETPROTOCOLREFERENCE:
64             response=  getsetStatusResponse(dbresposne);
65             break;    
66         case DesignServiceConstants.SETINCART:
67             response=  getsetStatusResponse(dbresposne);
68             break;    
69         case DesignServiceConstants.UPLOADADMINARTIFACT:
70            response=  getsetStatusResponse(dbresposne);
71            break;
72         case DesignServiceConstants.CHECKVNF:
73            response=  getStatusResponse(dbresposne);
74            break;
75         default:
76             log.error("Action " + action + " Not Supported by response Parser");
77             throw new Exception(" Action " + action + " not found while processing request ");
78
79         }        
80         return response;            
81
82     }
83
84     private String getArtifactResponse(String dbresposne) {
85         // TODO Auto-generated method stub
86         return dbresposne;
87     }
88
89     private String getsetStatusResponse(String dbresposne) {
90         // TODO Auto-generated method stub
91         return null;
92     }
93
94     private String getStatusResponse(String dbresposne) {
95         log.info("Returning reposne from Response Parser " + dbresposne);
96         return dbresposne;
97     }
98
99     private String getGuiReferenceResponse(String dbresposne) {
100         // TODO Auto-generated method stub
101         return null;
102     }
103
104     private String getArtifactReferenceResponse(String dbresposne) {
105         // TODO Auto-generated method stub
106         return null;
107     }
108
109     private String getAddInCartResponse(String dbresposne) {
110         // TODO Auto-generated method stub
111         return null;
112     }
113
114     private String getDesignsResponse(String dbresposne) {
115         return dbresposne;
116         
117     }
118
119     private String getAppcTimestampResponse(String dbresposne) {
120         log.info("getAppcTimestampResponse:["  + dbresposne +"]" );
121         return dbresposne;
122     }
123 }