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 org.openecomp.sdc.be.resources.data.ESArtifactData;
25 import org.openecomp.sdc.common.log.wrappers.Logger;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.ws.rs.GET;
29 import javax.ws.rs.Path;
30 import javax.ws.rs.PathParam;
31 import javax.ws.rs.core.Context;
32 import javax.ws.rs.core.Response;
34 @Loggable(prepend = true, value = Loggable.DEBUG, trim = false)
36 public class CsarBuildServlet extends ToscaDaoServlet {
38 private static final Logger log = Logger.getLogger(CsarBuildServlet.class);
41 @Path("/{serviceName}/{serviceVersion}")
42 public Response getDefaultTemplate(@Context final HttpServletRequest request, @PathParam("serviceName") final String serviceName, @PathParam("serviceVersion") final String serviceVersion) {
44 return null;// buildToscaCsar(request, serviceName, serviceVersion);
49 @Path("/{serviceName}/{serviceVersion}/csar")
50 public Response getToscaCsarTemplate(@Context final HttpServletRequest request, @PathParam("serviceName") final String serviceName, @PathParam("serviceVersion") final String serviceVersion) {
52 return null; // buildToscaCsar(request, serviceName, serviceVersion);
57 public static final String TOSCA_META_PATH = "TOSCA-Metadata/TOSCA.meta";
59 protected String[] prepareToscaMetaHeader(String serviceName) {
60 return new String[] { "TOSCA-Meta-File-Version: 1.0\n", "CSAR-Version: 1.1\n", "Created-By: INTERWISE\n", "\n", "Entry-Definitions: Definitions/" + serviceName + ".yaml\n", "\n", "Name: Definitions/" + serviceName + ".yaml\n",
61 "Content-Type: application/vnd.oasis.tosca.definitions.yaml\n" };
64 protected String getAppliactionMime(String fileName) {
66 if (fileName.contains(".sh")) {
68 } else if (fileName.contains(".yang")) {
72 else if (fileName.contains(".rar")) {
73 mimeType = "x-rar-compressed";
76 else if (fileName.contains(".zip")) {
80 else if (fileName.contains(".tar")) {
84 else if (fileName.contains(".7z")) {
85 mimeType = "x-7z-compressed";
90 mimeType = "undefined";
95 protected String getArtifactPath(String nodeTamplateName, ESArtifactData artifactData) {
96 return "Scripts/" + nodeTamplateName + "/" + artifactData.getId();
99 protected String getResourcePath(String resourceName) {
100 return "Definitions/" + resourceName + ".yaml";
104 public Logger getLogger() {