<?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 How to perform a parallel CMIS requests in Alfresco? in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/how-to-perform-a-parallel-cmis-requests-in-alfresco/m-p/112978#M31456</link>
    <description>&lt;P&gt;I have several CMIS requests and need to do them in parallel. But when I try it (using CompletableFutire or stream().parallel(), I got:&lt;/P&gt;&lt;P&gt;java.util.concurrent.ExecutionException: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;BR /&gt;The following code is one of my attempt to perform CMIS in parallel:&lt;/P&gt;&lt;PRE&gt;@Autowired
@Qualifier("searchService")
private org.alfresco.service.cmr.search.SearchService searchService;
....


List&amp;lt;CompletableFuture&amp;lt;Form14Row&amp;gt;&amp;gt; requests = Arrays.asList(setUpRow(1,beginnigString, endString, docType, NDBaseDocumentModel.DOC_KIND_GOST_R, searchParameters, "ГОСТ Р"),
setUpRow(2,beginnigString, endString, docType, NDBaseDocumentModel.DOC_KIND_GOST, searchParameters, "ГОСТ") );
CompletableFuture&amp;lt;Void&amp;gt; allRequests = CompletableFuture.allOf(
requests.toArray(new CompletableFuture[requests.size()])
);
CompletableFuture&amp;lt;List&amp;lt;Form14Row&amp;gt;&amp;gt; allPageContentsFuture = allRequests.thenApply(v -&amp;gt; {
return requests.stream()
.map(pageContentFuture -&amp;gt; pageContentFuture.join())
.collect(Collectors.toList());
});

//java.util.concurrent.ExecutionException: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
try {
List&amp;lt;Form14Row&amp;gt; rowss = allPageContentsFuture.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}

...
private CompletableFuture&amp;lt;Form14Row&amp;gt; setUpRow(Integer index, String beginnigString, String endString, String docType, String docKind, SearchParameters searchParameters, String groupPosition) {
return CompletableFuture.supplyAsync(() -&amp;gt; {
String cql = "SELECT p.cmis:objectId FROM ecmcnddoc:common_attr_aspect AS d JOIN ecmcnddoc:biblio_attr_aspect AS p ON d.cmis:objectId = p.cmis:objectId JOIN ecmcnddoc:reg_attr_aspect AS s ON s.cmis:objectId = p.cmis:objectId JOIN ecmcnddoc:spec_attr_aspect AS asp ON asp.cmis:objectId = p.cmis:objectId WHERE p.cmis:objectTypeId='D:" + docType + "' AND d.ecmcnddoc:doc_kind_cp_ecmcdict_value='" + docKind + "' AND p.ecmcnddoc:biblio_fond='" + NDBaseDocumentModel.BIBLIO_FUND + "' AND s.ecmcnddoc:doc_reg_date &amp;gt;= TIMESTAMP '" + beginnigString + "T00:00:00.000+00:00' AND s.ecmcnddoc:doc_reg_date &amp;lt;= TIMESTAMP '" + endString + "T00:00:00.000+00:00' AND (asp.ecmcnddoc:doc_status='draft' OR asp.ecmcnddoc:doc_status='actual')";
searchParameters.setQuery(cql);
ResultSet rs = customSearchService.query(searchParameters); // here is the Exception
Form14Row isoRow = new Form14Row();
isoRow.setCount(rs.length());
isoRow.setIndex(index);
isoRow.setKindName(groupPosition);
return isoRow;
});
}&lt;/PRE&gt;&lt;P&gt;Everything works fine in serial execution&lt;/P&gt;</description>
    <pubDate>Wed, 02 Sep 2020 14:02:39 GMT</pubDate>
    <dc:creator>iceja</dc:creator>
    <dc:date>2020-09-02T14:02:39Z</dc:date>
    <item>
      <title>How to perform a parallel CMIS requests in Alfresco?</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/how-to-perform-a-parallel-cmis-requests-in-alfresco/m-p/112978#M31456</link>
      <description>&lt;P&gt;I have several CMIS requests and need to do them in parallel. But when I try it (using CompletableFutire or stream().parallel(), I got:&lt;/P&gt;&lt;P&gt;java.util.concurrent.ExecutionException: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;BR /&gt;The following code is one of my attempt to perform CMIS in parallel:&lt;/P&gt;&lt;PRE&gt;@Autowired
@Qualifier("searchService")
private org.alfresco.service.cmr.search.SearchService searchService;
....


List&amp;lt;CompletableFuture&amp;lt;Form14Row&amp;gt;&amp;gt; requests = Arrays.asList(setUpRow(1,beginnigString, endString, docType, NDBaseDocumentModel.DOC_KIND_GOST_R, searchParameters, "ГОСТ Р"),
setUpRow(2,beginnigString, endString, docType, NDBaseDocumentModel.DOC_KIND_GOST, searchParameters, "ГОСТ") );
CompletableFuture&amp;lt;Void&amp;gt; allRequests = CompletableFuture.allOf(
requests.toArray(new CompletableFuture[requests.size()])
);
CompletableFuture&amp;lt;List&amp;lt;Form14Row&amp;gt;&amp;gt; allPageContentsFuture = allRequests.thenApply(v -&amp;gt; {
return requests.stream()
.map(pageContentFuture -&amp;gt; pageContentFuture.join())
.collect(Collectors.toList());
});

//java.util.concurrent.ExecutionException: net.sf.acegisecurity.AuthenticationCredentialsNotFoundException: A valid SecureContext was not provided in the RequestContext
try {
List&amp;lt;Form14Row&amp;gt; rowss = allPageContentsFuture.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}

...
private CompletableFuture&amp;lt;Form14Row&amp;gt; setUpRow(Integer index, String beginnigString, String endString, String docType, String docKind, SearchParameters searchParameters, String groupPosition) {
return CompletableFuture.supplyAsync(() -&amp;gt; {
String cql = "SELECT p.cmis:objectId FROM ecmcnddoc:common_attr_aspect AS d JOIN ecmcnddoc:biblio_attr_aspect AS p ON d.cmis:objectId = p.cmis:objectId JOIN ecmcnddoc:reg_attr_aspect AS s ON s.cmis:objectId = p.cmis:objectId JOIN ecmcnddoc:spec_attr_aspect AS asp ON asp.cmis:objectId = p.cmis:objectId WHERE p.cmis:objectTypeId='D:" + docType + "' AND d.ecmcnddoc:doc_kind_cp_ecmcdict_value='" + docKind + "' AND p.ecmcnddoc:biblio_fond='" + NDBaseDocumentModel.BIBLIO_FUND + "' AND s.ecmcnddoc:doc_reg_date &amp;gt;= TIMESTAMP '" + beginnigString + "T00:00:00.000+00:00' AND s.ecmcnddoc:doc_reg_date &amp;lt;= TIMESTAMP '" + endString + "T00:00:00.000+00:00' AND (asp.ecmcnddoc:doc_status='draft' OR asp.ecmcnddoc:doc_status='actual')";
searchParameters.setQuery(cql);
ResultSet rs = customSearchService.query(searchParameters); // here is the Exception
Form14Row isoRow = new Form14Row();
isoRow.setCount(rs.length());
isoRow.setIndex(index);
isoRow.setKindName(groupPosition);
return isoRow;
});
}&lt;/PRE&gt;&lt;P&gt;Everything works fine in serial execution&lt;/P&gt;</description>
      <pubDate>Wed, 02 Sep 2020 14:02:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/how-to-perform-a-parallel-cmis-requests-in-alfresco/m-p/112978#M31456</guid>
      <dc:creator>iceja</dc:creator>
      <dc:date>2020-09-02T14:02:39Z</dc:date>
    </item>
  </channel>
</rss>

