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);
verifyNoInteractions(harness);
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class WorkflowHelperImplTest method testBuildArguments.
@Test
public void testBuildArguments() throws Exception {
MetaDataMap map = mock(MetaDataMap.class);
when(map.get(WorkflowHelper.PROCESS_ARGS, String.class)).thenReturn("foo:bar,goo:baz");
String[] result = workflowHelper.buildArguments(map);
assertNotNull(result);
assertEquals(2, result.length);
assertEquals("foo:bar", result[0]);
assertEquals("goo:baz", result[1]);
}
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 {
String wfPayload = null;
try (ResourceResolver 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) {
String msg = String.format("Could not find the metadata node for Asset [ %s ]", asset.getPath());
throw new WorkflowException(msg);
}
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);
}
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class WorkflowHelperImplTest method testBuildArgumentsFromNullArguments.
@Test
public void testBuildArgumentsFromNullArguments() throws Exception {
MetaDataMap map = mock(MetaDataMap.class);
when(map.get(WorkflowHelper.PROCESS_ARGS, String.class)).thenReturn(null);
String[] result = workflowHelper.buildArguments(map);
assertNotNull(result);
assertEquals(0, result.length);
}
use of com.day.cq.workflow.metadata.MetaDataMap in project acs-aem-commons by Adobe-Consulting-Services.
the class WorkflowHelperImplTest method testBuildArgumentsFromBlankArguments.
@Test
public void testBuildArgumentsFromBlankArguments() throws Exception {
MetaDataMap map = mock(MetaDataMap.class);
when(map.get(WorkflowHelper.PROCESS_ARGS, String.class)).thenReturn("");
String[] result = workflowHelper.buildArguments(map);
assertNotNull(result);
assertEquals(0, result.length);
}
Aggregations