How to wait until dam update asset workflow completes in AEM - workflow

I am using a servlet to upload images programatically through asset manager api into dam and its renditions will be created by dam update asset workflow. In the servlet response I need to return the urls of all the generated renditions for the UI to consume.Now since the rendition generation will take time as dam update asset workflow takes time to start and to complete, how to ensure that my servlet sends the response only after all the renditions
are completely generated? Note:- I am using ImageMagic for generating renditions via dam update asset workflow.

The property dam:assetState=processed gets set on the jcr:content (dam:AssetContent nodetype node) if the asset is successfully processed by the "DAM Update Asset" workflow.
I would say that it is best to check the status using an AJAX call instead of keeping the connection open.
If you really would like to do this all synchronously then you could look into using "Synthetic Workflow" from ACS Commons: https://adobe-consulting-services.github.io/acs-aem-commons/features/synthetic-workflow/index.html

Related

How to get an asset all details in AEM with API request?

I am using AEM API in my automation. We published a file from workfront to AEM. That file have multiple information:
1. Basic
2. Test1
3. test2
4. etc
When I hit the api:
/api/assets/..../abc.pdf.json
I am getting very less information under the properties and metadata section. (In short, it does not have Test1, Test2 and other tab information)
Is there any way to fetch all these from aem API's? It will reduce my overhead to validate these details from UI Automation.
First of look checkout the metadata nodes of file for the desired data to be present. I would rather prefer writing a custom servlet in AEM which takes in path parameter as an asset path and gives back the response back in desired format.
I figured it out.
The following API returns all the JCR content in API response:
<baseURL>/content/dam/path to that file.-1.json

Support multi-site approval based workflow on wagtail

Objective
We would like to setup multi-site wagtail with approval chain.
Develop -> QA -> Release -> Production
Description
A develop / content editor goes to the wagtail admin and creates the content. Once done, sends the request for approval to move to QA site.
QA moderator reviews the content on develop site. If approved, the content gets moved to QA site. The content carries over to next stage approval (release).
Same process ahead for next sites in approval chain.
Questions
Is it possible to setup a publish chain with approval policy in wagtail? I tried to research a bit but could only find "workflow" and "workflow tasks". Do I need to custom code a workflow task to be able to achieve this?
This should be possible but you will need to consider what you really want to do in regards to the 'move' step, do you want to actually move the Page instance to a new site in a new tree or copy the current (and its history) and move that copy Page OR make a copy to put in place of the Page that was moved.
Nonetheless, the documentation on how to add a new Task type is the best place to start, it walks you through custom Task types.
In the solution below however, I thought it would be simplest to create a new model that behaves exactly like GroupApprovalTask (the default task included, used for moderation) but add a field that links it to the Site model.
This way, in the admin UI the admin users can now create as many PublishSiteTask as you want, one for each Site (QA/Dev/Prod etc) and then each of those could be linked to different user groups. It is important to differentiate between the database model (a task type with some fields) and the instances (a task created in the UI) and the actual task instances that are created against each page revision (not page) as the workflow steps progress.
Code Example
models.py
from django.db import models, transaction
from wagtail.core.models import GroupApprovalTask, Page, Site
# ... other imports
class PublishSiteTask(GroupApprovalTask):
site = models.OneToOneField(Site, on_delete=models.CASCADE)
admin_form_fields = ['site'] + GroupApprovalTask.admin_form_fields
#transaction.atomic
def on_action(self, task_state, user, action_name, **kwargs):
"""Performs an action on a task state determined by the ``action_name`` string passed"""
if action_name == 'approve':
# get the page that this action is referring to via the task_state.page_revision
page = task_state.page_revision.as_page_object()
# find the new parent target at this task's site
# how this is done depends on the site/page structure
new_parent_target = self.site.root_page
# move the page to a new location
# note: this will actually move it from its current tree, you may want to make a copy first
page.move(new_parent_target)
# be sure to preserve any existing task behaviour
super().on_action(task_state, user, action_name, **kwargs)
Additional Links
Task class definition
GroupApprovalTask class definition
You may want to do some pre-work in the code to check that the page can actually move to the different Site, each Page has a method can_move_to that could help.
The move method referenced above is part of the Wagtail code but the full docs for that method can be found in the Treebeard API docs which Wagtail uses to manage the tree structure.

How to implement Captioning in Azure Media services V3?

