2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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.vendorsoftwareproduct.impl.orchestration.csar;
23 import org.openecomp.sdc.logging.api.Logger;
24 import org.openecomp.sdc.logging.api.LoggerFactory;
25 import java.io.InputStream;
26 import java.io.IOException;
27 import org.apache.commons.io.IOUtils;
28 import java.util.List;
30 import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ENTRY_DEFINITIONS;
31 import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
33 public class OnboardingToscaMetadata {
35 private static final Logger LOGGER = LoggerFactory.getLogger(OnboardingToscaMetadata.class);
36 private String entryDefinitionsPath;
38 public OnboardingToscaMetadata(InputStream is) throws IOException {
39 parseToscaMetadataFile(is);
42 private void parseToscaMetadataFile(InputStream st) throws IOException {
45 List<String> metadataLines = IOUtils.readLines(st,"utf-8");
47 for (String line : metadataLines) {
49 if (line.startsWith(TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE)) {
51 entryDefinitionsPath = line.replaceAll(TOSCA_META_ENTRY_DEFINITIONS + SEPERATOR_MF_ATTRIBUTE, "")
58 } catch (IOException e) {
59 LOGGER.error(e.getMessage(), e);
60 throw new IOException("Invalid TOSCA Metadata file", e);
66 public String getEntryDefinitionsPath() {
67 return entryDefinitionsPath;