<?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: Populate List of Shared Files in Alfresco Forum</title>
    <link>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90517#M27012</link>
    <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;You can do this task with JS Console, or even with a custom webscript. You can search all public documents with an alfresco fts query:&lt;/P&gt;&lt;PRE&gt;'ASPECT:"qshare:shared"&lt;/PRE&gt;&lt;P&gt;And for the list of obtained noderefs just remove the aspect.&lt;/P&gt;&lt;P&gt;Kind regards.&lt;/P&gt;&lt;P&gt;--C.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 16:17:10 GMT</pubDate>
    <dc:creator>cesarista</dc:creator>
    <dc:date>2020-10-08T16:17:10Z</dc:date>
    <item>
      <title>Populate List of Shared Files</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90516#M27011</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm using Alfresco API exporer to run a query to list all files that have been "shared" with a public link. I need to be able to go through and remove that public link. What I have been doing is using this.&lt;/P&gt;&lt;PRE&gt;https://mydomain/alfresco/api/-default-/public/alfresco/versions/1/shared-links?skipCount=0&amp;amp;maxItems=1000&lt;/PRE&gt;&lt;P&gt;I get results of everything, but I need the actual path to where the file is and possibly from which site.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:53:56 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90516#M27011</guid>
      <dc:creator>eswbitto</dc:creator>
      <dc:date>2020-10-08T15:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: Populate List of Shared Files</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90517#M27012</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;&lt;P&gt;You can do this task with JS Console, or even with a custom webscript. You can search all public documents with an alfresco fts query:&lt;/P&gt;&lt;PRE&gt;'ASPECT:"qshare:shared"&lt;/PRE&gt;&lt;P&gt;And for the list of obtained noderefs just remove the aspect.&lt;/P&gt;&lt;P&gt;Kind regards.&lt;/P&gt;&lt;P&gt;--C.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 16:17:10 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90517#M27012</guid>
      <dc:creator>cesarista</dc:creator>
      <dc:date>2020-10-08T16:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Populate List of Shared Files</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90518#M27013</link>
      <description>&lt;P&gt;I am not familiar with using a fts query. Where and how would I go about it?&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 16:40:39 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90518#M27013</guid>
      <dc:creator>eswbitto</dc:creator>
      <dc:date>2020-10-09T16:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Populate List of Shared Files</title>
      <link>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90519#M27014</link>
      <description>&lt;P&gt;You can use below search api to get list of all shared files:&lt;/P&gt;

&lt;PRE&gt;&lt;STRONG&gt;POST&lt;/STRONG&gt;: http://localhost:8080/alfresco/api/-default-/public/search/versions/1/search

&lt;STRONG&gt;Payload:
&lt;/STRONG&gt;
{
 "query": {
&lt;STRONG&gt;    "query": "+TYPE:\"cm:content\" AND +ASPECT:\"qshare:shared\"",
&lt;/STRONG&gt;    "language": "afts"
  }
}&lt;/PRE&gt;
&lt;P&gt;This will return list of files, but you are looking for display path which may not be possible to get using the v1 search api.&lt;/P&gt;
&lt;P&gt;You would have to write a custom java/js webscript that will execute fts query and return the list of nodes. Using the returned nodes you can extract the displaypath.&lt;/P&gt;
&lt;P&gt;You seem to be unware of fts queries and stuff. I would recommend to go through these documentations:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/search-enterprise/concepts/searchsyntax-intro.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/search-enterprise/concepts/searchsyntax-intro.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-finding-content-by-search-query.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/concepts/dev-api-by-language-alf-rest-finding-content-by-search-query.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://docs.alfresco.com/6.2/tasks/ws-tutorials.html" target="_blank" rel="noopener nofollow noreferrer"&gt;https://docs.alfresco.com/6.2/tasks/ws-tutorials.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Here is a sample javascript webscript, you can register it dynamically by uploading the file in "/Data Dictionary/Web Scripts Extensions/" folder in repository and &lt;A href="https://docs.alfresco.com/6.2/tasks/ws-register.html" target="_blank" rel="noopener nofollow noreferrer"&gt;refresh the webscripts&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;get-shared-files.get.desc.xml&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;webscript&amp;gt;
     &amp;lt;shortname&amp;gt;Get shared files information&amp;lt;/shortname&amp;gt;
