2 * ============LICENSE_START=======================================================
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
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=========================================================
21 package org.openecomp.sdc.be.servlets;
23 import com.jcabi.aspects.Loggable;
24 import io.swagger.v3.oas.annotations.Operation;
25 import io.swagger.v3.oas.annotations.Parameter;
26 import io.swagger.v3.oas.annotations.media.Schema;
27 import io.swagger.v3.oas.annotations.responses.ApiResponse;
28 import io.swagger.v3.oas.annotations.servers.Server;
29 import io.swagger.v3.oas.annotations.servers.Servers;
30 import io.swagger.v3.oas.annotations.tags.Tag;
31 import io.swagger.v3.oas.annotations.tags.Tags;
33 import javax.inject.Singleton;
34 import javax.servlet.ServletContext;
35 import javax.servlet.http.HttpServletRequest;
36 import javax.ws.rs.Consumes;
37 import javax.ws.rs.DefaultValue;
38 import javax.ws.rs.HeaderParam;
39 import javax.ws.rs.POST;
40 import javax.ws.rs.Path;
41 import javax.ws.rs.PathParam;
42 import javax.ws.rs.Produces;
43 import javax.ws.rs.QueryParam;
44 import javax.ws.rs.core.Context;
45 import javax.ws.rs.core.MediaType;
46 import javax.ws.rs.core.Response;
47 import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
48 import org.glassfish.jersey.media.multipart.FormDataParam;
49 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
50 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
51 import org.openecomp.sdc.be.components.impl.ServiceImportManager;
52 import org.openecomp.sdc.be.config.BeEcompErrorManager;
53 import org.openecomp.sdc.be.dao.api.ActionStatus;
54 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
55 import org.openecomp.sdc.be.impl.ComponentsUtils;
56 import org.openecomp.sdc.be.impl.ServletUtils;
57 import org.openecomp.sdc.be.impl.WebAppContextWrapper;
58 import org.openecomp.sdc.be.model.UploadServiceInfo;
59 import org.openecomp.sdc.be.model.User;
60 import org.openecomp.sdc.be.user.UserBusinessLogic;
61 import org.openecomp.sdc.common.api.Constants;
62 import org.openecomp.sdc.common.datastructure.Wrapper;
63 import org.openecomp.sdc.common.log.wrappers.Logger;
64 import org.springframework.stereotype.Controller;
65 import org.springframework.web.context.WebApplicationContext;
68 * Root service (exposed at "/" path)
71 //upload Service model by Shiyong1989@hotmail.com
72 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
73 @Path("/v1/catalog/uploadservice")
74 @Tags({@Tag(name = "SDC Internal APIs")})
77 public class ServiceUploadServlet extends AbstractValidationsServlet {
79 private static final Logger log = Logger.getLogger(ServiceUploadServlet.class);
80 public static final String NORMATIVE_TYPE_SERVICE = "multipart";
81 public static final String CSAR_TYPE_SERVICE = "csar";
82 public static final String USER_TYPE_SERVICE = "user-service";
83 public static final String USER_TYPE_SERVICE_UI_IMPORT = "user-servcie-ui-import";
85 public ServiceUploadServlet(UserBusinessLogic userBusinessLogic,
86 ComponentInstanceBusinessLogic componentInstanceBL,
87 ComponentsUtils componentsUtils, ServletUtils servletUtils,
88 ResourceImportManager resourceImportManager) {
89 super(userBusinessLogic, componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
92 public enum ServiceAuthorityTypeEnum {
93 NORMATIVE_TYPE_BE(NORMATIVE_TYPE_SERVICE, true, false), USER_TYPE_BE(USER_TYPE_SERVICE, true, true),
94 USER_TYPE_UI(USER_TYPE_SERVICE_UI_IMPORT, false, true), CSAR_TYPE_BE(CSAR_TYPE_SERVICE, true, true);
96 private String urlPath;
97 private boolean isBackEndImport, isUserTypeService;
99 public static ServiceAuthorityTypeEnum findByUrlPath(String urlPath) {
100 ServiceAuthorityTypeEnum found = null;
101 for (ServiceAuthorityTypeEnum curr : ServiceAuthorityTypeEnum.values()) {
102 if (curr.getUrlPath().equals(urlPath)) {
110 private ServiceAuthorityTypeEnum(String urlPath, boolean isBackEndImport, boolean isUserTypeService) {
111 this.urlPath = urlPath;
112 this.isBackEndImport = isBackEndImport;
113 this.isUserTypeService = isUserTypeService;
116 public String getUrlPath() {
120 public boolean isBackEndImport() {
121 return isBackEndImport;
124 public boolean isUserTypeService() {
125 return isUserTypeService;