Site Service: GET and POST methods implemented on Site Membership REST API

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9042 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2008-05-08 17:00:35 +00:00
parent 76cea3002b
commit 6a4253117b

View File

@@ -173,6 +173,8 @@ public class ValueConverter
{ {
// convert JavaScript array of values to a List of Serializable objects // convert JavaScript array of values to a List of Serializable objects
Object[] propIds = values.getIds(); Object[] propIds = values.getIds();
if (isArray(propIds) == true)
{
List<Serializable> propValues = new ArrayList<Serializable>(propIds.length); List<Serializable> propValues = new ArrayList<Serializable>(propIds.length);
for (int i=0; i<propIds.length; i++) for (int i=0; i<propIds.length; i++)
{ {
@@ -188,9 +190,23 @@ public class ValueConverter
propValues.add(convertValueForRepo(val)); propValues.add(convertValueForRepo(val));
} }
} }
value = (Serializable)propValues; value = (Serializable)propValues;
} }
else else
{
Map<Serializable, Serializable> propValues = new HashMap<Serializable, Serializable>(propIds.length);
for (Object propId : propIds)
{
// Get the value and add to the map
Serializable val = (Serializable)values.get(propId.toString(), values);
propValues.put(convertValueForRepo((Serializable)propId), convertValueForRepo(val));
}
value = (Serializable)propValues;
}
}
else
{ {
// convert JavaScript map to values to a Map of Serializable objects // convert JavaScript map to values to a Map of Serializable objects
Object[] propIds = values.getIds(); Object[] propIds = values.getIds();
@@ -227,4 +243,24 @@ public class ValueConverter
return value; return value;
} }
/**
* Look at the id's of a native array and try to determine whether it's actually an Array or a Hashmap
*
* @param ids id's of the native array
* @return boolean true if it's an array, false otherwise (ie it's a map)
*/
private boolean isArray(Object[] ids)
{
boolean result = true;
for (Object id : ids)
{
if (id instanceof Integer == false)
{
result = false;
break;
}
}
return result;
}
} }