&lt;STRONG&gt;     &amp;lt;url&amp;gt;/search/get-shared-files?skipCount={skipCount}&amp;amp;amp;maxCount={maxCount}&amp;lt;/url&amp;gt;
&lt;/STRONG&gt;     &amp;lt;authentication&amp;gt;admin&amp;lt;/authentication&amp;gt;
&amp;lt;/webscript&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;get-shared-files.get.js&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;EM&gt;main();

function main() {
    var skipCount = (args["skipCount"] == null || args["skipCount"] == undefined) ? 0 : args["skipCount"];
    var maxCount = (args["maxCount"] == null || args["maxCount"] == undefined) ? 10000 : args["maxCount"];

    var successNodes = [];
    var failedNodes = [];
    var totalNodes;
     
&lt;STRONG&gt;    var query = "+TYPE:\"cm:content\" AND +ASPECT:\"qshare:shared\"";
&lt;/STRONG&gt;    var page = {
        skipCount: parseInt(skipCount),
        maxItems: parseInt(maxCount)
    };

    var searchQuery = {
        query: query,
        language: "fts-alfresco",
        page: page
    };

    logger.log("Executing SearchQuery: " + query)
    var nodes = search.query(searchQuery);
    totalNodes = nodes.length;
    logger.log("Total Nodes: " + totalNodes)

    for each(node in nodes) {
        var sharedFileDetails = [];
        var fileName = node.name;
        var nodeReference = node.nodeRef;
        try {
            logger.log("Fetching details for file: " + fileName);
            sharedFileDetails["fileName"] = fileName;
            sharedFileDetails["NodeRef"] = nodeReference;
			var fullDP = node.displayPath+"/"+fileName;
            sharedFileDetails["DisplayPath"] = fullDP;
			logger.log("DisplayPath: " + fullDP);
            successNodes[nodeReference] = sharedFileDetails;
        } catch (ex) {
            logger.log("Exception occurred: " + ex.message);
            failedNodes[nodeReference] = fileName + " - " + ex.message;
        }
    }
     
    model.successNodes = successNodes;
    model.failedNodes = failedNodes;
    model.totalNodes = totalNodes;
}&lt;/EM&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;get-shared-files.get.html.ftl&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Shared File Information&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
     &amp;lt;h3&amp;gt;Total Folders: &amp;lt;#if totalNodes??&amp;gt;${totalNodes}&amp;lt;#else&amp;gt;-&amp;lt;/#if&amp;gt;&amp;lt;/h3&amp;gt;
     &amp;lt;#if successNodes??&amp;gt;
         &amp;lt;table border="1"&amp;gt;
              &amp;lt;tr&amp;gt;
                   &amp;lt;th align="center"&amp;gt;FileName&amp;lt;/th&amp;gt;
                   &amp;lt;th align="center"&amp;gt;Type And NodeRef&amp;lt;/th&amp;gt;
                   &amp;lt;th align="center"&amp;gt;DisplayPath&amp;lt;/th&amp;gt;
              &amp;lt;/tr&amp;gt;
           
          &amp;lt;#list successNodes?keys as nodeReference&amp;gt;
               &amp;lt;tr&amp;gt;
                &amp;lt;td align="center"&amp;gt; ${successNodes[nodeReference].fileName}&amp;lt;/td&amp;gt;
                &amp;lt;td align="center"&amp;gt; ${successNodes[nodeReference].NodeRef}&amp;lt;/td&amp;gt;
                &amp;lt;td align="center"&amp;gt; ${successNodes[nodeReference].DisplayPath}&amp;lt;/td&amp;gt;
               &amp;lt;/tr&amp;gt;
        &amp;lt;/#list&amp;gt;
            &amp;lt;/table&amp;gt;
     &amp;lt;/#if&amp;gt;
     
     &amp;lt;#if failedNodes?is_hash_ex&amp;gt;
         &amp;lt;table border="1"&amp;gt;
              &amp;lt;tr&amp;gt;
                   &amp;lt;th align="center"&amp;gt;NodeRef&amp;lt;/th&amp;gt;
                   &amp;lt;th align="center"&amp;gt;ErrorMsg&amp;lt;/th&amp;gt;
              &amp;lt;/tr&amp;gt;
              &amp;lt;#assign keys = failedNodes ?keys&amp;gt;
           &amp;lt;#list keys as key&amp;gt;
             &amp;lt;tr&amp;gt;
                     &amp;lt;td align="center"&amp;gt;${key}&amp;lt;/td&amp;gt;
                     &amp;lt;td align="center"&amp;gt;${failedNodes [key]}&amp;lt;/td&amp;gt;
                &amp;lt;/tr&amp;gt;
           &amp;lt;/#list&amp;gt;
            &amp;lt;/table&amp;gt;
     &amp;lt;/#if&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Once the webscript is registred and refreshed, use this url to get the response:&lt;/U&gt;&lt;/P&gt;
