Remove legacy certificate handling
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / servlets / GroupTypesEndpoint.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20 package org.openecomp.sdc.be.servlets;
21
22 import com.jcabi.aspects.Loggable;
23 import 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.impl.ComponentsUtils;
43 import org.openecomp.sdc.be.mixin.GroupTypeMixin;
44 import org.openecomp.sdc.be.model.GroupTypeDefinition;
45 import org.openecomp.sdc.be.view.ResponseView;
46 import org.openecomp.sdc.common.api.Constants;
47 import org.openecomp.sdc.common.util.ValidationUtils;
48 import org.springframework.stereotype.Controller;
49
50 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
51 @Path("/v1/catalog")
52 @Tags({@Tag(name = "SDCE-2 APIs")})
53 @Servers({@Server(url = "/sdc2/rest")})
54 @Controller
55 @Consumes(MediaType.APPLICATION_JSON)
56 @Produces(MediaType.APPLICATION_JSON)
57 public class GroupTypesEndpoint extends BeGenericServlet {
58
59     private final GroupTypeBusinessLogic groupTypeBusinessLogic;
60
61     public GroupTypesEndpoint(ComponentsUtils componentsUtils, GroupTypeBusinessLogic groupTypeBusinessLogic) {
62         super(componentsUtils);
63         this.groupTypeBusinessLogic = groupTypeBusinessLogic;
64     }
65
66     @GET
67     @Path("/groupTypes")
68     @Operation(description = "Get group types ", method = "GET", summary = "Returns group types", responses = {
69         @ApiResponse(content = @Content(array = @ArraySchema(schema = @Schema(implementation = GroupTypeDefinition.class)))),
70         @ApiResponse(responseCode = "200", description = "group types found"),
71         @ApiResponse(responseCode = "400", description = "field name invalid type/length, characters;  mandatory field is absent, already exists (name)"),
72         @ApiResponse(responseCode = "403", description = "Restricted operation"), @ApiResponse(responseCode = "500", description = "Internal Error")})
73     @ResponseView(mixin = {GroupTypeMixin.class})
74     public List<GroupTypeDefinition> getGroupTypes(@HeaderParam(value = Constants.USER_ID_HEADER) String userId,
75                                                    @Parameter(description =
76                                                        "An optional parameter to indicate the type of the container from where this call is executed")
77                                                    @QueryParam("internalComponentType") String internalComponentType,
78                                                    @QueryParam("componentModel") String internalComponentModel) {
79         if (internalComponentModel != null) {
80             internalComponentModel = ValidationUtils.sanitizeInputString(internalComponentModel.trim());
81         }
82         return groupTypeBusinessLogic
83             .getAllGroupTypes(userId, internalComponentType, internalComponentModel);
84     }
85 }