[CST-5251] Improved builder's cleanup to avoid consumers executions

This commit is contained in:
Luca Giamminonni
2022-02-10 16:11:07 +01:00
parent 579d926e95
commit 35179b535e
19 changed files with 19 additions and 0 deletions

View File

@@ -206,6 +206,7 @@ public class BitstreamBuilder extends AbstractDSpaceObjectBuilder<Bitstream> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
bitstream = c.reloadEntity(bitstream);

View File

@@ -34,6 +34,7 @@ public class BitstreamFormatBuilder extends AbstractCRUDBuilder<BitstreamFormat>
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
bitstreamFormat = c.reloadEntity(bitstreamFormat);

View File

@@ -55,6 +55,7 @@ public class BundleBuilder extends AbstractDSpaceObjectBuilder<Bundle> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
bundle = c.reloadEntity(bundle);

View File

@@ -124,6 +124,7 @@ public class ClaimedTaskBuilder extends AbstractBuilder<ClaimedTask, ClaimedTask
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
workspaceItem = c.reloadEntity(workspaceItem);

View File

@@ -253,6 +253,7 @@ public class CollectionBuilder extends AbstractDSpaceObjectBuilder<Collection> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
collection = c.reloadEntity(collection);

View File

@@ -116,6 +116,7 @@ public class CommunityBuilder extends AbstractDSpaceObjectBuilder<Community> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
community = c.reloadEntity(community);

View File

@@ -32,6 +32,7 @@ public class EPersonBuilder extends AbstractDSpaceObjectBuilder<EPerson> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
ePerson = c.reloadEntity(ePerson);

View File

@@ -36,6 +36,7 @@ public class EntityTypeBuilder extends AbstractBuilder<EntityType, EntityTypeSer
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
entityType = c.reloadEntity(entityType);

View File

@@ -35,6 +35,7 @@ public class GroupBuilder extends AbstractDSpaceObjectBuilder<Group> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
group = c.reloadEntity(group);

View File

@@ -209,6 +209,7 @@ public class ItemBuilder extends AbstractDSpaceObjectBuilder<Item> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
item = c.reloadEntity(item);

View File

@@ -38,6 +38,7 @@ public class MetadataFieldBuilder extends AbstractBuilder<MetadataField, Metadat
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
metadataField = c.reloadEntity(metadataField);

View File

@@ -37,6 +37,7 @@ public class MetadataSchemaBuilder extends AbstractBuilder<MetadataSchema, Metad
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
metadataSchema = c.reloadEntity(metadataSchema);

View File

@@ -104,6 +104,7 @@ public class PoolTaskBuilder extends AbstractBuilder<PoolTask, PoolTaskService>
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
workspaceItem = c.reloadEntity(workspaceItem);

View File

@@ -60,6 +60,7 @@ public class ProcessBuilder extends AbstractBuilder<Process, ProcessService> {
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
process = c.reloadEntity(process);

View File

@@ -39,6 +39,7 @@ public class RelationshipBuilder extends AbstractBuilder<Relationship, Relations
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
relationship = c.reloadEntity(relationship);

View File

@@ -37,6 +37,7 @@ public class RelationshipTypeBuilder extends AbstractBuilder<RelationshipType, R
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
relationshipType = c.reloadEntity(relationshipType);

View File

@@ -41,6 +41,7 @@ public class ResourcePolicyBuilder extends AbstractBuilder<ResourcePolicy, Resou
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
resourcePolicy = c.reloadEntity(resourcePolicy);

View File

@@ -116,6 +116,7 @@ public class WorkflowItemBuilder extends AbstractBuilder<XmlWorkflowItem, XmlWor
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
workspaceItem = c.reloadEntity(workspaceItem);

View File

@@ -106,6 +106,7 @@ public class WorkspaceItemBuilder extends AbstractBuilder<WorkspaceItem, Workspa
@Override
public void cleanup() throws Exception {
try (Context c = new Context()) {
c.setDispatcher("noindex");
c.turnOffAuthorisationSystem();
// Ensure object and any related objects are reloaded before checking to see what needs cleanup
workspaceItem = c.reloadEntity(workspaceItem);