d9e5aed187e9cb8f7c4c5b7ead3199d10bba57aa
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / AdditionalInformationServlet.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 package org.openecomp.sdc.be.servlets;
21
22 import com.jcabi.aspects.Loggable;
23 import fj.data.Either;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.media.ArraySchema;
27 import io.swagger.v3.oas.annotations.media.Content;
28 import io.swagger.v3.oas.annotations.media.Schema;
29 import io.swagger.v3.oas.annotations.responses.ApiResponse;
30 import io.swagger.v3.oas.annotations.servers.Server;
31 import io.swagger.v3.oas.annotations.servers.Servers;
32 import io.swagger.v3.oas.annotations.tags.Tag;
33 import io.swagger.v3.oas.annotations.tags.Tags;
34 import javax.inject.Inject;
35 import javax.servlet.ServletContext;
36 import javax.servlet.http.HttpServletRequest;
37 import javax.ws.rs.Consumes;
38 import javax.ws.rs.DELETE;
39 import javax.ws.rs.GET;
40 import javax.ws.rs.HeaderParam;
41 import javax.ws.rs.POST;
42 import javax.ws.rs.PUT;
43 import javax.ws.rs.Path;
44 import javax.ws.rs.PathParam;
45 import javax.ws.rs.Produces;
46 import javax.ws.rs.core.Context;
47 import javax.ws.rs.core.MediaType;
48 import javax.ws.rs.core.Response;
49 import org.openecomp.sdc.be.components.impl.AdditionalInformationBusinessLogic;
50 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
51 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
52 import org.openecomp.sdc.be.config.BeEcompErrorManager;
53 import org.openecomp.sdc.be.dao.api.ActionStatus;
54 import org.openecomp.sdc.be.datatypes.elements.AdditionalInfoParameterInfo;
55 import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
56 import org.openecomp.sdc.be.impl.ComponentsUtils;
57 import org.openecomp.sdc.be.model.AdditionalInformationDefinition;
58 import org.openecomp.sdc.be.user.UserBusinessLogic;
59 import org.openecomp.sdc.common.api.Constants;
60 import org.openecomp.sdc.common.log.wrappers.Logger;
61 import org.openecomp.sdc.exception.ResponseFormat;
62 import org.springframework.stereotype.Controller;
63
64 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
65 @Path("/v1/catalog")
66 @Tags({@Tag(name = "SDC Internal APIs")})
67 @Servers({@Server(url = "/sdc2/rest")})
68 @Controller
69 public class AdditionalInformationServlet extends BeGenericServlet {
70
71     private static final Logger log = Logger.getLogger(AdditionalInformationServlet.class);
72     private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}";
73     private static final String MODIFIER_ID_IS = "modifier id is {}";
74     private static final String FAILED_TO_UPDATE_ADDITIONAL_INFO_PROPERTY = "Failed to update additional information property. Reason - {}";
75     private final AdditionalInformationBusinessLogic businessLogic;
76
77     @Inject
78     public AdditionalInformationServlet(UserBusinessLogic userBusinessLogic, ComponentsUtils componentsUtils,
79                                         AdditionalInformationBusinessLogic businessLogic) {
80         super(userBusinessLogic, componentsUtils);
81         this.businessLogic = businessLogic;
82     }
83
84     /**
85      * @param resourceId
86      * @param data
87      * @param request
88      * @param userUserId
89      * @return
90      */
91     @POST
92     @Path("/resources/{resourceId}/additionalinfo")
93     @Consumes(MediaType.APPLICATION_JSON)
94     @Produces(MediaType.APPLICATION_JSON)
95     @Operation(description = "Create Additional Information Label and Value", method = "POST", summary = "Returns created Additional Inforamtion property", responses = {
96         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
97         @ApiResponse(responseCode = "201", description = "Additional information created"),
98         @ApiResponse(responseCode = "403", description = "Restricted operation"),
99         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
100         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
101     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
102     public Response createResourceAdditionalInformationLabel(
103         @Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
104         @Parameter(description = "Additional information key value to be created", required = true) String data,
105         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userUserId) {
106         return createAdditionalInformationLabelForComponent(NodeTypeEnum.Resource, resourceId, request, userUserId, data);
107     }
108
109     /**
110      * @param serviceId
111      * @param data
112      * @param request
113      * @param userUserId
114      * @return
115      */
116     @POST
117     @Path("/services/{serviceId}/additionalinfo")
118     @Consumes(MediaType.APPLICATION_JSON)
119     @Produces(MediaType.APPLICATION_JSON)
120     @Operation(description = "Create Additional Information Label and Value", method = "POST", summary = "Returns created Additional Inforamtion property", responses = {
121         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
122         @ApiResponse(responseCode = "201", description = "Additional information created"),
123         @ApiResponse(responseCode = "403", description = "Restricted operation"),
124         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
125         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
126     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
127     public Response createServiceAdditionalInformationLabel(
128         @Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
129         @Parameter(description = "Additional information key value to be created", required = true) String data,
130         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userUserId) {
131         return createAdditionalInformationLabelForComponent(NodeTypeEnum.Service, serviceId, request, userUserId, data);
132     }
133
134     /**
135      * @param resourceId
136      * @param labelId
137      * @param data
138      * @param request
139      * @param userId
140      * @return
141      */
142     @PUT
143     @Path("/resources/{resourceId}/additionalinfo/{labelId}")
144     @Consumes(MediaType.APPLICATION_JSON)
145     @Produces(MediaType.APPLICATION_JSON)
146     @Operation(description = "Update Additional Information Label and Value", method = "PUT", summary = "Returns updated Additional Inforamtion property", responses = {
147         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
148         @ApiResponse(responseCode = "200", description = "Additional information updated"),
149         @ApiResponse(responseCode = "403", description = "Restricted operation"),
150         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
151         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
152     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
153     public Response updateResourceAdditionalInformationLabel(
154         @Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
155         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId,
156         @Parameter(description = "Additional information key value to be created", required = true) String data,
157         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
158         return updateAdditionalInformationLabelForComponent(NodeTypeEnum.Resource, resourceId, labelId, request, userId, data);
159     }
160
161     /**
162      * @param serviceId
163      * @param labelId
164      * @param data
165      * @param request
166      * @param userId
167      * @return
168      */
169     @PUT
170     @Path("/services/{serviceId}/additionalinfo/{labelId}")
171     @Consumes(MediaType.APPLICATION_JSON)
172     @Produces(MediaType.APPLICATION_JSON)
173     @Operation(description = "Update Additional Information Label and Value", method = "PUT", summary = "Returns updated Additional Inforamtion property", responses = {
174         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
175         @ApiResponse(responseCode = "200", description = "Additional information updated"),
176         @ApiResponse(responseCode = "403", description = "Restricted operation"),
177         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
178         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
179     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
180     public Response updateServiceAdditionalInformationLabel(
181         @Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
182         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId,
183         @Parameter(description = "Additional information key value to be created", required = true) String data,
184         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
185         return updateAdditionalInformationLabelForComponent(NodeTypeEnum.Service, serviceId, labelId, request, userId, data);
186     }
187
188     /**
189      * @param resourceId
190      * @param labelId
191      * @param request
192      * @param userId
193      * @return
194      */
195     @DELETE
196     @Path("/resources/{resourceId}/additionalinfo/{labelId}")
197     @Consumes(MediaType.APPLICATION_JSON)
198     @Produces(MediaType.APPLICATION_JSON)
199     @Operation(description = "Create Additional Information Label and Value", method = "DELETE", summary = "Returns deleted Additional Inforamtion property", responses = {
200         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
201         @ApiResponse(responseCode = "200", description = "Additional information deleted"),
202         @ApiResponse(responseCode = "403", description = "Restricted operation"),
203         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
204         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
205     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
206     public Response updateResourceAdditionalInformationLabel(
207         @Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
208         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId, @Context final HttpServletRequest request,
209         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
210         return deleteAdditionalInformationLabelForComponent(NodeTypeEnum.Resource, resourceId, labelId, request, userId);
211     }
212
213     /**
214      * @param serviceId
215      * @param labelId
216      * @param request
217      * @param userId
218      * @return
219      */
220     @DELETE
221     @Path("/services/{serviceId}/additionalinfo/{labelId}")
222     @Consumes(MediaType.APPLICATION_JSON)
223     @Produces(MediaType.APPLICATION_JSON)
224     @Operation(description = "Create Additional Information Label and Value", method = "DELETE", summary = "Returns deleted Additional Inforamtion property", responses = {
225         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
226         @ApiResponse(responseCode = "200", description = "Additional information deleted"),
227         @ApiResponse(responseCode = "403", description = "Restricted operation"),
228         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
229         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
230     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
231     public Response deleteServiceAdditionalInformationLabel(
232         @Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
233         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId, @Context final HttpServletRequest request,
234         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
235         return deleteAdditionalInformationLabelForComponent(NodeTypeEnum.Service, serviceId, labelId, request, userId);
236     }
237
238     /**
239      * @param resourceId
240      * @param labelId
241      * @param request
242      * @param userId
243      * @return
244      */
245     @GET
246     @Path("/resources/{resourceId}/additionalinfo/{labelId}")
247     @Consumes(MediaType.APPLICATION_JSON)
248     @Produces(MediaType.APPLICATION_JSON)
249     @Operation(description = "Get Additional Information by id", method = "GET", summary = "Returns Additional Inforamtion property", responses = {
250         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
251         @ApiResponse(responseCode = "200", description = "fetched additional information"),
252         @ApiResponse(responseCode = "403", description = "Restricted operation"),
253         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
254         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
255     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
256     public Response getResourceAdditionalInformationLabel(
257         @Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
258         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId, @Context final HttpServletRequest request,
259         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
260         return getAdditionalInformationLabelForComponent(NodeTypeEnum.Resource, resourceId, labelId, request, userId);
261     }
262
263     /**
264      * @param serviceId
265      * @param labelId
266      * @param request
267      * @param userId
268      * @return
269      */
270     @GET
271     @Path("/services/{serviceId}/additionalinfo/{labelId}")
272     @Consumes(MediaType.APPLICATION_JSON)
273     @Produces(MediaType.APPLICATION_JSON)
274     @Operation(description = "Get Additional Information by id", method = "GET", summary = "Returns Additional Inforamtion property", responses = {
275         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
276         @ApiResponse(responseCode = "200", description = "fetched additional information"),
277         @ApiResponse(responseCode = "403", description = "Restricted operation"),
278         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
279         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
280     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
281     public Response getServiceAdditionalInformationLabel(
282         @Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
283         @Parameter(description = "label id", required = true) @PathParam("labelId") final String labelId, @Context final HttpServletRequest request,
284         @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
285         return getAdditionalInformationLabelForComponent(NodeTypeEnum.Service, serviceId, labelId, request, userId);
286     }
287
288     /**
289      * @param resourceId
290      * @param request
291      * @param userId
292      * @return
293      */
294     @GET
295     @Path("/resources/{resourceId}/additionalinfo")
296     @Consumes(MediaType.APPLICATION_JSON)
297     @Produces(MediaType.APPLICATION_JSON)
298     @Operation(description = "Get all Additional Information under resource", method = "GET", summary = "Returns Additional Inforamtion property", responses = {
299         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
300         @ApiResponse(responseCode = "200", description = "list of additional information"),
301         @ApiResponse(responseCode = "403", description = "Restricted operation"),
302         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
303         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
304     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
305     public Response getAllResourceAdditionalInformationLabel(
306         @Parameter(description = "resource id to update with new property", required = true) @PathParam("resourceId") final String resourceId,
307         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
308         return getAllAdditionalInformationLabelForComponent(NodeTypeEnum.Resource, resourceId, request, userId);
309     }
310
311     /**
312      * @param serviceId
313      * @param request
314      * @param userId
315      * @return
316      */
317     @GET
318     @Path("/services/{serviceId}/additionalinfo")
319     @Consumes(MediaType.APPLICATION_JSON)
320     @Produces(MediaType.APPLICATION_JSON)
321     @Operation(description = "Get all Additional Information under service", method = "GET", summary = "Returns Additional Inforamtion property", responses = {
322         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = Response.class)))),
323         @ApiResponse(responseCode = "200", description = "list of additional information"),
324         @ApiResponse(responseCode = "403", description = "Restricted operation"),
325         @ApiResponse(responseCode = "400", description = "Invalid content / Missing content"),
326         @ApiResponse(responseCode = "409", description = "Additional information key already exist")})
327     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
328     public Response getAllServiceAdditionalInformationLabel(
329         @Parameter(description = "service id to update with new property", required = true) @PathParam("serviceId") final String serviceId,
330         @Context final HttpServletRequest request, @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
331         return getAllAdditionalInformationLabelForComponent(NodeTypeEnum.Service, serviceId, request, userId);
332     }
333
334     /**
335      * Create additional information property under given resource/service
336      *
337      * @param nodeType
338      * @param uniqueId
339      * @param request
340      * @param userId
341      * @param data
342      * @return
343      */
344     protected Response createAdditionalInformationLabelForComponent(NodeTypeEnum nodeType, String uniqueId, HttpServletRequest request, String userId,
345                                                                     String data) {
346         ServletContext context = request.getSession().getServletContext();
347         String url = request.getMethod() + " " + request.getRequestURI();
348         log.debug(START_HANDLE_REQUEST_OF, url);
349         log.debug(MODIFIER_ID_IS, userId);
350         log.debug("data is {}", data);
351         try {
352             // convert json to AdditionalInfoParameterInfo
353             AdditionalInfoParameterInfo additionalInfoParameterInfo = gson.fromJson(data, AdditionalInfoParameterInfo.class);
354             // create the new property
355             Either<AdditionalInfoParameterInfo, ResponseFormat> either = businessLogic
356                 .createAdditionalInformation(nodeType, uniqueId, additionalInfoParameterInfo, userId);
357             if (either.isRight()) {
358                 ResponseFormat responseFormat = either.right().value();
359                 log.info("Failed to create additional information {}. Reason - {}", additionalInfoParameterInfo, responseFormat);
360                 return buildErrorResponse(responseFormat);
361             }
362             AdditionalInfoParameterInfo createdAI = either.left().value();
363             log.debug("Additional information {}={} created successfully with id {}", createdAI.getKey(), createdAI.getValue(),
364                 createdAI.getUniqueId());
365             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.CREATED);
366             return buildOkResponse(responseFormat, createdAI);
367         } catch (Exception e) {
368             log.debug("Create additional information failed with exception", e);
369             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
370             return buildErrorResponse(responseFormat);
371         }
372     }
373
374     /**
375      * Update additional information property by id under given resource/service
376      *
377      * @param nodeType
378      * @param uniqueId
379      * @param labelId
380      * @param request
381      * @param userId
382      * @param data
383      * @return
384      */
385     protected Response updateAdditionalInformationLabelForComponent(NodeTypeEnum nodeType, String uniqueId, String labelId,
386                                                                     HttpServletRequest request, String userId, String data) {
387         ServletContext context = request.getSession().getServletContext();
388         String url = request.getMethod() + " " + request.getRequestURI();
389         log.debug(START_HANDLE_REQUEST_OF, url);
390         log.debug(MODIFIER_ID_IS, userId);
391         log.debug("data is {}", data);
392         try {
393             // convert json to AdditionalInfoParameterInfo
394             AdditionalInfoParameterInfo additionalInfoParameterInfo = gson.fromJson(data, AdditionalInfoParameterInfo.class);
395             // create the new property
396             additionalInfoParameterInfo.setUniqueId(labelId);
397             Either<AdditionalInfoParameterInfo, ResponseFormat> either = businessLogic
398                 .updateAdditionalInformation(nodeType, uniqueId, additionalInfoParameterInfo, userId);
399             if (either.isRight()) {
400                 ResponseFormat responseFormat = either.right().value();
401                 log.info(FAILED_TO_UPDATE_ADDITIONAL_INFO_PROPERTY, responseFormat);
402                 return buildErrorResponse(responseFormat);
403             }
404             AdditionalInfoParameterInfo createdAI = either.left().value();
405             log.debug("Additional information {}={} updated successfully with id {}", createdAI.getKey(), createdAI.getValue(),
406                 createdAI.getUniqueId());
407             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
408             return buildOkResponse(responseFormat, createdAI);
409         } catch (Exception e) {
410             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Update Additional Information");
411             log.debug("Update additional information failed with exception", e);
412             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
413             return buildErrorResponse(responseFormat);
414         }
415     }
416
417     /**
418      * Delete an additional information property by id under given resource/service
419      *
420      * @param nodeType
421      * @param uniqueId
422      * @param labelId
423      * @param request
424      * @param userId
425      * @return
426      */
427     protected Response deleteAdditionalInformationLabelForComponent(NodeTypeEnum nodeType, String uniqueId, String labelId,
428                                                                     HttpServletRequest request, String userId) {
429         ServletContext context = request.getSession().getServletContext();
430         String url = request.getMethod() + " " + request.getRequestURI();
431         log.debug(START_HANDLE_REQUEST_OF, url);
432         log.debug(MODIFIER_ID_IS, userId);
433         try {
434             AdditionalInfoParameterInfo additionalInfoParameterInfo = new AdditionalInfoParameterInfo();
435             additionalInfoParameterInfo.setUniqueId(labelId);
436             Either<AdditionalInfoParameterInfo, ResponseFormat> either = businessLogic
437                 .deleteAdditionalInformation(nodeType, uniqueId, additionalInfoParameterInfo, userId);
438             if (either.isRight()) {
439                 ResponseFormat responseFormat = either.right().value();
440                 log.info(FAILED_TO_UPDATE_ADDITIONAL_INFO_PROPERTY, responseFormat);
441                 return buildErrorResponse(responseFormat);
442             }
443             AdditionalInfoParameterInfo createdAI = either.left().value();
444             log.debug("Additional information {}={} deleted successfully with id {}", createdAI.getKey(), createdAI.getValue(),
445                 createdAI.getUniqueId());
446             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
447             return buildOkResponse(responseFormat, createdAI);
448         } catch (Exception e) {
449             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Delete Additional Information");
450             log.debug("Delete additional information failed with exception", e);
451             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
452             return buildErrorResponse(responseFormat);
453         }
454     }
455
456     /**
457      * Get a specific additional information property by a given id under given resource/service
458      *
459      * @param nodeType
460      * @param uniqueId
461      * @param labelId
462      * @param request
463      * @param userId
464      * @return
465      */
466     protected Response getAdditionalInformationLabelForComponent(NodeTypeEnum nodeType, String uniqueId, String labelId, HttpServletRequest request,
467                                                                  String userId) {
468         ServletContext context = request.getSession().getServletContext();
469         String url = request.getMethod() + " " + request.getRequestURI();
470         log.debug(START_HANDLE_REQUEST_OF, url);
471         log.debug(MODIFIER_ID_IS, userId);
472         try {
473             // create the new property
474             AdditionalInfoParameterInfo additionalInfoParameterInfo = new AdditionalInfoParameterInfo();
475             additionalInfoParameterInfo.setUniqueId(labelId);
476             Either<AdditionalInfoParameterInfo, ResponseFormat> either = businessLogic
477                 .getAdditionalInformation(nodeType, uniqueId, additionalInfoParameterInfo, userId);
478             if (either.isRight()) {
479                 ResponseFormat responseFormat = either.right().value();
480                 log.info(FAILED_TO_UPDATE_ADDITIONAL_INFO_PROPERTY, responseFormat);
481                 return buildErrorResponse(responseFormat);
482             }
483             AdditionalInfoParameterInfo createdAI = either.left().value();
484             log.debug("Additional information {}={} fetched successfully with id {}", createdAI.getKey(), createdAI.getValue(),
485                 createdAI.getUniqueId());
486             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
487             return buildOkResponse(responseFormat, createdAI);
488         } catch (Exception e) {
489             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Additional Information");
490             log.debug("get additional information failed with exception", e);
491             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
492             return buildErrorResponse(responseFormat);
493         }
494     }
495
496     /**
497      * Get all additional information properties under given resource/service
498      *
499      * @param nodeType
500      * @param uniqueId
501      * @param request
502      * @param userId
503      * @return
504      */
505     protected Response getAllAdditionalInformationLabelForComponent(NodeTypeEnum nodeType, String uniqueId, HttpServletRequest request,
506                                                                     String userId) {
507         ServletContext context = request.getSession().getServletContext();
508         String url = request.getMethod() + " " + request.getRequestURI();
509         log.debug(START_HANDLE_REQUEST_OF, url);
510         log.debug(MODIFIER_ID_IS, userId);
511         try {
512             Either<AdditionalInformationDefinition, ResponseFormat> either = businessLogic.getAllAdditionalInformation(nodeType, uniqueId, userId);
513             if (either.isRight()) {
514                 ResponseFormat responseFormat = either.right().value();
515                 log.info(FAILED_TO_UPDATE_ADDITIONAL_INFO_PROPERTY, responseFormat);
516                 return buildErrorResponse(responseFormat);
517             }
518             AdditionalInformationDefinition additionalInformationDefinition = either.left().value();
519             log.debug("All Additional information retrieved for component {} is {}", uniqueId, additionalInformationDefinition);
520             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.OK);
521             return buildOkResponse(responseFormat, additionalInformationDefinition);
522         } catch (Exception e) {
523             BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get All Additional Information");
524             log.debug("Get all addiotanl information properties failed with exception", e);
525             ResponseFormat responseFormat = getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR);
526             return buildErrorResponse(responseFormat);
527         }
528     }
529 }