<?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 Transaction and version management in a webscript in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54351#M32406</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am developing a webscript to add electronic signatures to a PDF document in Alfresco Share. I have a webscript in the repository which takes the input stream from the node, generates a new version, takes the output stream, and then calls a business method to insert the signature:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="language-java line-numbers"&gt;&lt;CODE&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InputStream is = contentService.getReader(nodeRef, ContentModel.PROP_CONTENT).getContentInputStream() ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Map&amp;lt;String, Serializable&amp;gt; versionProperties = new HashMap&amp;lt;String, Serializable&amp;gt;();&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;versionProperties.put(VersionModel.PROP_VERSION_TYPE, VersionType.MINOR);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Version newVersion = versionService.createVersion(nodeRef, versionProperties) ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;OutputStream os = contentService.getWriter(nodeRef, ContentModel.PROP_CONTENT, true).getContentOutputStream() ;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[…]&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;signer.sign(is, os, […]) ;&lt;BR /&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This works correctly if I use &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;transaction&amp;gt;none&amp;lt;/transaction&amp;gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt; in the webscript descriptor; if it is set to &lt;/SPAN&gt;&lt;PRE class="language-none line-numbers"&gt;&lt;CODE&gt;&amp;lt;transaction&amp;gt;required&amp;lt;/transaction&amp;gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;SPAN&gt;, the original version is overwritten, rather than a new one being generated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, in this configuration if the signing method fails, a useless new version is generated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure what is the better strategy to solve this problem: should I set transaction to required and manage streams differently, or should I leave it as it is and insert a transaction in the webscript?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestion is highly welcome…&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Nov 2014 11:35:11 GMT</pubDate>
    <dc:creator>fmstasi</dc:creator>
    <dc:date>2014-11-14T11:35:11Z</dc:date>
    <item>
      <title>Transaction and version management in a webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54351#M32406</link>
      <description>I am developing a webscript to add electronic signatures to a PDF document in Alfresco Share. I have a webscript in the repository which takes the input stream from the node, generates a new version, takes the output stream, and then calls a business method to insert the signature:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;InputStream</description>
      <pubDate>Fri, 14 Nov 2014 11:35:11 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54351#M32406</guid>
      <dc:creator>fmstasi</dc:creator>
      <dc:date>2014-11-14T11:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction and version management in a webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54352#M32407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ti suggerisco di lasciare transaction a required e probabilmente la versione viene sovrascritta perché le versionproperties sono le stesse.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Nov 2014 10:31:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54352#M32407</guid>
      <dc:creator>openpj</dc:creator>
      <dc:date>2014-11-17T10:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction and version management in a webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54353#M32408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, I was convinced I was posting in the English forum… I am afraid I selected an Italian subforum and then switched to English, while I should have done the opposite! Ok, I will reply in English anyway, for the sake of those searching answers via google in the future &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Piergiorgio, above, suggests to leave transaction required, and explains that probably the version is overwritten because there is no change in properties. Thank you, Piergiorgio, this sounds very reasonable; and if this is the case, the problem should probably solve by itself, since one of my next steps will be to add a "Signed" aspect, which should be enough to change properties. I will check soon, and then post my findings here!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Nov 2014 14:40:41 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54353#M32408</guid>
      <dc:creator>fmstasi</dc:creator>
      <dc:date>2014-11-17T14:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Transaction and version management in a webscript</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54354#M32409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Coming back to the forums after a while, I can confirm that adding the "signed" aspect and setting a property creates a new version even with transaction=required. Many thanks to Giorgio for his answer!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 09 Dec 2014 11:18:43 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/transaction-and-version-management-in-a-webscript/m-p/54354#M32409</guid>
      <dc:creator>fmstasi</dc:creator>
      <dc:date>2014-12-09T11:18:43Z</dc:date>
    </item>
  </channel>
</rss>

