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