Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for 1.3.1 release #25

Merged
merged 5 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>etoolbox-rollout-manager.core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@
* the rollout manager tool.
*/
public interface PageReplicationService {
List<RolloutStatus> replicateItems(ResourceResolver resourceResolver, RolloutItem[] items, PageManager pageManager);
List<RolloutStatus> replicateItems(ResourceResolver resourceResolver, RolloutItem[] items, PageManager pageManager, boolean isDeep);
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import javax.jcr.Session;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -74,23 +75,23 @@ public class PageReplicationServiceImpl implements PageReplicationService {
@Reference
private Replicator replicator;

public List<RolloutStatus> replicateItems(ResourceResolver resourceResolver, RolloutItem[] items, PageManager pageManager) {
public List<RolloutStatus> replicateItems(ResourceResolver resourceResolver, RolloutItem[] items, PageManager pageManager, boolean isDeep) {
return Arrays.stream(items)
.collect(Collectors.groupingBy(RolloutItem::getDepth))
.entrySet()
.stream()
.sorted(Map.Entry.comparingByKey())
.map(Map.Entry::getValue)
.flatMap(sortedByDepthItems -> replicateSortedByDepthItems(resourceResolver, sortedByDepthItems, pageManager))
.flatMap(sortedByDepthItems -> replicateSortedByDepthItems(resourceResolver, sortedByDepthItems, pageManager, isDeep))
.collect(Collectors.toList());
}

private Stream<RolloutStatus> replicateSortedByDepthItems(ResourceResolver resourceResolver, List<RolloutItem> items, PageManager pageManager) {
private Stream<RolloutStatus> replicateSortedByDepthItems(ResourceResolver resourceResolver, List<RolloutItem> items, PageManager pageManager, boolean isDeep) {
ExecutorService executorService = Executors.newFixedThreadPool(config.poolSize());
return items.stream()
.filter(item -> StringUtils.isNotBlank(item.getTarget()))
.filter(item -> !isBluePrintPage(item, resourceResolver))
.map(item -> CompletableFuture.supplyAsync(() -> replicate(resourceResolver, item, pageManager), executorService))
.map(item -> CompletableFuture.supplyAsync(() -> replicate(resourceResolver, item, pageManager, isDeep), executorService))
.collect(Collectors.toList())
.stream()
.map(CompletableFuture::join);
Expand All @@ -110,7 +111,7 @@ private boolean isBluePrintPage(RolloutItem item, ResourceResolver resourceResol
return hasRelationships;
}

private RolloutStatus replicate(ResourceResolver resourceResolver, RolloutItem targetItem, PageManager pageManager) {
private RolloutStatus replicate(ResourceResolver resourceResolver, RolloutItem targetItem, PageManager pageManager, boolean isDeep) {

String targetPath = targetItem.getTarget();
RolloutStatus status = new RolloutStatus(targetPath);
Expand All @@ -123,12 +124,28 @@ private RolloutStatus replicate(ResourceResolver resourceResolver, RolloutItem t
return status;
}
try {
replicator.replicate(session, ReplicationActionType.ACTIVATE, targetPath);
if (isDeep) {
replicatePageAndChildren(session, targetPage.get());
} else {
replicator.replicate(session, ReplicationActionType.ACTIVATE, targetPath);
}
status.setSuccess(true);
} catch (ReplicationException ex) {
status.setSuccess(false);
LOG.error("Exception during page replication", ex);
LOG.error("Exception during page replication: {}", targetPath, ex);
}
return status;
}

private void replicatePageAndChildren(Session session, Page page) {
try {
replicator.replicate(session, ReplicationActionType.ACTIVATE, page.getPath());
for (Iterator<Page> children = page.listChildren(); children.hasNext(); ) {
Page childPage = children.next();
replicatePageAndChildren(session, childPage);
}
} catch (Exception ex) {
LOG.error("Exception during page replication: {}", page.getPath(), ex);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected void doPost(final SlingHttpServletRequest request, final SlingHttpServ
LOG.debug("Should activate pages: {}", shouldActivate);
List<RolloutStatus> activationStatuses = new ArrayList<>();
if (shouldActivate) {
activationStatuses = pageReplicationService.replicateItems(request.getResourceResolver(), rolloutItems, request.getResourceResolver().adaptTo(PageManager.class));
activationStatuses = pageReplicationService.replicateItems(request.getResourceResolver(), rolloutItems, request.getResourceResolver().adaptTo(PageManager.class), isDeepRollout);
}

writeStatusesIfFailed(Stream.concat(rolloutStatuses.stream(), activationStatuses.stream())
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<packaging>pom</packaging>
<version>1.3.0</version>
<version>1.3.1</version>
<name>EToolbox Rollout Manager</name>
<description>EToolbox Rollout Manager</description>

Expand Down
2 changes: 1 addition & 1 deletion ui.apps.structure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
const PROCESSING_ERROR_MSG = Granite.I18n.get('Rollout failed');
const PROCESSING_ERROR_FAILED_PATHS_MSG = Granite.I18n.get('Rollout failed for the following paths:');
const SUCCESS_MSG = Granite.I18n.get('Completed');
const SUCCESS_REPLICATION_MSG = Granite.I18n.get('Rollout is completed. Publishing is in progress.');

function getProcessingErrorMsg(xhr) {
if (xhr.status === 400 && xhr.responseJSON && xhr.responseJSON.failedTargets) {
Expand Down Expand Up @@ -114,7 +115,7 @@
}).fail((xhr) => {
logger.log(getProcessingErrorMsg(xhr), false);
}).done(() => {
logger.log(SUCCESS_MSG, false);
data.shouldActivate ? logger.log(SUCCESS_REPLICATION_MSG, false) : logger.log(SUCCESS_MSG, false);
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion ui.config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion ui.content/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<parent>
<groupId>com.exadel.etoolbox</groupId>
<artifactId>etoolbox-rollout-manager</artifactId>
<version>1.3.0</version>
<version>1.3.1</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down
Loading