How to complete captioning in azure media service 3by using .net SDK
I am using Azure Media Services v3 tutorials (https://github.com/Azure-Samples/media-services-v3-dotnet-tutorials) but missing How to update a video caption file(vtt file) into a media service asset by using .net SDK. Can some body help me on same.
You would simply treat the caption file the same way as you would a video that you upload. The only difference is that the caption file would be put into an asset that already has video. In other words, you'd upload your video, encode it, and in the output asset you'd upload the VTT file.
From a code perspective you would use:
// Use Media Services API to get back a response that contains
// SAS URL for the Asset container into which to upload blobs.
// That is where you would specify read-write permissions
// and the exparation time for the SAS URL.
var response = await client.Assets.ListContainerSasAsync(
resourceGroupName,
accountName,
assetName,
permissions: AssetContainerPermission.ReadWrite,
expiryTime: DateTime.UtcNow.AddHours(4).ToUniversalTime());
var sasUri = new Uri(response.AssetContainerSasUrls.First());
// Use Storage API to get a reference to the Asset container
// that was created by calling Asset's CreateOrUpdate method.
CloudBlobContainer container = new CloudBlobContainer(sasUri);
var blob = container.GetBlockBlobReference(Path.GetFileName(fileToUpload));
// Use Strorage API to upload the file into the container in storage.
await blob.UploadFromFileAsync(fileToUpload);
Where assetName is the name of your output asset.
How were you planning to deliver captions for playback? For the example in the Azure Media Player, the VTT file is added as a separate URL (from the HLS or DASH streaming URL). If this works, then you can simply edit the streaming URL and add the file name of the VTT file (as shown in one of the examples in the player page).
If, however, you need playback of captions via other HLS or DASH players, then there are some additional steps needed to expose the captions track along with video and audio. We will update our documentation pages when certain service updates have been deployed.

Problems uploading images with "Share on LinkedIn"

So I am trying to post an image to my personal page through the new v2 LinkedIn API. I am sending the following data:
{"author":"urn:li:person:MYID","lifecycleState":"PUBLISHED","visibility":{"com.linkedin.ugc.MemberNetworkVisibility":"PUBLIC"},"specificContent":{"com.linkedin.ugc.ShareContent":{"shareMediaCategory":"IMAGE","shareCommentary":{"text":"Hello. Just testing the LinkedIn API."},"media":[{"status":"READY","originalUrl":"https:\/\/www.bbc.co.uk\/news","title":{"text":"BBC news"},"description":{"text":"A test post about BBC news"},"media":"urn:li:digitalmediaAsset:C4E22AQFmydgog-wKTw"}]}}}
As you'll see I've already uploaded the image and have a successful Asset ID and reference.
I get a successful id back from Linkedin: urn:li:share:651159824176993XXX but for some reason my image never appears?? What am I doing wrong?
Before creating the UGC post referencing the registered asset, you need to make sure that the asset is AVAILABLE, otherwise your image won't appear on LinkedIn.
When registering an asset, it goes through the following phases:
PROCESSING (LinkedIn probably does some optimizations to the image / checks if it's valid)
AVAILABLE (you should be good to go)
CLIENT_ERROR (or some other error I can't remember. Basically you should try it with a different asset)
For my app, before creating the UGC post with the image(s), I make sure the asset(s) is / are AVAILABLE first. How do I do that? By checking the status of each asset every 5 seconds with a timeout of 5 minutes (I tried it with a GIF once and to this day is still processing haha).
Once all assets are AVAILABLE, I create the UGC post referencing them, just like you did in your question.

Implement Inbox Functionality in custom cq component?

We want to develop a smooth-flowing workflow experience (but still use workflows). Currently, a user needs to use the sidekick to initiate the workflow, then to the inbox, which takes them back to the page to use the sidekick again. When they go to the inbox, they need to restrict to the model and path of the page. It would be nice for the user to only have to go to the content page and from there, launch the different workflow forms that need to happen, like a little "inbox" right on the page that is subject to the workflow.
I have written a custom component that can initiate the custom workflow. The custom component can also query the WorkFlowSession and obtain any active WorkItems for the current page that the component resides (using the WorkItemFilter interface). What I want to do is provide a link to the user to the next step in the workflow from the custom component, just like the inbox does.
Here is an example output from an WorkItem instance toString method:
21.05.2014 09:45:29.300 *ERROR* [0:0:0:0:0:0:0:1%0 [1400679929160] GET /content/test/mailing1.html HTTP/1.1] org.rand.whatcounts.EmailCampaignCoordinator Found workitem: -----------------------------
WorkItem Id: /etc/workflow/instances/2014-05-21/model_1400679794564399000/workItems/node4_etc_workflow_instances_2014-05-21_model_1400679794564399000
Workflow Id: /etc/workflow/instances/2014-05-21/model_1400679794564399000
Payload: /content/test/mailing1
Payload Type: JCR_PATH
key = historyEntryPath value = /etc/workflow/instances/2014-05-21/model_1400679794564399000/history/1400679924113
key = comment value =
My hope is that by using the workflow api items, I can create the link that the user could click on to proceed in the workflow (just like the inbox).
Thanks for listening!
Phillip
There are two ways to implement this
Java-Based Solution
I was able to figure out one way by looking at
http://localhost:4502/libs/cq/workflow/components/inbox/list/json.jsp
The important part of this jsp is that, given a workItem instance, you can get the path for your next step using the JcrPathBuilderManager:
pathBuilder.getPath(wi);
Using this, I was able to output a link to the next step in the workflow to the user (without having user go to their inbox).
Javascript/JSON Based Solution
I didn't go far with this solution (I didn't write any js) but this was my fall back position if I didn't find the java-solution listed above. Once could implement custom JS in CQ Component that would call the json feed for the user inbox, do some client side filtering (to restrict it to only items related to current page). The URL to the feed is
http://localhost:4502/libs/cq/workflow/content/inbox/list.json?start=0&limit=40
Thanks!