Expand my Community achievements bar.

Applications for the 2024-2025 Adobe Experience Manager Champion Program are open!
SOLVED

AEMasCS - programatically publish to Brand Portal

Avatar

Level 3

Hi all,

i'm trying to automatically publish assets to brand portal when a user upload them to a desired folder

Basically i added the following configuration to the Custom Dam Workflow runner 

 

<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0" jcr:primaryType="sling:OsgiConfig" postProcWorkflowsByExpression="[/content/dam(/.*/)bp-digital(/.*):/var/workflow/models/asset-publish-to-brand-portal]"/>

 

and the workflow models has:

Create Version -> Scheduled Publish to Brand Portal -> DAM Update Asset Workflow Completed

 

but the issue is when i try to deploy it with cloud manager pipeline, i have the following validation error 

The workflow process definition at /conf/global/settings/workflow/models/asset-publish-to-brand-portal/jcr:content/flow/process_1138020458 [Publish Asset] uses a workflow process com.day.cq.dam.core.process.ScheduledPublishBPProcess which is not supported on AEM as a Cloud Service.


i was also reviewing the executed JS code when we use the Touch UI and Publish asset to brand portal and it is doing a post to a servlet, should i use something similar to that?

 

Thanks in advance

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 3

exactly! i used that script to check the code compatibility and all is good. I dont understand. Yes i will try with a support ticket.

View solution in original post

6 Replies

Avatar

Community Advisor

Hi @VictorToledo , Are you getting any errors/warnings in logs stating com.day.cq.dam.core.process.ScheduledPublishBPProcess is not supported on Cloud or some documentation?

AFAIK, the process step works perfectly fine on AEM as Cloud Service and I was able to publish and view assets on BP

 

  <process
     jcr:lastModified="{Date}2023-05-24T17:14:03.819Z"
     jcr:lastModifiedBy="admin"
     jcr:primaryType="nt:unstructured"
     jcr:title="Process"
     sling:resourceType="cq/workflow/components/model/process">
     <metaData
        jcr:primaryType="nt:unstructured"
        PROCESS="com.day.cq.dam.core.process.ScheduledPublishBPProcess"/>
  </process>

 

 

Avatar

Level 3

Hi @shubhanshu_singh , thanks for your help.

below my workflow

 

<flow jcr:primaryType="nt:unstructured" sling:resourceType="foundation/components/parsys">
            <process
                    jcr:created="{Date}2023-05-17T16:12:26.943-03:00"
                     jcr:createdBy="admin"
                    jcr:description="The Version to be activated/replicated is created"
                    jcr:lastModified="{Date}2023-05-17T16:13:13.586-03:00"
                    jcr:lastModifiedBy="admin"
                    jcr:primaryType="nt:unstructured"
                    jcr:title="Create Version"
                    sling:resourceType="cq/workflow/components/model/process">
                <metaData PROCESS="com.day.cq.wcm.workflow.process.CreateVersionProcess"
                          PROCESS_AUTO_ADVANCE="true"
                          jcr:primaryType="nt:unstructured"/>
            </process>
            <process_1138020458
                    jcr:created="{Date}2023-05-17T16:12:28.468-03:00"
                    jcr:createdBy="admin"
                    jcr:description="Publish the asset to Brand Portal"
                    jcr:lastModified="{Date}2023-05-17T16:13:55.637-03:00"
                    jcr:lastModifiedBy="admin"
                    jcr:primaryType="nt:unstructured"
                    jcr:title="Publish Asset"
                    sling:resourceType="cq/workflow/components/model/process">
                <metaData
                        PROCESS="com.day.cq.dam.core.process.ScheduledPublishBPProcess"
                        PROCESS_AUTO_ADVANCE="true"
                        jcr:primaryType="nt:unstructured"/>
            </process_1138020458>
            <damupdateassetworkflowcompletedprocess
                    jcr:description="This process will send DamEvent.Type.DAM_UPDATE_ASSET_WORKFLOW_COMPLETED event when DAM update asset workflow is completed"
                    jcr:primaryType="nt:unstructured"
                    jcr:title="DAM Update Asset Workflow Completed"
                    sling:resourceType="dam/components/workflow/damupdateassetworkflowcompletedprocess">
                <metaData
                        PROCESS="com.day.cq.dam.core.impl.process.DamUpdateAssetWorkflowCompletedProcess"
                          PROCESS_AUTO_ADVANCE="true"
                        jcr:primaryType="nt:unstructured"/>
            </damupdateassetworkflowcompletedprocess>
        </flow>

 

 and the error is during the deployment to Cloud Manager environments.

