Skip to content

Commit

Permalink
check if component exists before getting metadata
Browse files Browse the repository at this point in the history
Signed-off-by: vithikashukla <[email protected]>
  • Loading branch information
vithikashukla committed Oct 17, 2023
1 parent 9003355 commit c44173b
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ public static void performIntegrityCheck(final IntegrityMetaComponent integrityM
LOGGER.info("Result received on topic does not have component uuid, integrity check cannot be performed");
return;
}
//if integritymetacomponent is null, try to get it from db
//it could be that integrity metadata is already in db
IntegrityMetaComponent metadata = integrityMetaComponent == null ? qm.getIntegrityMetaComponent(result.getComponent().getPurl().toString()) : integrityMetaComponent;
//check if the object is not null
final Component component = qm.getObjectByUuid(Component.class, result.getComponent().getUuid());
if (component == null) {
LOGGER.info("Component is not present in database for which Integrity Check is performed");
return;
}
//check if the object is not null
//if integritymetacomponent is null, try to get it from db
//it could be that integrity metadata is already in db
IntegrityMetaComponent metadata = integrityMetaComponent == null ? qm.getIntegrityMetaComponent(result.getComponent().getPurl().toString()) : integrityMetaComponent;
IntegrityMatchStatus md5Status = checkHash(metadata.getMd5(), component.getMd5());
IntegrityMatchStatus sha1Status = checkHash(metadata.getSha1(), component.getSha1());
IntegrityMatchStatus sha256Status = checkHash(metadata.getSha256(), component.getSha256());
Expand Down

0 comments on commit c44173b

Please sign in to comment.