dam:assetState property value remains "processing" after custom workflow finish

Avatar

Avatar

wolk_arkadiusz

Avatar

wolk_arkadiusz

wolk_arkadiusz

10-10-2017

Hi,

I have created custom workflow, which is generating additional renditions for assets after they are created/modified. Problem is that (after workflow finish) value of property dam:assetState remains "processing". Workflow is not transient. Assets are fully modifiable and I can use them normally.

I guess that probably I've forget about adding some step in workflow model, or whatever.

AEM version 6.2.0.SP1.

Please advise.

Thanks,

Arek

View Entire Topic

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Reply

2.3K
smacdonald2008

18-10-2017

There is not a specific workflow that places an asset in this state. The point is when you write a custom workflow step that modifies an asset - use the Asset Manager API. When it creates the asset and the workflow completes, the asset will automatically be put in this state - as shown in my illustration.

For example, if you had this custom workflow step in a workflow - the asset would be in the processed state.

@Component

@Service

 

@Properties({

    @Property(name = Constants.SERVICE_DESCRIPTION, value = "Test Email workflow process implementation."),

    @Property(name = Constants.SERVICE_VENDOR, value = "Adobe"),

    @Property(name = "process.label", value = "Test Email Workflow Process") })

public class CustomStep implements WorkflowProcess

{

      

     

/** Default log. */

protected final Logger log = LoggerFactory.getLogger(this.getClass());

     

//Inject a MessageGatewayService

//Inject a Sling ResourceResolverFactory

@Reference

private ResourceResolverFactory resolverFactory;

     

public void execute(WorkItem item, WorkflowSession wfsession,MetaDataMap args) throws WorkflowException {

         

try

{

    log.info("**** Here in execute method");    //ensure that the execute method is invoked   

         

    //Get the Assets from the file system for a test

   

    File file = new File("C:\\Users\\scottm\\Mal10.JPG");

    InputStream fis = null;

    fis = new FileInputStream(file);

   

        String name = writeToDam(fis, "Malcolm.jpg") ;

       

         log.info("**** Name of the new Assets is "+name);

}

 

    catch (Exception e)

    {

    e.printStackTrace()  ;

    }

}

//Save the uploaded file into the AEM DAM using AssetManager API

private String writeToDam(InputStream is, String fileName)

{

try

{

    //Inject a ResourceResolver

    ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

    

    //Use AssetManager to place the file into the AEM DAM

    com.day.cq.dam.api.AssetManager assetMgr = resourceResolver.adaptTo(com.day.cq.dam.api.AssetManager.class);

    String newFile = "/content/dam/summit-toys/"+fileName ;

    assetMgr.createAsset(newFile, is,"image/jpeg", true);

        

    // Return the path to the file was stored

    return newFile;

}

catch(Exception e)

{

    e.printStackTrace();

}

return null;

}

}

If you are not getting this result in a custom workflow - you are doing something wrong.