<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How do you access an uploaded file in a downstream service task? in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227575#M180705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for posting your solution. Many people googling towards here will appreciate it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your analysis is correct: Activiti won't flush to the database until the transaction is committed. If you really want that, you can make your next task asynchronous.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Side remark: change @Configuration to @Component to be more correct (on your JavaDelegate).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Jun 2016 12:28:14 GMT</pubDate>
    <dc:creator>jbarrez</dc:creator>
    <dc:date>2016-06-20T12:28:14Z</dc:date>
    <item>
      <title>How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227568#M180698</link>
      <description>I have a user task with a form that has a file upload field. In a separate java service task I would like to access the content of this file, or even just the path to the file on disk. For context… I am implementing a JavaDelegate, building a jar, and placing it in activiti-app/WEB-INF/lib. I can se</description>
      <pubDate>Mon, 16 May 2016 03:30:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227568#M180698</guid>
      <dc:creator>jmulieri</dc:creator>
      <dc:date>2016-05-16T03:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227569#M180699</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;only the db id is stored as process variable (for obvious performance reasons). You need to use the RelatedContentService to actually fetch the content wgen you need it.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 16:34:31 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227569#M180699</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2016-05-18T16:34:31Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227570#M180700</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for your reply. Can you help me understand how to use the RelatedContentService in my JavaDelegate? I have tried this but it is null when the execute method is called:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; protected RelatedContentService contentService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am sure it is something simple that I am missing, just need a little direction to understand how things actually come together. Thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 May 2016 19:32:37 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227570#M180700</guid>
      <dc:creator>jmulieri</dc:creator>
      <dc:date>2016-05-18T19:32:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227571#M180701</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I wanted to follow-up with my issue… to help someone in the future. I found a way to make this work, the gist of it is that you need to get a hold of the Spring application context to fetch the RelatedContentService bean. I tried various techniques for defining a bean with trying to auto wire in the dependencies with no success. So here is my workaround. I structured my code a little differently, and did the setup in my delegate's constructor, but for brevity, here is an example of a working execute method:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; public void execute(DelegateExecution execution) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String fileVariableName = "myfile"; // Id of 'upload file field' from form in previous User Task&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Class&amp;lt;?&amp;gt; theClass = Class.forName("com.activiti.conf.ApplicationConfiguration");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(theClass);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RelatedContentService relatedContentService = applicationContext.getBean(RelatedContentService.class);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;RelatedContent&amp;gt; contentList = relatedContentService.getFieldContentForProcessInstance(&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; execution.getProcessInstanceId(), fileVariableName, 1, 0).getContent();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (ClassNotFoundException e) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/java&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 May 2016 01:59:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227571#M180701</guid>
      <dc:creator>jmulieri</dc:creator>
      <dc:date>2016-05-24T01:59:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227572#M180702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Can you posts your whole class, including package and all?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Are you sure it's in the right package, so it can be found by component scanning?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;getting the application context is quite a heavy operation and shouldn't be needed.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 31 May 2016 10:01:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227572#M180702</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2016-05-31T10:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227573#M180703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks Joram!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I finally cycled back around to this, and as I was putting together an example your comment was very helpful in clueing me to look into component scanning. That led me to the secret sauce… needing package com.activiti.extension.bean. Once I did that, the @Autowiring worked. I'm pasting in a working delegate for the next wandering soul…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;package com.activiti.extension.bean;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.activiti.service.runtime.RelatedContentService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.activiti.engine.delegate.*;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.springframework.beans.factory.annotation.Autowired;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.springframework.context.annotation.Bean;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.springframework.context.annotation.Configuration;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;@Configuration&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;public class SomeActivitiDelegate implements JavaDelegate {&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; @Autowired&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; RelatedContentService relatedContentService;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; @Bean&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; public SomeActivitiDelegate someActivitiDelegate() {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return new SomeActivitiDelegate();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; public void execute(DelegateExecution execution) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (relatedContentService == null) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Source of great pain.");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } else {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Oh, sweet victory!");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, it is important to note that in order to use this, you must use the Delegate Expression property in your Service Task definition. In this example, setting the field to &amp;lt;code&amp;gt;${someActivitiDelegate}&amp;lt;/code&amp;gt; did the trick.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2016 18:10:35 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227573#M180703</guid>
      <dc:creator>jmulieri</dc:creator>
      <dc:date>2016-06-09T18:10:35Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227574#M180704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well… the saga continues… unfortunately, when using the above approach, I can't seem to be able to create RelatedContent. From within the execute method, if I call &amp;lt;java&amp;gt;relatedContentService.createRelatedContent(…)&amp;lt;/java&amp;gt; the record is created but never committed. I can see in &amp;lt;java&amp;gt;AbstractPlatformTransactionManager.processCommit&amp;lt;/java&amp;gt; the call to &amp;lt;java&amp;gt;doCommit(status)&amp;lt;/java&amp;gt; is being skipped because it is not a new transaction. Do you know how I can get this record committed to the database? Missing the secret decoder ring again…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Update: While I am not exactly sure the subtleties at play, I was able to work through my issue. Apparently the transaction was not yet committed before a custom task I defined using AbstractBpmnActivityBehavior was invoked as the next task in the process. The AbstractBpmnActivityBehavior task was needing the related content, but was not finding it. I simply refactored the latter task to also be a class implementing JavaDelegate using the same approach with an @Autowired RelatedContentService as the SomeActvitiDelegate mentioned previously, and all was well.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Jun 2016 18:33:42 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227574#M180704</guid>
      <dc:creator>jmulieri</dc:creator>
      <dc:date>2016-06-11T18:33:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227575#M180705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for posting your solution. Many people googling towards here will appreciate it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your analysis is correct: Activiti won't flush to the database until the transaction is committed. If you really want that, you can make your next task asynchronous.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Side remark: change @Configuration to @Component to be more correct (on your JavaDelegate).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jun 2016 12:28:14 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227575#M180705</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2016-06-20T12:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access an uploaded file in a downstream service task?</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227576#M180706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;thank you for your answer. I am new to alfresco.&lt;/P&gt;&lt;P&gt;I need some more help regarding this.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Let me be clear.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://connect.hyland.com/legacyfs/online/alfresco/13390_pastedImage_1.png" style="width: auto; height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;Suppose this upload file form. Its id is &lt;EM&gt;uploadurl&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;below is the method for execution listener.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;@Override&lt;BR /&gt; public void notify(DelegateExecution arg0) throws Exception {&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;File f = new File("D:/some_file.zip");&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;// I want&amp;nbsp;to get that zip file in f&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;}&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope you got my question&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Apr 2017 11:21:48 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/how-do-you-access-an-uploaded-file-in-a-downstream-service-task/m-p/227576#M180706</guid>
      <dc:creator>kangkan</dc:creator>
      <dc:date>2017-04-24T11:21:48Z</dc:date>
    </item>
  </channel>
</rss>

