mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Fix for ALF-10797 - "Recently added" and "Recently modified" sections in "My content" page are empty
- addition of index control aspect to surf-config objects - config xml files no longer indexed at all - refactoring of My Profile user contents fts-alfresco queries to search specific known containers only rather than all git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@31288 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,49 +1,91 @@
|
|||||||
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js">
|
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/search/search.lib.js">
|
||||||
|
|
||||||
function getContents(user, type, maxResults)
|
var maxResults = (args.maxResults !== undefined) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS;
|
||||||
|
|
||||||
|
function padZeros(number)
|
||||||
{
|
{
|
||||||
var padZeros = function padZeros(number)
|
return (number < 10) ? '0' + number : number;
|
||||||
{
|
}
|
||||||
return (number < 10) ? '0' + number : number;
|
|
||||||
}
|
function getContents(user, type)
|
||||||
|
{
|
||||||
//set range to within last 28 days
|
// set range to within last 28 days
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
var toQuery = date.getFullYear() + "-" + padZeros((date.getMonth()+1)) + "-" + padZeros(date.getDate());
|
var toQuery = date.getFullYear() + "-" + padZeros((date.getMonth()+1)) + "-" + padZeros(date.getDate());
|
||||||
date.setDate(date.getDate() - 28);
|
date.setDate(date.getDate() - 28);
|
||||||
var fromQuery = date.getFullYear() + "-" + padZeros((date.getMonth()+1)) + "-" + padZeros(date.getDate());
|
var fromQuery = date.getFullYear() + "-" + padZeros((date.getMonth()+1)) + "-" + padZeros(date.getDate());
|
||||||
|
|
||||||
var userProperty = (type == 'created') ? 'creator' : 'modifier';
|
var userProperty = (type == 'created') ? 'creator' : 'modifier';
|
||||||
var query = 'PATH:"/*/st:sites/*/*//*" ' +
|
|
||||||
'AND +@cm:' + userProperty + ':"' + user + '" ' +
|
|
||||||
'AND +@cm:' + type + ':["' + fromQuery + '" TO "' + toQuery + '"] ' +
|
|
||||||
'AND +TYPE:"cm:content" ' +
|
|
||||||
'AND -TYPE:"ia:calendarEvent" ' +
|
|
||||||
'AND -TYPE:"dl:dataListItem" ';
|
|
||||||
|
|
||||||
// perform fts-alfresco language query
|
var getBlogPostsQuery = function getBlogPosts()
|
||||||
|
{
|
||||||
|
return 'PATH:"/app:company_home/st:sites/*/cm:blog/*" ' +
|
||||||
|
'AND +TYPE:"cm:content" ' +
|
||||||
|
'AND +@cm:' + userProperty + ':"' + user + '" ' +
|
||||||
|
'AND +@cm:' + type + ':["' + fromQuery + '" TO "' + toQuery + '"]';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getWikiPagesQuery = function getWikiPagesQuery()
|
||||||
|
{
|
||||||
|
return 'PATH:"/app:company_home/st:sites/*/cm:wiki/*" ' +
|
||||||
|
'AND +TYPE:"cm:content" ' +
|
||||||
|
'AND +@cm:' + userProperty + ':"' + user + '" ' +
|
||||||
|
'AND +@cm:' + type + ':["' + fromQuery + '" TO "' + toQuery + '"]';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getDiscussionsQuery = function getDiscussionsQuery()
|
||||||
|
{
|
||||||
|
return 'PATH:"/app:company_home/st:sites/*/cm:discussions//*" ' +
|
||||||
|
'AND +TYPE:"fm:post" ' +
|
||||||
|
'AND +@cm:' + userProperty + ':"' + user + '" ' +
|
||||||
|
'AND +@cm:' + type + ':["' + fromQuery + '" TO "' + toQuery + '"]';
|
||||||
|
};
|
||||||
|
|
||||||
|
var getDocumentsQuery = function getDocumentsQuery()
|
||||||
|
{
|
||||||
|
return 'PATH:"/app:company_home/st:sites/*/cm:documentLibrary//*" ' +
|
||||||
|
'AND +TYPE:"cm:content" ' +
|
||||||
|
'AND +@cm:' + userProperty + ':"' + user + '" ' +
|
||||||
|
'AND +@cm:' + type + ':["' + fromQuery + '" TO "' + toQuery + '"]';
|
||||||
|
};
|
||||||
|
|
||||||
var sortColumns = [];
|
var sortColumns = [];
|
||||||
sortColumns.push(
|
sortColumns.push(
|
||||||
{
|
{
|
||||||
column: "@" + utils.longQName("cm:" + type),
|
column: "@" + utils.longQName("cm:" + type),
|
||||||
ascending: false
|
ascending: false
|
||||||
});
|
});
|
||||||
|
|
||||||
var queryDef = {
|
var queryDef = {
|
||||||
query: query,
|
query: "",
|
||||||
language: "fts-alfresco",
|
language: "fts-alfresco",
|
||||||
page: {maxItems: maxResults},
|
page: {maxItems: maxResults},
|
||||||
onerror: "no-results",
|
onerror: "no-results",
|
||||||
sort: sortColumns
|
sort: sortColumns
|
||||||
};
|
};
|
||||||
var nodes = search.query(queryDef);
|
|
||||||
|
|
||||||
// reset processed results (in search.lib.js)
|
// perform fts-alfresco language queries
|
||||||
processedCache = {}
|
var results;
|
||||||
return processResults(nodes, maxResults);
|
queryDef.query = getBlogPostsQuery();
|
||||||
|
results = search.query(queryDef);
|
||||||
|
queryDef.query = getWikiPagesQuery();
|
||||||
|
results = results.concat(search.query(queryDef));
|
||||||
|
queryDef.query = getDiscussionsQuery();
|
||||||
|
results = results.concat(search.query(queryDef));
|
||||||
|
queryDef.query = getDocumentsQuery();
|
||||||
|
results = results.concat(search.query(queryDef));
|
||||||
|
|
||||||
|
results.sort(function(a, b)
|
||||||
|
{
|
||||||
|
var date1 = a.properties[type].getTime(),
|
||||||
|
date2 = b.properties[type].getTime();
|
||||||
|
return (date1 < date2) ? 1 : (date1 > date2) ? -1 : 0;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return processResults(results, maxResults);
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxResults = (args.maxResults !== undefined) ? parseInt(args.maxResults, 10) : DEFAULT_MAX_RESULTS;
|
|
||||||
|
|
||||||
model.data = [];
|
model.data = [];
|
||||||
model.data['created'] = getContents(args.user, 'created', maxResults);
|
model.data['created'] = getContents(args.user, 'created', maxResults);
|
||||||
model.data['modified'] = getContents(args.user, 'modified', maxResults);
|
model.data['modified'] = getContents(args.user, 'modified', maxResults);
|
@@ -72,7 +72,7 @@ function getPersonDisplayName(userId)
|
|||||||
* Cache to not display twice the same element (e.g. if two comments of the
|
* Cache to not display twice the same element (e.g. if two comments of the
|
||||||
* same blog post match the search criteria
|
* same blog post match the search criteria
|
||||||
*/
|
*/
|
||||||
var processedCache = {};
|
var processedCache;
|
||||||
function checkProcessedCache(key)
|
function checkProcessedCache(key)
|
||||||
{
|
{
|
||||||
var found = processedCache.hasOwnProperty(key);
|
var found = processedCache.hasOwnProperty(key);
|
||||||
@@ -363,7 +363,7 @@ function getWikiItem(siteId, containerId, pathParts, node)
|
|||||||
};
|
};
|
||||||
item.modifiedBy = getPersonDisplayName(item.modifiedByUser);
|
item.modifiedBy = getPersonDisplayName(item.modifiedByUser);
|
||||||
item.createdBy = getPersonDisplayName(item.createdByUser);
|
item.createdBy = getPersonDisplayName(item.createdByUser);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -551,7 +551,9 @@ function splitQNamePath(node)
|
|||||||
* @return the final search results object
|
* @return the final search results object
|
||||||
*/
|
*/
|
||||||
function processResults(nodes, maxResults)
|
function processResults(nodes, maxResults)
|
||||||
{
|
{
|
||||||
|
// empty cache state
|
||||||
|
processedCache = {};
|
||||||
var results = [],
|
var results = [],
|
||||||
added = 0,
|
added = 0,
|
||||||
parts,
|
parts,
|
||||||
|
@@ -354,6 +354,9 @@ public class ADMRemoteStore extends BaseRemoteStore
|
|||||||
}
|
}
|
||||||
FileInfo fileInfo = fileFolderService.create(
|
FileInfo fileInfo = fileFolderService.create(
|
||||||
parentFolder.getNodeRef(), encpath.substring(off + 1), ContentModel.TYPE_CONTENT);
|
parentFolder.getNodeRef(), encpath.substring(off + 1), ContentModel.TYPE_CONTENT);
|
||||||
|
Map<QName, Serializable> aspectProperties = new HashMap<QName, Serializable>(1, 1.0f);
|
||||||
|
aspectProperties.put(ContentModel.PROP_IS_INDEXED, false);
|
||||||
|
nodeService.addAspect(fileInfo.getNodeRef(), ContentModel.ASPECT_INDEX_CONTROL, aspectProperties);
|
||||||
contentService.getWriter(
|
contentService.getWriter(
|
||||||
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true).putContent(content);
|
fileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true).putContent(content);
|
||||||
if (logger.isDebugEnabled())
|
if (logger.isDebugEnabled())
|
||||||
|
Reference in New Issue
Block a user