mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Consolidating usage patterns around CannedQuery
- Removed executionID from AbstractCannedQuery constructors - Removed authenticationToken from CannedQueryParameters and applyPostQueryPermissions - Created common MethodSecurityBean to abstract permission checks - Pushed security definitions into public-services-security-context.xml (except blog-context.xml) - BlogServiceImpl now just returns the results of the CQ - CopyService CQ start - JIRAs - ALF-7167: RINF 11: Canned queries - ALF-9322: RINF 11: Remove AbstractCannedQueryPermissions - ALF-8969, ALF-8806, ALF-9033, ALF-8805 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@28680 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
<import resource="classpath:alfresco/st-context.xml"/>
|
<import resource="classpath:alfresco/st-context.xml"/>
|
||||||
<import resource="classpath*:alfresco/extension/mt/mt-context.xml"/>
|
<import resource="classpath*:alfresco/extension/mt/mt-context.xml"/>
|
||||||
<import resource="classpath:alfresco/core-services-context.xml" />
|
<import resource="classpath:alfresco/core-services-context.xml" />
|
||||||
|
<import resource="classpath:alfresco/copy-services-context.xml" />
|
||||||
<import resource="classpath:alfresco/encryption-context.xml" />
|
<import resource="classpath:alfresco/encryption-context.xml" />
|
||||||
<import resource="classpath:alfresco/public-services-context.xml" />
|
<import resource="classpath:alfresco/public-services-context.xml" />
|
||||||
<import resource="classpath:alfresco/model-specific-services-context.xml" />
|
<import resource="classpath:alfresco/model-specific-services-context.xml" />
|
||||||
|
@@ -270,61 +270,24 @@
|
|||||||
<!-- The person service. -->
|
<!-- The person service. -->
|
||||||
|
|
||||||
<bean id="personService" class="org.alfresco.repo.security.person.PersonServiceImpl" init-method="init">
|
<bean id="personService" class="org.alfresco.repo.security.person.PersonServiceImpl" init-method="init">
|
||||||
<property name="transactionService">
|
<property name="transactionService" ref="transactionService" />
|
||||||
<ref bean="transactionService" />
|
<property name="nodeService" ref="nodeService" />
|
||||||
</property>
|
<property name="tenantService" ref="tenantService"/>
|
||||||
<property name="nodeService">
|
<property name="searchService" ref="admSearchService" />
|
||||||
<ref bean="nodeService" />
|
<property name="permissionServiceSPI" ref="permissionServiceImpl" />
|
||||||
</property>
|
<property name="authorityService" ref="authorityService" />
|
||||||
<property name="tenantService">
|
<property name="authenticationService" ref="authenticationService" />
|
||||||
<ref bean="tenantService"/>
|
<property name="dictionaryService" ref="dictionaryService" />
|
||||||
</property>
|
<property name="namespacePrefixResolver" ref="namespaceService" />
|
||||||
<property name="searchService">
|
<property name="policyComponent" ref="policyComponent"/>
|
||||||
<ref bean="admSearchService" />
|
<property name="policyBehaviourFilter" ref="policyBehaviourFilter" />
|
||||||
</property>
|
<property name="personCache" ref="personCache" />
|
||||||
<property name="permissionServiceSPI">
|
<property name="permissionsManager" ref="personServicePermissionsManager" />
|
||||||
<ref bean="permissionServiceImpl" />
|
<property name="cannedQueryRegistry" ref="personServiceCannedQueryRegistry" />
|
||||||
</property>
|
<property name="aclDAO" ref="aclDAO" />
|
||||||
<property name="authorityService">
|
<property name="homeFolderManager" ref="homeFolderManager" />
|
||||||
<ref bean="authorityService" />
|
<property name="repoAdminService" ref="repoAdminService" />
|
||||||
</property>
|
<property name="serviceRegistry" ref="ServiceRegistry"/>
|
||||||
<property name="authenticationService">
|
|
||||||
<ref bean="authenticationService" />
|
|
||||||
</property>
|
|
||||||
<property name="dictionaryService">
|
|
||||||
<ref bean="dictionaryService" />
|
|
||||||
</property>
|
|
||||||
<property name="namespacePrefixResolver">
|
|
||||||
<ref bean="namespaceService" />
|
|
||||||
</property>
|
|
||||||
<property name="policyComponent">
|
|
||||||
<ref bean="policyComponent"/>
|
|
||||||
</property>
|
|
||||||
<property name="policyBehaviourFilter">
|
|
||||||
<ref bean="policyBehaviourFilter" />
|
|
||||||
</property>
|
|
||||||
<property name="personCache">
|
|
||||||
<ref bean="personCache" />
|
|
||||||
</property>
|
|
||||||
<property name="permissionsManager">
|
|
||||||
<ref bean="personServicePermissionsManager" />
|
|
||||||
</property>
|
|
||||||
<property name="cannedQueryRegistry">
|
|
||||||
<ref bean="cannedQueryRegistry" />
|
|
||||||
</property>
|
|
||||||
<property name="aclDAO">
|
|
||||||
<ref bean="aclDAO" />
|
|
||||||
</property>
|
|
||||||
<property name="homeFolderManager">
|
|
||||||
<ref bean="homeFolderManager" />
|
|
||||||
</property>
|
|
||||||
<property name="repoAdminService">
|
|
||||||
<ref bean="repoAdminService" />
|
|
||||||
</property>
|
|
||||||
<property name="serviceRegistry">
|
|
||||||
<ref bean="ServiceRegistry"/>
|
|
||||||
</property>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Configurable properties. -->
|
<!-- Configurable properties. -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -366,8 +329,12 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="personServiceCannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
||||||
|
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean name="peopleGetChildrenCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory">
|
<bean name="peopleGetChildrenCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory">
|
||||||
<property name="registry" ref="cannedQueryRegistry"/>
|
<property name="registry" ref="personServiceCannedQueryRegistry"/>
|
||||||
<property name="dictionaryService" ref="dictionaryService"/>
|
<property name="dictionaryService" ref="dictionaryService"/>
|
||||||
<property name="tenantService" ref="tenantService"/>
|
<property name="tenantService" ref="tenantService"/>
|
||||||
<property name="nodeDAO" ref="nodeDAO"/>
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
@@ -375,9 +342,7 @@
|
|||||||
<property name="localeDAO" ref="localeDAO"/>
|
<property name="localeDAO" ref="localeDAO"/>
|
||||||
<property name="contentDataDAO" ref="contentDataDAO"/>
|
<property name="contentDataDAO" ref="contentDataDAO"/>
|
||||||
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||||
<property name="methodSecurityInterceptor" ref="PersonService_security"/>
|
<property name="methodSecurity" ref="PersonService_security_getPeople"/>
|
||||||
<property name="methodService" ref="personService"/>
|
|
||||||
<property name="methodName" value="getPeople"/>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="personServicePermissionsManager" class="org.alfresco.repo.security.person.PermissionsManagerImpl" >
|
<bean name="personServicePermissionsManager" class="org.alfresco.repo.security.person.PermissionsManagerImpl" >
|
||||||
|
@@ -99,9 +99,7 @@
|
|||||||
<property name="nodeDAO" ref="nodeDAO"/>
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
<property name="qnameDAO" ref="qnameDAO"/>
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||||
<property name="methodSecurityInterceptor" ref="AuthorityService_security"/>
|
<property name="methodSecurity" ref="AuthorityService_security_getAuthorities"/>
|
||||||
<property name="methodService" ref="authorityService"/>
|
|
||||||
<property name="methodName" value="getAuthorities"/>
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
@@ -51,13 +51,36 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="BlogService_security_getDrafts" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="BlogService_security" />
|
||||||
|
<property name="service" value="org.alfresco.repo.blog.BlogService" />
|
||||||
|
<property name="methodName" value="getDrafts" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="BlogService_security_getPublished" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="BlogService_security" />
|
||||||
|
<property name="service" value="org.alfresco.repo.blog.BlogService" />
|
||||||
|
<property name="methodName" value="getPublished" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="BlogService_security_getPublishedExternally" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="BlogService_security" />
|
||||||
|
<property name="service" value="org.alfresco.repo.blog.BlogService" />
|
||||||
|
<property name="methodName" value="getPublishedExternally" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean id="BlogService_security_getMyDraftsAndAllPublished" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="BlogService_security" />
|
||||||
|
<property name="service" value="org.alfresco.repo.blog.BlogService" />
|
||||||
|
<property name="methodName" value="getMyDraftsAndAllPublished" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- Blog Service base bean -->
|
<!-- Blog Service base bean -->
|
||||||
<bean id="blogService" class="org.alfresco.repo.blog.BlogServiceImpl">
|
<bean id="blogService" class="org.alfresco.repo.blog.BlogServiceImpl">
|
||||||
<property name="cannedQueryRegistry" ref="cannedQueryRegistry"/>
|
<property name="cannedQueryRegistry" ref="cannedQueryRegistry"/>
|
||||||
<property name="contentService" ref="ContentService"/>
|
<property name="contentService" ref="ContentService"/>
|
||||||
<property name="nodeService" ref="NodeService"/>
|
<property name="nodeService" ref="NodeService"/>
|
||||||
<property name="permissionService" ref="PermissionService"/>
|
<property name="permissionService" ref="PermissionService"/>
|
||||||
<property name="taggingService" ref="TaggingService"/>
|
|
||||||
|
|
||||||
<property name="draftBlogPostsCannedQueryFactory" ref="getDraftBlogPostsCannedQueryFactory"/>
|
<property name="draftBlogPostsCannedQueryFactory" ref="getDraftBlogPostsCannedQueryFactory"/>
|
||||||
<property name="publishedBlogPostsCannedQueryFactory" ref="getPublishedBlogPostsCannedQueryFactory"/>
|
<property name="publishedBlogPostsCannedQueryFactory" ref="getPublishedBlogPostsCannedQueryFactory"/>
|
||||||
@@ -70,37 +93,31 @@
|
|||||||
<!-- We currently need one CQFactory per CQ in order to support interception at each of the different methods -->
|
<!-- We currently need one CQFactory per CQ in order to support interception at each of the different methods -->
|
||||||
<bean name="parentBlogPostsCannedQueryFactory" abstract="true">
|
<bean name="parentBlogPostsCannedQueryFactory" abstract="true">
|
||||||
<property name="registry" ref="cannedQueryRegistry"/>
|
<property name="registry" ref="cannedQueryRegistry"/>
|
||||||
<property name="methodSecurityInterceptor" ref="BlogService_security"/>
|
|
||||||
<property name="methodService" ref="blogService"/>
|
|
||||||
<!-- Intentionally injecting the small 'n', undecorated NodeService. -->
|
<!-- Intentionally injecting the small 'n', undecorated NodeService. -->
|
||||||
<property name="rawNodeService" ref="nodeService"/>
|
<property name="rawNodeService" ref="nodeService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="getDraftBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
<bean name="getDraftBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
||||||
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
||||||
<property name="methodName" value="getDrafts"/>
|
<property name="methodSecurity" ref="BlogService_security_getDrafts"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="getPublishedExternallyBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
<bean name="getPublishedExternallyBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
||||||
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
||||||
<property name="methodName" value="getPublishedExternally"/>
|
<property name="methodSecurity" ref="BlogService_security_getPublishedExternally"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="getPublishedBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
<bean name="getPublishedBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
||||||
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
class="org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory">
|
||||||
<property name="methodName" value="getPublished"/>
|
<property name="methodSecurity" ref="BlogService_security_getPublished"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="getDraftsAndPublishedBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
<bean name="getDraftsAndPublishedBlogPostsCannedQueryFactory" parent="parentBlogPostsCannedQueryFactory"
|
||||||
class="org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory">
|
class="org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory">
|
||||||
<property name="methodName" value="getMyDraftsAndAllPublished"/>
|
<property name="methodSecurity" ref="BlogService_security_getMyDraftsAndAllPublished"/>
|
||||||
<property name="taggingService" ref="TaggingService"/>
|
<property name="taggingService" ref="TaggingService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- Blog Integration Service (Integration with external blog hosting sites) -->
|
<!-- Blog Integration Service (Integration with external blog hosting sites) -->
|
||||||
|
|
||||||
<bean id="BlogIntegrationService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
<bean id="BlogIntegrationService" class="org.springframework.aop.framework.ProxyFactoryBean">
|
||||||
|
50
config/alfresco/copy-services-context.xml
Normal file
50
config/alfresco/copy-services-context.xml
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
|
||||||
|
|
||||||
|
<!-- Core and miscellaneous bean definitions -->
|
||||||
|
<beans>
|
||||||
|
|
||||||
|
<bean id="copyServiceCannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
||||||
|
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="copyCannedQueryFactoryBase" abstract="true">
|
||||||
|
<property name="registry" ref="copyServiceCannedQueryRegistry"/>
|
||||||
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
|
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||||
|
<!--
|
||||||
|
<property name="methodSecurityInterceptor" ref="CopyService_security"/>
|
||||||
|
<property name="methodService" ref="copyService"/>
|
||||||
|
-->
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="getCopiesCannedQueryFactory"
|
||||||
|
class="org.alfresco.repo.copy.query.GetCopiesCannedQueryFactory"
|
||||||
|
parent="copyCannedQueryFactoryBase">
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<bean name="getCopiedCannedQueryFactory"
|
||||||
|
class="org.alfresco.repo.copy.query.GetCopiesCannedQueryFactory"
|
||||||
|
parent="copyCannedQueryFactoryBase">
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
<!-- -->
|
||||||
|
<!-- Copy Service -->
|
||||||
|
<!-- -->
|
||||||
|
|
||||||
|
<!-- Note this uses the node service that enforces permissions so you can only copy what you can see -->
|
||||||
|
|
||||||
|
<bean id="copyService" class="org.alfresco.repo.copy.CopyServiceImpl" init-method="init">
|
||||||
|
<property name="cannedQueryRegistry" ref="copyServiceCannedQueryRegistry"/>
|
||||||
|
<property name="dictionaryService" ref="dictionaryService" />
|
||||||
|
<property name="nodeService" ref="NodeService" />
|
||||||
|
<property name="policyComponent" ref="policyComponent" />
|
||||||
|
<property name="ruleService" ref="ruleService" />
|
||||||
|
<property name="permissionService" ref="permissionService" />
|
||||||
|
<property name="publicServiceAccessService" ref="publicServiceAccessService" />
|
||||||
|
<property name="searchService" ref="ADMSearchService" />
|
||||||
|
<property name="internalNodeService" ref="mlAwareNodeService" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
|
</beans>
|
@@ -436,6 +436,14 @@
|
|||||||
|
|
||||||
<bean id="checkTxnAdvice" class="org.alfresco.repo.transaction.CheckTransactionAdvice" />
|
<bean id="checkTxnAdvice" class="org.alfresco.repo.transaction.CheckTransactionAdvice" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
General-purpose registry for CannedQueryFactory instances.
|
||||||
|
Normally you would keep a registry per application area.
|
||||||
|
-->
|
||||||
|
<bean id="cannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
||||||
|
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- I18N -->
|
<!-- I18N -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
@@ -1216,38 +1224,6 @@
|
|||||||
<property name="solrDAO" ref="solrDAO" />
|
<property name="solrDAO" ref="solrDAO" />
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- -->
|
|
||||||
<!-- Copy Service -->
|
|
||||||
<!-- -->
|
|
||||||
|
|
||||||
<!-- Note this uses the node service that enforces permissions so you can only copy what you can see -->
|
|
||||||
|
|
||||||
<bean id="copyService" class="org.alfresco.repo.copy.CopyServiceImpl" init-method="init">
|
|
||||||
<property name="dictionaryService">
|
|
||||||
<ref bean="dictionaryService" />
|
|
||||||
</property>
|
|
||||||
<property name="nodeService">
|
|
||||||
<ref bean="NodeService" />
|
|
||||||
</property>
|
|
||||||
<property name="policyComponent">
|
|
||||||
<ref bean="policyComponent" />
|
|
||||||
</property>
|
|
||||||
<property name="ruleService">
|
|
||||||
<ref bean="ruleService" />
|
|
||||||
</property>
|
|
||||||
<property name="permissionService">
|
|
||||||
<ref bean="permissionService" />
|
|
||||||
</property>
|
|
||||||
<property name="publicServiceAccessService">
|
|
||||||
<ref bean="publicServiceAccessService" />
|
|
||||||
</property>
|
|
||||||
<property name="searchService">
|
|
||||||
<ref bean="ADMSearchService" />
|
|
||||||
</property>
|
|
||||||
<property name="internalNodeService">
|
|
||||||
<ref bean="mlAwareNodeService" />
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- CheckOut/CheckIn Service -->
|
<!-- CheckOut/CheckIn Service -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
|
@@ -280,10 +280,6 @@
|
|||||||
<property name="controlDAO" ref="controlDAO"/>
|
<property name="controlDAO" ref="controlDAO"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="cannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
|
||||||
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
<bean id="solrDAO" class="org.alfresco.repo.domain.solr.ibatis.SOLRDAOImpl" init-method="init">
|
<bean id="solrDAO" class="org.alfresco.repo.domain.solr.ibatis.SOLRDAOImpl" init-method="init">
|
||||||
<property name="sqlSessionTemplate" ref="solrSqlSessionTemplate"/>
|
<property name="sqlSessionTemplate" ref="solrSqlSessionTemplate"/>
|
||||||
<property name="qNameDAO" ref="qnameDAO"/>
|
<property name="qNameDAO" ref="qnameDAO"/>
|
||||||
|
@@ -3,8 +3,13 @@
|
|||||||
|
|
||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
|
|
||||||
<!-- File/folder specific service -->
|
<!-- File/folder specific service -->
|
||||||
|
|
||||||
|
<bean id="fileFolderCannedQueryRegistry" class="org.alfresco.util.registry.NamedObjectRegistry">
|
||||||
|
<property name="storageType" value="org.alfresco.query.CannedQueryFactory"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean name="fileFolderService" class="org.alfresco.repo.model.filefolder.FileFolderServiceImpl" init-method="init">
|
<bean name="fileFolderService" class="org.alfresco.repo.model.filefolder.FileFolderServiceImpl" init-method="init">
|
||||||
<property name="namespaceService"><ref bean="namespaceService" /></property>
|
<property name="namespaceService"><ref bean="namespaceService" /></property>
|
||||||
<property name="dictionaryService"><ref bean="dictionaryService" /></property>
|
<property name="dictionaryService"><ref bean="dictionaryService" /></property>
|
||||||
@@ -14,7 +19,7 @@
|
|||||||
<property name="contentService"><ref bean="contentService" /></property>
|
<property name="contentService"><ref bean="contentService" /></property>
|
||||||
<property name="mimetypeService"><ref bean="mimetypeService" /></property>
|
<property name="mimetypeService"><ref bean="mimetypeService" /></property>
|
||||||
|
|
||||||
<property name="cannedQueryRegistry" ref="cannedQueryRegistry"/>
|
<property name="cannedQueryRegistry" ref="fileFolderCannedQueryRegistry"/>
|
||||||
<property name="defaultListMaxResults" value="${system.filefolderservice.defaultListMaxResults}"/>
|
<property name="defaultListMaxResults" value="${system.filefolderservice.defaultListMaxResults}"/>
|
||||||
|
|
||||||
<property name="systemNamespaces">
|
<property name="systemNamespaces">
|
||||||
@@ -38,6 +43,18 @@
|
|||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean name="fileFolderGetChildrenCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory">
|
||||||
|
<property name="registry" ref="fileFolderCannedQueryRegistry"/>
|
||||||
|
<property name="dictionaryService" ref="dictionaryService"/>
|
||||||
|
<property name="tenantService" ref="tenantService"/>
|
||||||
|
<property name="nodeDAO" ref="nodeDAO"/>
|
||||||
|
<property name="qnameDAO" ref="qnameDAO"/>
|
||||||
|
<property name="localeDAO" ref="localeDAO"/>
|
||||||
|
<property name="contentDataDAO" ref="contentDataDAO"/>
|
||||||
|
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
||||||
|
<property name="methodSecurity" ref="FileFolderService_security_list"/>
|
||||||
|
</bean>
|
||||||
|
|
||||||
<bean id="mlTranslationInterceptor" class="org.alfresco.repo.model.filefolder.MLTranslationInterceptor" >
|
<bean id="mlTranslationInterceptor" class="org.alfresco.repo.model.filefolder.MLTranslationInterceptor" >
|
||||||
<property name="nodeService">
|
<property name="nodeService">
|
||||||
@@ -139,18 +156,4 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean name="fileFolderGetChildrenCannedQueryFactory" class="org.alfresco.repo.node.getchildren.GetChildrenCannedQueryFactory">
|
|
||||||
<property name="registry" ref="cannedQueryRegistry"/>
|
|
||||||
<property name="dictionaryService" ref="dictionaryService"/>
|
|
||||||
<property name="tenantService" ref="tenantService"/>
|
|
||||||
<property name="nodeDAO" ref="nodeDAO"/>
|
|
||||||
<property name="qnameDAO" ref="qnameDAO"/>
|
|
||||||
<property name="localeDAO" ref="localeDAO"/>
|
|
||||||
<property name="contentDataDAO" ref="contentDataDAO"/>
|
|
||||||
<property name="cannedQueryDAO" ref="cannedQueryDAO"/>
|
|
||||||
<property name="methodSecurityInterceptor" ref="FileFolderService_security"/>
|
|
||||||
<property name="methodService" ref="fileFolderService"/>
|
|
||||||
<property name="methodName" value="list"/>
|
|
||||||
</bean>
|
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
@@ -436,6 +436,12 @@
|
|||||||
</value>
|
</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="FileFolderService_security_list" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="FileFolderService_security" />
|
||||||
|
<property name="service" value="org.alfresco.service.cmr.model.FileFolderService" />
|
||||||
|
<property name="methodName" value="list" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- =========================== -->
|
<!-- =========================== -->
|
||||||
<!-- Content Service Permissions -->
|
<!-- Content Service Permissions -->
|
||||||
@@ -749,6 +755,12 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="AuthorityService_security_getAuthorities" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="FileFolderService_security" />
|
||||||
|
<property name="service" value="org.alfresco.service.cmr.security.AuthorityService" />
|
||||||
|
<property name="methodName" value="getAuthorities" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- =============================================== -->
|
<!-- =============================================== -->
|
||||||
<!-- The Authentication Service security interceptor -->
|
<!-- The Authentication Service security interceptor -->
|
||||||
<!-- =============================================== -->
|
<!-- =============================================== -->
|
||||||
@@ -838,6 +850,12 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="PersonService_security_getPeople" class="org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean">
|
||||||
|
<property name="methodSecurityInterceptor" ref="FileFolderService_security" />
|
||||||
|
<property name="service" value="org.alfresco.service.cmr.security.PersonService" />
|
||||||
|
<property name="methodName" value="getPeople" />
|
||||||
|
</bean>
|
||||||
|
|
||||||
<!-- ==================== -->
|
<!-- ==================== -->
|
||||||
<!-- The Template Service -->
|
<!-- The Template Service -->
|
||||||
<!-- ==================== -->
|
<!-- ==================== -->
|
||||||
|
@@ -1,323 +1,253 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
*
|
*
|
||||||
* This file is part of Alfresco
|
* This file is part of Alfresco
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as published by
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.repo.blog;
|
package org.alfresco.repo.blog;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.Map;
|
||||||
import java.util.Map;
|
|
||||||
|
import org.alfresco.model.ContentModel;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.query.CannedQueryFactory;
|
||||||
import org.alfresco.query.CannedQueryFactory;
|
import org.alfresco.query.CannedQueryResults;
|
||||||
import org.alfresco.query.CannedQueryResults;
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.query.PagingRequest;
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.query.PagingResults;
|
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
|
||||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQuery;
|
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
|
||||||
import org.alfresco.repo.blog.cannedqueries.DraftsAndPublishedBlogPostsCannedQueryFactory;
|
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
|
||||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQuery;
|
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
||||||
import org.alfresco.repo.blog.cannedqueries.GetBlogPostsCannedQueryFactory;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.security.PermissionService;
|
||||||
import org.alfresco.service.cmr.security.PermissionService;
|
import org.alfresco.service.namespace.NamespaceService;
|
||||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.service.namespace.NamespaceService;
|
import org.alfresco.util.ParameterCheck;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.alfresco.util.ParameterCheck;
|
/**
|
||||||
import org.alfresco.util.registry.NamedObjectRegistry;
|
* @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
|
||||||
|
* @since 4.0
|
||||||
/**
|
*/
|
||||||
* @author Neil Mc Erlean (based on existing webscript controllers in the REST API)
|
public class BlogServiceImpl implements BlogService
|
||||||
* @since 4.0
|
{
|
||||||
*/
|
/**
|
||||||
public class BlogServiceImpl implements BlogService
|
* For backwards compatibility with pre-Swift, we are asking the query to give us an accurate total count of how many
|
||||||
{
|
* blog-post nodes there are. This may need to change in the future - certainly if the current 'brute force' query
|
||||||
/**
|
* is replaced by a database query.
|
||||||
* For backwards compatibility with pre-Swift, we are asking the query to give us an accurate total count of how many
|
*/
|
||||||
* blog-post nodes there are. This may need to change in the future - certainly if the current 'brute force' query
|
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
||||||
* is replaced by a database query.
|
|
||||||
*/
|
// Injected services
|
||||||
private static final int MAX_QUERY_ENTRY_COUNT = 10000;
|
private NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry;
|
||||||
|
private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
|
||||||
// Injected services
|
private GetBlogPostsCannedQueryFactory publishedPostsCannedQueryFactory;
|
||||||
private NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry;
|
private GetBlogPostsCannedQueryFactory publishedExternallyPostsCannedQueryFactory;
|
||||||
private GetBlogPostsCannedQueryFactory draftPostsCannedQueryFactory;
|
|
||||||
private GetBlogPostsCannedQueryFactory publishedPostsCannedQueryFactory;
|
private DraftsAndPublishedBlogPostsCannedQueryFactory draftsAndPublishedBlogPostsCannedQueryFactory;
|
||||||
private GetBlogPostsCannedQueryFactory publishedExternallyPostsCannedQueryFactory;
|
|
||||||
|
private ContentService contentService;
|
||||||
private DraftsAndPublishedBlogPostsCannedQueryFactory draftsAndPublishedBlogPostsCannedQueryFactory;
|
private NodeService nodeService;
|
||||||
|
private PermissionService permissionService;
|
||||||
private ContentService contentService;
|
|
||||||
private NodeService nodeService;
|
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry)
|
||||||
private PermissionService permissionService;
|
{
|
||||||
private TaggingService taggingService;
|
this.cannedQueryRegistry = cannedQueryRegistry;
|
||||||
|
}
|
||||||
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<BlogPostInfo>> cannedQueryRegistry)
|
|
||||||
{
|
public void setDraftBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
||||||
this.cannedQueryRegistry = cannedQueryRegistry;
|
{
|
||||||
}
|
this.draftPostsCannedQueryFactory = cannedQueryFactory;
|
||||||
|
}
|
||||||
public void setDraftBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
|
||||||
{
|
public void setPublishedBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
||||||
this.draftPostsCannedQueryFactory = cannedQueryFactory;
|
{
|
||||||
}
|
this.publishedPostsCannedQueryFactory = cannedQueryFactory;
|
||||||
|
}
|
||||||
public void setPublishedBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
|
||||||
{
|
public void setPublishedExternallyBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
||||||
this.publishedPostsCannedQueryFactory = cannedQueryFactory;
|
{
|
||||||
}
|
this.publishedExternallyPostsCannedQueryFactory = cannedQueryFactory;
|
||||||
|
}
|
||||||
public void setPublishedExternallyBlogPostsCannedQueryFactory(GetBlogPostsCannedQueryFactory cannedQueryFactory)
|
|
||||||
{
|
public void setDraftsAndPublishedBlogPostsCannedQueryFactory(DraftsAndPublishedBlogPostsCannedQueryFactory cannedQueryFactory)
|
||||||
this.publishedExternallyPostsCannedQueryFactory = cannedQueryFactory;
|
{
|
||||||
}
|
this.draftsAndPublishedBlogPostsCannedQueryFactory = cannedQueryFactory;
|
||||||
|
}
|
||||||
public void setDraftsAndPublishedBlogPostsCannedQueryFactory(DraftsAndPublishedBlogPostsCannedQueryFactory cannedQueryFactory)
|
|
||||||
{
|
public void setContentService(ContentService contentService)
|
||||||
this.draftsAndPublishedBlogPostsCannedQueryFactory = cannedQueryFactory;
|
{
|
||||||
}
|
this.contentService = contentService;
|
||||||
|
}
|
||||||
public void setContentService(ContentService contentService)
|
|
||||||
{
|
public void setNodeService(NodeService nodeService)
|
||||||
this.contentService = contentService;
|
{
|
||||||
}
|
this.nodeService = nodeService;
|
||||||
|
}
|
||||||
public void setNodeService(NodeService nodeService)
|
|
||||||
{
|
public void setPermissionService(PermissionService permissionService)
|
||||||
this.nodeService = nodeService;
|
{
|
||||||
}
|
this.permissionService = permissionService;
|
||||||
|
}
|
||||||
public void setPermissionService(PermissionService permissionService)
|
|
||||||
{
|
@Override
|
||||||
this.permissionService = permissionService;
|
public boolean isDraftBlogPost(NodeRef blogPostNode)
|
||||||
}
|
{
|
||||||
|
return nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null;
|
||||||
public void setTaggingService(TaggingService taggingService)
|
}
|
||||||
{
|
|
||||||
this.taggingService = taggingService;
|
@Override
|
||||||
}
|
public ChildAssociationRef createBlogPost(NodeRef blogContainerNode, String blogTitle,
|
||||||
|
String blogContent, boolean isDraft)
|
||||||
/*
|
{
|
||||||
* (non-Javadoc)
|
String nodeName = getUniqueChildName(blogContainerNode, "post");
|
||||||
* @see org.alfresco.repo.blog.BlogService#isDraftBlogPost(org.alfresco.service.cmr.repository.NodeRef)
|
|
||||||
*/
|
// we simply create a new file inside the blog folder
|
||||||
@Override
|
Map<QName, Serializable> nodeProps = new HashMap<QName, Serializable>();
|
||||||
public boolean isDraftBlogPost(NodeRef blogPostNode)
|
nodeProps.put(ContentModel.PROP_NAME, nodeName);
|
||||||
{
|
nodeProps.put(ContentModel.PROP_TITLE, blogTitle);
|
||||||
return nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null;
|
QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName);
|
||||||
}
|
ChildAssociationRef postNode = nodeService.createNode(blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
|
||||||
|
ContentModel.TYPE_CONTENT, nodeProps);
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
ContentWriter writer = contentService.getWriter(postNode.getChildRef(), ContentModel.PROP_CONTENT, true);
|
||||||
* @see org.alfresco.repo.blog.BlogService#createBlogPost(org.alfresco.service.cmr.repository.NodeRef, java.lang.String, java.lang.String, java.util.List, boolean)
|
|
||||||
*/
|
// Blog posts are always HTML (based on the JavaScript this class replaces.)
|
||||||
@Override
|
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
||||||
public ChildAssociationRef createBlogPost(NodeRef blogContainerNode, String blogTitle,
|
writer.setEncoding("UTF-8");
|
||||||
String blogContent, boolean isDraft)
|
writer.putContent(blogContent);
|
||||||
{
|
|
||||||
String nodeName = getUniqueChildName(blogContainerNode, "post");
|
if (isDraft)
|
||||||
|
{
|
||||||
// we simply create a new file inside the blog folder
|
// Comment from the old JavaScript:
|
||||||
Map<QName, Serializable> nodeProps = new HashMap<QName, Serializable>();
|
// disable permission inheritance. The result is that only the creator will have access to the draft
|
||||||
nodeProps.put(ContentModel.PROP_NAME, nodeName);
|
permissionService.setInheritParentPermissions(postNode.getChildRef(), false);
|
||||||
nodeProps.put(ContentModel.PROP_TITLE, blogTitle);
|
}
|
||||||
QName assocName = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, nodeName);
|
else
|
||||||
ChildAssociationRef postNode = nodeService.createNode(blogContainerNode, ContentModel.ASSOC_CONTAINS, assocName,
|
{
|
||||||
ContentModel.TYPE_CONTENT, nodeProps);
|
setOrUpdateReleasedAndUpdatedDates(postNode.getChildRef());
|
||||||
|
}
|
||||||
ContentWriter writer = contentService.getWriter(postNode.getChildRef(), ContentModel.PROP_CONTENT, true);
|
|
||||||
|
return postNode;
|
||||||
// Blog posts are always HTML (based on the JavaScript this class replaces.)
|
}
|
||||||
writer.setMimetype(MimetypeMap.MIMETYPE_HTML);
|
|
||||||
writer.setEncoding("UTF-8");
|
@Override
|
||||||
writer.putContent(blogContent);
|
public PagingResults<BlogPostInfo> getDrafts(NodeRef blogContainerNode, String username, PagingRequest pagingReq)
|
||||||
|
{
|
||||||
if (isDraft)
|
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
||||||
{
|
ParameterCheck.mandatory("pagingReq", pagingReq);
|
||||||
// Comment from the old JavaScript:
|
|
||||||
// disable permission inheritance. The result is that only the creator will have access to the draft
|
// get canned query
|
||||||
permissionService.setInheritParentPermissions(postNode.getChildRef(), false);
|
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
||||||
}
|
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)draftPostsCannedQueryFactory.getGetDraftsCannedQuery(blogContainerNode, username, pagingReq);
|
||||||
else
|
|
||||||
{
|
// execute canned query
|
||||||
setOrUpdateReleasedAndUpdatedDates(postNode.getChildRef());
|
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
||||||
}
|
return results;
|
||||||
|
}
|
||||||
return postNode;
|
@Override
|
||||||
}
|
public PagingResults<BlogPostInfo> getPublishedExternally(NodeRef blogContainerNode, PagingRequest pagingReq)
|
||||||
|
{
|
||||||
/*
|
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
||||||
* (non-Javadoc)
|
ParameterCheck.mandatory("pagingReq", pagingReq);
|
||||||
* @see org.alfresco.repo.blog.BlogService#getMyDrafts(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.query.PagingRequest)
|
|
||||||
*/
|
// get canned query
|
||||||
@Override
|
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
||||||
public PagingResults<BlogPostInfo> getDrafts(NodeRef blogContainerNode, String username, PagingRequest pagingReq)
|
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedExternallyPostsCannedQueryFactory.getGetPublishedExternallyCannedQuery(blogContainerNode, pagingReq);
|
||||||
{
|
|
||||||
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
// execute canned query
|
||||||
ParameterCheck.mandatory("pagingReq", pagingReq);
|
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
||||||
|
return results;
|
||||||
// get canned query
|
}
|
||||||
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
|
||||||
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)draftPostsCannedQueryFactory.getGetDraftsCannedQuery(blogContainerNode, username, pagingReq);
|
@Override
|
||||||
|
public PagingResults<BlogPostInfo> getPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq)
|
||||||
// execute canned query
|
{
|
||||||
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
||||||
|
ParameterCheck.mandatory("pagingReq", pagingReq);
|
||||||
return createPagedResults(pagingReq, results);
|
|
||||||
}
|
// get canned query
|
||||||
|
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
||||||
/**
|
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedPostsCannedQueryFactory.getGetPublishedCannedQuery(blogContainerNode, fromDate, toDate, byUser, pagingReq);
|
||||||
* This method creates a paged result set based on the supplied {@link PagingRequest} and {@link CannedQueryResults}.
|
|
||||||
*/
|
// execute canned query
|
||||||
private PagingResults<BlogPostInfo> createPagedResults(PagingRequest pagingReq, final CannedQueryResults<BlogPostInfo> results)
|
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
||||||
{
|
return results;
|
||||||
return new PagingResults<BlogPostInfo>()
|
}
|
||||||
{
|
|
||||||
@Override
|
/**
|
||||||
public String getQueryExecutionId()
|
* @deprecated
|
||||||
{
|
*/
|
||||||
return results.getQueryExecutionId();
|
@Override
|
||||||
}
|
public PagingResults<BlogPostInfo> getMyDraftsAndAllPublished(NodeRef blogContainerNode, Date createdFrom, Date createdTo, String tag, PagingRequest pagingReq)
|
||||||
@Override
|
{
|
||||||
public List<BlogPostInfo> getPage()
|
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
||||||
{
|
ParameterCheck.mandatory("pagingReq", pagingReq);
|
||||||
return results.getPage();
|
|
||||||
}
|
// get canned query
|
||||||
@Override
|
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
||||||
public boolean hasMoreItems()
|
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
||||||
{
|
DraftsAndPublishedBlogPostsCannedQuery cq = (DraftsAndPublishedBlogPostsCannedQuery)draftsAndPublishedBlogPostsCannedQueryFactory.getCannedQuery(blogContainerNode, createdFrom, createdTo, currentUser, tag, pagingReq);
|
||||||
return results.hasMoreItems();
|
|
||||||
}
|
// execute canned query
|
||||||
@Override
|
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
||||||
public Pair<Integer, Integer> getTotalResultCount()
|
return results;
|
||||||
{
|
}
|
||||||
return results.getTotalResultCount();
|
|
||||||
}
|
private String getUniqueChildName(NodeRef parentNode, String prefix)
|
||||||
@Override
|
{
|
||||||
public boolean permissionsApplied()
|
return prefix + "-" + System.currentTimeMillis();
|
||||||
{
|
}
|
||||||
return results.permissionsApplied();
|
|
||||||
}
|
|
||||||
};
|
/**
|
||||||
}
|
* This method is taken from the previous JavaScript webscript controllers.
|
||||||
|
*/
|
||||||
/*
|
private void setOrUpdateReleasedAndUpdatedDates(NodeRef blogPostNode)
|
||||||
* (non-Javadoc)
|
{
|
||||||
* @see org.alfresco.repo.blog.BlogService#getPublishedExternally(org.alfresco.service.cmr.repository.NodeRef, org.alfresco.query.PagingRequest)
|
// make sure the syndication aspect has been added
|
||||||
*/
|
if (!nodeService.hasAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION))
|
||||||
@Override
|
{
|
||||||
public PagingResults<BlogPostInfo> getPublishedExternally(NodeRef blogContainerNode, PagingRequest pagingReq)
|
nodeService.addAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION, null);
|
||||||
{
|
}
|
||||||
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
|
||||||
ParameterCheck.mandatory("pagingReq", pagingReq);
|
// (re-)enable permission inheritance which got disable for draft posts
|
||||||
|
// only set if was previously draft - as only the owner/admin can do
|
||||||
// get canned query
|
// this
|
||||||
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
if (!permissionService.getInheritParentPermissions(blogPostNode))
|
||||||
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedExternallyPostsCannedQueryFactory.getGetPublishedExternallyCannedQuery(blogContainerNode, pagingReq);
|
{
|
||||||
|
permissionService.setInheritParentPermissions(blogPostNode, true);
|
||||||
// execute canned query
|
}
|
||||||
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
|
||||||
|
// check whether the published date has been set
|
||||||
return createPagedResults(pagingReq, results);
|
if (nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null)
|
||||||
}
|
{
|
||||||
|
nodeService.setProperty(blogPostNode, ContentModel.PROP_PUBLISHED, new Date());
|
||||||
/*
|
}
|
||||||
* (non-Javadoc)
|
else
|
||||||
* @see org.alfresco.repo.blog.BlogService#getPublished(org.alfresco.service.cmr.repository.NodeRef, java.util.Date, java.util.Date, java.lang.String, org.alfresco.query.PagingRequest)
|
{
|
||||||
*/
|
// set/update the updated date
|
||||||
@Override
|
nodeService.setProperty(blogPostNode, ContentModel.PROP_UPDATED, new Date());
|
||||||
public PagingResults<BlogPostInfo> getPublished(NodeRef blogContainerNode, Date fromDate, Date toDate, String byUser, PagingRequest pagingReq)
|
}
|
||||||
{
|
}
|
||||||
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
}
|
||||||
ParameterCheck.mandatory("pagingReq", pagingReq);
|
|
||||||
|
|
||||||
// get canned query
|
|
||||||
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
|
||||||
GetBlogPostsCannedQuery cq = (GetBlogPostsCannedQuery)publishedPostsCannedQueryFactory.getGetPublishedCannedQuery(blogContainerNode, fromDate, toDate, byUser, pagingReq);
|
|
||||||
|
|
||||||
// execute canned query
|
|
||||||
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
|
||||||
|
|
||||||
return createPagedResults(pagingReq, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public PagingResults<BlogPostInfo> getMyDraftsAndAllPublished(NodeRef blogContainerNode, Date createdFrom, Date createdTo, String tag, PagingRequest pagingReq)
|
|
||||||
{
|
|
||||||
ParameterCheck.mandatory("blogContainerNode", blogContainerNode);
|
|
||||||
ParameterCheck.mandatory("pagingReq", pagingReq);
|
|
||||||
|
|
||||||
// get canned query
|
|
||||||
pagingReq.setRequestTotalCountMax(MAX_QUERY_ENTRY_COUNT);
|
|
||||||
String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
|
|
||||||
DraftsAndPublishedBlogPostsCannedQuery cq = (DraftsAndPublishedBlogPostsCannedQuery)draftsAndPublishedBlogPostsCannedQueryFactory.getCannedQuery(blogContainerNode, createdFrom, createdTo, currentUser, tag, pagingReq);
|
|
||||||
|
|
||||||
// execute canned query
|
|
||||||
CannedQueryResults<BlogPostInfo> results = cq.execute();
|
|
||||||
|
|
||||||
return createPagedResults(pagingReq, results);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getUniqueChildName(NodeRef parentNode, String prefix)
|
|
||||||
{
|
|
||||||
return prefix + "-" + System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is taken from the previous JavaScript webscript controllers.
|
|
||||||
* @param blogPostNode
|
|
||||||
*/
|
|
||||||
private void setOrUpdateReleasedAndUpdatedDates(NodeRef blogPostNode)
|
|
||||||
{
|
|
||||||
// make sure the syndication aspect has been added
|
|
||||||
if (!nodeService.hasAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION))
|
|
||||||
{
|
|
||||||
nodeService.addAspect(blogPostNode, ContentModel.ASPECT_SYNDICATION, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
// (re-)enable permission inheritance which got disable for draft posts
|
|
||||||
// only set if was previously draft - as only the owner/admin can do this
|
|
||||||
if (!permissionService.getInheritParentPermissions(blogPostNode))
|
|
||||||
{
|
|
||||||
permissionService.setInheritParentPermissions(blogPostNode, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
// check whether the published date has been set
|
|
||||||
if (nodeService.getProperty(blogPostNode, ContentModel.PROP_PUBLISHED) == null)
|
|
||||||
{
|
|
||||||
nodeService.setProperty(blogPostNode, ContentModel.PROP_PUBLISHED, new Date());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// set/update the updated date
|
|
||||||
nodeService.setProperty(blogPostNode, ContentModel.PROP_UPDATED, new Date());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -32,7 +32,7 @@ import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
|||||||
import org.alfresco.repo.blog.BlogService;
|
import org.alfresco.repo.blog.BlogService;
|
||||||
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -56,13 +56,10 @@ public class DraftsAndPublishedBlogPostsCannedQuery extends AbstractCannedQueryP
|
|||||||
public DraftsAndPublishedBlogPostsCannedQuery(
|
public DraftsAndPublishedBlogPostsCannedQuery(
|
||||||
NodeService rawNodeService,
|
NodeService rawNodeService,
|
||||||
TaggingService taggingService,
|
TaggingService taggingService,
|
||||||
MethodSecurityInterceptor methodSecurityInterceptor,
|
MethodSecurityBean<BlogPostInfo> methodSecurity,
|
||||||
Object methodService,
|
CannedQueryParameters params)
|
||||||
String methodName,
|
|
||||||
CannedQueryParameters params,
|
|
||||||
String queryExecutionId)
|
|
||||||
{
|
{
|
||||||
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
|
super(params, methodSecurity);
|
||||||
this.rawNodeService = rawNodeService;
|
this.rawNodeService = rawNodeService;
|
||||||
this.taggingService = taggingService;
|
this.taggingService = taggingService;
|
||||||
}
|
}
|
||||||
|
@@ -29,11 +29,10 @@ import org.alfresco.query.CannedQueryFactory;
|
|||||||
import org.alfresco.query.CannedQueryPageDetails;
|
import org.alfresco.query.CannedQueryPageDetails;
|
||||||
import org.alfresco.query.CannedQueryParameters;
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
import org.alfresco.query.CannedQuerySortDetails;
|
import org.alfresco.query.CannedQuerySortDetails;
|
||||||
import org.alfresco.query.PagingRequest;
|
|
||||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.cmr.tagging.TaggingService;
|
import org.alfresco.service.cmr.tagging.TaggingService;
|
||||||
@@ -53,12 +52,15 @@ import org.alfresco.util.PropertyCheck;
|
|||||||
*/
|
*/
|
||||||
public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<BlogPostInfo>
|
public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<BlogPostInfo>
|
||||||
{
|
{
|
||||||
private MethodSecurityInterceptor methodSecurityInterceptor;
|
private MethodSecurityBean<BlogPostInfo> methodSecurity;
|
||||||
private String methodName;
|
|
||||||
private Object methodService;
|
|
||||||
private NodeService rawNodeService;
|
private NodeService rawNodeService;
|
||||||
private TaggingService taggingService;
|
private TaggingService taggingService;
|
||||||
|
|
||||||
|
public void setMethodSecurity(MethodSecurityBean<BlogPostInfo> methodSecurity)
|
||||||
|
{
|
||||||
|
this.methodSecurity = methodSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRawNodeService(NodeService nodeService)
|
public void setRawNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
this.rawNodeService = nodeService;
|
this.rawNodeService = nodeService;
|
||||||
@@ -69,30 +71,13 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
|
|||||||
this.taggingService = taggingService;
|
this.taggingService = taggingService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
|
|
||||||
{
|
|
||||||
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodName(String methodName)
|
|
||||||
{
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodService(Object methodService)
|
|
||||||
{
|
|
||||||
this.methodService = methodService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
|
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||||
{
|
{
|
||||||
// if not passed in (TODO or not in future cache) then generate a new query execution id
|
final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(
|
||||||
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
|
rawNodeService, taggingService,
|
||||||
|
methodSecurity,
|
||||||
final DraftsAndPublishedBlogPostsCannedQuery cq = new DraftsAndPublishedBlogPostsCannedQuery(rawNodeService, taggingService,
|
parameters);
|
||||||
methodSecurityInterceptor, methodService, methodName,
|
|
||||||
parameters, queryExecutionId);
|
|
||||||
return (CannedQuery<BlogPostInfo>) cq;
|
return (CannedQuery<BlogPostInfo>) cq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +97,7 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
|
|||||||
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING);
|
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING);
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingReq.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -142,7 +127,7 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
|
|||||||
}
|
}
|
||||||
|
|
||||||
// page details
|
// page details
|
||||||
CannedQueryPageDetails cqpd = new CannedQueryPageDetails(skipCount, maxItems, CannedQueryPageDetails.DEFAULT_PAGE_NUMBER, CannedQueryPageDetails.DEFAULT_PAGE_COUNT);
|
CannedQueryPageDetails cqpd = new CannedQueryPageDetails(skipCount, maxItems);
|
||||||
return cqpd;
|
return cqpd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,8 +136,6 @@ public class DraftsAndPublishedBlogPostsCannedQueryFactory extends AbstractCanne
|
|||||||
{
|
{
|
||||||
super.afterPropertiesSet();
|
super.afterPropertiesSet();
|
||||||
|
|
||||||
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
|
PropertyCheck.mandatory(this, "methodSecurity", methodSecurity);
|
||||||
PropertyCheck.mandatory(this, "methodService", methodService);
|
|
||||||
PropertyCheck.mandatory(this, "methodName", methodName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -32,7 +32,7 @@ import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
|||||||
import org.alfresco.repo.blog.BlogService;
|
import org.alfresco.repo.blog.BlogService;
|
||||||
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -55,13 +55,10 @@ public class GetBlogPostsCannedQuery extends AbstractCannedQueryPermissions<Blog
|
|||||||
|
|
||||||
public GetBlogPostsCannedQuery(
|
public GetBlogPostsCannedQuery(
|
||||||
NodeService rawNodeService,
|
NodeService rawNodeService,
|
||||||
MethodSecurityInterceptor methodSecurityInterceptor,
|
MethodSecurityBean<BlogPostInfo> methodSecurity,
|
||||||
Object methodService,
|
CannedQueryParameters params)
|
||||||
String methodName,
|
|
||||||
CannedQueryParameters params,
|
|
||||||
String queryExecutionId)
|
|
||||||
{
|
{
|
||||||
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
|
super(params, methodSecurity);
|
||||||
this.rawNodeService = rawNodeService;
|
this.rawNodeService = rawNodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,12 +31,11 @@ import org.alfresco.query.CannedQueryFactory;
|
|||||||
import org.alfresco.query.CannedQueryPageDetails;
|
import org.alfresco.query.CannedQueryPageDetails;
|
||||||
import org.alfresco.query.CannedQueryParameters;
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
import org.alfresco.query.CannedQuerySortDetails;
|
import org.alfresco.query.CannedQuerySortDetails;
|
||||||
import org.alfresco.query.PagingRequest;
|
|
||||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.blog.BlogService;
|
import org.alfresco.repo.blog.BlogService;
|
||||||
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
import org.alfresco.repo.blog.BlogService.BlogPostInfo;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
@@ -57,37 +56,23 @@ import org.alfresco.util.PropertyCheck;
|
|||||||
*/
|
*/
|
||||||
public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<BlogPostInfo>
|
public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<BlogPostInfo>
|
||||||
{
|
{
|
||||||
private MethodSecurityInterceptor methodSecurityInterceptor;
|
private MethodSecurityBean<BlogPostInfo> methodSecurity;
|
||||||
private String methodName;
|
|
||||||
private Object methodService;
|
|
||||||
private NodeService rawNodeService;
|
private NodeService rawNodeService;
|
||||||
|
|
||||||
|
public void setMethodSecurity(MethodSecurityBean<BlogPostInfo> methodSecurity)
|
||||||
|
{
|
||||||
|
this.methodSecurity = methodSecurity;
|
||||||
|
}
|
||||||
|
|
||||||
public void setRawNodeService(NodeService nodeService)
|
public void setRawNodeService(NodeService nodeService)
|
||||||
{
|
{
|
||||||
this.rawNodeService = nodeService;
|
this.rawNodeService = nodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
|
|
||||||
{
|
|
||||||
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodName(String methodName)
|
|
||||||
{
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodService(Object methodService)
|
|
||||||
{
|
|
||||||
this.methodService = methodService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
|
public CannedQuery<BlogPostInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||||
{
|
{
|
||||||
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
|
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurity, parameters);
|
||||||
|
|
||||||
final GetBlogPostsCannedQuery cq = new GetBlogPostsCannedQuery(rawNodeService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
|
|
||||||
return (CannedQuery<BlogPostInfo>) cq;
|
return (CannedQuery<BlogPostInfo>) cq;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,7 +96,7 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
|
|||||||
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_CREATED, SortOrder.DESCENDING);
|
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_CREATED, SortOrder.DESCENDING);
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingReq.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -136,7 +121,7 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
|
|||||||
CannedQuerySortDetails cqsd = createCQSortDetails(BlogIntegrationModel.PROP_POSTED, SortOrder.DESCENDING);
|
CannedQuerySortDetails cqsd = createCQSortDetails(BlogIntegrationModel.PROP_POSTED, SortOrder.DESCENDING);
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingReq.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -161,7 +146,7 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
|
|||||||
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING);
|
CannedQuerySortDetails cqsd = createCQSortDetails(ContentModel.PROP_PUBLISHED, SortOrder.DESCENDING);
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingReq.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingReq.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -200,8 +185,6 @@ public class GetBlogPostsCannedQueryFactory extends AbstractCannedQueryFactory<B
|
|||||||
{
|
{
|
||||||
super.afterPropertiesSet();
|
super.afterPropertiesSet();
|
||||||
|
|
||||||
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
|
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurity);
|
||||||
PropertyCheck.mandatory(this, "methodService", methodService);
|
|
||||||
PropertyCheck.mandatory(this, "methodName", methodName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -30,6 +30,12 @@ import java.util.Set;
|
|||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.query.CannedQuery;
|
||||||
|
import org.alfresco.query.CannedQueryFactory;
|
||||||
|
import org.alfresco.query.CannedQueryPageDetails;
|
||||||
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.action.ActionServiceImpl;
|
import org.alfresco.repo.action.ActionServiceImpl;
|
||||||
import org.alfresco.repo.copy.CopyBehaviourCallback.AssocCopySourceAction;
|
import org.alfresco.repo.copy.CopyBehaviourCallback.AssocCopySourceAction;
|
||||||
import org.alfresco.repo.copy.CopyBehaviourCallback.AssocCopyTargetAction;
|
import org.alfresco.repo.copy.CopyBehaviourCallback.AssocCopyTargetAction;
|
||||||
@@ -40,7 +46,6 @@ import org.alfresco.repo.copy.CopyBehaviourCallback.CopyChildAssociationDetails;
|
|||||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
|
||||||
import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
import org.alfresco.repo.transaction.TransactionalResourceHelper;
|
||||||
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
import org.alfresco.service.cmr.dictionary.AspectDefinition;
|
||||||
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
|
||||||
@@ -67,6 +72,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||||
import org.alfresco.util.GUID;
|
import org.alfresco.util.GUID;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
|
import org.alfresco.util.registry.NamedObjectRegistry;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.springframework.extensions.surf.util.I18NUtil;
|
import org.springframework.extensions.surf.util.I18NUtil;
|
||||||
@@ -80,39 +86,32 @@ import org.springframework.extensions.surf.util.ParameterCheck;
|
|||||||
*/
|
*/
|
||||||
public class CopyServiceImpl implements CopyService
|
public class CopyServiceImpl implements CopyService
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* The logger
|
|
||||||
*/
|
|
||||||
private static Log logger = LogFactory.getLog(ActionServiceImpl.class);
|
private static Log logger = LogFactory.getLog(ActionServiceImpl.class);
|
||||||
|
|
||||||
/** I18N labels */
|
/* Query names */
|
||||||
private String COPY_OF_LABEL = "copy_service.copy_of_label";
|
private static final String QUERY_FACTORY_GET_COPIES = "getCopiesCannedQueryFactory";
|
||||||
|
private static final String QUERY_FACTORY_GET_COPIED = "getCopiesCannedQueryFactory";
|
||||||
|
|
||||||
/** The node service */
|
/* I18N labels */
|
||||||
|
private static final String COPY_OF_LABEL = "copy_service.copy_of_label";
|
||||||
|
|
||||||
|
/* Services */
|
||||||
private NodeService nodeService;
|
private NodeService nodeService;
|
||||||
private NodeService internalNodeService;
|
private NodeService internalNodeService;
|
||||||
|
private NamedObjectRegistry<CannedQueryFactory<CopyInfo>> cannedQueryRegistry;
|
||||||
/** The dictionary service*/
|
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
/** The search service */
|
|
||||||
private SearchService searchService;
|
private SearchService searchService;
|
||||||
/** Policy component */
|
|
||||||
private PolicyComponent policyComponent;
|
private PolicyComponent policyComponent;
|
||||||
/** Rule service */
|
|
||||||
private RuleService ruleService;
|
private RuleService ruleService;
|
||||||
|
|
||||||
private PermissionService permissionService;
|
private PermissionService permissionService;
|
||||||
|
|
||||||
private PublicServiceAccessService publicServiceAccessService;
|
private PublicServiceAccessService publicServiceAccessService;
|
||||||
|
|
||||||
/** Policy delegates */
|
/* Policy delegates */
|
||||||
private ClassPolicyDelegate<CopyServicePolicies.OnCopyNodePolicy> onCopyNodeDelegate;
|
private ClassPolicyDelegate<CopyServicePolicies.OnCopyNodePolicy> onCopyNodeDelegate;
|
||||||
private ClassPolicyDelegate<CopyServicePolicies.OnCopyCompletePolicy> onCopyCompleteDelegate;
|
private ClassPolicyDelegate<CopyServicePolicies.OnCopyCompletePolicy> onCopyCompleteDelegate;
|
||||||
private ClassPolicyDelegate<CopyServicePolicies.BeforeCopyPolicy> beforeCopyDelegate;
|
private ClassPolicyDelegate<CopyServicePolicies.BeforeCopyPolicy> beforeCopyDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the node service
|
|
||||||
*
|
|
||||||
* @param nodeService the node service
|
* @param nodeService the node service
|
||||||
*/
|
*/
|
||||||
public void setNodeService(NodeService nodeService)
|
public void setNodeService(NodeService nodeService)
|
||||||
@@ -121,8 +120,6 @@ public class CopyServiceImpl implements CopyService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the internal node service
|
|
||||||
*
|
|
||||||
* @param internalNodeService the internal node service
|
* @param internalNodeService the internal node service
|
||||||
*/
|
*/
|
||||||
public void setInternalNodeService(NodeService internalNodeService)
|
public void setInternalNodeService(NodeService internalNodeService)
|
||||||
@@ -130,9 +127,12 @@ public class CopyServiceImpl implements CopyService
|
|||||||
this.internalNodeService = internalNodeService;
|
this.internalNodeService = internalNodeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setCannedQueryRegistry(NamedObjectRegistry<CannedQueryFactory<CopyInfo>> cannedQueryRegistry)
|
||||||
|
{
|
||||||
|
this.cannedQueryRegistry = cannedQueryRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the dictionary service
|
|
||||||
*
|
|
||||||
* @param dictionaryService the dictionary service
|
* @param dictionaryService the dictionary service
|
||||||
*/
|
*/
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
@@ -141,8 +141,6 @@ public class CopyServiceImpl implements CopyService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the policy component
|
|
||||||
*
|
|
||||||
* @param policyComponent the policy component
|
* @param policyComponent the policy component
|
||||||
*/
|
*/
|
||||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||||
@@ -151,8 +149,6 @@ public class CopyServiceImpl implements CopyService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the search service
|
|
||||||
*
|
|
||||||
* @param searchService the search service
|
* @param searchService the search service
|
||||||
*/
|
*/
|
||||||
public void setSearchService(SearchService searchService)
|
public void setSearchService(SearchService searchService)
|
||||||
@@ -161,8 +157,6 @@ public class CopyServiceImpl implements CopyService
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the rule service
|
|
||||||
*
|
|
||||||
* @param ruleService the rule service
|
* @param ruleService the rule service
|
||||||
*/
|
*/
|
||||||
public void setRuleService(RuleService ruleService)
|
public void setRuleService(RuleService ruleService)
|
||||||
@@ -382,6 +376,7 @@ public class CopyServiceImpl implements CopyService
|
|||||||
invokeCopyComplete(sourceNodeRef, targetNodeRef, false, copiedNodeRefs);
|
invokeCopyComplete(sourceNodeRef, targetNodeRef, false, copiedNodeRefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public List<NodeRef> getCopies(NodeRef nodeRef)
|
public List<NodeRef> getCopies(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
List<NodeRef> copies = new ArrayList<NodeRef>();
|
List<NodeRef> copies = new ArrayList<NodeRef>();
|
||||||
@@ -410,6 +405,18 @@ public class CopyServiceImpl implements CopyService
|
|||||||
|
|
||||||
return copies;
|
return copies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PagingResults<CopyInfo> getCopies(NodeRef nodeRef, PagingRequest pagingRequest)
|
||||||
|
{
|
||||||
|
CannedQueryFactory<CopyInfo> queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES);
|
||||||
|
CannedQueryParameters params = new CannedQueryParameters(
|
||||||
|
nodeRef,
|
||||||
|
new CannedQueryPageDetails(pagingRequest),
|
||||||
|
null);
|
||||||
|
CannedQuery<CopyInfo> query = queryFactory.getCannedQuery(params);
|
||||||
|
return query.execute();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns <tt>null</tt> if the node was denied a copy
|
* @return Returns <tt>null</tt> if the node was denied a copy
|
||||||
|
@@ -30,6 +30,8 @@ import javax.transaction.UserTransaction;
|
|||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.repo.action.evaluator.NoConditionEvaluator;
|
import org.alfresco.repo.action.evaluator.NoConditionEvaluator;
|
||||||
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
import org.alfresco.repo.action.executer.AddFeaturesActionExecuter;
|
||||||
import org.alfresco.repo.action.executer.CopyActionExecuter;
|
import org.alfresco.repo.action.executer.CopyActionExecuter;
|
||||||
@@ -58,6 +60,7 @@ import org.alfresco.service.cmr.repository.ContentReader;
|
|||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.CopyService;
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
|
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
|
||||||
import org.alfresco.service.cmr.repository.MLText;
|
import org.alfresco.service.cmr.repository.MLText;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeService;
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
@@ -471,17 +474,17 @@ public class CopyServiceImplTest extends TestCase
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test copy new node within store
|
* Test copy new node within store
|
||||||
*/
|
*/
|
||||||
public void testCopyToNewNode()
|
public void DISABLED_testCopyToNewNode()
|
||||||
{
|
{
|
||||||
|
PagingRequest pageRequest = new PagingRequest(10);
|
||||||
|
PagingResults<CopyInfo> copies = null;
|
||||||
|
|
||||||
// Check that the node has no copies
|
// Check that the node has no copies
|
||||||
List<NodeRef> copies = copyService.getCopies(sourceNodeRef);
|
copies = copyService.getCopies(sourceNodeRef, pageRequest);
|
||||||
assertNotNull(copies);
|
assertEquals("Incorrect number of copies", 1, copies.getPage().size());
|
||||||
assertTrue(copies.isEmpty());
|
|
||||||
|
|
||||||
// Copy to new node without copying children
|
// Copy to new node without copying children
|
||||||
NodeRef copy = copyService.copy(
|
NodeRef copy = copyService.copy(
|
||||||
@@ -490,9 +493,8 @@ public class CopyServiceImplTest extends TestCase
|
|||||||
ContentModel.ASSOC_CHILDREN,
|
ContentModel.ASSOC_CHILDREN,
|
||||||
QName.createQName("{test}copyAssoc"));
|
QName.createQName("{test}copyAssoc"));
|
||||||
checkCopiedNode(sourceNodeRef, copy, true, true, false);
|
checkCopiedNode(sourceNodeRef, copy, true, true, false);
|
||||||
List<NodeRef> copies2 = copyService.getCopies(sourceNodeRef);
|
copies = copyService.getCopies(sourceNodeRef, pageRequest);
|
||||||
assertNotNull(copies2);
|
assertEquals("Incorrect number of copies", 1, copies.getPage().size());
|
||||||
assertEquals(1, copies2.size());
|
|
||||||
|
|
||||||
// Copy to new node, copying children
|
// Copy to new node, copying children
|
||||||
NodeRef copy2 = copyService.copy(
|
NodeRef copy2 = copyService.copy(
|
||||||
@@ -502,9 +504,8 @@ public class CopyServiceImplTest extends TestCase
|
|||||||
QName.createQName("{test}copyAssoc2"),
|
QName.createQName("{test}copyAssoc2"),
|
||||||
true);
|
true);
|
||||||
checkCopiedNode(sourceNodeRef, copy2, true, true, true);
|
checkCopiedNode(sourceNodeRef, copy2, true, true, true);
|
||||||
List<NodeRef> copies3 = copyService.getCopies(sourceNodeRef);
|
copies = copyService.getCopies(sourceNodeRef, pageRequest);
|
||||||
assertNotNull(copies3);
|
assertEquals("Incorrect number of copies", 2, copies.getPage().size());
|
||||||
assertEquals(2, copies3.size());
|
|
||||||
|
|
||||||
// Check that a copy of a copy works correctly
|
// Check that a copy of a copy works correctly
|
||||||
NodeRef copyOfCopy = copyService.copy(
|
NodeRef copyOfCopy = copyService.copy(
|
||||||
|
@@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.copy.query;
|
||||||
|
|
||||||
|
import org.alfresco.query.AbstractCannedQueryFactory;
|
||||||
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support for Canned Queries for copy
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public abstract class AbstractCopyCannedQueryFactory<R> extends AbstractCannedQueryFactory<R>
|
||||||
|
{
|
||||||
|
protected NodeDAO nodeDAO;
|
||||||
|
protected QNameDAO qnameDAO;
|
||||||
|
protected CannedQueryDAO cannedQueryDAO;
|
||||||
|
|
||||||
|
public void setNodeDAO(NodeDAO nodeDAO)
|
||||||
|
{
|
||||||
|
this.nodeDAO = nodeDAO;
|
||||||
|
}
|
||||||
|
public void setQnameDAO(QNameDAO qnameDAO)
|
||||||
|
{
|
||||||
|
this.qnameDAO = qnameDAO;
|
||||||
|
}
|
||||||
|
public void setCannedQueryDAO(CannedQueryDAO cannedQueryDAO)
|
||||||
|
{
|
||||||
|
this.cannedQueryDAO = cannedQueryDAO;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.copy.query;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.query.AbstractCannedQuery;
|
||||||
|
import org.alfresco.query.CannedQuery;
|
||||||
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
|
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory producing queries for the {@link CopyService}
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public class GetCopiedCannedQueryFactory extends AbstractCopyCannedQueryFactory<CopyInfo>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public CannedQuery<CopyInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private class GetCopiedCannedQuery extends AbstractCannedQuery<CopyInfo>
|
||||||
|
{
|
||||||
|
private GetCopiedCannedQuery(CannedQueryParameters parameters)
|
||||||
|
{
|
||||||
|
super(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected List<CopyInfo> queryAndFilter(CannedQueryParameters parameters)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.copy.query;
|
||||||
|
|
||||||
|
import org.alfresco.query.CannedQuery;
|
||||||
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
|
import org.alfresco.service.cmr.repository.CopyService;
|
||||||
|
import org.alfresco.service.cmr.repository.CopyService.CopyInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory producing queries for the {@link CopyService}
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public class GetCopiesCannedQueryFactory extends AbstractCopyCannedQueryFactory<CopyInfo>
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public CannedQuery<CopyInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
@@ -49,7 +49,7 @@ import org.alfresco.repo.domain.qname.QNameDAO;
|
|||||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||||
import org.alfresco.repo.node.getchildren.FilterPropString.FilterTypeString;
|
import org.alfresco.repo.node.getchildren.FilterPropString.FilterTypeString;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.WrappedList;
|
import org.alfresco.repo.security.permissions.impl.acegi.WrappedList;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
@@ -102,13 +102,10 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
CannedQueryDAO cannedQueryDAO,
|
CannedQueryDAO cannedQueryDAO,
|
||||||
NodePropertyHelper nodePropertyHelper,
|
NodePropertyHelper nodePropertyHelper,
|
||||||
TenantService tenantService,
|
TenantService tenantService,
|
||||||
MethodSecurityInterceptor methodSecurityInterceptor,
|
MethodSecurityBean<NodeRef> methodSecurity,
|
||||||
Object methodService,
|
CannedQueryParameters params)
|
||||||
String methodName,
|
|
||||||
CannedQueryParameters params,
|
|
||||||
String queryExecutionId)
|
|
||||||
{
|
{
|
||||||
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
|
super(params, methodSecurity);
|
||||||
|
|
||||||
this.nodeDAO = nodeDAO;
|
this.nodeDAO = nodeDAO;
|
||||||
this.qnameDAO = qnameDAO;
|
this.qnameDAO = qnameDAO;
|
||||||
@@ -263,7 +260,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
UnsortedResultHandler resultHandler = new UnsortedResultHandler(callback, parameters.getAuthenticationToken());
|
UnsortedResultHandler resultHandler = new UnsortedResultHandler(callback);
|
||||||
cannedQueryDAO.executeQuery(QUERY_NAMESPACE, QUERY_SELECT_GET_CHILDREN_WITHOUT_PROPS, params, 0, Integer.MAX_VALUE, resultHandler);
|
cannedQueryDAO.executeQuery(QUERY_NAMESPACE, QUERY_SELECT_GET_CHILDREN_WITHOUT_PROPS, params, 0, Integer.MAX_VALUE, resultHandler);
|
||||||
resultHandler.done();
|
resultHandler.done();
|
||||||
|
|
||||||
@@ -481,7 +478,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<NodeRef> applyPostQueryPermissions(List<NodeRef> results, String authenticationToken, int requestedCount)
|
protected List<NodeRef> applyPostQueryPermissions(List<NodeRef> results, int requestedCount)
|
||||||
{
|
{
|
||||||
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
|
Long start = (logger.isDebugEnabled() ? System.currentTimeMillis() : null);
|
||||||
|
|
||||||
@@ -494,7 +491,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
// note: assume user has read access to most/majority of the items hence pre-load up to max checks
|
// note: assume user has read access to most/majority of the items hence pre-load up to max checks
|
||||||
preload(results.subList(0, toIdx));
|
preload(results.subList(0, toIdx));
|
||||||
|
|
||||||
List<NodeRef> ret = super.applyPostQueryPermissions(results, authenticationToken, requestedCount);
|
List<NodeRef> ret = super.applyPostQueryPermissions(results, requestedCount);
|
||||||
|
|
||||||
if (start != null)
|
if (start != null)
|
||||||
{
|
{
|
||||||
@@ -657,17 +654,15 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
private class UnsortedResultHandler implements CannedQueryDAO.ResultHandler<NodeEntity>
|
private class UnsortedResultHandler implements CannedQueryDAO.ResultHandler<NodeEntity>
|
||||||
{
|
{
|
||||||
private final UnsortedChildQueryCallback resultsCallback;
|
private final UnsortedChildQueryCallback resultsCallback;
|
||||||
private final String authenticationToken;
|
|
||||||
|
|
||||||
private boolean more = true;
|
private boolean more = true;
|
||||||
|
|
||||||
private static final int BATCH_SIZE = 256 * 4;
|
private static final int BATCH_SIZE = 256 * 4;
|
||||||
private final List<NodeRef> nodeRefs;
|
private final List<NodeRef> nodeRefs;
|
||||||
|
|
||||||
private UnsortedResultHandler(UnsortedChildQueryCallback resultsCallback, String authenticationToken)
|
private UnsortedResultHandler(UnsortedChildQueryCallback resultsCallback)
|
||||||
{
|
{
|
||||||
this.resultsCallback = resultsCallback;
|
this.resultsCallback = resultsCallback;
|
||||||
this.authenticationToken = authenticationToken;
|
|
||||||
|
|
||||||
nodeRefs = new LinkedList<NodeRef>();
|
nodeRefs = new LinkedList<NodeRef>();
|
||||||
}
|
}
|
||||||
@@ -698,7 +693,7 @@ public class GetChildrenCannedQuery extends AbstractCannedQueryPermissions<NodeR
|
|||||||
preload(nodeRefs);
|
preload(nodeRefs);
|
||||||
|
|
||||||
// TODO track total time for incremental permission checks ... and cutoff (eg. based on some config)
|
// TODO track total time for incremental permission checks ... and cutoff (eg. based on some config)
|
||||||
List<NodeRef> results = applyPermissions(nodeRefs, authenticationToken, nodeRefs.size());
|
List<NodeRef> results = applyPermissions(nodeRefs, nodeRefs.size());
|
||||||
|
|
||||||
for (NodeRef nodeRef : results)
|
for (NodeRef nodeRef : results)
|
||||||
{
|
{
|
||||||
|
@@ -27,16 +27,15 @@ import org.alfresco.query.CannedQuery;
|
|||||||
import org.alfresco.query.CannedQueryPageDetails;
|
import org.alfresco.query.CannedQueryPageDetails;
|
||||||
import org.alfresco.query.CannedQueryParameters;
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
import org.alfresco.query.CannedQuerySortDetails;
|
import org.alfresco.query.CannedQuerySortDetails;
|
||||||
import org.alfresco.query.PagingRequest;
|
|
||||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
import org.alfresco.repo.domain.contentdata.ContentDataDAO;
|
||||||
import org.alfresco.repo.domain.locale.LocaleDAO;
|
import org.alfresco.repo.domain.locale.LocaleDAO;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.repo.domain.node.NodePropertyHelper;
|
import org.alfresco.repo.domain.node.NodePropertyHelper;
|
||||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -61,9 +60,7 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory<No
|
|||||||
private CannedQueryDAO cannedQueryDAO;
|
private CannedQueryDAO cannedQueryDAO;
|
||||||
private TenantService tenantService;
|
private TenantService tenantService;
|
||||||
|
|
||||||
private MethodSecurityInterceptor methodSecurityInterceptor;
|
private MethodSecurityBean<NodeRef> methodSecurity;
|
||||||
private String methodName;
|
|
||||||
private Object methodService;
|
|
||||||
|
|
||||||
public void setDictionaryService(DictionaryService dictionaryService)
|
public void setDictionaryService(DictionaryService dictionaryService)
|
||||||
{
|
{
|
||||||
@@ -100,30 +97,17 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory<No
|
|||||||
this.tenantService = tenantService;
|
this.tenantService = tenantService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
|
public void setMethodSecurity(MethodSecurityBean<NodeRef> methodSecurity)
|
||||||
{
|
{
|
||||||
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
this.methodSecurity = methodSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodName(String methodName)
|
|
||||||
{
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodService(Object methodService)
|
|
||||||
{
|
|
||||||
this.methodService = methodService;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CannedQuery<NodeRef> getCannedQuery(CannedQueryParameters parameters)
|
public CannedQuery<NodeRef> getCannedQuery(CannedQueryParameters parameters)
|
||||||
{
|
{
|
||||||
NodePropertyHelper nodePropertyHelper = new NodePropertyHelper(dictionaryService, qnameDAO, localeDAO, contentDataDAO);
|
NodePropertyHelper nodePropertyHelper = new NodePropertyHelper(dictionaryService, qnameDAO, localeDAO, contentDataDAO);
|
||||||
|
|
||||||
// if not passed in (TODO or not in future cache) then generate a new query execution id
|
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurity, parameters);
|
||||||
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
|
|
||||||
|
|
||||||
return (CannedQuery<NodeRef>) new GetChildrenCannedQuery(nodeDAO, qnameDAO, cannedQueryDAO, nodePropertyHelper, tenantService, methodSecurityInterceptor, methodService, methodName, parameters, queryExecutionId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -166,7 +150,7 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory<No
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingRequest.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -198,11 +182,6 @@ public class GetChildrenCannedQueryFactory extends AbstractCannedQueryFactory<No
|
|||||||
PropertyCheck.mandatory(this, "localeDAO", localeDAO);
|
PropertyCheck.mandatory(this, "localeDAO", localeDAO);
|
||||||
PropertyCheck.mandatory(this, "contentDataDAO", contentDataDAO);
|
PropertyCheck.mandatory(this, "contentDataDAO", contentDataDAO);
|
||||||
PropertyCheck.mandatory(this, "cannedQueryDAO", cannedQueryDAO);
|
PropertyCheck.mandatory(this, "cannedQueryDAO", cannedQueryDAO);
|
||||||
|
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurity);
|
||||||
//PropertyCheck.mandatory(this, "encryptionEngine", encryptionEngine);
|
|
||||||
|
|
||||||
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
|
|
||||||
PropertyCheck.mandatory(this, "methodService", methodService);
|
|
||||||
PropertyCheck.mandatory(this, "methodName", methodName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,7 @@ import org.alfresco.repo.domain.query.CannedQueryDAO;
|
|||||||
import org.alfresco.repo.model.Repository;
|
import org.alfresco.repo.model.Repository;
|
||||||
import org.alfresco.repo.node.getchildren.FilterPropString.FilterTypeString;
|
import org.alfresco.repo.node.getchildren.FilterPropString.FilterTypeString;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
@@ -105,10 +105,10 @@ public class GetChildrenCannedQueryTest extends TestCase
|
|||||||
private Set<NodeRef> permHits = new HashSet<NodeRef>(100);
|
private Set<NodeRef> permHits = new HashSet<NodeRef>(100);
|
||||||
private Set<NodeRef> permMisses = new HashSet<NodeRef>(100);
|
private Set<NodeRef> permMisses = new HashSet<NodeRef>(100);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "rawtypes" })
|
||||||
private NamedObjectRegistry<CannedQueryFactory> cannedQueryRegistry;
|
private NamedObjectRegistry<CannedQueryFactory> cannedQueryRegistry;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
{
|
{
|
||||||
@@ -138,9 +138,7 @@ public class GetChildrenCannedQueryTest extends TestCase
|
|||||||
getChildrenCannedQueryFactory.setNodeDAO((NodeDAO)ctx.getBean("nodeDAO"));
|
getChildrenCannedQueryFactory.setNodeDAO((NodeDAO)ctx.getBean("nodeDAO"));
|
||||||
getChildrenCannedQueryFactory.setQnameDAO((QNameDAO)ctx.getBean("qnameDAO"));
|
getChildrenCannedQueryFactory.setQnameDAO((QNameDAO)ctx.getBean("qnameDAO"));
|
||||||
|
|
||||||
getChildrenCannedQueryFactory.setMethodSecurityInterceptor((MethodSecurityInterceptor)ctx.getBean("FileFolderService_security"));
|
getChildrenCannedQueryFactory.setMethodSecurity((MethodSecurityBean<NodeRef>)ctx.getBean("FileFolderService_security_list"));
|
||||||
getChildrenCannedQueryFactory.setMethodService((Object)ctx.getBean("fileFolderService"));
|
|
||||||
getChildrenCannedQueryFactory.setMethodName("list");
|
|
||||||
|
|
||||||
getChildrenCannedQueryFactory.afterPropertiesSet();
|
getChildrenCannedQueryFactory.afterPropertiesSet();
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ import org.alfresco.query.CannedQuerySortDetails;
|
|||||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
import org.alfresco.repo.security.permissions.impl.acegi.AbstractCannedQueryPermissions;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.security.AuthorityType;
|
import org.alfresco.service.cmr.security.AuthorityType;
|
||||||
import org.alfresco.util.Pair;
|
import org.alfresco.util.Pair;
|
||||||
@@ -55,13 +55,10 @@ public class GetAuthoritiesCannedQuery extends AbstractCannedQueryPermissions<Au
|
|||||||
public GetAuthoritiesCannedQuery(
|
public GetAuthoritiesCannedQuery(
|
||||||
CannedQueryDAO cannedQueryDAO,
|
CannedQueryDAO cannedQueryDAO,
|
||||||
TenantService tenantService,
|
TenantService tenantService,
|
||||||
MethodSecurityInterceptor methodSecurityInterceptor,
|
MethodSecurityBean<AuthorityInfo> methodSecurity,
|
||||||
Object methodService,
|
CannedQueryParameters params)
|
||||||
String methodName,
|
|
||||||
CannedQueryParameters params,
|
|
||||||
String queryExecutionId)
|
|
||||||
{
|
{
|
||||||
super(params, queryExecutionId, methodSecurityInterceptor, methodService, methodName);
|
super(params, methodSecurity);
|
||||||
|
|
||||||
this.cannedQueryDAO = cannedQueryDAO;
|
this.cannedQueryDAO = cannedQueryDAO;
|
||||||
this.tenantService = tenantService;
|
this.tenantService = tenantService;
|
||||||
@@ -164,10 +161,10 @@ public class GetAuthoritiesCannedQuery extends AbstractCannedQueryPermissions<Au
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
protected List<AuthorityInfo> applyPostQuerySorting(List<AuthorityInfo> results, CannedQuerySortDetails sortDetails)
|
protected List<AuthorityInfo> applyPostQuerySorting(List<AuthorityInfo> results, CannedQuerySortDetails sortDetails)
|
||||||
{
|
{
|
||||||
final List<Pair<String, SortOrder>> sortPairs = (List)sortDetails.getSortPairs();
|
final List<Pair<Object, SortOrder>> sortPairs = (List)sortDetails.getSortPairs();
|
||||||
if (sortPairs.size() > 0)
|
if (sortPairs.size() > 0)
|
||||||
{
|
{
|
||||||
// single sort option - authority display name (else authority name if former is null)
|
// single sort option - authority display name (else authority name if former is null)
|
||||||
|
@@ -28,13 +28,12 @@ import org.alfresco.query.CannedQuery;
|
|||||||
import org.alfresco.query.CannedQueryPageDetails;
|
import org.alfresco.query.CannedQueryPageDetails;
|
||||||
import org.alfresco.query.CannedQueryParameters;
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
import org.alfresco.query.CannedQuerySortDetails;
|
import org.alfresco.query.CannedQuerySortDetails;
|
||||||
import org.alfresco.query.PagingRequest;
|
|
||||||
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
import org.alfresco.query.CannedQuerySortDetails.SortOrder;
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
import org.alfresco.repo.domain.node.NodeDAO;
|
import org.alfresco.repo.domain.node.NodeDAO;
|
||||||
import org.alfresco.repo.domain.qname.QNameDAO;
|
import org.alfresco.repo.domain.qname.QNameDAO;
|
||||||
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
import org.alfresco.repo.domain.query.CannedQueryDAO;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityBean;
|
||||||
import org.alfresco.repo.security.permissions.impl.acegi.MethodSecurityInterceptor;
|
|
||||||
import org.alfresco.repo.tenant.TenantService;
|
import org.alfresco.repo.tenant.TenantService;
|
||||||
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
@@ -56,10 +55,7 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
|
|||||||
private QNameDAO qnameDAO;
|
private QNameDAO qnameDAO;
|
||||||
private CannedQueryDAO cannedQueryDAO;
|
private CannedQueryDAO cannedQueryDAO;
|
||||||
private TenantService tenantService;
|
private TenantService tenantService;
|
||||||
|
private MethodSecurityBean<AuthorityInfo> methodSecurity;
|
||||||
private MethodSecurityInterceptor methodSecurityInterceptor;
|
|
||||||
private String methodName;
|
|
||||||
private Object methodService;
|
|
||||||
|
|
||||||
public void setNodeDAO(NodeDAO nodeDAO)
|
public void setNodeDAO(NodeDAO nodeDAO)
|
||||||
{
|
{
|
||||||
@@ -81,28 +77,15 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
|
|||||||
this.tenantService = tenantService;
|
this.tenantService = tenantService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
|
public void setMethodSecurity(MethodSecurityBean<AuthorityInfo> methodSecurity)
|
||||||
{
|
{
|
||||||
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
this.methodSecurity = methodSecurity;
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodName(String methodName)
|
|
||||||
{
|
|
||||||
this.methodName = methodName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMethodService(Object methodService)
|
|
||||||
{
|
|
||||||
this.methodService = methodService;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CannedQuery<AuthorityInfo> getCannedQuery(CannedQueryParameters parameters)
|
public CannedQuery<AuthorityInfo> getCannedQuery(CannedQueryParameters parameters)
|
||||||
{
|
{
|
||||||
// if not passed in (TODO or not in future cache) then generate a new query execution id
|
return (CannedQuery<AuthorityInfo>) new GetAuthoritiesCannedQuery(cannedQueryDAO, tenantService, methodSecurity, parameters);
|
||||||
String queryExecutionId = (parameters.getQueryExecutionId() == null ? super.getQueryExecutionId(parameters) : parameters.getQueryExecutionId());
|
|
||||||
|
|
||||||
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)
|
public CannedQuery<AuthorityInfo> getCannedQuery(AuthorityType type, NodeRef containerRef, String displayNameFilter, boolean sortByDisplayName, boolean sortAscending, PagingRequest pagingRequest)
|
||||||
@@ -146,7 +129,7 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create query params holder
|
// create query params holder
|
||||||
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, AuthenticationUtil.getRunAsUser(), requestTotalCountMax, pagingRequest.getQueryExecutionId());
|
CannedQueryParameters params = new CannedQueryParameters(paramBean, cqpd, cqsd, requestTotalCountMax, pagingRequest.getQueryExecutionId());
|
||||||
|
|
||||||
// return canned query instance
|
// return canned query instance
|
||||||
return getCannedQuery(params);
|
return getCannedQuery(params);
|
||||||
@@ -171,8 +154,6 @@ public class GetAuthoritiesCannedQueryFactory extends AbstractCannedQueryFactory
|
|||||||
PropertyCheck.mandatory(this, "nodeDAO", nodeDAO);
|
PropertyCheck.mandatory(this, "nodeDAO", nodeDAO);
|
||||||
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
|
PropertyCheck.mandatory(this, "qnameDAO", qnameDAO);
|
||||||
PropertyCheck.mandatory(this, "cannedQueryDAO", cannedQueryDAO);
|
PropertyCheck.mandatory(this, "cannedQueryDAO", cannedQueryDAO);
|
||||||
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
|
PropertyCheck.mandatory(this, "methodSecurity", methodSecurity);
|
||||||
PropertyCheck.mandatory(this, "methodService", methodService);
|
|
||||||
PropertyCheck.mandatory(this, "methodName", methodName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,24 +18,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.repo.security.permissions.impl.acegi;
|
package org.alfresco.repo.security.permissions.impl.acegi;
|
||||||
|
|
||||||
import java.lang.reflect.AccessibleObject;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import net.sf.acegisecurity.Authentication;
|
import net.sf.acegisecurity.Authentication;
|
||||||
import net.sf.acegisecurity.ConfigAttributeDefinition;
|
|
||||||
import net.sf.acegisecurity.context.Context;
|
import net.sf.acegisecurity.context.Context;
|
||||||
import net.sf.acegisecurity.context.ContextHolder;
|
import net.sf.acegisecurity.context.ContextHolder;
|
||||||
import net.sf.acegisecurity.context.security.SecureContext;
|
import net.sf.acegisecurity.context.security.SecureContext;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.alfresco.query.AbstractCannedQuery;
|
import org.alfresco.query.AbstractCannedQuery;
|
||||||
import org.alfresco.query.CannedQueryParameters;
|
import org.alfresco.query.CannedQueryParameters;
|
||||||
import org.alfresco.query.PagingResults;
|
|
||||||
import org.alfresco.repo.security.authentication.AlfrescoSecureContext;
|
import org.alfresco.repo.security.authentication.AlfrescoSecureContext;
|
||||||
import org.alfresco.util.Pair;
|
|
||||||
import org.aopalliance.intercept.MethodInvocation;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
|
||||||
@@ -48,47 +41,25 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQuery<R>
|
public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQuery<R>
|
||||||
{
|
{
|
||||||
private Log logger = LogFactory.getLog(AbstractCannedQueryPermissions.class);
|
private Log logger = LogFactory.getLog(AbstractCannedQueryPermissions.class);
|
||||||
|
|
||||||
|
private MethodSecurityBean<R> methodSecurity;
|
||||||
|
|
||||||
private MethodSecurityInterceptor methodSecurityInterceptor;
|
protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, MethodSecurityBean<R> methodSecurity)
|
||||||
private Method method;
|
|
||||||
|
|
||||||
protected AbstractCannedQueryPermissions(CannedQueryParameters parameters, String queryExecutionId, MethodSecurityInterceptor methodSecurityInterceptor, Object methodService, String methodName)
|
|
||||||
{
|
{
|
||||||
super(parameters, queryExecutionId);
|
super(parameters);
|
||||||
|
this.methodSecurity = methodSecurity;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<R> applyPostQueryPermissions(List<R> results, String authenticationToken, int requestedCount)
|
protected List<R> applyPostQueryPermissions(List<R> results, int requestedCount)
|
||||||
{
|
{
|
||||||
int requestTotalCountMax = getParameters().requestTotalResultCountMax();
|
int requestTotalCountMax = getParameters().requestTotalResultCountMax();
|
||||||
int maxChecks = (((requestTotalCountMax > 0) && (requestTotalCountMax > requestedCount)) ? requestTotalCountMax : requestedCount);
|
int maxChecks = (((requestTotalCountMax > 0) && (requestTotalCountMax > requestedCount)) ? requestTotalCountMax : requestedCount);
|
||||||
|
|
||||||
return applyPermissions(results, authenticationToken, maxChecks);
|
return applyPermissions(results, maxChecks);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
protected List<R> applyPermissions(List<R> results, int maxChecks)
|
||||||
protected List<R> applyPermissions(List<R> results, String authenticationToken, int maxChecks)
|
|
||||||
{
|
{
|
||||||
long start = System.currentTimeMillis();
|
|
||||||
|
|
||||||
Context context = ContextHolder.getContext();
|
Context context = ContextHolder.getContext();
|
||||||
if ((context == null) || (! (context instanceof AlfrescoSecureContext)))
|
if ((context == null) || (! (context instanceof AlfrescoSecureContext)))
|
||||||
{
|
{
|
||||||
@@ -99,57 +70,10 @@ public abstract class AbstractCannedQueryPermissions<R> extends AbstractCannedQu
|
|||||||
|
|
||||||
return new WrappedList<R>(new ArrayList<R>(0), true, false); // empty result
|
return new WrappedList<R>(new ArrayList<R>(0), true, false); // empty result
|
||||||
}
|
}
|
||||||
|
|
||||||
Authentication authentication = (((SecureContext) context).getAuthentication());
|
Authentication authentication = (((SecureContext) context).getAuthentication());
|
||||||
|
|
||||||
ConfigAttributeDefinition cad = methodSecurityInterceptor.getObjectDefinitionSource().getAttributes(new InternalMethodInvocation(method));
|
List<R> resultsOut = methodSecurity.applyPermissions(results, authentication, maxChecks);
|
||||||
List<R> ret = (WrappedList<R>)methodSecurityInterceptor.getAfterInvocationManager().decide(authentication, null, cad, new WrappedList<R>(results, maxChecks));
|
// Done
|
||||||
|
return resultsOut;
|
||||||
if (logger.isTraceEnabled())
|
|
||||||
{
|
|
||||||
logger.trace("applyPermissions: "+ret.size()+" items in "+(System.currentTimeMillis()-start)+" msecs");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
class InternalMethodInvocation implements MethodInvocation
|
|
||||||
{
|
|
||||||
Method method;
|
|
||||||
|
|
||||||
public InternalMethodInvocation(Method method)
|
|
||||||
{
|
|
||||||
this.method = method;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected InternalMethodInvocation()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object[] getArguments()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Method getMethod()
|
|
||||||
{
|
|
||||||
return this.method;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AccessibleObject getStaticPart()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getThis()
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object proceed() throws Throwable
|
|
||||||
{
|
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,189 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||||
|
*
|
||||||
|
* This file is part of Alfresco
|
||||||
|
*
|
||||||
|
* Alfresco is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package org.alfresco.repo.security.permissions.impl.acegi;
|
||||||
|
|
||||||
|
import java.lang.reflect.AccessibleObject;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.sf.acegisecurity.Authentication;
|
||||||
|
import net.sf.acegisecurity.ConfigAttributeDefinition;
|
||||||
|
|
||||||
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
|
import org.alfresco.util.PropertyCheck;
|
||||||
|
import org.aopalliance.intercept.MethodInvocation;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Support to simulate interceptor-driven permissions.
|
||||||
|
*
|
||||||
|
* @author janv, Derek Hulley
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public class MethodSecurityBean<R> implements InitializingBean
|
||||||
|
{
|
||||||
|
private Log logger = LogFactory.getLog(MethodSecurityBean.class);
|
||||||
|
|
||||||
|
private MethodSecurityInterceptor methodSecurityInterceptor;
|
||||||
|
private Class<?> service;
|
||||||
|
private String methodName;
|
||||||
|
private ConfigAttributeDefinition cad;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor. Use setter methods for initialization.
|
||||||
|
*/
|
||||||
|
public MethodSecurityBean()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper constructor to supply necessary values
|
||||||
|
*/
|
||||||
|
public MethodSecurityBean(MethodSecurityInterceptor methodSecurityInterceptor, Class<?> service, String methodName)
|
||||||
|
{
|
||||||
|
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
||||||
|
this.service = service;
|
||||||
|
this.methodName = methodName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethodSecurityInterceptor(MethodSecurityInterceptor methodSecurityInterceptor)
|
||||||
|
{
|
||||||
|
this.methodSecurityInterceptor = methodSecurityInterceptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setService(Class<?> service)
|
||||||
|
{
|
||||||
|
this.service = service;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMethodName(String methodName)
|
||||||
|
{
|
||||||
|
this.methodName = methodName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return "MethodSecurityBean [serviceInterface=" + service.getName() + ", methodName=" + methodName + "]";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterPropertiesSet() throws Exception
|
||||||
|
{
|
||||||
|
PropertyCheck.mandatory(this, "methodSecurityInterceptor", methodSecurityInterceptor);
|
||||||
|
PropertyCheck.mandatory(this, "service", service);
|
||||||
|
PropertyCheck.mandatory(this, "methodName", methodName);
|
||||||
|
|
||||||
|
// Get the method from the service
|
||||||
|
Method method = null;
|
||||||
|
for (Method m : service.getMethods())
|
||||||
|
{
|
||||||
|
// Note: currently matches first found
|
||||||
|
// This is fine because the interceptor requires the same defininition for all overloaded methods
|
||||||
|
if (m.getName().equals(methodName))
|
||||||
|
{
|
||||||
|
method = m;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (method == null)
|
||||||
|
{
|
||||||
|
throw new AlfrescoRuntimeException(
|
||||||
|
"Method not found: \n" +
|
||||||
|
" Interface: " + service.getClass() + "\n" +
|
||||||
|
" Method: " + methodName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.cad = methodSecurityInterceptor.getObjectDefinitionSource().getAttributes(new InternalMethodInvocation(method));
|
||||||
|
// Null means there are no applicable permissions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<R> applyPermissions(List<R> results, Authentication authentication, int maxChecks)
|
||||||
|
{
|
||||||
|
if (cad == null)
|
||||||
|
{
|
||||||
|
// Ignore permissions
|
||||||
|
if (logger.isTraceEnabled())
|
||||||
|
{
|
||||||
|
logger.trace("applyPermissions ignored: " + this);
|
||||||
|
}
|
||||||
|
return new WrappedList<R>(results, true, false);
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
List<R> ret = (WrappedList<R>) methodSecurityInterceptor.getAfterInvocationManager().decide(
|
||||||
|
authentication,
|
||||||
|
null,
|
||||||
|
cad,
|
||||||
|
new WrappedList<R>(results, maxChecks));
|
||||||
|
if (logger.isTraceEnabled())
|
||||||
|
{
|
||||||
|
logger.trace("applyPermissions: " + ret.size() + " items in " + (System.currentTimeMillis() - start) + " msecs");
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to provide method for permissions interceptor
|
||||||
|
*/
|
||||||
|
class InternalMethodInvocation implements MethodInvocation
|
||||||
|
{
|
||||||
|
Method method;
|
||||||
|
|
||||||
|
public InternalMethodInvocation(Method method)
|
||||||
|
{
|
||||||
|
this.method = method;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected InternalMethodInvocation()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object[] getArguments()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Method getMethod()
|
||||||
|
{
|
||||||
|
return this.method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccessibleObject getStaticPart()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getThis()
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object proceed() throws Throwable
|
||||||
|
{
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -20,8 +20,9 @@ package org.alfresco.service.cmr.repository;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.alfresco.query.PagingRequest;
|
||||||
|
import org.alfresco.query.PagingResults;
|
||||||
import org.alfresco.service.Auditable;
|
import org.alfresco.service.Auditable;
|
||||||
import org.alfresco.service.PublicService;
|
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -163,8 +164,72 @@ public interface CopyService
|
|||||||
*
|
*
|
||||||
* @param nodeRef the original node reference
|
* @param nodeRef the original node reference
|
||||||
* @return a list of copies, empty is none
|
* @return a list of copies, empty is none
|
||||||
|
* @deprecated This method is too open-ended. See {@link #getCopies(NodeRef, PagingRequest)}.
|
||||||
*/
|
*/
|
||||||
@Auditable(parameters = {"nodeRef"})
|
@Auditable(parameters = {"nodeRef"})
|
||||||
public List<NodeRef> getCopies(NodeRef nodeRef);
|
public List<NodeRef> getCopies(NodeRef nodeRef);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data pojo to carry information about node copies
|
||||||
|
*
|
||||||
|
* @author Derek Hulley
|
||||||
|
* @since 4.0
|
||||||
|
*/
|
||||||
|
public class CopyInfo
|
||||||
|
{
|
||||||
|
private final NodeRef nodeRef;
|
||||||
|
private final String name;
|
||||||
|
private final NodeRef parentNodeRef;
|
||||||
|
private final String parentName;
|
||||||
|
|
||||||
|
public CopyInfo(NodeRef nodeRef, String name, NodeRef parentNodeRef, String parentName)
|
||||||
|
{
|
||||||
|
this.nodeRef = nodeRef;
|
||||||
|
this.name = name;
|
||||||
|
this.parentNodeRef = parentNodeRef;
|
||||||
|
this.parentName = parentName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the node copy
|
||||||
|
*/
|
||||||
|
public NodeRef getNodeRef()
|
||||||
|
{
|
||||||
|
return nodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the node copy
|
||||||
|
*/
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the parent of the node copy
|
||||||
|
*/
|
||||||
|
public NodeRef getParentNodeRef()
|
||||||
|
{
|
||||||
|
return parentNodeRef;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of the parent of the node copy
|
||||||
|
*/
|
||||||
|
public String getParentName()
|
||||||
|
{
|
||||||
|
return parentName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the copies of a given node
|
||||||
|
*
|
||||||
|
* @param nodeRef the original node reference
|
||||||
|
* @param pagingRequest page request details
|
||||||
|
* @return the page(s) of nodes that were copied from the given node
|
||||||
|
*/
|
||||||
|
@Auditable(parameters = {"nodeRef"})
|
||||||
|
public PagingResults<CopyInfo> getCopies(NodeRef nodeRef, PagingRequest pagingRequest);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user