&lt;PRE&gt;http://127.0.0.1:8080/alfresco/service/search/get-shared-files?skipCount=0&amp;amp;maxCount=1000&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;Your result will similar to this one:&lt;/U&gt;&lt;/P&gt;
&lt;TABLE width="782px"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="82.4px" height="24px"&gt;&lt;STRONG&gt;FileName&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="364px" height="24px"&gt;&lt;STRONG&gt;Type and NodeRef&amp;nbsp;&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="334.4px" height="24px"&gt;&lt;STRONG&gt;Display Path&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="82.4px" height="67px"&gt;Test.pdf&lt;/TD&gt;
&lt;TD width="364px" height="67px"&gt;Node Type: cm:content NodeRef: workspace://SpacesStore/4e28d5fd-f596-4403-b61b-2501ae910e0d&amp;nbsp;&lt;/TD&gt;
&lt;TD width="334.4px" height="67px"&gt;&lt;STRONG&gt;/Company Home/Sites/test/documentLibrary/Test.pdf&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;

&lt;P&gt;You can update the same webscript to remove the&amp;nbsp;"qshare:shared" aspect, e.g.:&lt;/P&gt;
&lt;PRE&gt;for each(node in nodes) {
        var sharedFileDetails = [];
        var fileName = node.name;
        var nodeReference = node.nodeRef;
        try {
            logger.log("Fetching details for file: " + fileName);
            sharedFileDetails["fileName"] = fileName;
            sharedFileDetails["NodeRef"] = nodeReference;
			var fullDP = node.displayPath+"/"+fileName;
            sharedFileDetails["DisplayPath"] = fullDP;
			logger.log("DisplayPath: " + fullDP);
            &lt;STRONG&gt;if(node.hasAspect("qshare:shared")) {
               node.removeAspect("qshare:shared");
            }&lt;/STRONG&gt;
            successNodes[nodeReference] = sharedFileDetails;
        } catch (ex) {
            logger.log("Exception occurred: " + ex.message);
            failedNodes[nodeReference] = fileName + " - " + ex.message;
        }
    }&lt;/PRE&gt;
&lt;P&gt;This will remove the shared aspect and files will no more be publicly accesible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Oct 2020 17:47:28 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-forum/populate-list-of-shared-files/m-p/90519#M27014</guid>
      <dc:creator>abhinavmishra14</dc:creator>
      <dc:date>2020-10-09T17:47:28Z</dc:date>
    </item>
  </channel>
</rss>

