Skip to content

Commit

Permalink
DSC-1455 fix lazy initialization iterating over the hierarchy with th…
Browse files Browse the repository at this point in the history
…e object scope
  • Loading branch information
abollini committed Jan 15, 2024
1 parent dd699c2 commit 1b1fbac
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dspace-api/src/main/java/org/dspace/curate/Curator.java
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,8 @@ protected boolean doSite(TaskRunner tr, Site site) throws IOException {
//Then, perform this task for all Top-Level Communities in the Site
// (this will recursively perform task for all objects in DSpace)
for (Community subcomm : communityService.findAllTop(ctx)) {
// force a reload of the community in case a commit was performed
subcomm = ctx.reloadEntity(subcomm);
if (!doCommunity(tr, subcomm)) {
return false;
}
Expand All @@ -488,17 +490,22 @@ protected boolean doCommunity(TaskRunner tr, Community comm) throws IOException,
if (!tr.run(comm)) {
return false;
}
Context context = curationContext();
// force a reload in case we are committing after each object
comm = context.reloadEntity(comm);
for (Community subcomm : comm.getSubcommunities()) {
if (!doCommunity(tr, subcomm)) {
return false;
}
}
// force a reload in case we are committing after each object
comm = context.reloadEntity(comm);
for (Collection coll : comm.getCollections()) {
context.reloadEntity(coll);
if (!doCollection(tr, coll)) {
return false;
}
}
Context context = curationContext();
context.uncacheEntity(comm);
return true;
}
Expand Down Expand Up @@ -545,7 +552,6 @@ protected void visit(DSpaceObject dso) throws IOException, SQLException {
Context curCtx = curationContext();
if (curCtx != null && txScope.equals(TxScope.OBJECT)) {
curCtx.commit();
curCtx.reloadEntity(dso);
}
}

Expand Down

0 comments on commit 1b1fbac

Please sign in to comment.