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=========================================================
20 package org.openecomp.sdc.be.servlets;
22 import com.jcabi.aspects.Loggable;
23 import io.swagger.v3.oas.annotations.tags.Tag;
24 import io.swagger.v3.oas.annotations.tags.Tags;
25 import javax.inject.Singleton;
26 import javax.ws.rs.Path;
27 import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
28 import org.openecomp.sdc.be.components.impl.ResourceImportManager;
29 import org.openecomp.sdc.be.impl.ComponentsUtils;
30 import org.openecomp.sdc.be.impl.ServletUtils;
31 import org.openecomp.sdc.common.log.wrappers.Logger;
34 * Root service (exposed at "/" path)
37 //upload Service model by Shiyong1989@hotmail.com
38 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
39 @Path("/v1/catalog/uploadservice")
40 @Tags({@Tag(name = "SDCE-2 APIs")})
42 public class ServiceUploadServlet extends AbstractValidationsServlet {
44 public static final String NORMATIVE_TYPE_SERVICE = "multipart";
45 public static final String CSAR_TYPE_SERVICE = "csar";
46 public static final String USER_TYPE_SERVICE = "user-service";
47 public static final String USER_TYPE_SERVICE_UI_IMPORT = "user-servcie-ui-import";
48 private static final Logger log = Logger.getLogger(ServiceUploadServlet.class);
50 public ServiceUploadServlet(ComponentInstanceBusinessLogic componentInstanceBL,
51 ComponentsUtils componentsUtils, ServletUtils servletUtils, ResourceImportManager resourceImportManager) {
52 super(componentInstanceBL, componentsUtils, servletUtils, resourceImportManager);
55 public enum ServiceAuthorityTypeEnum {
56 NORMATIVE_TYPE_BE(NORMATIVE_TYPE_SERVICE, true, false), USER_TYPE_BE(USER_TYPE_SERVICE, true, true), USER_TYPE_UI(USER_TYPE_SERVICE_UI_IMPORT,
57 false, true), CSAR_TYPE_BE(CSAR_TYPE_SERVICE, true, true);
58 private String urlPath;
59 private boolean isBackEndImport, isUserTypeService;
61 private ServiceAuthorityTypeEnum(String urlPath, boolean isBackEndImport, boolean isUserTypeService) {
62 this.urlPath = urlPath;
63 this.isBackEndImport = isBackEndImport;
64 this.isUserTypeService = isUserTypeService;
67 public static ServiceAuthorityTypeEnum findByUrlPath(String urlPath) {
68 ServiceAuthorityTypeEnum found = null;
69 for (ServiceAuthorityTypeEnum curr : ServiceAuthorityTypeEnum.values()) {
70 if (curr.getUrlPath().equals(urlPath)) {
78 public String getUrlPath() {
82 public boolean isBackEndImport() {
83 return isBackEndImport;
86 public boolean isUserTypeService() {
87 return isUserTypeService;