Merged HEAD-BUG-FIX (5.1/Cloud) to HEAD (5.1/Cloud)

91788: Merged 5.0.N (5.0.1) to HEAD-BUG-FIX (5.1/Cloud)
      91682: Merged 5.0.0 (5.0.0.1) to 5.0.N (5.0.1)
         91617: MNT-12879: Cannot preview or download document with explicit permissions
         Disabled activity generation for file downloads from a private site if the user is not a member of the site.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@94831 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2015-01-31 11:39:15 +00:00
parent 95283567ba
commit a35aee7b1e
3 changed files with 199 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ import java.util.Map;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.Client;
import org.alfresco.repo.Client.ClientType;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.web.scripts.content.ContentGet;
@@ -84,7 +85,15 @@ public class SlingshotContentGet extends ContentGet
if (storeType != null && storeId != null && nodeId != null)
{
final NodeRef nodeRef = new NodeRef(storeType, storeId, nodeId);
final SiteInfo site = this.siteService.getSite(nodeRef);
SiteInfo site = null;
try
{
site = this.siteService.getSite(nodeRef);
}
catch (AccessDeniedException ade)
{
// We don't have access to the site, don't post any permissions
}
if (site != null)
{
// found a valid parent Site - gather the details to post an Activity
@@ -94,13 +103,15 @@ public class SlingshotContentGet extends ContentGet
filename = (String)this.nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
}
final String strFilename = filename;
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>() {
final String siteName = site.getShortName();
transactionHelper.doInTransaction(new RetryingTransactionCallback<Void>()
{
@Override
public Void execute() throws Throwable
{
// post an activity - mirror the mechanism as if from the Share application
poster.postFileFolderActivity(ActivityPoster.DOWNLOADED, null, null,
site.getShortName(), null, nodeRef, strFilename, "documentlibrary", Client.asType(ClientType.webclient), null);
poster.postFileFolderActivity(ActivityPoster.DOWNLOADED, null, null,
siteName, null, nodeRef, strFilename, "documentlibrary", Client.asType(ClientType.webclient), null);
return null;
}
}, false, true);
@@ -109,4 +120,4 @@ public class SlingshotContentGet extends ContentGet
}
super.execute(req, res);
}
}
}