Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure modifying project endpoints are transactional #925

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.jdo.Transaction;
import javax.jdo.metadata.MemberMetadata;
import javax.jdo.metadata.TypeMetadata;
import java.io.IOException;
Expand Down Expand Up @@ -741,20 +740,14 @@ private static Set<UUID> parseDirectDependenciesUuids(
}

/**
* Deletes a Project and all objects dependant on the project.
* Deletes a Project and all objects dependent on the project.
*
* @param project the Project to delete
* @param commitIndex specifies if the search index should be committed (an expensive operation)
*/
@Override
public void recursivelyDelete(final Project project, final boolean commitIndex) {
final Transaction trx = pm.currentTransaction();
final boolean isJoiningExistingTrx = trx.isActive();
try {
if (!isJoiningExistingTrx) {
trx.begin();
}

runInTransaction(() -> {
for (final Project child : project.getChildren()) {
// Note: This could be refactored such that each project is deleted
// in its own transaction. That would break semantics when it comes
Expand Down Expand Up @@ -791,16 +784,7 @@ public void recursivelyDelete(final Project project, final boolean commitIndex)
} finally {
projectQuery.closeAll();
}

if (!isJoiningExistingTrx) {
trx.commit();
}

} finally {
if (!isJoiningExistingTrx && trx.isActive()) {
trx.rollback();
}
}
});
}

/**
Expand Down
Loading
Loading