Commit 963b589d authored by Christos Tranoris's avatar Christos Tranoris
Browse files

fix for #42

parent 1228d56d
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1144,7 +1144,7 @@ public class ServiceSpecificationRepoService {
			return null;
		}

		logger.error("nsdid returned: " + nsd.getName());
		logger.debug("nsdid returned: " + nsd.getName());
		
		List<ServiceSpecification> newRfservices = new ArrayList<>(); 
		
+23 −6
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import org.yaml.snakeyaml.Yaml;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

@@ -107,10 +108,20 @@ public class PrimitivesParser {
    public static JSONObject processNSD(NetworkServiceDescriptor nsd) {
        // Parse the NSD descriptor from string to YAML
        Yaml yaml = new Yaml();
        Map<String, Object> yamlMap = yaml.load(nsd.getDescriptor());
        JSONObject nsdJson;
        
        Object obj = yaml.load(nsd.getDescriptor());
        
        if ( obj instanceof ArrayList) {
          // Parse the NSD descriptor from YAML to JSONObject          
          nsdJson = new JSONObject( (ArrayList<Object>)obj );
          
        }else {
          Map<String, Object> yamlMap = ( Map<String, Object> ) obj;
          // Parse the NSD descriptor from YAML to JSONObject
        JSONObject nsdJson = new JSONObject(yamlMap);
          nsdJson = new JSONObject(yamlMap);
        }
        

        return nsdJson;
    }
@@ -164,8 +175,14 @@ public class PrimitivesParser {
        
        // Attach the empty array to the JSONObject under the key "vnfs"
        vnfs.put("vnfs", vnfsArray);
        JSONArray nsdArray = null;
        if ( nsdJson.has("nsd") ) {
          nsdArray = nsdJson.getJSONObject("nsd").getJSONArray("nsd");
        } else {
          nsdArray  = new JSONArray();
          nsdArray.put(nsdJson);
        }
        
        JSONArray nsdArray = nsdJson.getJSONObject("nsd").getJSONArray("nsd");

        // Assuming that there might be multiple 'nsd' entries, iterate over them
        processNSDEntries(nsdArray, vnfsArray);