2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.sdc.be.servlets;
\r
23 import java.util.ArrayList;
\r
24 import java.util.EnumMap;
\r
25 import java.util.List;
\r
26 import java.util.Map;
\r
27 import javax.inject.Inject;
\r
28 import javax.servlet.http.HttpServletRequest;
\r
29 import javax.ws.rs.Consumes;
\r
30 import javax.ws.rs.GET;
\r
31 import javax.ws.rs.HeaderParam;
\r
32 import javax.ws.rs.POST;
\r
33 import javax.ws.rs.Path;
\r
34 import javax.ws.rs.PathParam;
\r
35 import javax.ws.rs.Produces;
\r
36 import javax.ws.rs.QueryParam;
\r
37 import javax.ws.rs.core.Context;
\r
38 import javax.ws.rs.core.MediaType;
\r
39 import javax.ws.rs.core.Response;
\r
40 import org.apache.commons.collections.CollectionUtils;
\r
41 import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
\r
42 import org.openecomp.sdc.be.components.impl.ComponentBusinessLogicProvider;
\r
43 import org.openecomp.sdc.be.config.BeEcompErrorManager;
\r
44 import org.openecomp.sdc.be.dao.api.ActionStatus;
\r
45 import org.openecomp.sdc.be.datamodel.api.HighestFilterEnum;
\r
46 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
\r
47 import org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum;
\r
48 import org.openecomp.sdc.be.impl.ComponentsUtils;
\r
49 import org.openecomp.sdc.be.mixin.GroupCompositionMixin;
\r
50 import org.openecomp.sdc.be.mixin.PolicyCompositionMixin;
\r
51 import org.openecomp.sdc.be.model.CapReqDef;
\r
52 import org.openecomp.sdc.be.model.Component;
\r
53 import org.openecomp.sdc.be.model.ComponentInstance;
\r
54 import org.openecomp.sdc.be.model.IComponentInstanceConnectedElement;
\r
55 import org.openecomp.sdc.be.model.Resource;
\r
56 import org.openecomp.sdc.be.model.User;
\r
57 import org.openecomp.sdc.be.ui.model.UiComponentDataTransfer;
\r
58 import org.openecomp.sdc.be.user.UserBusinessLogic;
\r
59 import org.openecomp.sdc.be.view.ResponseView;
\r
60 import org.openecomp.sdc.common.api.Constants;
\r
61 import org.openecomp.sdc.common.log.wrappers.Logger;
\r
62 import org.openecomp.sdc.exception.ResponseFormat;
\r
63 import org.springframework.stereotype.Controller;
\r
64 import com.jcabi.aspects.Loggable;
\r
65 import fj.data.Either;
\r
66 import io.swagger.v3.oas.annotations.OpenAPIDefinition;
\r
67 import io.swagger.v3.oas.annotations.Operation;
\r
68 import io.swagger.v3.oas.annotations.Parameter;
\r
69 import io.swagger.v3.oas.annotations.info.Info;
\r
70 import io.swagger.v3.oas.annotations.media.ArraySchema;
\r
71 import io.swagger.v3.oas.annotations.media.Content;
\r
72 import io.swagger.v3.oas.annotations.media.Schema;
\r
73 import io.swagger.v3.oas.annotations.responses.ApiResponse;
\r
74 import io.swagger.v3.oas.annotations.responses.ApiResponses;
\r
76 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
\r
77 @Path("/v1/catalog")
\r
78 @OpenAPIDefinition(info = @Info(title = "Component Servlet",description = "Component Servlet"))
\r
80 public class ComponentServlet extends BeGenericServlet {
\r
81 private static final String GET_CERTIFIED_NOT_ABSTRACT_COMPONENTS_FAILED_WITH_EXCEPTION = "getCertifiedNotAbstractComponents failed with exception";
\r
83 private static final String GET_CERTIFIED_NON_ABSTRACT = "Get Certified Non Abstract";
\r
85 private static final String FAILED_TO_GET_ALL_NON_ABSTRACT = "failed to get all non abstract {}";
\r
87 private static final String START_HANDLE_REQUEST_OF = "Start handle request of {}";
\r
89 private static final Logger log = Logger.getLogger(ComponentServlet.class);
\r
91 private final ComponentBusinessLogicProvider componentBusinessLogicProvider;
\r
94 public ComponentServlet(UserBusinessLogic userBusinessLogic,
\r
95 ComponentsUtils componentsUtils,
\r
96 ComponentBusinessLogicProvider componentBusinessLogicProvider) {
\r
97 super(userBusinessLogic, componentsUtils);
\r
98 this.componentBusinessLogicProvider = componentBusinessLogicProvider;
\r
102 @Path("/{componentType}/{componentUuid}/conformanceLevelValidation")
\r
103 @Consumes(MediaType.APPLICATION_JSON)
\r
104 @Produces(MediaType.APPLICATION_JSON)
\r
105 @Operation(description = "Validate Component Conformance Level", method = "GET",
\r
106 summary = "Returns the result according to conformance level in BE config", responses = @ApiResponse(
\r
107 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
108 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
109 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
110 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
111 public Response conformanceLevelValidation(@PathParam("componentType") final String componentType,
\r
112 @PathParam("componentUuid") final String componentUuid, @Context final HttpServletRequest request,
\r
113 @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
116 String url = request.getMethod() + " " + request.getRequestURI();
\r
117 log.debug(START_HANDLE_REQUEST_OF, url);
\r
119 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
120 if (componentTypeEnum != null) {
\r
121 ComponentBusinessLogic compBL = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
122 Either<Boolean, ResponseFormat> eitherConformanceLevel = compBL.validateConformanceLevel(componentUuid, componentTypeEnum, userId);
\r
123 if (eitherConformanceLevel.isRight()) {
\r
124 response = buildErrorResponse(eitherConformanceLevel.right().value());
\r
126 response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), gson.toJson(eitherConformanceLevel.left().value()));
\r
129 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
\r
136 @Path("/{componentType}/{componentId}/requirmentsCapabilities")
\r
137 @Consumes(MediaType.APPLICATION_JSON)
\r
138 @Produces(MediaType.APPLICATION_JSON)
\r
139 @Operation(description = "Get Component Requirments And Capabilities", method = "GET",
\r
140 summary = "Returns Requirements And Capabilities according to componentId", responses = @ApiResponse(
\r
141 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
142 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
143 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
144 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
145 public Response getRequirementAndCapabilities(@PathParam("componentType") final String componentType,
\r
146 @PathParam("componentId") final String componentId, @Context final HttpServletRequest request,
\r
147 @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
150 String url = request.getMethod() + " " + request.getRequestURI();
\r
151 log.debug(START_HANDLE_REQUEST_OF, url);
\r
153 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
154 if (componentTypeEnum != null) {
\r
156 ComponentBusinessLogic compBL = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
157 Either<CapReqDef, ResponseFormat> eitherRequirementsAndCapabilities = compBL.getRequirementsAndCapabilities(componentId, componentTypeEnum, userId);
\r
158 if (eitherRequirementsAndCapabilities.isRight()) {
\r
159 response = buildErrorResponse(eitherRequirementsAndCapabilities.right().value());
\r
161 response = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), RepresentationUtils.toRepresentation(eitherRequirementsAndCapabilities.left().value()));
\r
163 } catch (Exception e) {
\r
164 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Capabilities and requirements for " + componentId);
\r
165 log.debug("getRequirementAndCapabilities failed with exception", e);
\r
166 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
169 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.INVALID_CONTENT));
\r
176 @Path("/{componentType}/latestversion/notabstract")
\r
177 @Consumes(MediaType.APPLICATION_JSON)
\r
178 @Produces(MediaType.APPLICATION_JSON)
\r
179 @Operation(description = "Get Component Requirments And Capabilities", method = "GET",
\r
180 summary = "Returns Requirments And Capabilities according to componentId", responses = @ApiResponse(
\r
181 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
182 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
183 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
184 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
185 public Response getLatestVersionNotAbstractCheckoutComponents(
\r
186 @PathParam("componentType") final String componentType, @Context final HttpServletRequest request,
\r
187 @QueryParam("internalComponentType") String internalComponentType,
\r
188 @QueryParam("componentUids") List<String> componentUids,
\r
189 @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
191 String url = request.getMethod() + " " + request.getRequestURI();
\r
192 log.debug("(get) Start handle request of {}", url);
\r
193 Response response = null;
\r
197 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
198 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
200 log.debug("Received componentUids size is {}", componentUids == null ? 0 : componentUids.size());
\r
202 Either<List<Component>, ResponseFormat> actionResponse = businessLogic.getLatestVersionNotAbstractComponents(false, componentTypeEnum, internalComponentType, componentUids, userId);
\r
204 if (actionResponse.isRight()) {
\r
205 log.debug(FAILED_TO_GET_ALL_NON_ABSTRACT, componentType);
\r
206 return buildErrorResponse(actionResponse.right().value());
\r
208 Object components = RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
209 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), components);
\r
211 } catch (Exception e) {
\r
212 BeEcompErrorManager.getInstance().logBeRestApiGeneralError(GET_CERTIFIED_NON_ABSTRACT + componentType);
\r
213 log.debug(GET_CERTIFIED_NOT_ABSTRACT_COMPONENTS_FAILED_WITH_EXCEPTION, e);
\r
214 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
222 @Path("/{componentType}/latestversion/notabstract")
\r
223 @Consumes(MediaType.APPLICATION_JSON)
\r
224 @Produces(MediaType.APPLICATION_JSON)
\r
225 @Operation(description = "Get Component Requirments And Capabilities", method = "GET",
\r
226 summary = "Returns Requirments And Capabilities according to componentId", responses = @ApiResponse(
\r
227 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
228 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
229 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
230 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
231 public Response getLatestVersionNotAbstractCheckoutComponentsByBody(
\r
232 @PathParam("componentType") final String componentType, @Context final HttpServletRequest request,
\r
233 @QueryParam("internalComponentType") String internalComponentType,
\r
234 @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
\r
235 @Parameter(description = "Consumer Object to be created", required = true) List<String> data) {
\r
237 String url = request.getMethod() + " " + request.getRequestURI();
\r
238 log.debug("(GET) Start handle request of {}", url);
\r
239 Response response = null;
\r
243 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
244 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
245 if (log.isDebugEnabled()) {
\r
246 log.debug("Received componentUids size is {}", data == null ? 0 : data.size());
\r
249 Either<List<Component>, ResponseFormat> actionResponse = businessLogic.getLatestVersionNotAbstractComponents(false, componentTypeEnum, internalComponentType, data, userId);
\r
251 if (actionResponse.isRight()) {
\r
252 log.debug(FAILED_TO_GET_ALL_NON_ABSTRACT, componentType);
\r
253 return buildErrorResponse(actionResponse.right().value());
\r
256 Object components = RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
257 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), components);
\r
261 } catch (Exception e) {
\r
262 BeEcompErrorManager.getInstance().logBeRestApiGeneralError(GET_CERTIFIED_NON_ABSTRACT + componentType);
\r
263 log.debug(GET_CERTIFIED_NOT_ABSTRACT_COMPONENTS_FAILED_WITH_EXCEPTION, e);
\r
264 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
272 @Path("/{componentType}/latestversion/notabstract/metadata")
\r
273 @Consumes(MediaType.APPLICATION_JSON)
\r
274 @Produces(MediaType.APPLICATION_JSON)
\r
275 @Operation(description = "Get Component uid only", method = "GET", summary = "Returns componentId",
\r
276 responses = @ApiResponse(
\r
277 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
278 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
279 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
280 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
281 public Response getLatestVersionNotAbstractCheckoutComponentsIdesOnly(
\r
282 @PathParam("componentType") final String componentType, @Context final HttpServletRequest request,
\r
283 @QueryParam("internalComponentType") String internalComponentType,
\r
284 @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
\r
285 @Parameter(description = "uid list", required = true) String data) {
\r
287 String url = request.getMethod() + " " + request.getRequestURI();
\r
288 log.debug("(get) Start handle request of {}", url);
\r
289 Response response = null;
\r
291 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
292 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
294 Either<List<Component>, ResponseFormat> actionResponse = businessLogic.getLatestVersionNotAbstractComponentsMetadata(false, HighestFilterEnum.HIGHEST_ONLY, componentTypeEnum, internalComponentType, userId);
\r
295 if (actionResponse.isRight()) {
\r
296 log.debug(FAILED_TO_GET_ALL_NON_ABSTRACT, componentType);
\r
297 return buildErrorResponse(actionResponse.right().value());
\r
299 Object components = RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
300 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), components);
\r
302 } catch (Exception e) {
\r
303 BeEcompErrorManager.getInstance().logBeRestApiGeneralError(GET_CERTIFIED_NON_ABSTRACT + componentType);
\r
304 log.debug(GET_CERTIFIED_NOT_ABSTRACT_COMPONENTS_FAILED_WITH_EXCEPTION, e);
\r
305 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
313 @Path("/{componentType}/{componentId}/componentInstances")
\r
314 @Consumes(MediaType.APPLICATION_JSON)
\r
315 @Produces(MediaType.APPLICATION_JSON)
\r
316 @Operation(description = "Get Component instances", method = "GET", summary = "Returns component instances",
\r
317 responses = @ApiResponse(
\r
318 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
319 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
320 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
321 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
322 public Response getComponentInstancesFilteredByPropertiesAndInputs(
\r
323 @PathParam("componentType") final String componentType, @PathParam("componentId") final String componentId,
\r
324 @Context final HttpServletRequest request, @QueryParam("searchText") String searchText,
\r
325 @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
\r
326 @Parameter(description = "uid" + " " + "list", required = true) String data) {
\r
328 String url = request.getMethod() + " " + request.getRequestURI();
\r
329 log.debug("(GET) Start handle request of {}", url);
\r
330 Response response = null;
\r
332 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
333 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
335 Either<List<ComponentInstance>, ResponseFormat> actionResponse = businessLogic.getComponentInstancesFilteredByPropertiesAndInputs(componentId, userId);
\r
336 if (actionResponse.isRight()) {
\r
337 log.debug("failed to get all component instances filtered by properties and inputs", componentType);
\r
338 return buildErrorResponse(actionResponse.right().value());
\r
340 Object components = RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
341 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), components);
\r
343 } catch (Exception e) {
\r
344 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Component Instances filtered by properties & inputs" + componentType);
\r
345 log.debug("getComponentInstancesFilteredByPropertiesAndInputs failed with exception", e);
\r
346 response = buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
354 * This API is a generic api for ui - the api get a list of strings and return the data on the component according to to list.
\r
355 * for example: list of the string "properties, inputs" will return component with the list of properties and inputs.
\r
357 * @param componentType
\r
358 * @param componentId
\r
359 * @param dataParamsToReturn
\r
366 @Path("/{componentType}/{componentId}/filteredDataByParams")
\r
367 @Consumes(MediaType.APPLICATION_JSON)
\r
368 @Produces(MediaType.APPLICATION_JSON)
\r
369 @Operation(description = "Retrieve Resource", method = "GET", summary = "Returns resource according to resourceId",
\r
370 responses = @ApiResponse(
\r
371 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Resource.class)))))
\r
372 @ResponseView(mixin = {GroupCompositionMixin.class, PolicyCompositionMixin.class})
\r
373 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Resource found"),
\r
374 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
375 @ApiResponse(responseCode = "404", description = "Resource not found")})
\r
376 public Response getComponentDataFilteredByParams(@PathParam("componentType") final String componentType,
\r
377 @PathParam("componentId") final String componentId,
\r
378 @QueryParam("include") final List<String> dataParamsToReturn, @Context final HttpServletRequest request,
\r
379 @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
381 String url = request.getMethod() + " " + request.getRequestURI();
\r
382 log.debug(START_HANDLE_REQUEST_OF , url);
\r
385 User modifier = new User();
\r
386 modifier.setUserId(userId);
\r
387 log.debug("modifier id is {}" , userId);
\r
392 String resourceIdLower = componentId.toLowerCase();
\r
393 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
394 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
396 log.trace("get component with id {} filtered by ui params", componentId);
\r
397 Either<UiComponentDataTransfer, ResponseFormat> actionResponse = businessLogic.getComponentDataFilteredByParams(resourceIdLower, modifier, dataParamsToReturn);
\r
399 if (actionResponse.isRight()) {
\r
400 log.debug("failed to get component data filtered by ui params");
\r
401 response = buildErrorResponse(actionResponse.right().value());
\r
404 RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
405 return buildOkResponse(actionResponse.left().value());
\r
407 } catch (Exception e) {
\r
408 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get component filtered by ui params");
\r
409 log.debug("get resource failed with exception", e);
\r
410 return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r
417 @Path("/{componentType}/{componentId}/filteredproperties/{propertyNameFragment}")
\r
418 @Consumes(MediaType.APPLICATION_JSON)
\r
419 @Produces(MediaType.APPLICATION_JSON)
\r
421 description = "Retrieve properties belonging to component instances of specific component by name and optionally resource type",
\r
423 summary = "Returns properties belonging to component instances of specific component by name and optionally resource type",
\r
424 responses = @ApiResponse(
\r
425 content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))))
\r
426 @ApiResponses(value = {@ApiResponse(responseCode = "200", description = "Component found"),
\r
427 @ApiResponse(responseCode = "403", description = "Restricted operation"),
\r
428 @ApiResponse(responseCode = "404", description = "Component not found")})
\r
429 public Response getFilteredComponentInstanceProperties(
\r
430 @PathParam("componentType") final String componentType,
\r
431 @PathParam("componentId") final String componentId,
\r
432 @PathParam("propertyNameFragment") final String propertyNameFragment,
\r
433 @QueryParam("resourceType") List<String> resourceTypes,
\r
434 @Context final HttpServletRequest request,
\r
435 @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
\r
437 User user = new User();
\r
438 user.setUserId(userId);
\r
439 log.debug("User Id is {}" , userId);
\r
442 ComponentTypeEnum componentTypeEnum = ComponentTypeEnum.findByParamName(componentType);
\r
443 ComponentBusinessLogic businessLogic = componentBusinessLogicProvider.getInstance(componentTypeEnum);
\r
444 Map<FilterKeyEnum, List<String>> filters = new EnumMap<>(FilterKeyEnum.class);
\r
445 List<String> propertyNameFragments = new ArrayList<>();
\r
446 propertyNameFragments.add(propertyNameFragment);
\r
447 filters.put(FilterKeyEnum.NAME_FRAGMENT, propertyNameFragments);
\r
448 if(CollectionUtils.isNotEmpty(resourceTypes)){
\r
449 filters.put(FilterKeyEnum.RESOURCE_TYPE, resourceTypes);
\r
451 Either<Map<String, List<IComponentInstanceConnectedElement>>, ResponseFormat> actionResponse = businessLogic.getFilteredComponentInstanceProperties(componentId, filters, userId);
\r
452 if (actionResponse.isRight()) {
\r
453 response = buildErrorResponse(actionResponse.right().value());
\r
456 Object resource = RepresentationUtils.toRepresentation(actionResponse.left().value());
\r
457 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), resource);
\r
459 } catch (Exception e) {
\r
460 BeEcompErrorManager.getInstance().logBeRestApiGeneralError("Get Filtered Component Instance Properties");
\r
461 log.debug("Getting of filtered component instance properties failed with exception", e);
\r
462 return buildErrorResponse(getComponentsUtils().getResponseFormat(ActionStatus.GENERAL_ERROR));
\r