Skip to content

Commit

Permalink
Merge branch 'DCX6.3' into v6.3-qdr
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Jul 31, 2024
2 parents ccffafa + abd88ed commit 7805598
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
3 changes: 3 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2004,8 +2004,11 @@ private String init(boolean initFull) {
// ... And now the "real" working version lookup:

if (versionId != null) {
logger.info("Start time: " + System.currentTimeMillis());
this.workingVersion = datasetVersionService.findDeep(versionId);
logger.info("End time: " + System.currentTimeMillis());
dataset = workingVersion.getDataset();
logger.info("Dataset time: " + System.currentTimeMillis());
}

if (workingVersion == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,6 @@ public IndexResponse indexPermissionsOnSelfAndChildren(long definitionPointId) {
* inheritance
*/
public IndexResponse indexPermissionsOnSelfAndChildren(DvObject definitionPoint) {
List<DvObject> dvObjectsToReindexPermissionsFor = new ArrayList<>();
List<DataFile> filesToReindexAsBatch = new ArrayList<>();
/**
* @todo Re-indexing the definition point itself seems to be necessary for
Expand All @@ -393,25 +392,33 @@ public IndexResponse indexPermissionsOnSelfAndChildren(DvObject definitionPoint)
// We don't create a Solr "primary/content" doc for the root dataverse
// so don't create a Solr "permission" doc either.
int i = 0;
int numObjects = 0;
if (definitionPoint.isInstanceofDataverse()) {
Dataverse selfDataverse = (Dataverse) definitionPoint;
if (!selfDataverse.equals(dataverseService.findRootDataverse())) {
dvObjectsToReindexPermissionsFor.add(definitionPoint);
indexPermissionsForOneDvObject(definitionPoint);
numObjects++;
}
List<Dataset> directChildDatasetsOfDvDefPoint = datasetService.findByOwnerId(selfDataverse.getId());
for (Dataset dataset : directChildDatasetsOfDvDefPoint) {
dvObjectsToReindexPermissionsFor.add(dataset);
indexPermissionsForOneDvObject(dataset);
numObjects++;
for (DataFile datafile : filesToReIndexPermissionsFor(dataset)) {
filesToReindexAsBatch.add(datafile);
i++;
if (i % 100 == 0) {
reindexFilesInBatches(filesToReindexAsBatch);
filesToReindexAsBatch.clear();
}
if (i % 1000 == 0) {
logger.info("Progress: " +i + "files permissions reindexed");
}
}
logger.info("Progress : dataset " + dataset.getId() + " permissions reindexed");
}
} else if (definitionPoint.isInstanceofDataset()) {
dvObjectsToReindexPermissionsFor.add(definitionPoint);
indexPermissionsForOneDvObject(definitionPoint);
numObjects++;
// index files
Dataset dataset = (Dataset) definitionPoint;
for (DataFile datafile : filesToReIndexPermissionsFor(dataset)) {
Expand All @@ -423,7 +430,8 @@ public IndexResponse indexPermissionsOnSelfAndChildren(DvObject definitionPoint)
}
}
} else {
dvObjectsToReindexPermissionsFor.add(definitionPoint);
indexPermissionsForOneDvObject(definitionPoint);
numObjects++;
}

/**
Expand All @@ -432,17 +440,10 @@ public IndexResponse indexPermissionsOnSelfAndChildren(DvObject definitionPoint)
* @todo Should update timestamps, probably, even thought these are files, see
* https://github.com/IQSS/dataverse/issues/2421
*/
String response = reindexFilesInBatches(filesToReindexAsBatch);
logger.fine("Reindexed permissions for " + i + " files");
for (DvObject dvObject : dvObjectsToReindexPermissionsFor) {
/**
* @todo do something with this response
*/
IndexResponse indexResponse = indexPermissionsForOneDvObject(dvObject);
}

reindexFilesInBatches(filesToReindexAsBatch);
logger.info("Reindexed permissions for " + i + " files and " + numObjects + "datasets/collections");
return new IndexResponse("Number of dvObject permissions indexed for " + definitionPoint
+ ": " + dvObjectsToReindexPermissionsFor.size());
+ ": " + numObjects);
}

private String reindexFilesInBatches(List<DataFile> filesToReindexPermissionsFor) {
Expand Down

0 comments on commit 7805598

Please sign in to comment.