We use the valtech migration tool to update refactored components etc. automatically on deployment. It uses the groovy console.
We would prefer to run this only on author, then publish the changed artifacts to publish.
The migration script might update components in hundreds of pages.
How could we publish the affected artifacts programmatically?
Someone mentioned a workflow might be able to do this. Any ideas how?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @TB3dock,
I think there are few prgramatic options you could take into account:
activate(String path)
//or
activate(String path, ReplicationOptions options)
import com.adobe.granite.workflow.WorkflowSession
import com.adobe.granite.workflow.exec.WorkflowData
import com.adobe.granite.workflow.model.WorkflowModel
// workflow model path
def model = "/var/workflow/models/metadata_map_example"
// path to payload that will be processed by the workflow
def payloadPath = "/content/we-retail/language-masters/en/equipment"
def workflowSession = resolver.adaptTo(WorkflowSession.class)
def workflowModel = workflowSession.getModel(model)
def workflowData = workflowSession.newWorkflowData("JCR_PATH", payloadPath)
// optional metadata
Map<String, Object> workflowMetadata = new HashMap<>()
workflowMetadata.put("anyData", "You Want")
// start the workflow
workflowSession.startWorkflow(workflowModel, workflowData, workflowMetadata)
You can also consider some manually executed options, dedicated to handle publication or bulk workflow execution:
Hi @TB3dock,
I think there are few prgramatic options you could take into account:
activate(String path)
//or
activate(String path, ReplicationOptions options)
import com.adobe.granite.workflow.WorkflowSession
import com.adobe.granite.workflow.exec.WorkflowData
import com.adobe.granite.workflow.model.WorkflowModel
// workflow model path
def model = "/var/workflow/models/metadata_map_example"
// path to payload that will be processed by the workflow
def payloadPath = "/content/we-retail/language-masters/en/equipment"
def workflowSession = resolver.adaptTo(WorkflowSession.class)
def workflowModel = workflowSession.getModel(model)
def workflowData = workflowSession.newWorkflowData("JCR_PATH", payloadPath)
// optional metadata
Map<String, Object> workflowMetadata = new HashMap<>()
workflowMetadata.put("anyData", "You Want")
// start the workflow
workflowSession.startWorkflow(workflowModel, workflowData, workflowMetadata)
You can also consider some manually executed options, dedicated to handle publication or bulk workflow execution:
Hi @TB3dock,
You can make use of this interface to replicate programmatically -
Here are couple of examples to use this:
def replicator = sling.getService(Replicator.class)
def rp = replicator.replicate(session, ReplicationActionType.ACTIVATE, parentNode.getPath());
2. If you want to replicate from a java class -
@Reference
private Replicator replicator;
//replicate a page
replicator.replicate(session, ReplicationActionType.ACTIVATE, pagePath);
//replicate a node
replicator.replicate(node.getSession(), ReplicationActionType.ACTIVATE, node.getPath());
//Sample method
protected void activateNode(Node node) {
try {
LOG.info("ACTIVATE NODE {}", node.getPath());
replicator.replicate(node.getSession(), ReplicationActionType.ACTIVATE, node.getPath());
LOG.info("NODE HAS BEEN ACTIVATED {}", node.getPath());
} catch (RepositoryException e) {
LOG.error("RepositoryException", e);
} catch (ReplicationException e) {
LOG.error("ReplicationException", e);
}
}
Hope this helps!! Let me know if you have more questions on this.