I'm looking to create a workflow in Adobe Assets CS to update the name of modified assets.
I see on posts people referring to the Update Asset model but when I look in the existing Models I don't see it Nor can I find processes that match.
Any help is appreciated.
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Civison
In AEM as a Cloud Service (AEMaaCS), the traditional DAM Update Asset workflow is not available because AEMaaCS relies more on microservices and out-of-the-box automated processes for asset processing but for your use case you can use an event listener to capture and respond to asset updates.
Below is a similar code example with title update:
import com.day.cq.dam.api.Asset;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.event.jobs.JobManager;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
@Component(
service = EventHandler.class,
immediate = true,
property = {
"event.topics=org/apache/sling/api/resource/Resource/CHANGED",
"event.filter=(path=/content/dam/*)"
}
)
public class AssetTitleUpdateListener implements EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(AssetTitleUpdateListener.class);
@Reference
private ResourceResolverFactory resourceResolverFactory;
@Reference
private JobManager jobManager;
@Override
public void handleEvent(Event event) {
try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(Map.of(ResourceResolverFactory.SUBSERVICE, "dataWrite"))) {
String path = (String) event.getProperty("path");
Resource resource = resolver.getResource(path);
if (resource != null && resource.isResourceType("dam:Asset")) {
Asset asset = resource.adaptTo(Asset.class);
if (asset != null) {
String newTitle = asset.getMetadataValue("dc:title");
// Custom logic on title change
LOG.info("Asset title updated to: {}", newTitle);
// Here you can add further processing logic if needed
}
}
} catch (Exception e) {
LOG.error("Error handling asset title update event: ", e);
}
}
}
Hi @Civison
In AEM as a Cloud Service (AEMaaCS), the traditional DAM Update Asset workflow is not available because AEMaaCS relies more on microservices and out-of-the-box automated processes for asset processing but for your use case you can use an event listener to capture and respond to asset updates.
Below is a similar code example with title update:
import com.day.cq.dam.api.Asset;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.event.jobs.JobManager;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
@Component(
service = EventHandler.class,
immediate = true,
property = {
"event.topics=org/apache/sling/api/resource/Resource/CHANGED",
"event.filter=(path=/content/dam/*)"
}
)
public class AssetTitleUpdateListener implements EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(AssetTitleUpdateListener.class);
@Reference
private ResourceResolverFactory resourceResolverFactory;
@Reference
private JobManager jobManager;
@Override
public void handleEvent(Event event) {
try (ResourceResolver resolver = resourceResolverFactory.getServiceResourceResolver(Map.of(ResourceResolverFactory.SUBSERVICE, "dataWrite"))) {
String path = (String) event.getProperty("path");
Resource resource = resolver.getResource(path);
if (resource != null && resource.isResourceType("dam:Asset")) {
Asset asset = resource.adaptTo(Asset.class);
if (asset != null) {
String newTitle = asset.getMetadataValue("dc:title");
// Custom logic on title change
LOG.info("Asset title updated to: {}", newTitle);
// Here you can add further processing logic if needed
}
}
} catch (Exception e) {
LOG.error("Error handling asset title update event: ", e);
}
}
}
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies