mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALF-20023 Recent Sites and Favourite Sites in copy/move pickers empty
So the bug was caused by 2 problems: one in ScriptPreferenceService and one in person.sites.get.js The first problem was that ScriptPreferenceService constructs raw Mozilla NativeObjects - a very unusual practice in itself - and it does not provide a default value as required by ECMA 9.1 from the ECMA standard. I've added this code to the NativeObject (can't change the type to ScriptableHashMap<K, V> or similar as the API is published). I've also fixed the same bug (unreported, possibly never apparent) in a jbpm class. The second problem was that person.sites.get.js simply could never return preferences data if the caller provided a filter (favourites or recents) and did not also provide a page size. There was a logic error in the algorithm such that the size defaulted to 0 thus providing a 'page' of zero results as a default. I assume this is a merge error from cloud, but I don't know. I added tests for the JavaScript API's favourites/recents filter calls and logging here and there. Also deleted some dead code. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@55474 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,8 +68,10 @@ public class ScriptPreferenceService extends BaseScopableProcessorExtension
|
||||
|
||||
public NativeObject getPreferences(String userName, String preferenceFilter)
|
||||
{
|
||||
// It's a tad unusual to return a NativeObject like this - at least within Alfresco.
|
||||
// But we can't change it to e.g. a ScriptableHashMap as the API is published.
|
||||
Map<String, Serializable> prefs = this.preferenceService.getPreferences(userName, preferenceFilter);
|
||||
NativeObject result = new NativeObject();
|
||||
NativeObject result = new NativeObjectDV();
|
||||
|
||||
for (Map.Entry<String, Serializable> entry : prefs.entrySet())
|
||||
{
|
||||
@@ -80,6 +82,16 @@ public class ScriptPreferenceService extends BaseScopableProcessorExtension
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* This extension of NativeObject adds a default value. See ALF-20023 for some background.
|
||||
*/
|
||||
private static class NativeObjectDV extends NativeObject
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override public Object getDefaultValue(@SuppressWarnings("rawtypes") Class typeHint) { return toString(); }
|
||||
}
|
||||
|
||||
private void setPrefValue(String[] keys, Serializable value, NativeObject object)
|
||||
{
|
||||
NativeObject currentObject = object;
|
||||
@@ -96,7 +108,7 @@ public class ScriptPreferenceService extends BaseScopableProcessorExtension
|
||||
Object temp = currentObject.get(key, currentObject);
|
||||
if (temp == null || temp instanceof NativeObject == false)
|
||||
{
|
||||
newObject = new NativeObject();
|
||||
newObject = new NativeObjectDV();
|
||||
currentObject.put(key, currentObject, newObject);
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user