e13212600e5e48ae36c2756afe0ce139f3f85e48
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 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.appc.dg.mock.instance;
22
23 import java.io.FileNotFoundException;
24 import java.io.IOException;
25 import java.util.Map;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31 import org.openecomp.sdnc.sli.SvcLogicContext;
32 import org.openecomp.sdnc.sli.SvcLogicException;
33 import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
34
35 public class MockSvcLogicJavaPlugin implements SvcLogicJavaPlugin{
36         private final static Logger logger = LoggerFactory.getLogger(MockSvcLogicJavaPlugin.class);
37         public static String INPUT_PARAM_RESPONSE_PREFIX = "responsePrefix";
38         public static String OUTPUT_STATUS_SUCCESS = "success";
39         public static String OUTPUT_STATUS_FAILURE = "failure";
40         public static String OUTPUT_PARAM_STATUS = "status";
41         
42
43         public void mountDevice(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException{
44                 logger.info("Executed MountDevice Plugin");
45         }
46
47         public void downloadDeviceConfiguration(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException{
48                 ctx.setAttribute("downloadStatus", "success");
49                 logger.info("Executed Download Device Configuration Plugin");
50                 throw new SvcLogicException("failed in Download..");
51         }
52
53
54         
55         
56         public void getCommonConfigInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException, FileNotFoundException, IOException {
57                 logger.info("Mock getCommonConfigInfo Called....");
58                 
59         
60                 /***
61                 ctx.setAttribute("device-authentication.USER-NAME", "root");
62                 
63                 String responsePrefix = inParams.get(INPUT_PARAM_RESPONSE_PREFIX);
64                 responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : "";
65                 
66                 
67                 ctx.setAttribute(responsePrefix +OUTPUT_PARAM_STATUS,
68                                 OUTPUT_STATUS_SUCCESS);
69                                 
70                 **/
71                 
72         }
73
74         
75         public void getConfigFileReference(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
76                 logger.info("Mock getConfigFileReference Called....");
77         }
78         
79         
80         
81         public void getTemplate(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
82
83                 logger.info("Mock getTemplate Called....");
84         }
85         
86         
87         
88         public void saveConfigFiles(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
89
90                 logger.info("Mock saveConfigFiles called...");
91                 
92         }
93         
94         
95         
96         public void updateUploadConfig(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
97
98                 logger.info("Mock updateUploadConfig called...");
99         }
100         
101         
102         
103         
104         public void savePrepareRelationship(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
105                 logger.info("Mock savePrepareRelationship called...");
106         }
107         
108         
109         
110         
111         
112         public void saveConfigBlock(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
113                 logger.info("Mock saveConfigBlock called...");
114                 
115                 if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
116                         logger.info("No params...");
117                         ctx.setAttribute("file-category", "device_configuration");
118                         ctx.setAttribute("deviceconfig-file-content", "deviceConfig");
119                 
120                 } else {
121                         logger.info("Config params exist...");
122                         ctx.setAttribute("file-category", "device_configuration");
123                         ctx.setAttribute("file-category1", "configuration_block");
124                         ctx.setAttribute("file-category2", "config_data");
125                         
126                 }
127         
128         }
129         
130         public void saveTemplateConfig(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
131                 
132                 logger.info("Mock saveTemplateConfig called...");
133                 
134                 if (StringUtils.isBlank(ctx.getAttribute("configuration-params"))) {
135                         logger.info("No params...");
136                         ctx.setAttribute("file-category", "device_configuration");
137                         ctx.setAttribute("deviceconfig-file-content", "deviceConfig");
138                 
139                 } else {
140                         logger.info("Config params exist...");
141                         ctx.setAttribute("file-category", "device_configuration");
142                         ctx.setAttribute("file-category1", "config_data");
143                         
144                 }
145                 
146                 
147         }
148 }