Skip to content
Closed
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
10 changes: 8 additions & 2 deletions src/main/java/edu/harvard/iq/dataverse/EditDatafilesPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import edu.harvard.iq.dataverse.authorization.AuthenticationServiceBean;
import edu.harvard.iq.dataverse.authorization.Permission;
import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser;
import edu.harvard.iq.dataverse.batch.util.LoggingUtil;
import edu.harvard.iq.dataverse.branding.BrandingUtil;
import edu.harvard.iq.dataverse.datasetutility.AddReplaceFileHelper;
import edu.harvard.iq.dataverse.datasetutility.FileReplaceException;
Expand Down Expand Up @@ -84,6 +85,7 @@
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.solr.client.solrj.SolrServerException;
import org.primefaces.context.RequestContext;

/**
Expand Down Expand Up @@ -1377,6 +1379,12 @@ public String save() {
dataset = datasetService.find(dataset.getId());
}
}
//We also need to reindex since no commands that include reindexing have been called.
indexService.indexDataset(dataset, true);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To fix the bug in 4.15.1, I could have added this at line ~1430, but reindexing is also needed at ~1438 for another case (see issue). I think adding it here catches both cases and avoids reindexing when it isn't needed (as would be the case if 1438 were uncommented).

I also tried to mimic the new exception handling/logging from #4425.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, really this logic should go through a Command. Not sure how it got in without that. We'll need to decide if we want his simple fix or require the refactoring to a command.

(my guess is we'll seetle on accepting this but open up a new issue for the refactoring - being in a command is important for permissions, automatic logging, and allowing same code for UI and API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 - it might be as easy as always forcing datasetUpdateRequired == true as was done with prov around line 1178 (or just removing that flag completely).

} catch (IOException | SolrServerException e) {
String failureLogText = "Post EditDatafilePage save() indexing failed. You can kickoff a re-index of this dataset with: \r\n curl http://localhost:8080/api/admin/index/datasets/" + dataset.getId().toString();
failureLogText += "\r\n" + e.getLocalizedMessage();
LoggingUtil.writeOnSuccessFailureLog(null, failureLogText, dataset);
} finally {
datasetService.removeDatasetLocks(dataset, DatasetLock.Reason.EditInProgress);
}
Expand Down Expand Up @@ -1434,8 +1442,6 @@ public String save() {
//if (newDraftVersion) {
// return returnToDraftVersionById();
//}
// indexService.indexDataset(dataset, true);
// indexing is handled by the commands
logger.fine("Redirecting to the dataset page, from the edit/upload page.");
return returnToDraftVersion();
}
Expand Down