Skip to content

Commit

Permalink
Merge pull request #11114 from QualitativeDataRepository/IQSS/11113-F…
Browse files Browse the repository at this point in the history
…ix_file_perm_doc_creation

IQSS/11113 fix file perm doc creation
  • Loading branch information
ofahimIQSS authored Jan 10, 2025
2 parents 7fdb21a + e16ff35 commit 4d089cc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions doc/release-notes/11113-avoid-orphan-perm-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This release fixes a bug that caused Dataverse to generate unnecessary solr documents for files when a file is added/deleted from a draft dataset. These documents could accumulate and potentially impact performance.

Assuming the upgrade to solr 9.7.0 also occurs in this release, there's nothing else needed for this PR. (Starting with a new solr insures the solr db is empty and that a reindex is already required.)


8 changes: 8 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DataFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -1142,4 +1142,12 @@ public boolean isDeaccessioned() {
}
return inDeaccessionedVersions; // since any published version would have already returned
}
public boolean isInDatasetVersion(DatasetVersion version) {
for (FileMetadata fmd : getFileMetadatas()) {
if (fmd.getDatasetVersion().equals(version)) {
return true;
}
}
return false;
}
} // end of class
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,15 @@ private List<DvObjectSolrDoc> constructDatafileSolrDocs(DataFile dataFile, Map<L
Map<DatasetVersion.VersionState, Boolean> desiredCards = searchPermissionsService.getDesiredCards(dataFile.getOwner());
for (DatasetVersion datasetVersionFileIsAttachedTo : datasetVersionsToBuildCardsFor(dataFile.getOwner())) {
boolean cardShouldExist = desiredCards.get(datasetVersionFileIsAttachedTo.getVersionState());
if (cardShouldExist) {
/*
* Since datasetVersionFileIsAttachedTo should be a draft or the most recent
* released one, it could be more efficient to stop the search through
* FileMetadatas after those two (versus continuing through all prior versions
* as in isInDatasetVersion). Alternately, perhaps filesToReIndexPermissionsFor
* should not combine the list of files for the different datsetversions into a
* single list to start with.
*/
if (cardShouldExist && dataFile.isInDatasetVersion(datasetVersionFileIsAttachedTo)) {
String solrIdStart = IndexServiceBean.solrDocIdentifierFile + dataFile.getId();
String solrIdEnd = getDatasetOrDataFileSolrEnding(datasetVersionFileIsAttachedTo.getVersionState());
String solrId = solrIdStart + solrIdEnd;
Expand Down

0 comments on commit 4d089cc

Please sign in to comment.