mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2)
124565 gjames: RA-884: Posting DOWNLOAD activities in a new (non-readonly) transaction git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@126569 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -57,6 +57,7 @@ import org.alfresco.repo.tenant.TenantUtil;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailDefinition;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailHelper;
|
||||
import org.alfresco.repo.thumbnail.ThumbnailRegistry;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.version.VersionModel;
|
||||
import org.alfresco.rest.antlr.WhereClauseParser;
|
||||
import org.alfresco.rest.api.Nodes;
|
||||
@@ -183,6 +184,7 @@ public class NodesImpl implements Nodes
|
||||
private ThumbnailService thumbnailService;
|
||||
private SiteService siteService;
|
||||
private ActivityPoster poster;
|
||||
private RetryingTransactionHelper retryingTransactionHelper;
|
||||
|
||||
private enum Activity_Type
|
||||
{
|
||||
@@ -226,6 +228,7 @@ public class NodesImpl implements Nodes
|
||||
this.authorityService = sr.getAuthorityService();
|
||||
this.thumbnailService = sr.getThumbnailService();
|
||||
this.siteService = sr.getSiteService();
|
||||
this.retryingTransactionHelper = sr.getRetryingTransactionHelper();
|
||||
|
||||
if (defaultIgnoreTypesAndAspects != null)
|
||||
{
|
||||
@@ -1913,6 +1916,19 @@ public class NodesImpl implements Nodes
|
||||
}
|
||||
String attachFileName = (attach ? name : null);
|
||||
|
||||
final ActivityInfo activityInfo = getActivityInfo(getParentNodeRef(nodeRef), nodeRef);
|
||||
|
||||
//Activity posting needs a transaction
|
||||
retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<Void>()
|
||||
{
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
postActivity(Activity_Type.DOWNLOADED, activityInfo);
|
||||
return null;
|
||||
}
|
||||
}, false, true);
|
||||
|
||||
return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT, ci, attachFileName);
|
||||
}
|
||||
|
||||
|
@@ -102,11 +102,16 @@ public class ActivitiesPostingTest extends AbstractBaseApiTest
|
||||
dUpdate.setName("d1b.txt");
|
||||
HttpResponse response = put(URL_NODES, u1.getId(), documentResp.getId(), toJsonAsStringNonNull(dUpdate), null, 200);
|
||||
|
||||
//Now download it
|
||||
response = getSingle(NodesEntityResource.class, u1.getId(), documentResp.getId()+"/content", null, 200);
|
||||
String textContent = response.getResponse();
|
||||
assertNotNull(textContent);
|
||||
|
||||
delete(URL_NODES, u1.getId(), documentResp.getId(), 204);
|
||||
delete(URL_NODES, u1.getId(), createdFolder.getId(), 204);
|
||||
|
||||
List<Activity> activities = getMyActivites();
|
||||
assertEquals(activities.size(),5);
|
||||
assertEquals(activities.size(),6);
|
||||
Activity act = matchActivity(activities, ActivityType.FOLDER_ADDED, u1.getId(), tSite.getSiteId(), docLibNodeRef.getId(), folder1);
|
||||
assertNotNull(act);
|
||||
|
||||
@@ -121,6 +126,9 @@ public class ActivitiesPostingTest extends AbstractBaseApiTest
|
||||
|
||||
act = matchActivity(activities, ActivityType.FILE_DELETED, u1.getId(), tSite.getSiteId(), createdFolder.getId(), dUpdate.getName());
|
||||
assertNotNull(act);
|
||||
|
||||
act = matchActivity(activities, ActivityPoster.DOWNLOADED, u1.getId(), tSite.getSiteId(), createdFolder.getId(), dUpdate.getName());
|
||||
assertNotNull(act);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Reference in New Issue
Block a user