mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Improved doc lib extensibility
* doclist.lib.js now has an overridable "doclist_getAllNodes" function that makes it easier to reuse doclist.lib.js and its "doclist_main" method * DefaultDoclistDataUrlResolver now has a basePath parameter so its possible to redirect doclib rest calls to a custom repo webscript using only config git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42652 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,43 +1,33 @@
|
|||||||
const REQUEST_MAX = 1000;
|
const REQUEST_MAX = 1000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main entry point: Create collection of documents and folders in the given space
|
* Method that performs the actual loading of the nodes.
|
||||||
*
|
*
|
||||||
* @method doclist_main
|
* Note!
|
||||||
|
* Will optimize performance by using ScriptNode.childFileFolders for directory listings
|
||||||
|
* In other words when the "path" filter is used.
|
||||||
|
*
|
||||||
|
* @method doclist_getAllNodes
|
||||||
|
* @param parsedArgs {Object}
|
||||||
|
* @param filterParams {Object}
|
||||||
|
* @param query {String}
|
||||||
|
* @param totalItemCount {int}
|
||||||
|
* @return {object} Returns the node and corresponding pagination metadata
|
||||||
|
* {
|
||||||
|
* allNodes: {Array}
|
||||||
|
* totalRecords: {int}
|
||||||
|
* requestTotalCountMax: {int}
|
||||||
|
* paged: {boolean}
|
||||||
|
* query: {String}
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
function doclist_main()
|
function doclist_getAllNodes(parsedArgs, filterParams, query, totalItemCount)
|
||||||
{
|
{
|
||||||
// Use helper function to get the arguments
|
|
||||||
var parsedArgs = ParseArgs.getParsedArgs();
|
|
||||||
if (parsedArgs === null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var filter = args.filter,
|
var filter = args.filter,
|
||||||
items = [];
|
|
||||||
|
|
||||||
// Try to find a filter query based on the passed-in arguments
|
|
||||||
var allNodes = [],
|
|
||||||
totalRecords = 0,
|
totalRecords = 0,
|
||||||
requestTotalCountMax = 0,
|
requestTotalCountMax = 0,
|
||||||
paged = false,
|
paged = false,
|
||||||
favourites = Common.getFavourites(),
|
allNodes = [];
|
||||||
filterParams = Filters.getFilterParams(filter, parsedArgs,
|
|
||||||
{
|
|
||||||
favourites: favourites
|
|
||||||
}),
|
|
||||||
query = filterParams.query,
|
|
||||||
allSites = (parsedArgs.nodeRef == "alfresco://sites/home");
|
|
||||||
|
|
||||||
if (logger.isLoggingEnabled())
|
|
||||||
logger.log("doclist.lib.js - NodeRef: " + parsedArgs.nodeRef + " Query: " + query);
|
|
||||||
|
|
||||||
var totalItemCount = filterParams.limitResults ? parseInt(filterParams.limitResults, 10) : -1;
|
|
||||||
// For all sites documentLibrary query we pull in all available results and post filter
|
|
||||||
if (totalItemCount === 0) totalItemCount = -1;
|
|
||||||
else if (allSites) totalItemCount = (totalItemCount > 0 ? totalItemCount * 10 : 500);
|
|
||||||
|
|
||||||
if ((filter || "path") == "path")
|
if ((filter || "path") == "path")
|
||||||
{
|
{
|
||||||
// TODO also add DB filter by "node" (in addition to "path")
|
// TODO also add DB filter by "node" (in addition to "path")
|
||||||
@@ -90,6 +80,62 @@ function doclist_main()
|
|||||||
totalRecords = allNodes.length;
|
totalRecords = allNodes.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return {
|
||||||
|
allNodes: allNodes,
|
||||||
|
totalRecords: totalRecords,
|
||||||
|
requestTotalCountMax: requestTotalCountMax,
|
||||||
|
paged: paged,
|
||||||
|
query: query
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Main entry point: Create collection of documents and folders in the given space
|
||||||
|
*
|
||||||
|
* @method doclist_main
|
||||||
|
*/
|
||||||
|
function doclist_main()
|
||||||
|
{
|
||||||
|
// Use helper function to get the arguments
|
||||||
|
var parsedArgs = ParseArgs.getParsedArgs();
|
||||||
|
if (parsedArgs === null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var filter = args.filter,
|
||||||
|
items = [];
|
||||||
|
|
||||||
|
// Try to find a filter query based on the passed-in arguments
|
||||||
|
var allNodes = [],
|
||||||
|
totalRecords = 0,
|
||||||
|
requestTotalCountMax = 0,
|
||||||
|
paged = false,
|
||||||
|
favourites = Common.getFavourites(),
|
||||||
|
filterParams = Filters.getFilterParams(filter, parsedArgs,
|
||||||
|
{
|
||||||
|
favourites: favourites
|
||||||
|
}),
|
||||||
|
query = filterParams.query,
|
||||||
|
allSites = (parsedArgs.nodeRef == "alfresco://sites/home");
|
||||||
|
|
||||||
|
if (logger.isLoggingEnabled())
|
||||||
|
logger.log("doclist.lib.js - NodeRef: " + parsedArgs.nodeRef + " Query: " + query);
|
||||||
|
|
||||||
|
var totalItemCount = filterParams.limitResults ? parseInt(filterParams.limitResults, 10) : -1;
|
||||||
|
// For all sites documentLibrary query we pull in all available results and post filter
|
||||||
|
if (totalItemCount === 0) totalItemCount = -1;
|
||||||
|
else if (allSites) totalItemCount = (totalItemCount > 0 ? totalItemCount * 10 : 500);
|
||||||
|
|
||||||
|
|
||||||
|
var allNodesResult = doclist_getAllNodes(parsedArgs, filterParams, query, totalItemCount);
|
||||||
|
allNodes = allNodesResult.allNodes;
|
||||||
|
totalRecords = allNodesResult.totalRecords;
|
||||||
|
requestTotalCountMax = allNodesResult.requestTotalCountMax;
|
||||||
|
paged = allNodesResult.paged;
|
||||||
|
query = allNodesResult.query;
|
||||||
|
|
||||||
|
|
||||||
if (logger.isLoggingEnabled())
|
if (logger.isLoggingEnabled())
|
||||||
logger.log("doclist.lib.js - query results: " + allNodes.length);
|
logger.log("doclist.lib.js - query results: " + allNodes.length);
|
||||||
// Generate the qname path match regex required for all sites 'documentLibrary' results match
|
// Generate the qname path match regex required for all sites 'documentLibrary' results match
|
||||||
|
Reference in New Issue
Block a user