[sdc] update to the current code base
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / InputsServlet.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.be.servlets;
22
23 import java.util.List;
24
25 import javax.inject.Singleton;
26 import javax.servlet.ServletContext;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.ws.rs.Consumes;
29 import javax.ws.rs.DELETE;
30 import javax.ws.rs.GET;
31 import javax.ws.rs.HeaderParam;
32 import javax.ws.rs.POST;
33 import javax.ws.rs.PUT;
34 import javax.ws.rs.Path;
35 import javax.ws.rs.PathParam;
36 import javax.ws.rs.Produces;
37 import javax.ws.rs.QueryParam;
38 import javax.ws.rs.core.Context;
39 import javax.ws.rs.core.MediaType;
40 import javax.ws.rs.core.Response;
41
42 import org.codehaus.jackson.map.ObjectMapper;
43 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
44 import org.openecomp.sdc.be.components.impl.InputsBusinessLogic;
45 import org.openecomp.sdc.be.config.BeEcompErrorManager;
46 import org.openecomp.sdc.be.dao.api.ActionStatus;
47 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
48 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
49 import org.openecomp.sdc.be.model.ComponentInstInputsMap;
50 import org.openecomp.sdc.be.model.ComponentInstanceInput;
51 import org.openecomp.sdc.be.model.ComponentInstanceProperty;
52 import org.openecomp.sdc.be.model.InputDefinition;
53 import org.openecomp.sdc.be.model.Resource;
54 import org.openecomp.sdc.be.model.User;
55 import org.openecomp.sdc.be.resources.data.auditing.AuditingActionEnum;
56 import org.openecomp.sdc.common.api.Constants;
57 import org.openecomp.sdc.common.config.EcompErrorName;
58 import org.openecomp.sdc.common.datastructure.Wrapper;
59 import org.openecomp.sdc.exception.ResponseFormat;
60 import org.slf4j.Logger;
61 import org.slf4j.LoggerFactory;
62 import org.springframework.web.context.WebApplicationContext;
63
64 import com.jcabi.aspects.Loggable;
65 import com.wordnik.swagger.annotations.Api;
66 import com.wordnik.swagger.annotations.ApiOperation;
67 import com.wordnik.swagger.annotations.ApiParam;
68 import com.wordnik.swagger.annotations.ApiResponse;
69 import com.wordnik.swagger.annotations.ApiResponses;
70
71 import fj.data.Either;
72
73 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
74 @Path("/v1/catalog")
75 @Api(value = "Input Catalog", description = "Input Servlet")
76 @Singleton
77 public class InputsServlet extends AbstractValidationsServlet {
78
79         private static Logger log = LoggerFactory.getLogger(ProductServlet.class.getName());
80
81         @GET
82         @Path("/services/{componentId}/inputs")
83         @Consumes(MediaType.APPLICATION_JSON)
84         @Produces(MediaType.APPLICATION_JSON)
85         @ApiOperation(value = "Get Inputs only", httpMethod = "GET", notes = "Returns Inputs list", response = Resource.class)
86         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
87         public Response getComponentInputs(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @Context final HttpServletRequest request, @QueryParam("fromId") String fromName,
88                         @QueryParam("amount") int amount, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
89
90                 ServletContext context = request.getSession().getServletContext();
91                 String url = request.getMethod() + " " + request.getRequestURI();
92                 log.debug("(get) Start handle request of {}", url);
93                 Response response = null;
94
95                 try {
96
97                         InputsBusinessLogic businessLogic = getInputBL(context);
98
99                         Either<List<InputDefinition>, ResponseFormat> inputsResponse = businessLogic.getInputs(userId, componentId, fromName, amount);
100                         if (inputsResponse.isRight()) {
101                                 log.debug("failed to get inputs {}", componentType);
102                                 return buildErrorResponse(inputsResponse.right().value());
103                         }
104                         Object inputs = RepresentationUtils.toRepresentation(inputsResponse.left().value());
105                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), inputs);
106
107                 } catch (Exception e) {
108                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Get Component Instance Inputs" + componentType);
109                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Inputs " + componentType);
110                         log.debug("getInputs failed with exception", e);
111                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
112                         return response;
113
114                 }
115         }
116         
117
118         @POST
119         @Path("/{containerComponentType}/{componentId}/update/inputs")
120         @Consumes(MediaType.APPLICATION_JSON)
121         @Produces(MediaType.APPLICATION_JSON)
122         @ApiOperation(value = "Update resource  inputs", httpMethod = "POST", notes = "Returns updated input", response = Response.class)
123         @ApiResponses(value = { @ApiResponse(code = 200, message = "Input updated"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 400, message = "Invalid content / Missing content") })
124         public Response updateComponentInputs(
125                         @ApiParam(value = "valid values: resources / services", allowableValues = ComponentTypeEnum.RESOURCE_PARAM_NAME + "," + ComponentTypeEnum.SERVICE_PARAM_NAME) @PathParam("containerComponentType") final String containerComponentType,
126                         @PathParam("componentId") final String componentId, 
127                         @ApiParam(value = "json describe the input", required = true) String data, @Context final HttpServletRequest request) {
128
129
130                 String url = request.getMethod() + " " + request.getRequestURI();
131                 log.debug("Start handle request of {}", url);
132                 String userId = request.getHeader(Constants.USER_ID_HEADER);
133
134                 try {
135                         User modifier = new User();
136                         modifier.setUserId(userId);
137                         log.debug("modifier id is {}", userId);
138
139                         Either<InputDefinition, ResponseFormat> inputEither = getComponentsUtils().convertJsonToObjectUsingObjectMapper(data, modifier, InputDefinition.class, AuditingActionEnum.UPDATE_RESOURCE_METADATA, ComponentTypeEnum.SERVICE);;
140                         if(inputEither.isRight()){
141                                 log.debug("Failed to convert data to input definition. Status is {}", inputEither.right().value());
142                                 return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
143                         }
144                         InputDefinition input = inputEither.left().value();
145
146                         log.debug("Start handle request of updateResourceInstanceProperty. Received property is {}", input);
147
148                         ServletContext context = request.getSession().getServletContext();
149                         ComponentTypeEnum componentType = ComponentTypeEnum.findByParamName(containerComponentType);
150                         
151                         InputsBusinessLogic businessLogic = getInputBL(context);
152                         if (businessLogic == null) {
153                                 log.debug("Unsupported component type {}", containerComponentType);
154                                 return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.UNSUPPORTED_ERROR));
155                         }
156
157                         Either<InputDefinition, ResponseFormat> actionResponse = businessLogic.updateInputValue(componentType, componentId, input, userId, true, false);
158
159                         if (actionResponse.isRight()) {
160                                 return buildErrorResponse(actionResponse.right().value());
161                         }
162
163                         InputDefinition resourceInstanceProperty = actionResponse.left().value();
164                         ObjectMapper mapper = new ObjectMapper();
165                         String result = mapper.writeValueAsString(resourceInstanceProperty);
166                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), result);
167
168                 } catch (Exception e) {
169                         log.error("create and associate RI failed with exception: {}", e.getMessage(), e);
170                         return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
171                 }
172         }
173
174
175         @GET
176         @Path("/{componentType}/{componentId}/componentInstances/{instanceId}/{originComponentUid}/inputs")
177         @Consumes(MediaType.APPLICATION_JSON)
178         @Produces(MediaType.APPLICATION_JSON)
179         @ApiOperation(value = "Get Inputs only", httpMethod = "GET", notes = "Returns Inputs list", response = Resource.class)
180         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
181         public Response getComponentInstanceInputs(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @PathParam("instanceId") final String instanceId,
182                         @PathParam("originComponentUid") final String originComonentUid, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
183
184                 ServletContext context = request.getSession().getServletContext();
185                 String url = request.getMethod() + " " + request.getRequestURI();
186                 log.debug("(get) Start handle request of {}", url);
187                 Response response = null;
188
189                 try {
190                         InputsBusinessLogic businessLogic = getInputBL(context);
191
192                         Either<List<ComponentInstanceInput>, ResponseFormat> inputsResponse = businessLogic.getComponentInstanceInputs(userId, componentId, instanceId);
193                         if (inputsResponse.isRight()) {
194                                 log.debug("failed to get component instance inputs {}", componentType);
195                                 return buildErrorResponse(inputsResponse.right().value());
196                         }
197                         Object inputs = RepresentationUtils.toRepresentation(inputsResponse.left().value());
198                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), inputs);
199
200                 } catch (Exception e) {
201                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Get Component Instance Inputs" + componentType);
202                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Inputs " + componentType);
203                         log.debug("getInputs failed with exception", e);
204                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
205                         return response;
206
207                 }
208         }
209
210         @GET
211         @Path("/{componentType}/{componentId}/componentInstances/{instanceId}/{inputId}/properties")
212         @Consumes(MediaType.APPLICATION_JSON)
213         @Produces(MediaType.APPLICATION_JSON)
214         @ApiOperation(value = "Get properties", httpMethod = "GET", notes = "Returns properties list", response = Resource.class)
215         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
216         public Response getInputPropertiesForComponentInstance(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @PathParam("instanceId") final String instanceId,
217                         @PathParam("inputId") final String inputId, @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
218
219                 ServletContext context = request.getSession().getServletContext();
220                 String url = request.getMethod() + " " + request.getRequestURI();
221                 log.debug("(GET) Start handle request of {}", url);
222                 Response response = null;
223
224                 try {
225                         InputsBusinessLogic businessLogic = getInputBL(context);
226
227                         Either<List<ComponentInstanceProperty>, ResponseFormat> inputPropertiesRes = businessLogic.getComponentInstancePropertiesByInputId(userId, componentId, instanceId, inputId);
228                         if (inputPropertiesRes.isRight()) {
229                                 log.debug("failed to get properties of input: {}, with instance id: {}", inputId, instanceId);
230                                 return buildErrorResponse(inputPropertiesRes.right().value());
231                         }
232                         Object properties = RepresentationUtils.toRepresentation(inputPropertiesRes.left().value());
233                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), properties);
234
235                 } catch (Exception e) {
236                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Get properties by input id {}, for component instance {} ", inputId, instanceId);
237                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Properites by input id: " + inputId + " for instance with id: " + instanceId);
238                         log.debug("getInputPropertiesForComponentInstance failed with exception", e);
239                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
240                         return response;
241
242                 }
243         }
244
245         @GET
246         @Path("/{componentType}/{componentId}/inputs/{inputId}/inputs")
247         @Consumes(MediaType.APPLICATION_JSON)
248         @Produces(MediaType.APPLICATION_JSON)
249         @ApiOperation(value = "Get inputs", httpMethod = "GET", notes = "Returns inputs list", response = Resource.class)
250         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
251         public Response getInputsForComponentInput(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @PathParam("inputId") final String inputId, @Context final HttpServletRequest request,
252                         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
253
254                 ServletContext context = request.getSession().getServletContext();
255                 String url = request.getMethod() + " " + request.getRequestURI();
256                 log.debug("(get) Start handle request of {}", url);
257                 Response response = null;
258
259                 try {
260                         InputsBusinessLogic businessLogic = getInputBL(context);
261
262                         Either<List<ComponentInstanceInput>, ResponseFormat> inputsRes = businessLogic.getInputsForComponentInput(userId, componentId, inputId);
263                         
264                         if (inputsRes.isRight()) {
265                                 log.debug("failed to get inputs of input: {}, with instance id: {}", inputId, componentId);
266                                 return buildErrorResponse(inputsRes.right().value());
267                         }
268                         Object properties = RepresentationUtils.toRepresentation(inputsRes.left().value());
269                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), properties);
270
271                 } catch (Exception e) {
272                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Get inputs by input id {}, for component {} ", inputId, componentId);
273                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get inputs by input id: " + inputId + " for component with id: " + componentId);
274                         log.debug("getInputsForComponentInput failed with exception", e);
275                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
276                         return response;
277
278                 }
279         }
280         
281         @GET
282         @Path("/{componentType}/{componentId}/inputs/{inputId}")
283         @Consumes(MediaType.APPLICATION_JSON)
284         @Produces(MediaType.APPLICATION_JSON)
285         @ApiOperation(value = "Get inputs", httpMethod = "GET", notes = "Returns inputs list", response = Resource.class)
286         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
287         public Response getInputsAndPropertiesForComponentInput(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @PathParam("inputId") final String inputId, @Context final HttpServletRequest request,
288                         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
289
290                 ServletContext context = request.getSession().getServletContext();
291                 String url = request.getMethod() + " " + request.getRequestURI();
292                 log.debug("(get) Start handle request of {}", url);
293                 Response response = null;
294
295                 try {
296                         InputsBusinessLogic businessLogic = getInputBL(context);
297
298                         Either<InputDefinition, ResponseFormat> inputsRes = businessLogic.getInputsAndPropertiesForComponentInput(userId, componentId, inputId, false);
299                         
300                         if (inputsRes.isRight()) {
301                                 log.debug("failed to get inputs of input: {}, with instance id: {}", inputId, componentId);
302                                 return buildErrorResponse(inputsRes.right().value());
303                         }
304                         Object properties = RepresentationUtils.toRepresentation(inputsRes.left().value());
305                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), properties);
306
307                 } catch (Exception e) {
308                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Get inputs by input id {}, for component {} ", inputId, componentId);
309                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get inputs by input id: " + inputId + " for component with id: " + componentId);
310                         log.debug("getInputsForComponentInput failed with exception", e);
311                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
312                         return response;
313
314                 }
315         }
316
317         public Either<ComponentInstInputsMap, ResponseFormat> parseToComponentInstanceMap(String serviceJson, User user) {
318                 return getComponentsUtils().convertJsonToObjectUsingObjectMapper(serviceJson, user, ComponentInstInputsMap.class, AuditingActionEnum.CREATE_RESOURCE, ComponentTypeEnum.SERVICE);
319         }
320
321         @POST
322         @Path("/{componentType}/{componentId}/create/inputs")
323         @Consumes(MediaType.APPLICATION_JSON)
324         @Produces(MediaType.APPLICATION_JSON)
325         @ApiOperation(value = "Create inputs on service", httpMethod = "POST", notes = "Return inputs list", response = Resource.class)
326         @ApiResponses(value = { @ApiResponse(code = 200, message = "Component found"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Component not found") })
327         public Response createMultipleInputs(@PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId, @Context final HttpServletRequest request,
328                         @HeaderParam(value = Constants.USER_ID_HEADER) String userId, @ApiParam(value = "ComponentIns Inputs Object to be created", required = true) String componentInstInputsMapObj) {
329
330                 ServletContext context = request.getSession().getServletContext();
331                 String url = request.getMethod() + " " + request.getRequestURI();
332                 log.debug("(get) Start handle request of {}", url);
333                 Response response = null;
334
335                 try {
336                         InputsBusinessLogic businessLogic = getInputBL(context);
337
338                         // get modifier id
339                         User modifier = new User();
340                         modifier.setUserId(userId);
341                         log.debug("modifier id is {}", userId);
342
343                         Either<ComponentInstInputsMap, ResponseFormat> componentInstInputsMapRes = parseToComponentInstanceMap(componentInstInputsMapObj, modifier);
344                         if (componentInstInputsMapRes.isRight()) {
345                                 log.debug("failed to parse componentInstInputsMap");
346                                 response = buildErrorResponse(componentInstInputsMapRes.right().value());
347                                 return response;
348                         }
349
350                         ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
351                         ComponentInstInputsMap componentInstInputsMap = componentInstInputsMapRes.left().value();
352
353                         Either<List<InputDefinition>, ResponseFormat> inputPropertiesRes = businessLogic.createMultipleInputs(userId, componentId, componentTypeEnum, componentInstInputsMap, true, false);
354                         if (inputPropertiesRes.isRight()) {
355                                 log.debug("failed to create inputs  for service: {}", componentId);
356                                 return buildErrorResponse(inputPropertiesRes.right().value());
357                         }
358                         Object properties = RepresentationUtils.toRepresentation(inputPropertiesRes.left().value());
359                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), properties);
360
361                 } catch (Exception e) {
362                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Create inputs for service with id: {}", componentId);
363                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Create inputs for service with id: " + componentId);
364                         log.debug("createMultipleInputs failed with exception", e);
365                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
366                         return response;
367
368                 }
369         }
370         
371
372         
373         @DELETE
374         @Path("/{componentType}/{componentId}/delete/{inputId}/input")
375         @Consumes(MediaType.APPLICATION_JSON)
376         @Produces(MediaType.APPLICATION_JSON)
377         @ApiOperation(value = "Delete input from service", httpMethod = "DELETE", notes = "Delete service input", response = Resource.class)
378         @ApiResponses(value = { @ApiResponse(code = 200, message = "Input deleted"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Input not found") })
379         public Response deleteInput (
380                         @PathParam("componentType") final String componentType,
381                         @PathParam("componentId") final String componentId,
382                         @PathParam("inputId") final String inputId,
383             @Context final HttpServletRequest request,
384             @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
385             @ApiParam(value = "Service Input to be deleted", required = true) String componentInstInputsMapObj) {
386
387                 ServletContext context = request.getSession().getServletContext();
388                 String url = request.getMethod() + " " + request.getRequestURI();
389                 log.debug("(get) Start handle request of {}", url);
390                 Response response = null;
391
392                 try {
393                         InputsBusinessLogic businessLogic = getInputBL(context);
394                         Either<InputDefinition, ResponseFormat> deleteInput = businessLogic.deleteInput(componentType, componentId, userId, inputId);
395                         if (deleteInput.isRight()){
396                                 ResponseFormat deleteResponseFormat = deleteInput.right().value();
397                                 response = buildErrorResponse(deleteResponseFormat);
398                                 return response;
399                         }               
400                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), deleteInput.left().value());
401                 } catch (Exception e){
402                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Delete input for service {} with id: {}", componentId, inputId);
403                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete input for service + " + componentId + " + with id: " + inputId);
404                         log.debug("Delete input failed with exception", e);
405                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
406                         return response;
407
408                 }
409         }
410         
411         
412         
413         /*@PUT
414         @Path("/{componentType}/{componentId}/edit/{inputId}/input")
415         @Consumes(MediaType.APPLICATION_JSON)
416         @Produces(MediaType.APPLICATION_JSON)
417         @ApiOperation(value = "Delete input from service", httpMethod = "DELETE", notes = "Delete service input", response = Resource.class)
418         @ApiResponses(value = { @ApiResponse(code = 200, message = "Input deleted"), @ApiResponse(code = 403, message = "Restricted operation"), @ApiResponse(code = 404, message = "Input not found") })
419         public Response editInputValue (
420                         @PathParam("componentType") final String componentType,
421                         @PathParam("componentId") final String componentId,
422                         @PathParam("inputId") final String inputId,
423             @Context final HttpServletRequest request,
424             @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
425
426                 ServletContext context = request.getSession().getServletContext();
427                 String url = request.getMethod() + " " + request.getRequestURI();
428                 log.debug("(get) Start handle request of {}", url);
429                 Response response = null;
430
431                 try {
432                         InputsBusinessLogic businessLogic = getInputBL(context);
433                         Either<InputDefinition, ResponseFormat> deleteInput = businessLogic.deleteInput(componentType, componentId, userId, inputId);
434                         if (deleteInput.isRight()){
435                                 ResponseFormat deleteResponseFormat = deleteInput.right().value();
436                                 response = buildErrorResponse(deleteResponseFormat);
437                                 return response;
438                         }               
439                         return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), deleteInput.left().value());
440                 } catch (Exception e){
441                         BeEcompErrorManager.getInstance().processEcompError(EcompErrorName.BeRestApiGeneralError, "Delete input for service {} with id: {}", componentId, inputId);
442                         BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete input for service + " + componentId + " + with id: " + inputId);
443                         log.debug("Delete input failed with exception", e);
444                         response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
445                         return response;
446
447                 }
448         }*/
449         
450         protected InputsBusinessLogic getInputBL(ServletContext context) {
451
452                 WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
453                 WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
454                 InputsBusinessLogic inputsBusinessLogic = webApplicationContext.getBean(InputsBusinessLogic.class);
455                 return inputsBusinessLogic;
456         }
457
458 }