ALF-9321 (RINF 11): CQ permissions

- minor: push down common method lookup code

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28640 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2011-06-28 08:03:21 +00:00
parent 97f676b895
commit bde2b2e293
13 changed files with 45 additions and 132 deletions

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.repo.blog;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -56,11 +55,12 @@ public class DraftsAndPublishedBlogPostsCannedQuery extends AbstractCannedQueryP
NodeService rawNodeService,
TaggingService taggingService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.rawNodeService = rawNodeService;
this.taggingService = taggingService;
}

View File

@@ -18,12 +18,10 @@
*/
package org.alfresco.repo.blog;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.query.AbstractCannedQueryFactory;
import org.alfresco.query.CannedQuery;
@@ -88,27 +86,12 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
@Override
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
{
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
// if not passed in (TODO or not in future cache) then generate a new query execution id
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(rawNodeService, taggingService,
methodSecurityInterceptor, method, parameters, queryExecutionId);
methodSecurityInterceptor, methodService, methodName,
parameters, queryExecutionId);
return (CannedQuery<BlogPostInfo>) cq;
}

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.repo.blog;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -55,11 +54,12 @@ public class GetBlogPostsCannedQuery extends AbstractCannedQueryPermissions<Blog
public GetBlogPostsCannedQuery(
NodeService rawNodeService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.rawNodeService = rawNodeService;
}

View File

@@ -18,13 +18,11 @@
*/
package org.alfresco.repo.blog;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.BlogIntegrationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.query.AbstractCannedQueryFactory;
@@ -85,25 +83,9 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
@Override
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
{
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, method, parameters, queryExecutionId);
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
return (CannedQuery<BlogPostInfo>) cq;
}

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.repo.blog.cannedqueries;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -58,11 +57,12 @@ public class DraftsAndPublishedBlogPostsCannedQuery extends AbstractCannedQueryP
NodeService rawNodeService,
TaggingService taggingService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.rawNodeService = rawNodeService;
this.taggingService = taggingService;
}

View File

@@ -18,12 +18,10 @@
*/
package org.alfresco.repo.blog.cannedqueries;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.query.AbstractCannedQueryFactory;
import org.alfresco.query.CannedQuery;
@@ -89,27 +87,12 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
@Override
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
{
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
// if not passed in (TODO or not in future cache) then generate a new query execution id
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(rawNodeService, taggingService,
methodSecurityInterceptor, method, parameters, queryExecutionId);
methodSecurityInterceptor, methodService, methodName,
parameters, queryExecutionId);
return (CannedQuery<BlogPostInfo>) cq;
}

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.repo.blog.cannedqueries;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -57,11 +56,12 @@ public class GetBlogPostsCannedQuery extends AbstractCannedQueryPermissions<Blog
public GetBlogPostsCannedQuery(
NodeService rawNodeService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.rawNodeService = rawNodeService;
}

View File

@@ -18,13 +18,11 @@
*/
package org.alfresco.repo.blog.cannedqueries;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.BlogIntegrationModel;
import org.alfresco.model.ContentModel;
import org.alfresco.query.AbstractCannedQueryFactory;
@@ -87,25 +85,9 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
@Override
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
{
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, method, parameters, queryExecutionId);
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
return (CannedQuery<BlogPostInfo>) cq;
}

View File

@@ -19,7 +19,6 @@
package org.alfresco.repo.node.getchildren;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -105,11 +104,12 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
NodePropertyHelper nodePropertyHelper,
TenantService tenantService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.nodeDAO = nodeDAO;
this.qnameDAO = qnameDAO;

View File

@@ -18,19 +18,17 @@
*/
package org.alfresco.repo.node.getchildren;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.query.AbstractCannedQueryFactory;
import org.alfresco.query.CannedQuery;
import org.alfresco.query.CannedQueryPageDetails;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.CannedQuerySortDetails;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
import org.alfresco.repo.domain.locale.LocaleDAO;
import org.alfresco.repo.domain.node.NodeDAO;
@@ -122,26 +120,10 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory<No
{
NodePropertyHelper nodePropertyHelper = new NodePropertyHelper(dictionaryService, qnameDAO, localeDAO, contentDataDAO);
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
// if not passed in (TODO or not in future cache) then generate a new query execution id
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurityInterceptor, method, parameters, queryExecutionId);
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
}
/**

View File

@@ -18,7 +18,6 @@
*/
package org.alfresco.repo.security.authority;
import java.lang.reflect.Method;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -57,11 +56,12 @@ public class GetAuthoritiesCannedQuery extends AbstractCannedQueryPermissions<Au
CannedQueryDAO cannedQueryDAO,
TenantService tenantService,
MethodSecurityInterceptor methodSecurityInterceptor,
Method method,
Object methodService,
String methodName,
CannedQueryParameters params,
String queryExecutionId)
{
super(params, queryExecutionId, methodSecurityInterceptor, method);
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
this.cannedQueryDAO = cannedQueryDAO;
this.tenantService = tenantService;

View File

@@ -100,26 +100,10 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
@Override
public CannedQuery<AuthorityInfo> getCannedQuery(CannedQueryParameters parameters)
{
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
// if not passed in (TODO or not in future cache) then generate a new query execution id
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
return (CannedQuery<AuthorityInfo>) new GetAuthoritiesCannedQuery(cannedQueryDAO, tenantService, methodSecurityInterceptor, method, parameters, queryExecutionId);
return (CannedQuery<AuthorityInfo>) new GetAuthoritiesCannedQuery(cannedQueryDAO, tenantService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
}
public CannedQuery<AuthorityInfo> getCannedQuery(AuthorityType type, NodeRef containerRef, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest)

View File

@@ -29,6 +29,7 @@ import net.sf.acegisecurity.context.Context;
import net.sf.acegisecurity.context.ContextHolder;
import net.sf.acegisecurity.context.security.SecureContext;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.query.AbstractCannedQuery;
import org.alfresco.query.CannedQueryParameters;
import org.alfresco.query.PagingResults;
@@ -51,10 +52,26 @@ public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQu
private MethodSecurityInterceptor methodSecurityInterceptor;
private Method method;
protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, String queryExecutionId, MethodSecurityInterceptor methodSecurityInterceptor, Method method)
protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, String queryExecutionId, MethodSecurityInterceptor methodSecurityInterceptor, Object methodService, String methodName)
{
super(parameters, queryExecutionId);
Method method = null;
for (Method m : methodService.getClass().getMethods())
{
// note: currently matches first found
if (m.getName().equals(methodName))
{
method = m;
break;
}
}
if (method == null)
{
throw new AlfrescoRuntimeException("Method not found: "+methodName);
}
this.methodSecurityInterceptor = methodSecurityInterceptor;
this.method = method;
}