use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class RenditionModifyingProcessTest method test_with_null_rendition_arg_is_noop.
@Test
public void test_with_null_rendition_arg_is_noop() throws Exception {
WorkItem workItem = mock(WorkItem.class);
MetaDataMap metaData = new SimpleMetaDataMap();
process.execute(workItem, workflowSession, metaData, workflowHelper);
verifyZeroInteractions(harness);
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class RenditionModifyingProcessTest method test_with_blank_rendition_arg_is_noop.
@Test
public void test_with_blank_rendition_arg_is_noop() throws Exception {
WorkItem workItem = mock(WorkItem.class);
MetaDataMap metaData = new SimpleMetaDataMap();
metaData.put("PROCESS_ARGS", "");
process.execute(workItem, workflowSession, metaData, workflowHelper);
verifyZeroInteractions(harness);
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class RenditionModifyingProcessTest method test_with_rendition_arg_getting_no_rendition_is_noop.
@Test
public void test_with_rendition_arg_getting_no_rendition_is_noop() throws Exception {
String path = "/content/dam/some/path.ext";
WorkItem workItem = mock(WorkItem.class);
WorkflowData data = mock(WorkflowData.class);
when(workItem.getWorkflowData()).thenReturn(data);
when(data.getPayloadType()).thenReturn(WorkflowHelper.TYPE_JCR_PATH);
when(data.getPayload()).thenReturn(path);
Resource resource = mock(Resource.class);
Asset asset = mock(Asset.class);
when(resource.adaptTo(Asset.class)).thenReturn(asset);
when(resource.getResourceType()).thenReturn(DamConstants.NT_DAM_ASSET);
when(resourceResolver.getResource(path)).thenReturn(resource);
MetaDataMap metaData = new SimpleMetaDataMap();
metaData.put("PROCESS_ARGS", "renditionName:test");
process.execute(workItem, workflowSession, metaData, workflowHelper);
verifyZeroInteractions(harness);
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class DamMetadataPropertyResetProcess method execute.
@Override
public final void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws WorkflowException {
ResourceResolver resourceResolver = null;
String wfPayload = null;
try {
resourceResolver = this.getResourceResolver(workflowSession.getSession());
wfPayload = (String) workItem.getWorkflowData().getPayload();
final List<String> payloads = workflowPackageManager.getPaths(resourceResolver, wfPayload);
final Map<String, String> srcDestMap = this.getProcessArgsMap(metaDataMap);
for (final String payload : payloads) {
final Asset asset = DamUtil.resolveToAsset(resourceResolver.getResource(payload));
if (asset == null) {
log.debug("Payload path [ {} ] does not resolve to an asset", payload);
continue;
}
String metadataPath = String.format("%s/%s/%s", asset.getPath(), JcrConstants.JCR_CONTENT, DamConstants.METADATA_FOLDER);
Resource metadataResource = resourceResolver.getResource(metadataPath);
if (metadataResource == null) {
log.error("Could not find the metadata node for Asset [ " + asset.getPath() + " ]");
throw new WorkflowException("Could not find the metadata node for Asset [ " + asset.getPath() + " ]");
}
final ModifiableValueMap mvm = metadataResource.adaptTo(ModifiableValueMap.class);
for (final Map.Entry<String, String> entry : srcDestMap.entrySet()) {
final String srcProperty = entry.getValue();
final String destProperty = entry.getKey();
if (mvm.get(srcProperty) != null) {
// Remove dest property first in case Types differ
mvm.remove(destProperty);
// If the src value is NOT null, update the dest property
mvm.put(destProperty, mvm.get(srcProperty));
} else if (mvm.containsKey(srcProperty)) {
// Else if the src value IS null, AND the src property exists on the node, remove the dest property
mvm.remove(destProperty);
}
// Else leave the dest property alone since there is no source defined to overwrite it with
// Remove the source
mvm.remove(srcProperty);
}
}
} catch (LoginException e) {
throw new WorkflowException("Could not get a ResourceResolver object from the WorkflowSession", e);
} catch (RepositoryException e) {
throw new WorkflowException(String.format("Could not find the payload for '%s'", wfPayload), e);
} finally {
if (resourceResolver != null) {
resourceResolver.close();
}
}
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class SendTemplatedEmailProcessTest method test_with_payload_notJcrPath_is_noop.
@Test
public void test_with_payload_notJcrPath_is_noop() throws Exception {
WorkflowData workflowData = mock(WorkflowData.class);
when(workItem.getWorkflowData()).thenReturn(workflowData);
when(workflowData.getPayloadType()).thenReturn("");
MetaDataMap metaData = new SimpleMetaDataMap();
process.execute(workItem, workflowSession, metaData);
verifyZeroInteractions(harness);
}
Aggregations