Commit fa6ccebe authored by Eduardo Santos's avatar Eduardo Santos
Browse files

Put the primitives parsing inside a try-catch, to handle cases were the are no...

Put the primitives parsing inside a try-catch, to handle cases were the are no descriptor to parse the primitives from
parent ae4b2817
Loading
Loading
Loading
Loading
+30 −13
Original line number Diff line number Diff line
@@ -1213,9 +1213,18 @@ public class ServiceSpecificationRepoService {

			/******************** Begin Primitives Handling ********************/

			JSONObject allPrimitives = new JSONObject();

			try {
				// Access the first element only, to handle the case where there are duplicate descriptor fields
				ConstituentVxF vxf = nsd.getConstituentVxF().get(0);
				
				if (vxf.getVxfref() == null) {
					throw new NullPointerException("vxf.getVxfref() is null");
				}

				System.out.println("vxf.getVxfref(): " + vxf.getVxfref());
				
				JSONObject nsdJson = PrimitivesParser.processNSD(nsd);
				JSONObject vnfdJson = PrimitivesParser.processVxF(vxf);
		
@@ -1225,7 +1234,15 @@ public class ServiceSpecificationRepoService {

				JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs);
		
            JSONObject allPrimitives = PrimitivesParser.extractVNFPrimitives(vnfdJson, vduPrimitives);
				allPrimitives = PrimitivesParser.extractVNFPrimitives(vnfdJson, vduPrimitives);
			} catch (NullPointerException e) {
				System.err.println("Error: " + e.getMessage());
				e.printStackTrace();
				// allPrimitives is already initialized to an empty JSONObject
			} catch (Exception e) {
				System.err.println("An unexpected error occurred.");
				e.printStackTrace();
			}
    
            addServiceSpecCharacteristic(serviceSpec, "PrimitivesList", "NSPrimitives", new Any(allPrimitives.toString(), ""), EValueType.TEXT);