Skip to content

Commit

Permalink
Fix search indexing processor to expand the changeset inside of doMai…
Browse files Browse the repository at this point in the history
…nProcess method execution (#483)
  • Loading branch information
jmendeza authored Jan 10, 2025
1 parent c9d6c77 commit beb6f6f
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,82 +199,81 @@ public boolean supportsMode(Deployment.Mode mode) {
protected abstract void doCreateIndexIfMissing();

/**
* Override to add pages/components that need to be updated because a component that they include was updated.
* Expand changeSet by adding pages/components that need to be updated because a component that they include was updated.
*
* @param changeSet original change set
* @return filtered change set
*/
@Override
protected ChangeSet getFilteredChangeSet(ChangeSet changeSet) {
protected ChangeSet expandChangeSet(ChangeSet changeSet) {
if (createIndexIfMissing) {
logger.info("Ensuring that index {} exists", indexId);
doCreateIndexIfMissing();
}
boolean isReprocessAll = BooleanUtils.toBoolean(getDeploymentParam(REPROCESS_ALL_FILES_PARAM_NAME));
changeSet = super.getFilteredChangeSet(changeSet);
if (changeSet != null && !changeSet.isEmpty() && xmlFlatteningEnabled && !isReprocessAll) {
List<String> createdFiles = changeSet.getCreatedFiles();
List<String> updatedFiles = changeSet.getUpdatedFiles();
List<String> deletedFiles = changeSet.getDeletedFiles();
List<String> newUpdatedFiles = new ArrayList<>(updatedFiles);

if (CollectionUtils.isNotEmpty(createdFiles)) {
for (String path : createdFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
if (changeSet == null || changeSet.isEmpty() || !xmlFlatteningEnabled || isReprocessAll) {
return changeSet;
}
List<String> createdFiles = changeSet.getCreatedFiles();
List<String> updatedFiles = changeSet.getUpdatedFiles();
List<String> deletedFiles = changeSet.getDeletedFiles();
List<String> newUpdatedFiles = new ArrayList<>(updatedFiles);

if (CollectionUtils.isNotEmpty(createdFiles)) {
for (String path : createdFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
}
}

if (CollectionUtils.isNotEmpty(updatedFiles)) {
for (String path : updatedFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
if (CollectionUtils.isNotEmpty(updatedFiles)) {
for (String path : updatedFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
}
}


if (CollectionUtils.isNotEmpty(deletedFiles)) {
for (String path : deletedFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
if (CollectionUtils.isNotEmpty(deletedFiles)) {
for (String path : deletedFiles) {
if (isDescriptor(path)) {
addItemsThatInheritFromDescriptorToUpdatedFiles(path, createdFiles, newUpdatedFiles,
deletedFiles);
}
if (reindexItemsOnComponentUpdates && isComponent(path)) {
addItemsThatIncludeComponentToUpdatedFiles(path, createdFiles, newUpdatedFiles, deletedFiles);
}
}

ChangeSet filteredChangeSet = new ChangeSet(createdFiles, newUpdatedFiles, deletedFiles);
filteredChangeSet.setUpdateDetails(changeSet.getUpdateDetails());
filteredChangeSet.setUpdateLog(changeSet.getUpdateLog());
return filteredChangeSet;
} else {
return changeSet;
}

ChangeSet filteredChangeSet = new ChangeSet(createdFiles, newUpdatedFiles, deletedFiles);
filteredChangeSet.setUpdateDetails(changeSet.getUpdateDetails());
filteredChangeSet.setUpdateLog(changeSet.getUpdateLog());
return filteredChangeSet;
}

@Override
protected ChangeSet doMainProcess(Deployment deployment, ProcessorExecution execution,
ChangeSet filteredChangeSet, ChangeSet originalChangeSet) throws DeployerException {
logger.info("Performing search indexing...");

List<String> createdFiles = emptyIfNull(filteredChangeSet.getCreatedFiles());
List<String> updatedFiles = emptyIfNull(filteredChangeSet.getUpdatedFiles());
List<String> deletedFiles = emptyIfNull(filteredChangeSet.getDeletedFiles());
ChangeSet expandedChangeSet = expandChangeSet(filteredChangeSet);

List<String> createdFiles = emptyIfNull(expandedChangeSet.getCreatedFiles());
List<String> updatedFiles = emptyIfNull(expandedChangeSet.getUpdatedFiles());
List<String> deletedFiles = emptyIfNull(expandedChangeSet.getDeletedFiles());
UpdateSet updateSet = new UpdateSet(ListUtils.union(createdFiles, updatedFiles), deletedFiles);
updateSet.setUpdateDetails(filteredChangeSet.getUpdateDetails());
updateSet.setUpdateLog(filteredChangeSet.getUpdateLog());
updateSet.setUpdateDetails(expandedChangeSet.getUpdateDetails());
updateSet.setUpdateLog(expandedChangeSet.getUpdateLog());
UpdateStatus updateStatus = new UpdateStatus();

execution.setStatusDetails(updateStatus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private boolean matchesStatusCondition(Deployment deployment) {
return switch (statusCondition) {
case SUCCESS -> status == Deployment.Status.SUCCESS;
case ON_ANY_STATUS -> true;
case ON_ANY_FAILURE -> hasExecutionsFailures(deployment);
case ON_ANY_FAILURE -> status == Deployment.Status.FAILURE || hasExecutionsFailures(deployment);
case ON_TOTAL_FAILURE -> status == Deployment.Status.FAILURE;
};
}
Expand Down

0 comments on commit beb6f6f

Please sign in to comment.