Skip to content

Commit

Permalink
Merge pull request #3876 from IQSS/3875-destroy-dataset-thumbnail-dat…
Browse files Browse the repository at this point in the history
…afile-constraint

Fixes the constraint violation error in DestroyDataseCommand (3875)
  • Loading branch information
kcondon authored Jun 1, 2017
2 parents f6441f8 + 0ecdd35 commit a9c5354
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
this, Collections.singleton(Permission.DeleteDatasetDraft), doomed);
}

// If there is a dedicated thumbnail DataFile, it needs to be reset
// explicitly, or we'll get a constraint violation when deleting:
doomed.setThumbnailFile(null);
final Dataset managedDoomed = ctxt.em().merge(doomed);


List<String> datasetAndFileSolrIdsToDelete = new ArrayList<>();
// files need to iterate through and remove 'by hand' to avoid
// optimistic lock issues....
// optimistic lock issues... (plus the physical files need to be
// deleted too!)

Iterator <DataFile> dfIt = doomed.getFiles().iterator();
while (dfIt.hasNext()){
DataFile df = dfIt.next();
Expand Down

0 comments on commit a9c5354

Please sign in to comment.