2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation.
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 * SPDX-License-Identifier: Apache-2.0
18 * ============LICENSE_END=========================================================
21 package org.openecomp.sdc.tosca.csar;
23 import com.google.common.collect.ImmutableList;
24 import org.openecomp.sdc.common.errors.Messages;
25 import java.util.Iterator;
27 import static org.openecomp.sdc.tosca.csar.CSARConstants.SEPERATOR_MF_ATTRIBUTE;
28 import static org.openecomp.sdc.tosca.csar.CSARConstants.SOURCE_MF_ATTRIBUTE;
30 public class ONAPManifestOnboarding extends AbstractOnboardingManifest implements Manifest {
33 protected void processManifest(ImmutableList<String> lines) {
34 super.processManifest(lines);
35 if (errors.isEmpty() && sources.isEmpty()) {
36 errors.add(Messages.MANIFEST_NO_SOURCES.getErrorMessage());
41 protected void processMetadata(Iterator<String> iterator) {
42 if(!iterator.hasNext()){
45 String line = iterator.next();
46 if(isEmptyLine(iterator, line)) {
49 String[] metaSplit = line.split(SEPERATOR_MF_ATTRIBUTE);
50 if (isInvalidLine(line, metaSplit)) {
53 if (!metaSplit[0].equals(SOURCE_MF_ATTRIBUTE)){
54 String value = line.substring((metaSplit[0] + SEPERATOR_MF_ATTRIBUTE).length()).trim();
55 metadata.put(metaSplit[0].trim(),value.trim());
56 processMetadata(iterator);
57 }else if(metaSplit[0].startsWith(SOURCE_MF_ATTRIBUTE)){
58 String value = line.substring((metaSplit[0] + SEPERATOR_MF_ATTRIBUTE).length()).trim();
60 processMetadata(iterator);