Skip to content

Commit

Permalink
ufal/be-s3-checker-sync (#486)
Browse files Browse the repository at this point in the history
* Fixed UserCheck - There was created a wrong select

* Fixed ChecksumCheck - the session was closed but there were some requests do the database then
  • Loading branch information
milanmajchrak authored Dec 22, 2023
1 parent 3f2ecbb commit 51d7a45
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public List<Collection> findAuthorizedByGroup(Context context, EPerson ePerson,

@Override
public List<Collection> findCollectionsWithSubscribers(Context context) throws SQLException {
return list(createQuery(context, "SELECT DISTINCT col FROM Subscription s join s.collection col"));
return list(createQuery(context, "SELECT DISTINCT col FROM Subscription s join s.dSpaceObject col"));
}

@Override
Expand Down
46 changes: 24 additions & 22 deletions dspace-api/src/main/java/org/dspace/health/ChecksumCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.dspace.checker.ChecksumResultsCollector;
import org.dspace.checker.MostRecentChecksum;
import org.dspace.checker.SimpleDispatcher;
import org.dspace.content.Bitstream;
import org.dspace.core.Context;

/**
Expand All @@ -40,37 +41,38 @@ public String run(ReportInfo ri) {
checker.setReportVerbose(true);
try {
checker.process();
if (collector.arr.size() > 0) {
ret = String.format("Checksum performed on [%d] items:\n",
collector.arr.size());
int ok_items = 0;
for (MostRecentChecksum bi : collector.arr) {
if (!ChecksumResultCode.CHECKSUM_MATCH.equals(bi
.getChecksumResult().getResultCode())) {
Bitstream reloadedBitstream = context.reloadEntity(bi.getBitstream());
ret += String
.format("md5 checksum FAILED (%s): %s id: %s bitstream-id: %s\n was: %s\n is: %s\n",
bi.getChecksumResult(), reloadedBitstream.getName(),
reloadedBitstream.getInternalId(), reloadedBitstream.getID(),
bi.getExpectedChecksum(),
bi.getCurrentChecksum());
} else {
ok_items++;
}
}

ret += String.format("checksum OK for [%d] items\n", ok_items);
}
context.complete();
context = null;
return ret;
} catch (SQLException e) {
error(e);
} finally {
if (context != null) {
context.abort();
}
}

if (collector.arr.size() > 0) {
ret = String.format("Checksum performed on [%d] items:\n",
collector.arr.size());
int ok_items = 0;
for (MostRecentChecksum bi : collector.arr) {
if (!ChecksumResultCode.CHECKSUM_MATCH.equals(bi
.getChecksumResult().getResultCode())) {
ret += String
.format("md5 checksum FAILED (%s): %s id: %s bitstream-id: %s\n was: %s\n is: %s\n",
bi.getChecksumResult(), bi.getBitstream().getName(),
bi.getBitstream().getInternalId(), bi.getBitstream().getID(),
bi.getExpectedChecksum(),
bi.getCurrentChecksum());
} else {
ok_items++;
}
}

ret += String.format("checksum OK for [%d] items\n", ok_items);
}
return ret;
return ret;
}
}

Expand Down

0 comments on commit 51d7a45

Please sign in to comment.