VictorToledo_0-1684951401382.png

2023-05-24T14:10:05.739Z

com.myproject:aem-myproject-project.ui.content:1.0.1-SNAPSHOT

The workflow process definition at /conf/global/settings/workflow/models/asset-publish-to-brand-portal/jcr:content/flow/process_1138020458 [Publish Asset] uses a workflow process com.day.cq.dam.core.process.ScheduledPublishBPProcess which is not supported on AEM as a Cloud Service.

Bug

Blocker

I know that i can override the results and continue with the deployment but i would like to use the recommended approach and avoid the issue on cloud manager

Avatar

Community Advisor

Hi @VictorToledo , the best way forward for this would be to create a adobe support ticket for build pipeline issue and mention your cloud sdk version in the ticket. I am pretty much sure the process step is supported. 

You can have a look here https://github.com/adobe/aem-cloud-migration/blob/master/src/main/resources/workflowSteps.properties 
com.day.cq.dam.core.process.ScheduledPublishBPProcess  and com.day.cq.dam.core.process.ScheduledUnPublishBPProcess
both are marked to be supported.

Avatar

Correct answer by
Level 3

exactly! i used that script to check the code compatibility and all is good. I dont understand. Yes i will try with a support ticket.

Avatar

Community Advisor

@VictorToledo - Did you find a fix for the above issue with Adobe support?

Avatar

Level 3

hi, 

i used my custom workflow process to avoid the issue.

public class PublishToBPProcess  implements WorkflowProcess {

    private final Logger log = LoggerFactory.getLogger(getClass());

    private static final String OPERATION = "dam.mac.sync";

    private static final String SERVICE_USER_ID = "assetidhelper";

    @reference
    private SlingRepository repository;

    @reference
    private FolderSyncHelper folderSyncHelper;

    @reference
    private ResourceResolverFactory resourceResolverFactory;

    public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metadataMap) throws WorkflowException {
        if (workItem == null || workItem.getWorkflow() == null || workItem.getWorkflow().getInitiator() == null) {
            throw new WorkflowException("invalid workflow item");
        }
        try (ResourceResolver userResourceResolver = getInitiatorResolver(workItem)) {
            this.log.info("Stating scheduled publish/unpublish to BrandPortal ..");
            WorkflowData data = workItem.getWorkflowData();
            String path = (String)data.getPayload();
            FolderSyncRequest request = new FolderSyncRequest();
            request.setType("mediaportal");
            request.setOperation(OPERATION);
            request.setContextPath("");
            request.setPaths(new String[] { path });
            request.setUserResourceResolver(userResourceResolver);
            FolderSyncResponse response = this.folderSyncHelper.process(request);
            this.log.info("Finished scheduled publish/unpublish to BrandPortal. success = {} error = {}", response.getStatus() == null, response.getStatus());
        } catch (RepositoryException | LoginException ex) {
            throw new WorkflowException(ex);
        }
    }

    private ResourceResolver getInitiatorResolver(WorkItem workItem) throws RepositoryException, LoginException {
        String initiator = workItem.getWorkflow().getInitiator();
        Session initiatorSession = getUserSession(initiator);
        return getResourceResolver(initiatorSession);
    }

    private Session getUserSession(String userId) throws RepositoryException {
        SimpleCredentials credentials = new SimpleCredentials(userId, new char[0]);
        return this.repository.impersonateFromService(SERVICE_USER_ID, credentials, null);
    }

    protected ResourceResolver getResourceResolver(Session session) throws LoginException {
        return this.resourceResolverFactory.getResourceResolver(Collections.singletonMap(AUTHENTICATION_INFO_SESSION, session));
    }
}