Source:
public NetworkServiceDescriptor onboardNSD(byte[] bytes, String projectId) throws NotFoundException, PluginException, VimException, IOException, IncompatibleVNFPackage, org.openbaton.tosca.exceptions.NotFoundException, BadRequestException, AlreadyExistingException { File temp = File.createTempFile("CSAR", null); FileOutputStream fos = new FileOutputStream(temp); fos.write(bytes); InputStream input = new FileInputStream(temp); ArrayList<String> ids = new ArrayList<>(); readFiles(input); NSDTemplate nsdTemplate = Utils.bytesToNSDTemplate(this.template); NetworkServiceDescriptor nsd = toscaParser.parseNSDTemplate(nsdTemplate); for (VirtualNetworkFunctionDescriptor vnfd : nsd.getVnfd()) { if (!folderNames.contains(vnfd.getType())) { log.info("No Scripts specified for the VNFD of type: " + vnfd.getType()); } Set<Script> vnfScripts = new HashSet<>(); for (Script script : scripts) { String[] splitted_name = script.getName().split("!_!"); log.debug(splitted_name[0]); log.debug(script.getName()); if (splitted_name.length == 2) { String folder_name = splitted_name[0]; if (folder_name.equals(vnfd.getType())) { Script s = new Script(); s.setName(splitted_name[1]); s.setPayload(script.getPayload()); vnfScripts.add(s); } } } ids.add(saveVNFD(vnfd, projectId, vnfScripts)); } nsd.getVnfd().clear(); for (String id : ids) { String vnfdId = ""; Iterable<VirtualNetworkFunctionDescriptor> vnfds = vnfdRepository.findByProjectId(projectId); for (VirtualNetworkFunctionDescriptor vnfd : vnfds) { if (vnfd.getVnfPackageLocation().equals(id)) { vnfdId = vnfd.getId(); } } VirtualNetworkFunctionDescriptor vnfd = new VirtualNetworkFunctionDescriptor(); vnfd.setId(vnfdId); nsd.getVnfd().add(vnfd); } input.close(); fos.close(); this.template.close(); this.metadata.close(); return nsd; }

Target:
public NetworkServiceDescriptor onboardNSD(byte[] bytes, String projectId) throws NotFoundException, PluginException, VimException, IOException, IncompatibleVNFPackage, org.openbaton.tosca.exceptions.NotFoundException, BadRequestException, AlreadyExistingException { File temp = File.createTempFile("CSAR", null); FileOutputStream fos = new FileOutputStream(temp); fos.write(bytes); InputStream input = new FileInputStream(temp); ArrayList<String> ids = new ArrayList<>(); readFiles(input); NSDTemplate nsdTemplate = Utils.bytesToNSDTemplate(this.template); NetworkServiceDescriptor nsd = toscaParser.parseNSDTemplate(nsdTemplate); for (VirtualNetworkFunctionDescriptor vnfd : nsd.getVnfd()) { if (!folderNames.contains(vnfd.getType())) { log.warn("No Scripts specified for the VNFD of type: " + vnfd.getType()); } Set<Script> vnfScripts = new HashSet<>(); for (Script script : scripts) { String[] splitted_name = script.getName().split("!_!"); log.debug(splitted_name[0]); log.debug(script.getName()); if (splitted_name.length == 2) { String folder_name = splitted_name[0]; if (folder_name.equals(vnfd.getType())) { Script s = new Script(); s.setName(splitted_name[1]); s.setPayload(script.getPayload()); vnfScripts.add(s); } } } ids.add(saveVNFD(vnfd, projectId, vnfScripts)); } nsd.getVnfd().clear(); for (String id : ids) { String vnfdId = ""; Iterable<VirtualNetworkFunctionDescriptor> vnfds = vnfdRepository.findByProjectId(projectId); for (VirtualNetworkFunctionDescriptor vnfd : vnfds) { if (vnfd.getVnfPackageLocation().equals(id)) { vnfdId = vnfd.getId(); } } VirtualNetworkFunctionDescriptor vnfd = new VirtualNetworkFunctionDescriptor(); vnfd.setId(vnfdId); nsd.getVnfd().add(vnfd); } input.close(); fos.close(); this.template.close(); this.metadata.close(); return nsd; }