@@ -229,6 +229,8 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
229229 Integer relReuseCount = Integer .valueOf (messageMap .get (REL_REUSE_COUNT_KEY ));
230230 Integer pkgReuseCount = Integer .valueOf (messageMap .get (PKG_REUSE_COUNT_KEY ));
231231 Integer pkgCreationCount = Integer .valueOf (messageMap .get (PKG_CREATION_COUNT_KEY ));
232+ String errorCountStr = messageMap .get (COMPONENT_IMPORT_ERROR_COUNT_KEY );
233+ int compImportErrorCount = CommonUtils .isNullEmptyOrWhitespace (errorCountStr ) ? 0 : Integer .parseInt (errorCountStr );
232234
233235 String packages = messageMap .get (DUPLICATE_PACKAGE );
234236 if (CommonUtils .isNotNullEmptyOrWhitespace (packages )) {
@@ -254,6 +256,7 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
254256 if (pkg == null || CommonUtils .isNullEmptyOrWhitespace (pkg .getName ()) || CommonUtils .isNullEmptyOrWhitespace (pkg .getVersion ())
255257 || CommonUtils .isNullEmptyOrWhitespace (pkg .getPurl ())) {
256258 invalidPackages .add (fullName );
259+ compImportErrorCount ++;
257260 log .error (String .format ("Invalid package '%s' found in SBoM, missing name or version or purl! " , fullName ));
258261 continue ;
259262 }
@@ -288,6 +291,7 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
288291 project .setPackageIds (linkedPackages );
289292 } catch (SW360Exception e ) {
290293 log .error ("An error occured while creating/adding package from SBOM: " + e .getMessage ());
294+ compImportErrorCount ++;
291295 continue ;
292296 }
293297 }
@@ -306,6 +310,7 @@ public RequestSummary importFromBOM(InputStream inputStream, AttachmentContent a
306310 messageMap .put (REL_REUSE_COUNT_KEY , String .valueOf (relReuseCount ));
307311 messageMap .put (PKG_CREATION_COUNT_KEY , String .valueOf (pkgCreationCount ));
308312 messageMap .put (PKG_REUSE_COUNT_KEY , String .valueOf (pkgReuseCount ));
313+ messageMap .put (COMPONENT_IMPORT_ERROR_COUNT_KEY , String .valueOf (compImportErrorCount ));
309314 requestSummary .setMessage (convertCollectionToJSONString (messageMap ));
310315 }
311316 } else {
@@ -508,6 +513,7 @@ private Map<String, String> importAllComponentsAsReleases(Map<String, List<org.c
508513 if (CommonUtils .isNullEmptyOrWhitespace (release .getVersion ()) ) {
509514 log .error ("release version is not present in SBoM for component: " + comp .getName ());
510515 invalidReleases .add (comp .getName ());
516+ compImportErrorCount ++;
511517 continue ;
512518 }
513519 relName = SW360Utils .getVersionedName (release .getName (), release .getVersion ());
@@ -650,6 +656,7 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c
650656 if (CommonUtils .isNullEmptyOrWhitespace (release .getVersion ()) ) {
651657 log .error ("release version is not present in SBoM for component: " + comp .getName ());
652658 invalidReleases .add (comp .getName ());
659+ compImportErrorCount ++;
653660 continue ;
654661 }
655662 String relName = SW360Utils .getVersionedName (release .getName (), release .getVersion ());
@@ -712,6 +719,7 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c
712719 if (pkg == null || CommonUtils .isNullEmptyOrWhitespace (pkg .getName ()) || CommonUtils .isNullEmptyOrWhitespace (pkg .getVersion ())
713720 || CommonUtils .isNullEmptyOrWhitespace (pkg .getPurl ())) {
714721 invalidPackages .add (pkgName );
722+ compImportErrorCount ++;
715723 log .error (String .format ("Invalid package '%s' found in SBoM, missing name or version or purl! " , pkgName ));
716724 continue ;
717725 }
@@ -786,6 +794,7 @@ private Map<String, String> importAllComponentsAsPackages(Map<String, List<org.c
786794 if (CommonUtils .isNullEmptyOrWhitespace (release .getVersion ()) ) {
787795 log .error ("release version is not present in SBoM for component: " + comp .getName ());
788796 invalidReleases .add (comp .getName ());
797+ compImportErrorCount ++;
789798 continue ;
790799 }
791800
0 commit comments