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