ALF-6706 - MT: activities not generated (for tenants)

- related to ALF-1605

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@30736 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2011-09-23 14:56:06 +00:00
parent f966c4a391
commit c2e5a7546c

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
@@ -32,6 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.springframework.extensions.surf.util.ParameterCheck;
/**
@@ -165,7 +168,42 @@ public class ActivityPostServiceImpl implements ActivityPostService
{
activityData = "";
}
else if (activityData.length() > ActivityPostDAO.MAX_LEN_ACTIVITY_DATA)
if (AuthenticationUtil.isMtEnabled())
{
// MT share - required for canRead
try
{
JSONObject jo = new JSONObject(new JSONTokener(activityData));
boolean update = false;
if (! jo.isNull(PostLookup.JSON_NODEREF))
{
String nodeRefStr = jo.getString(PostLookup.JSON_NODEREF);
jo.put(PostLookup.JSON_NODEREF, tenantService.getName(new NodeRef(nodeRefStr)));
update = true;
}
if (! jo.isNull(PostLookup.JSON_NODEREF_PARENT))
{
String nodeRefStr = jo.getString(PostLookup.JSON_NODEREF_PARENT);
jo.put(PostLookup.JSON_NODEREF_PARENT, tenantService.getName(new NodeRef(nodeRefStr)));
update = true;
}
if (update)
{
activityData = jo.toString();
}
}
catch (JSONException e)
{
throw new IllegalArgumentException("Invalid activity data - not valid JSON: " + e);
}
}
if (activityData.length() > ActivityPostDAO.MAX_LEN_ACTIVITY_DATA)
{
throw new IllegalArgumentException("Invalid activity data - exceeds " + ActivityPostDAO.MAX_LEN_ACTIVITY_DATA + " chars: " + activityData);
}