<?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: Adding an aspect to Alfresco node comments? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74544#M23832</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for giving pointers on the Web Scripts and JavaScript API. Sometimes, in the crunch of time based work, it is hard to search online and land on a good article or resource.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I went ahead with&amp;nbsp;the "&lt;STRONG&gt;Alfresco Content Services REST API&lt;/STRONG&gt;" (not the web-script one) to add the aspect to the comment. This is the method. This value&amp;nbsp;&lt;SPAN style="color: #0000ff;"&gt;c6c9e3af-6e0b-46ad-8e11-648e1a27e7e6&lt;SPAN style="color: #000000;"&gt; is the comment node id. The comment must have been created already using a prior Rest API call.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;HTTP PUT (for attaching aspect with its value to a comment node)&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;lt;AlfrescoServerPort&amp;gt;/alfresco/api/-default-/public/alfresco/versions/1/nodes/c6c9e3af-6e0b-46ad-8e11-648e1a27e7e6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HTTP Body&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; "aspectNames":[&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;perationInfo"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; "properties": {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;peration_user":"Goose",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;peration_info":"A comment is added"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my code, I do like shown below. The variable&amp;nbsp;&lt;STRONG&gt;restApiUrl&lt;/STRONG&gt; contains the PUT url as given above, and the variable&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;jsonString&lt;/STRONG&gt; contains the above HttpBody Json content.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;CloseableHttpResponse response = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; URL restApiUrl = null;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;CredentialsProvider provider = new BasicCredentialsProvider();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.configUser, this.configUserPassword);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; provider.setCredentials(AuthScope.ANY, creds);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;HttpPut putFunction = new HttpPut(restApiUrl.toString());&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; StringEntity entity = new StringEntity(jsonString);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setEntity(entity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setHeader("Accept", "application/json");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setHeader("Content-type", "application/json");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; response = httpClient.execute(putFunction);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; catch (Exception e) {}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; finally {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; if (response != null) { try { response.close(); } catch (Exception ignore) {} }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;As you have mentioned before, I see that this is a two call approach. First there is a Rest API call to create the comment (node). Then we have a Rest API call to attach/create the custom aspect.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;For now, since this is purely user (navigation) action driven, there is only a remote possibility that it would pose scaling problem.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;In future version of our application, I would certainly consider a Web Script approach, where I can achieve all this in a single call.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 27 Sep 2018 18:45:32 GMT</pubDate>
    <dc:creator>sepgs2004</dc:creator>
    <dc:date>2018-09-27T18:45:32Z</dc:date>
    <item>
      <title>Adding an aspect to Alfresco node comments?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74542#M23830</link>
      <description>BackgroundWe are using node/alfresco comments feature.What is the comment feature that I am referring to?If we go to Share UI, and go to edit a document, we will see comments way below. There, we can add, edit or delete comments of a document.For now, our application communicates with (or accesses d</description>
      <pubDate>Fri, 14 Sep 2018 19:03:22 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74542#M23830</guid>
      <dc:creator>sepgs2004</dc:creator>
      <dc:date>2018-09-14T19:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an aspect to Alfresco node comments?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74543#M23831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It looks like you may have decided to use the REST API to add the aspect to your comment node based on this question: &lt;A href="https://migration33.stage.lithium.com/thread/238910"&gt;Adding an aspect to a comment node has error&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you haven't already, you should read &lt;A href="https://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html" rel="nofollow noopener noreferrer"&gt;my tutorial on Web Scripts&lt;/A&gt;. It includes an example that uses the NodeService to add an aspect to a node with an addAspect method call.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you decide to use a JavaScript controller you should read the JavaScript API documentation. &lt;A href="https://docs.alfresco.com/5.2/references/API-JS-addAspect.html" rel="nofollow noopener noreferrer"&gt;Here&lt;/A&gt; is one of the docs that discusses addAspect.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding whether you use a Java or a JavaScript controller, it really doesn't matter much. You should probably use whichever you are more comfortable developing with.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You might some day find API's that are easier to work with in one versus the other, but simple stuff like addAspect is well-covered in both Java and JavaScript.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Sep 2018 03:50:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74543#M23831</guid>
      <dc:creator>jpotts</dc:creator>
      <dc:date>2018-09-21T03:50:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding an aspect to Alfresco node comments?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74544#M23832</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much for giving pointers on the Web Scripts and JavaScript API. Sometimes, in the crunch of time based work, it is hard to search online and land on a good article or resource.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yes, I went ahead with&amp;nbsp;the "&lt;STRONG&gt;Alfresco Content Services REST API&lt;/STRONG&gt;" (not the web-script one) to add the aspect to the comment. This is the method. This value&amp;nbsp;&lt;SPAN style="color: #0000ff;"&gt;c6c9e3af-6e0b-46ad-8e11-648e1a27e7e6&lt;SPAN style="color: #000000;"&gt; is the comment node id. The comment must have been created already using a prior Rest API call.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;HTTP PUT (for attaching aspect with its value to a comment node)&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;lt;AlfrescoServerPort&amp;gt;/alfresco/api/-default-/public/alfresco/versions/1/nodes/c6c9e3af-6e0b-46ad-8e11-648e1a27e7e6&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;HTTP Body&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; "aspectNames":[&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;perationInfo"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; ],&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; "properties": {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;peration_user":"Goose",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; &amp;nbsp; "slo&lt;img id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://connect.hyland.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;peration_info":"A comment is added"&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&amp;nbsp; }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #0000ff;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In my code, I do like shown below. The variable&amp;nbsp;&lt;STRONG&gt;restApiUrl&lt;/STRONG&gt; contains the PUT url as given above, and the variable&amp;nbsp;&lt;SPAN&gt;&lt;STRONG&gt;jsonString&lt;/STRONG&gt; contains the above HttpBody Json content.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;CloseableHttpResponse response = null;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; URL restApiUrl = null;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;CredentialsProvider provider = new BasicCredentialsProvider();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; UsernamePasswordCredentials creds = new UsernamePasswordCredentials(this.configUser, this.configUserPassword);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; provider.setCredentials(AuthScope.ANY, creds);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; CloseableHttpClient httpClient = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;HttpPut putFunction = new HttpPut(restApiUrl.toString());&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;try {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; StringEntity entity = new StringEntity(jsonString);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setEntity(entity);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setHeader("Accept", "application/json");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; putFunction.setHeader("Content-type", "application/json");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt;&amp;nbsp; response = httpClient.execute(putFunction);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #808080;"&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; catch (Exception e) {}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; finally {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; if (response != null) { try { response.close(); } catch (Exception ignore) {} }&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #808080;"&gt; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;As you have mentioned before, I see that this is a two call approach. First there is a Rest API call to create the comment (node). Then we have a Rest API call to attach/create the custom aspect.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;For now, since this is purely user (navigation) action driven, there is only a remote possibility that it would pose scaling problem.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;In future version of our application, I would certainly consider a Web Script approach, where I can achieve all this in a single call.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Sep 2018 18:45:32 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/adding-an-aspect-to-alfresco-node-comments/m-p/74544#M23832</guid>
      <dc:creator>sepgs2004</dc:creator>
      <dc:date>2018-09-27T18:45:32Z</dc:date>
    </item>
  </channel>
</rss>

