<?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 Retrieving of comments is not working in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143969#M38223</link>
    <description>&lt;P&gt;We access comments associated to a document object through an out-of-the-box webscript. In some environments, it works good. In others, we get some authentication error. We have Alfresco Community 5.2.x, Alfresco Community 6.0.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is a snippet of the error&lt;/P&gt;&lt;P&gt;{"error":{"errorKey":"framework.exception.ApiDefault","statusCode":401,"briefSummary":"00100014 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"&lt;A href="https://api-explorer.alfresco.com" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api-explorer.alfresco.com&lt;/A&gt;"}}&lt;/P&gt;&lt;P&gt;Anyone had this issue and solved?&lt;/P&gt;</description>
    <pubDate>Tue, 06 Jul 2021 12:09:19 GMT</pubDate>
    <dc:creator>sepgs2004</dc:creator>
    <dc:date>2021-07-06T12:09:19Z</dc:date>
    <item>
      <title>Retrieving of comments is not working</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143969#M38223</link>
      <description>&lt;P&gt;We access comments associated to a document object through an out-of-the-box webscript. In some environments, it works good. In others, we get some authentication error. We have Alfresco Community 5.2.x, Alfresco Community 6.0.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is a snippet of the error&lt;/P&gt;&lt;P&gt;{"error":{"errorKey":"framework.exception.ApiDefault","statusCode":401,"briefSummary":"00100014 Authentication failed for Web Script org/alfresco/api/ResourceWebScript.get","stackTrace":"For security reasons the stack trace is no longer displayed, but the property is kept for previous versions","descriptionURL":"&lt;A href="https://api-explorer.alfresco.com" target="_blank" rel="noopener nofollow noreferrer"&gt;https://api-explorer.alfresco.com&lt;/A&gt;"}}&lt;/P&gt;&lt;P&gt;Anyone had this issue and solved?&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 12:09:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143969#M38223</guid>
      <dc:creator>sepgs2004</dc:creator>
      <dc:date>2021-07-06T12:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving of comments is not working</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143970#M38224</link>
      <description>&lt;P&gt;Can you provide details on the api you are using? Check the alfresco logs and see if you can identify anything. The error message you have provided is related to this :&amp;nbsp;&lt;A href="https://github.com/Alfresco/alfresco-community-repo/blob/master/remote-api/src/main/resources/alfresco/templates/publicapi/org/alfresco/api/ResourceWebScript.get.desc.xml" target="_blank" rel="noopener nofollow noreferrer"&gt;https://github.com/Alfresco/alfresco-community-repo/blob/master/remote-api/src/main/resources/alfresco/templates/publicapi/org/alfresco/api/ResourceWebScript.get.desc.xml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;which requires 'user' level authentication to succeed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what i tried to retrieve the comments from a node and it works.&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV class="request-url"&gt;
&lt;PRE class="microlight"&gt;http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/9bbcfd1d-3279-4c4a-af6e-8a1177141779/comments?skipCount=0&amp;amp;maxItems=100&amp;amp;alf_ticket=TICKET_5290e90d9d99388c6d098b70cb8794fcb8292a53&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Response example&lt;/U&gt;:&lt;/P&gt;
&lt;PRE&gt;{
	"list": {
		"pagination": {
			"count": 1,
			"hasMoreItems": false,
			"totalItems": 1,
			"skipCount": 0,
			"maxItems": 100
		},
		"entries": [
			{
				"entry": {
					"createdAt": "2021-07-06T15:06:01.970+0000",
					"createdBy": {
						"enabled": true,
						"firstName": "Administrator",
						"displayName": "Administrator",
						"email": "admin@alfresco.com",
						"emailNotificationsEnabled": true,
						"company": {},
						"id": "admin"
					},
					"edited": false,
					"modifiedAt": "2021-07-06T15:06:01.970+0000",
					"canEdit": true,
					"modifiedBy": {
						"enabled": true,
						"firstName": "Administrator",
						"displayName": "Administrator",
						"email": "admin@alfresco.com",
						"emailNotificationsEnabled": true,
						"company": {},
						"id": "admin"
					},
					"canDelete": true,
					"id": "2f2df18e-8cbd-4690-80e7-93150211e487",
&lt;STRONG&gt;					"content": "&amp;lt;p&amp;gt;comment1&amp;lt;/p&amp;gt;"
&lt;/STRONG&gt;				}
			}
		]
	}
}&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:36:19 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143970#M38224</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2021-07-06T14:36:19Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving of comments is not working</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143971#M38225</link>
      <description>&lt;P&gt;Hi &lt;SPAN class="UserName lia-user-name lia-user-rank-Established-Member lia-component-message-view-widget-author-username"&gt;&lt;A href="https://hub.alfresco.com/t5/user/viewprofilepage/user-id/24818" target="_self" rel="nofollow noopener noreferrer"&gt;&lt;SPAN class=""&gt;sepgs2004.&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;401 means unauthorized, you should pass an Authorization header, either basic or bearer works. &lt;A href="https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/resources/alfresco/templates/publicapi/org/alfresco/api/ResourceWebScript.get.desc.xml" target="_self" rel="nofollow noopener noreferrer"&gt;Checking the webscript&lt;/A&gt; you need at least to have user authtentication.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;It's quite complex to know in deep what is happening without more details. Why is not happening in all your environments? This is interesting because looks like in some cases you have alredy login with a valid credentials and other cases no. Or maybe some of your documents are public... Here we have different possibilities. If you can specify more details that can help us to figure out what is happening. Also, check alfresco logs, if it's possible.&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 14:41:59 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143971#M38225</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-07-06T14:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving of comments is not working</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143972#M38226</link>
      <description>&lt;P&gt;This is the extract of the code as of now. I am not sure if this is correct as of the necessary authentication. As far as I know, the user credentials that is passed is the cred that has access to the Alfresco Share site. Do the webscripts have separate authentication?&lt;BR /&gt;If it does not work, it does not work for all documents. So, for this problem, it is not document specific.&lt;BR /&gt;One difference is that retrieval of comments, does not work in some secure hosted environments.&amp;nbsp;&lt;BR /&gt;I wonder if it has anything to do with using HTTP Rest in such an environment.&lt;/P&gt;&lt;PRE&gt;private ArrayList&amp;lt;DocComment&amp;gt; retrieveDocumentCommentsFromRepo (String objectId)&lt;BR /&gt;{&lt;BR /&gt;...&lt;BR /&gt;ArrayList&amp;lt;DocComment&amp;gt; comments = new ArrayList&amp;lt;DocComment&amp;gt;();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(this.communicationDateFormat);
SimpleDateFormat displayDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a");
		
CloseableHttpResponse response = null;
URL cmisUrl = null;
		
CredentialsProvider provider = new BasicCredentialsProvider();
UsernamePasswordCredentials creds = new UsernamePasswordCredentials(configUser, this.configUserPassword);
provider.setCredentials(AuthScope.ANY, creds);
CloseableHttpClient httpClient = HttpClientBuilder.create()
  .setDefaultCredentialsProvider(provider)
  .build();
		  
try {
	int index = objectId.indexOf(";");
	String nodeId = (index &amp;gt;= 0 ? (objectId.substring(0, index)) : objectId);
	cmisUrl = new URL ( (this.repoHost + this.restApiAccessPoint + "/nodes/" + nodeId + "/comments?fields=createdAt,modifiedAt,id,content,createdBy") );
}
catch (Exception exc) {log.error("URL construction error!");}

if (cmisUrl == null) return comments;
		
HttpGet callFunction = new HttpGet(cmisUrl.toString());&lt;BR /&gt;&lt;BR /&gt;try {&lt;BR /&gt;  response = httpClient.execute(callFunction);&lt;BR /&gt;  StatusLine sl = response.getStatusLine();&lt;BR /&gt;&lt;BR /&gt;  HttpEntity responseEntity = response.getEntity(); &lt;BR /&gt;  String content = EntityUtils.toString(responseEntity);&lt;BR /&gt;  ...&lt;BR /&gt;  JsonElement jelement = new JsonParser().parse(content);&lt;BR /&gt;  JsonObject commentsObject = jelement.getAsJsonObject();&lt;BR /&gt;  commentsObject = commentsObject.getAsJsonObject("list");&lt;BR /&gt;&lt;BR /&gt;  if (commentsObject == null) return comments;&lt;BR /&gt;  JsonArray commentItems = commentsObject.getAsJsonArray("entries");&lt;BR /&gt;  ...&lt;BR /&gt;}&lt;BR /&gt;} catch (Exception e) {&lt;BR /&gt;System.out.println("@RetrieveDocumentComments - Exception occurred");&lt;BR /&gt;e.printStackTrace();&lt;BR /&gt;}&lt;BR /&gt;finally {&lt;BR /&gt;if (response != null) { try {response.close();} catch (Exception ignore) {} }&lt;BR /&gt;if (httpClient != null) { try { httpClient.close();} catch (Exception ignore) {} }&lt;BR /&gt;}&lt;BR /&gt;return comments;&lt;/PRE&gt;</description>
      <pubDate>Tue, 06 Jul 2021 15:31:00 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143972#M38226</guid>
      <dc:creator>sepgs2004</dc:creator>
      <dc:date>2021-07-06T15:31:00Z</dc:date>
    </item>
    <item>
      <title>Re: Retrieving of comments is not working</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143973#M38227</link>
      <description>&lt;P&gt;You can do a simple test to discard or confirm the problem is in that code:&lt;/P&gt;&lt;P&gt;- Find a document which is failing.&lt;/P&gt;&lt;P&gt;- Go to RESTClient (or a rest client similar) and launch the petition.&lt;/P&gt;&lt;P&gt;And check if you have the same error as with your code.&lt;/P&gt;&lt;P&gt;Let us know the results.&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 15:55:17 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/retrieving-of-comments-is-not-working/m-p/143973#M38227</guid>
      <dc:creator>cristinamr</dc:creator>
      <dc:date>2021-07-06T15:55:17Z</dc:date>
    </item>
  </channel>
</rss>

