use of com.day.cq.replication.ReplicationActionType in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImplTest method testConfigureReplicationActionType_DELETE.
@Test
public void testConfigureReplicationActionType_DELETE() throws Exception {
final ReplicationActionType expected = ReplicationActionType.DELETE;
final ReplicationActionType actual = dispatcherFlushRules.configureReplicationActionType("DELETE");
assertEquals(expected, actual);
}
use of com.day.cq.replication.ReplicationActionType in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImplTest method testConfigureReplicationActionType_INHERIT.
@Test
public void testConfigureReplicationActionType_INHERIT() throws Exception {
final ReplicationActionType expected = null;
final ReplicationActionType actual = dispatcherFlushRules.configureReplicationActionType("INHERIT");
assertEquals(expected, actual);
}
use of com.day.cq.replication.ReplicationActionType in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImpl method preprocess.
/**
* {@inheritDoc}
*/
@Override
@SuppressWarnings("squid:S3776")
public final void preprocess(final ReplicationAction replicationAction, final ReplicationOptions replicationOptions) throws ReplicationException {
if (!this.accepts(replicationAction, replicationOptions)) {
return;
}
// Path being replicated
final String path = replicationAction.getPath();
// Replication action type occurring
final ReplicationActionType flushActionType = replicationActionType == null ? replicationAction.getType() : replicationActionType;
ResourceResolver resourceResolver = null;
try {
resourceResolver = resourceResolverFactory.getServiceResourceResolver(AUTH_INFO);
// Flush full content hierarchies
for (final Map.Entry<Pattern, String[]> entry : this.hierarchicalFlushRules.entrySet()) {
final Pattern pattern = entry.getKey();
final Matcher m = pattern.matcher(path);
if (m.matches()) {
for (final String value : entry.getValue()) {
final String flushPath = m.replaceAll(value);
log.debug("Requesting hierarchical flush of associated path: {} ~> {}", path, flushPath);
dispatcherFlusher.flush(resourceResolver, flushActionType, false, HIERARCHICAL_FILTER, flushPath);
}
}
}
// Flush explicit resources using the CQ-Action-Scope ResourceOnly header
for (final Map.Entry<Pattern, String[]> entry : this.resourceOnlyFlushRules.entrySet()) {
final Pattern pattern = entry.getKey();
final Matcher m = pattern.matcher(path);
if (m.matches()) {
for (final String value : entry.getValue()) {
final String flushPath = m.replaceAll(value);
log.debug("Requesting ResourceOnly flush of associated path: {} ~> {}", path, entry.getValue());
dispatcherFlusher.flush(resourceResolver, flushActionType, false, RESOURCE_ONLY_FILTER, flushPath);
}
}
}
} catch (LoginException e) {
log.error("Error issuing dispatcher flush rules do to repository login exception: {}", e.getMessage());
} finally {
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
use of com.day.cq.replication.ReplicationActionType in project acs-aem-commons by Adobe-Consulting-Services.
the class DispatcherFlushRulesImpl method configureReplicationActionType.
/**
* Derive the ReplicationActionType to be used for Flushes.
*
* @param replicationActionTypeName String name of ReplicationActionType to use
* @return the ReplicationActionType to use, or null if the ReplicationActionType should be inherited from the
* incoming ReplicationAction
*/
protected final ReplicationActionType configureReplicationActionType(final String replicationActionTypeName) {
try {
final ReplicationActionType repActionType = ReplicationActionType.valueOf(replicationActionTypeName);
log.debug("Using replication action type: {}", repActionType.name());
return repActionType;
} catch (IllegalArgumentException ex) {
log.debug("Using replication action type: {}", OPTION_INHERIT);
return null;
}
}
use of com.day.cq.replication.ReplicationActionType in project acs-aem-commons by Adobe-Consulting-Services.
the class BrandPortalSyncProcess method execute.
public final void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
ResourceResolver resourceResolver = null;
final List<String> assetPaths = new ArrayList<String>();
final ReplicationActionType replicationActionType = getReplicationActionType(metaDataMap);
try {
resourceResolver = workflowHelper.getResourceResolver(workflowSession);
final List<String> payloads = workflowPackageManager.getPaths(resourceResolver, (String) workItem.getWorkflowData().getPayload());
for (final String payload : payloads) {
// Convert the payloads to Assets, in preparation for Brand Portal publication
// Note that this only supports Assets as payloads and NOT Asset Folders
final Asset asset = DamUtil.resolveToAsset(resourceResolver.getResource(payload));
if (asset == null) {
log.debug("Payload path [ {} ] does not resolve to an asset", payload);
} else {
assetPaths.add(asset.getPath());
}
}
// Based on the WF Process activation/deactivation directive; leverage the DamSyncService to publish the the Asset
if (ReplicationActionType.ACTIVATE.equals(replicationActionType)) {
damSyncService.publishResourcesToMP(assetPaths, resourceResolver);
} else if (ReplicationActionType.DEACTIVATE.equals(replicationActionType)) {
damSyncService.unpublishResourcesFromMP(assetPaths, resourceResolver);
} else {
log.warn("Unknown replication action type [ {} ] for AEM Assets Brand Portal Sync", replicationActionType);
}
} catch (RepositoryException e) {
log.error("Could not find the payload", e);
throw new WorkflowException("Could not find the payload");
} finally {
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
Aggregations