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