Merged API-STRIKES-BACK (5.2.0) to HEAD (5.2)

127621 jkaabimofrad: Replaced anonymous class with lambda, to force the use of Java 8!


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@127622 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jamal Kaabi-Mofrad
2016-06-03 01:33:13 +00:00
parent 8cc239c53c
commit f9da6185f0
2 changed files with 28 additions and 52 deletions

View File

@@ -213,24 +213,20 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
String networkTenantDomain = pair.getFirst(); String networkTenantDomain = pair.getFirst();
final NodeRef nodeRef = pair.getSecond(); final NodeRef nodeRef = pair.getSecond();
return TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<BinaryResource>() return TenantUtil.runAsSystemTenant(() -> {
{ // belt-and-braces (similar to QuickShareContentGet)
public BinaryResource doWork() throws Exception if (!nodeService.hasAspect(nodeRef, QuickShareModel.ASPECT_QSHARE))
{ {
// belt-and-braces (similar to QuickShareContentGet) throw new InvalidNodeRefException(nodeRef);
if (!nodeService.hasAspect(nodeRef, QuickShareModel.ASPECT_QSHARE)) }
{
throw new InvalidNodeRefException(nodeRef);
}
if (renditionId != null) if (renditionId != null)
{ {
return renditions.getContent(nodeRef, renditionId, parameters); return renditions.getContent(nodeRef, renditionId, parameters);
} }
else else
{ {
return nodes.getContent(nodeRef, parameters, false); return nodes.getContent(nodeRef, parameters, false);
}
} }
}, networkTenantDomain); }, networkTenantDomain);
} }
@@ -396,21 +392,17 @@ public class QuickShareLinksImpl implements QuickShareLinks, InitializingBean
String networkTenantDomain = pair.getFirst(); String networkTenantDomain = pair.getFirst();
final NodeRef nodeRef = pair.getSecond(); final NodeRef nodeRef = pair.getSecond();
return TenantUtil.runAsSystemTenant(new TenantUtil.TenantRunAsWork<CollectionWithPagingInfo<Rendition>>() return TenantUtil.runAsSystemTenant(() -> {
{ String nodeId = nodeRef.getId();
public CollectionWithPagingInfo<Rendition> doWork() throws Exception
{
String nodeId = nodeRef.getId();
// hmm ... can we simplify ? // hmm ... can we simplify ?
String filterStatusCreated = "("+Renditions.PARAM_STATUS+"='"+Rendition.RenditionStatus.CREATED+"')"; String filterStatusCreated = "(" + Renditions.PARAM_STATUS + "='" + Rendition.RenditionStatus.CREATED + "')";
Query whereQuery = ResourceWebScriptHelper.getWhereClause(filterStatusCreated); Query whereQuery = ResourceWebScriptHelper.getWhereClause(filterStatusCreated);
Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false); Params.RecognizedParams recParams = new Params.RecognizedParams(null, null, null, null, null, null, whereQuery, null, false);
Parameters params = Params.valueOf(recParams, null, null, null); Parameters params = Params.valueOf(recParams, null, null, null);
return renditions.getRenditions(nodeId, params); return renditions.getRenditions(nodeId, params);
}
}, networkTenantDomain); }, networkTenantDomain);
} }
catch (InvalidSharedIdException ex) catch (InvalidSharedIdException ex)

View File

@@ -26,6 +26,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.tenant.TenantUtil; import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.tenant.TenantUtil.TenantRunAsWork;
import org.alfresco.rest.api.Nodes; import org.alfresco.rest.api.Nodes;
import org.alfresco.rest.api.model.Site; import org.alfresco.rest.api.model.Site;
import org.alfresco.rest.api.nodes.NodesEntityResource; import org.alfresco.rest.api.nodes.NodesEntityResource;
@@ -373,14 +374,9 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
{ {
final String siteName = "RandomSite" + System.currentTimeMillis(); final String siteName = "RandomSite" + System.currentTimeMillis();
final TestSite site = TenantUtil.runAsUserTenant(new TenantUtil.TenantRunAsWork<TestSite>() final TestSite site = TenantUtil.runAsUserTenant(() -> {
{ SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, siteVisibility);
@Override return repoService.createSite(testNetwork, siteInfo);
public TestSite doWork() throws Exception
{
SiteInformation siteInfo = new SiteInformation(siteName, siteName, siteName, siteVisibility);
return repoService.createSite(testNetwork, siteInfo);
}
}, user.getId(), testNetwork.getId()); }, user.getId(), testNetwork.getId());
return site; return site;
@@ -439,27 +435,15 @@ public abstract class AbstractBaseApiTest extends EnterpriseTestApi
protected void inviteToSite(final TestSite testSite, final TestPerson invitee, final SiteRole siteRole) protected void inviteToSite(final TestSite testSite, final TestPerson invitee, final SiteRole siteRole)
{ {
TenantUtil.runAsTenant(new TenantUtil.TenantRunAsWork<Void>() TenantUtil.runAsTenant((TenantRunAsWork<Void>) () -> {
{ testSite.inviteToSite(invitee.getId(), siteRole);
@Override return null;
public Void doWork() throws Exception
{
testSite.inviteToSite(invitee.getId(), siteRole);
return null;
}
}, testSite.getNetworkId()); }, testSite.getNetworkId());
} }
protected NodeRef getSiteDocLib(final TestSite testSite) protected NodeRef getSiteDocLib(final TestSite testSite)
{ {
return TenantUtil.runAsTenant(new TenantUtil.TenantRunAsWork<NodeRef>() return TenantUtil.runAsTenant(() -> testSite.getContainerNodeRef(("documentLibrary")), testSite.getNetworkId());
{
@Override
public NodeRef doWork() throws Exception
{
return testSite.getContainerNodeRef(("documentLibrary"));
}
}, testSite.getNetworkId());
} }
protected void checkStatus(int expectedStatus, int actualStatus) protected void checkStatus(int expectedStatus, int actualStatus)