<?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: Desirialization of JPA process variables via REST in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132525#M93092</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are few things that I needed to do to make it work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First use this artifact:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&amp;nbsp; &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;groupId&amp;gt;com.sun.jersey&amp;lt;/groupId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;artifactId&amp;gt;jersey-bundle&amp;lt;/artifactId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1.8&amp;lt;/version&amp;gt;&amp;lt;!– 1.17.1 –&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;/dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second, I'm using jackson lib for this (it worked better for me)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;groupId&amp;gt;org.codehaus.jackson&amp;lt;/groupId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;artifactId&amp;gt;jackson-core-asl&amp;lt;/artifactId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1.9.4&amp;lt;/version&amp;gt; //or newer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;/dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your BusinessPartner must have @XmlRootElement annotation but I'm not sure if you can send this object to activiti as a variable (unless you did something I dont know about &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; ).&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2013 18:58:22 GMT</pubDate>
    <dc:creator>augustus</dc:creator>
    <dc:date>2013-07-02T18:58:22Z</dc:date>
    <item>
      <title>Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132524#M93091</link>
      <description>Hey – I am trying to deserialize a JPA process variable via the new REST API (amazing work, by the way). I am using Hibernate for JPA and Jersey for deserialization.import com.sun.jersey.api.client.Client;import com.sun.jersey.api.client.ClientResponse;import com.sun.jersey.api.client.WebResource;im</description>
      <pubDate>Mon, 01 Jul 2013 11:43:07 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132524#M93091</guid>
      <dc:creator>kaihuener</dc:creator>
      <dc:date>2013-07-01T11:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132525#M93092</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;There are few things that I needed to do to make it work.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First use this artifact:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&amp;nbsp; &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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;groupId&amp;gt;com.sun.jersey&amp;lt;/groupId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;artifactId&amp;gt;jersey-bundle&amp;lt;/artifactId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1.8&amp;lt;/version&amp;gt;&amp;lt;!– 1.17.1 –&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;/dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Second, I'm using jackson lib for this (it worked better for me)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;groupId&amp;gt;org.codehaus.jackson&amp;lt;/groupId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;artifactId&amp;gt;jackson-core-asl&amp;lt;/artifactId&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; &amp;lt;version&amp;gt;1.9.4&amp;lt;/version&amp;gt; //or newer&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &amp;lt;/dependency&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your BusinessPartner must have @XmlRootElement annotation but I'm not sure if you can send this object to activiti as a variable (unless you did something I dont know about &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://connect.hyland.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&amp;nbsp; ).&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 18:58:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132525#M93092</guid>
      <dc:creator>augustus</dc:creator>
      <dc:date>2013-07-02T18:58:22Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132526#M93093</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hey mojsilo,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all: Thank you for your comment – it is great to get some community support.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;In the meantime, I tried various things to better understand what actually is provided by the REST API (including several media types, self-written message body writer), without success.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Finally I realized – and of course it is also written in the User Guide – that the variables are just serialized, not in JSON or XML or something, just "raw" serialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So, finally, both the following solutions work in my case (by the way, both without any annotation in the serialized bean, maybe I am wrong, but "@XmlRootElement" or something is not required, except for dedicated XML serialization):&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;import java.io.InputStream;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.apache.commons.httpclient.HttpClient;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.apache.commons.httpclient.methods.GetMethod;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import org.apache.commons.lang.SerializationUtils;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;HttpClient client = new HttpClient();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;GetMethod get = new GetMethod(uri);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;client.executeMethod(get);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;InputStream stream = get.getResponseBodyAsStream();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BusinessPartner bp = (BusinessPartner)SerializationUtils.deserialize(stream);&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;&amp;lt;java&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import java.io.InputStream;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.sun.jersey.api.client.Client;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.sun.jersey.api.client.WebResource;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Client client = Client.create();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;WebResource r = client .resource(uri);&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;InputStream response= r.get(InputStream.class);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;BusinessPartner bp = (BusinessPartner)SerializationUtils.deserialize(response);&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;But I am not sure, if this is the intended way for process variable deserialization, because I would expect this solution to be heavily implementation dependent (i.e. how java serializes objects). So maybe the Activiti team can clarify the intended way? I also wonder why variables (except binary ones) are not provided as json, because coming from the REST API implementation, I would have expected a json response.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;best,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Kai&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2013 20:27:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132526#M93093</guid>
      <dc:creator>kaihuener</dc:creator>
      <dc:date>2013-07-02T20:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132527#M93094</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;What do you mean by "not provided as json" ? &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 10:46:56 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132527#M93094</guid>
      <dc:creator>augustus</dc:creator>
      <dc:date>2013-07-03T10:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132528#M93095</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;See the user guide, to use custom representation of certain objects:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;It's possible to support additional variable-types with a custom JSON representation (either simple value or complex/nested JSON object). By extending the initializeVariableConverters() method on org.activiti.rest.api.RestResponseFactory, you can add additional org.activiti.rest.api.engine.variable.RestVariableConverter classes to support converting your POJO's to a format suitable for transerring through REST and converting the REST-value back to your POJO. The actual transformation to JSON is done by Jackson.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;So if you add a org.activiti.rest.api.engine.variable.RestVariableConverter for the JPA-type, that returns a Jackson-serializable POJO (which by default, are all of them). Alternatively, you can return a map&amp;lt;String, Object&amp;gt; of key-values where key is the resulting JSON-key and value the -no shit- value &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt; If you want to have sub-json-objects, use another Map as value. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Or stick with the default "serializable" that is being used now, off course…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I was planning on writing a blog on this subject, so any feedback on my "theory" is appreciated &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://connect.hyland.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Jul 2013 10:49:06 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132528#M93095</guid>
      <dc:creator>frederikherema1</dc:creator>
      <dc:date>2013-07-03T10:49:06Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132529#M93096</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Using the custom RestVariableConverter approach works pretty well for simple types.&amp;nbsp; And, being able to send a serializable object directly to Jackson when serializing (a one-liner in the convertVariableValue implementation) is fantastic.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I have some pretty deeply nested datatypes I would like deserialize from JSON sent to the REST service.&amp;nbsp; Deserializing by iterating over all the Maps of Maps of Maps in getVariableValue just feels wrong and is resulting in a lot of converter code.&amp;nbsp; Jackson is probably already able to deserialize without the helper converter code, if it only know about the object type corresponding to the JSON stream.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to instruct the Jackson mapper in the REST service to DE-serialize a JsonNode into a specific type (which could be provided with all sorts of Jackson helper annotations)?&amp;nbsp; Is there a place in the REST webapp code where I can look to see how to shim that in?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There seems to be something called a CustomVariableType, but it sounds like that is for storing variables in a custom manner into the database, and after the REST service deserialization I just want to use the default database process variable serialization.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;gd&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Oct 2014 13:10:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132529#M93096</guid>
      <dc:creator>gregdavisfromnj</dc:creator>
      <dc:date>2014-10-24T13:10:45Z</dc:date>
    </item>
    <item>
      <title>Re: Desirialization of JPA process variables via REST</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132530#M93097</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;VariableType is for the engine only, not for REST.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Your remark makes a lot of sense. I was wondering (haven't tried it), but couldn't you simply write the jackson code in a custom implementation of the RestVariableConverter already now? Eg by calling the readValue() method from Jackson?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Oct 2014 11:08:44 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/desirialization-of-jpa-process-variables-via-rest/m-p/132530#M93097</guid>
      <dc:creator>jbarrez</dc:creator>
      <dc:date>2014-10-27T11:08:44Z</dc:date>
    </item>
  </channel>
</rss>

