use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImplTest method testPreprocess_success_resourceOnly.
@Test
public void testPreprocess_success_resourceOnly() throws Exception {
resourceOnlyFlushRules.put(Pattern.compile("/content/acs-aem-commons/.*"), new String[] { "/content/target" });
final ReplicationAction replicationAction = mock(ReplicationAction.class);
when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/page");
when(replicationAction.getType()).thenReturn(ReplicationActionType.ACTIVATE);
final ReplicationOptions replicationOptions = new ReplicationOptions();
replicationOptions.setSynchronous(false);
final ArgumentCaptor<DispatcherFlushFilter> agentFilterCaptor = ArgumentCaptor.forClass(DispatcherFlushFilter.class);
dispatcherFlushRules.preprocess(replicationAction, replicationOptions);
verify(dispatcherFlusher, times(1)).flush(any(ResourceResolver.class), eq(ReplicationActionType.ACTIVATE), eq(false), agentFilterCaptor.capture(), eq("/content/target"));
assertEquals(DispatcherFlushFilter.FlushType.ResourceOnly, agentFilterCaptor.getValue().getFlushType());
// Private impl class; no access to test for instanceof
assertEquals("DispatcherFlushRulesFilter", agentFilterCaptor.getValue().getClass().getSimpleName());
verifyNoMoreInteractions(dispatcherFlusher);
}
use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImplTest method testPreprocess_notAccepts_ReplicationActionNoFlushRules.
@Test
public void testPreprocess_notAccepts_ReplicationActionNoFlushRules() throws Exception {
when(this.hierarchicalFlushRules.size()).thenReturn(0);
when(this.resourceOnlyFlushRules.size()).thenReturn(0);
final ReplicationAction replicationAction = mock(ReplicationAction.class);
when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons");
dispatcherFlushRules.preprocess(replicationAction, new ReplicationOptions());
verifyZeroInteractions(dispatcherFlusher);
}
use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class PageRelocator method init.
@Override
public void init() throws RepositoryException {
if (mode == Mode.MOVE) {
String nodeName = sourcePath.substring(sourcePath.lastIndexOf('/'));
destinationPath += nodeName;
}
replicationOptions = new ReplicationOptions();
switch(publishMethod) {
case SELF_MANAGED:
replicationOptions.setSynchronous(true);
break;
default:
replicationOptions.setSynchronous(false);
break;
}
replicationOptions.setSuppressVersions(!createVerionsOnReplicate);
replicationOptions.setSuppressStatusUpdate(!updateStatus);
if (referenceSearchRoot == null || referenceSearchRoot.trim().isEmpty()) {
referenceSearchRoot = "/";
}
}
use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlusherImpl method flush.
/**
* {@inheritDoc}
*/
@Override
public final Map<Agent, ReplicationResult> flush(final ResourceResolver resourceResolver, final ReplicationActionType actionType, final boolean synchronous, final AgentFilter agentFilter, final String... paths) throws ReplicationException {
final ReplicationOptions options = new ReplicationOptions();
final ReplicationResultListener listener = new ReplicationResultListener();
options.setFilter(agentFilter);
options.setSynchronous(synchronous);
options.setSuppressStatusUpdate(true);
options.setSuppressVersions(true);
options.setListener(listener);
for (final String path : paths) {
if (log.isDebugEnabled()) {
log.debug("--------------------------------------------------------------------------------");
log.debug("Issuing Dispatcher Flush (via AEM Replication API) request for: {}", path);
log.debug(" > Synchronous: {}", options.isSynchronous());
log.debug(" > Replication Action Type: {}", actionType.name());
}
replicator.replicate(resourceResolver.adaptTo(Session.class), actionType, path, options);
}
return listener.getResults();
}
use of com.day.cq.replication.ReplicationOptions in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImplTest method testPreprocess_success_hierarchicalAndResourceOnly.
@Test
public void testPreprocess_success_hierarchicalAndResourceOnly() throws Exception {
hierarchicalFlushRules.put(Pattern.compile("/content/.*"), new String[] { "/content/hierarchical" });
resourceOnlyFlushRules.put(Pattern.compile("/content/.*"), new String[] { "/content/resource-only" });
final ReplicationAction replicationAction = mock(ReplicationAction.class);
when(replicationAction.getPath()).thenReturn("/content/acs-aem-commons/page");
when(replicationAction.getType()).thenReturn(ReplicationActionType.ACTIVATE);
final ReplicationOptions replicationOptions = new ReplicationOptions();
replicationOptions.setSynchronous(false);
replicationOptions.setFilter(new DispatcherFlushFilter());
final ArgumentCaptor<DispatcherFlushFilter> agentFilterCaptor = ArgumentCaptor.forClass(DispatcherFlushFilter.class);
dispatcherFlushRules.preprocess(replicationAction, replicationOptions);
verify(dispatcherFlusher, times(1)).flush(any(ResourceResolver.class), eq(ReplicationActionType.ACTIVATE), eq(false), agentFilterCaptor.capture(), eq("/content/hierarchical"));
assertEquals(DispatcherFlushFilter.FlushType.Hierarchical, agentFilterCaptor.getValue().getFlushType());
// Private impl class; no access to test for instanceof
assertEquals("DispatcherFlushRulesFilter", agentFilterCaptor.getValue().getClass().getSimpleName());
verify(dispatcherFlusher, times(1)).flush(any(ResourceResolver.class), eq(ReplicationActionType.ACTIVATE), eq(false), agentFilterCaptor.capture(), eq("/content/resource-only"));
assertEquals(DispatcherFlushFilter.FlushType.ResourceOnly, agentFilterCaptor.getValue().getFlushType());
// Private impl class; no access to test for instanceof
assertEquals("DispatcherFlushRulesFilter", agentFilterCaptor.getValue().getClass().getSimpleName());
verifyNoMoreInteractions(dispatcherFlusher);
}
Aggregations