Loading src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java +1 −30 Original line number Diff line number Diff line Loading @@ -1213,36 +1213,7 @@ 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); JSONObject vnfs = PrimitivesParser.extractVNFIds(nsdJson); vnfs = PrimitivesParser.mapVDUsToVNFs(vnfdJson, vnfs); JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs); 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(); } JSONObject allPrimitives = PrimitivesParser.extractPrimitives(nsd); addServiceSpecCharacteristic(serviceSpec, "PrimitivesList", "NSPrimitives", new Any(allPrimitives.toString(), ""), EValueType.TEXT); Loading src/main/java/org/etsi/osl/tmf/util/PrimitivesParser.java +50 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ * @Author: Eduardo Santos * @Date: 2024-04-23 20:11:31 * @Last Modified by: Eduardo Santos * @Last Modified time: 2024-05-01 20:13:05 * @Last Modified time: 2024-05-26 15:26:17 */ /*- Loading Loading @@ -39,6 +39,10 @@ import java.util.Map; import org.etsi.osl.model.ConstituentVxF; /** * This class is responsible for parsing available primitives from a Network Service * from its Network Service Descriptor (NSD) and Virtual Network Function Descriptor (VNFD). */ public class PrimitivesParser { public static Map<String, String> cpdToVduMap = new HashMap<String, String>(); Loading Loading @@ -66,6 +70,51 @@ public class PrimitivesParser { */ /** * Extracts all available primitives from a given Network Service Descriptor (NSD). * This method processes the NSD to retrieve and map its constituent VNF descriptors (VNFDs) and Virtual Deployment Units (VDUs), * then extracts the configuration primitives associated with each VDU and VNF, returning a consolidated JSON object with all primitives. * * @param nsd The NetworkServiceDescriptor object containing the network service data. * @return A JSONObject containing all the extracted primitives from the NSD. */ public static JSONObject extractPrimitives(NetworkServiceDescriptor nsd) { 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); JSONObject vnfs = PrimitivesParser.extractVNFIds(nsdJson); vnfs = PrimitivesParser.mapVDUsToVNFs(vnfdJson, vnfs); JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs); 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(); } return allPrimitives; } /** * Retrieves a NetworkServiceDescriptor object from a JSON file. Loading Loading
src/main/java/org/etsi/osl/tmf/scm633/reposervices/ServiceSpecificationRepoService.java +1 −30 Original line number Diff line number Diff line Loading @@ -1213,36 +1213,7 @@ 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); JSONObject vnfs = PrimitivesParser.extractVNFIds(nsdJson); vnfs = PrimitivesParser.mapVDUsToVNFs(vnfdJson, vnfs); JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs); 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(); } JSONObject allPrimitives = PrimitivesParser.extractPrimitives(nsd); addServiceSpecCharacteristic(serviceSpec, "PrimitivesList", "NSPrimitives", new Any(allPrimitives.toString(), ""), EValueType.TEXT); Loading
src/main/java/org/etsi/osl/tmf/util/PrimitivesParser.java +50 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ * @Author: Eduardo Santos * @Date: 2024-04-23 20:11:31 * @Last Modified by: Eduardo Santos * @Last Modified time: 2024-05-01 20:13:05 * @Last Modified time: 2024-05-26 15:26:17 */ /*- Loading Loading @@ -39,6 +39,10 @@ import java.util.Map; import org.etsi.osl.model.ConstituentVxF; /** * This class is responsible for parsing available primitives from a Network Service * from its Network Service Descriptor (NSD) and Virtual Network Function Descriptor (VNFD). */ public class PrimitivesParser { public static Map<String, String> cpdToVduMap = new HashMap<String, String>(); Loading Loading @@ -66,6 +70,51 @@ public class PrimitivesParser { */ /** * Extracts all available primitives from a given Network Service Descriptor (NSD). * This method processes the NSD to retrieve and map its constituent VNF descriptors (VNFDs) and Virtual Deployment Units (VDUs), * then extracts the configuration primitives associated with each VDU and VNF, returning a consolidated JSON object with all primitives. * * @param nsd The NetworkServiceDescriptor object containing the network service data. * @return A JSONObject containing all the extracted primitives from the NSD. */ public static JSONObject extractPrimitives(NetworkServiceDescriptor nsd) { 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); JSONObject vnfs = PrimitivesParser.extractVNFIds(nsdJson); vnfs = PrimitivesParser.mapVDUsToVNFs(vnfdJson, vnfs); JSONObject vduPrimitives = PrimitivesParser.extractVDUPrimitives(vnfdJson, vnfs); 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(); } return allPrimitives; } /** * Retrieves a NetworkServiceDescriptor object from a JSON file. Loading