Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ut-manager into develop
  • Loading branch information
smiakchilo committed Nov 4, 2024
2 parents 5a341cd + 29f2a7e commit db9af33
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import org.apache.commons.lang3.time.StopWatch;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.SlingHttpServletResponse;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.servlets.HttpConstants;
import org.apache.sling.api.servlets.SlingAllMethodsServlet;
import org.apache.sling.servlets.annotations.SlingServletResourceTypes;
Expand Down Expand Up @@ -188,10 +190,18 @@ private RolloutStatus rollout(RolloutItem targetItem, PageManager pageManager, b
status.setSuccess(false);
String message = String.format("Item rollout failed, master: %s, target: %s", masterPath, targetPath);
LOG.error(message, e);
discardUnsavedChanges(masterPage.get());
}
return status;
}

private static void discardUnsavedChanges(Page masterPage) {
Optional.of(masterPage)
.map(page -> page.adaptTo(Resource.class))
.map(Resource::getResourceResolver)
.ifPresent(ResourceResolver::revert);
}

private RolloutManager.RolloutParams toRolloutParams(Page masterPage, String targetPath, boolean isDeep) {
RolloutManager.RolloutParams params = new RolloutManager.RolloutParams();
params.master = masterPage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class RolloutServletTest {
"/content/we-retail/ch/ca-es-ch-livecopy/experience"
);

private final AemContext context = new AemContext(ResourceResolverType.JCR_MOCK);
private final AemContext context = new AemContext(ResourceResolverType.RESOURCERESOLVER_MOCK);

@Mock
private RolloutManager rolloutManager;
Expand Down

0 comments on commit db9af33

Please sign in to comment.