2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2019 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
20 package org.openecomp.sdc.be.servlets;
22 import com.jcabi.aspects.Loggable;
23 import io.swagger.v3.oas.annotations.Operation;
24 import io.swagger.v3.oas.annotations.Parameter;
25 import io.swagger.v3.oas.annotations.media.ArraySchema;
26 import io.swagger.v3.oas.annotations.media.Content;
27 import io.swagger.v3.oas.annotations.media.Schema;
28 import io.swagger.v3.oas.annotations.responses.ApiResponse;
29 import io.swagger.v3.oas.annotations.servers.Server;
30 import io.swagger.v3.oas.annotations.servers.Servers;
31 import io.swagger.v3.oas.annotations.tags.Tag;
32 import io.swagger.v3.oas.annotations.tags.Tags;
33 import java.util.List;
34 import javax.ws.rs.Consumes;
35 import javax.ws.rs.GET;
36 import javax.ws.rs.HeaderParam;
37 import javax.ws.rs.Path;
38 import javax.ws.rs.Produces;
39 import javax.ws.rs.QueryParam;
40 import javax.ws.rs.core.MediaType;
41 import org.openecomp.sdc.be.components.impl.GroupTypeBusinessLogic;
42 import org.openecomp.sdc.be.components.impl.aaf.AafPermission;
43 import org.openecomp.sdc.be.components.impl.aaf.PermissionAllowed;
44 import org.openecomp.sdc.be.impl.ComponentsUtils;
45 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
46 import org.openecomp.sdc.be.model.GroupTypeDefinition;
47 import org.openecomp.sdc.be.user.UserBusinessLogic;
48 import org.openecomp.sdc.be.view.ResponseView;
49 import org.openecomp.sdc.common.api.Constants;
50 import org.openecomp.sdc.common.util.ValidationUtils;
51 import org.springframework.stereotype.Controller;
53 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
55 @Tags({@Tag(name = "SDCE-2 APIs")})
56 @Servers({@Server(url = "/sdc2/rest")})
58 @Consumes(MediaType.APPLICATION_JSON)
59 @Produces(MediaType.APPLICATION_JSON)
60 public class GroupTypesEndpoint extends BeGenericServlet {
62 private final GroupTypeBusinessLogic groupTypeBusinessLogic;
64 public GroupTypesEndpoint(UserBusinessLogic userBusinessLogic, ComponentsUtils componentsUtils, GroupTypeBusinessLogic groupTypeBusinessLogic) {
65 super(userBusinessLogic, componentsUtils);
66 this.groupTypeBusinessLogic = groupTypeBusinessLogic;
71 @Operation(description = "Get group types ", method = "GET", summary = "Returns group types", responses = {
72 @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = GroupTypeDefinition.class)))),
73 @ApiResponse(responseCode = "200", description = "group types found"),
74 @ApiResponse(responseCode = "400", description = "field name invalid type/length, characters; mandatory field is absent, already exists (name)"),
75 @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "500", description = "Internal Error")})
76 @ResponseView(mixin = {GroupTypeMixin.class})
77 @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
78 public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
79 @Parameter(description =
80 "An optional parameter to indicate the type of the container from where this call is executed")
81 @QueryParam("internalComponentType") String internalComponentType,
82 @QueryParam("componentModel") String internalComponentModel) {
83 if (internalComponentModel != null) {
84 internalComponentModel = ValidationUtils.sanitizeInputString(internalComponentModel.trim());
86 return groupTypeBusinessLogic
87 .getAllGroupTypes(userId, internalComponentType, internalComponentModel);