我需要创建一个新类,将其用作引导程序来创建文件夹和节点
<bean id="com.ds.module.extensions.Core.securityRequirementBootstrap" class="com.ds.ui.bean.dialog.module.SecurityRequirementBootstrap" init-method="init">
<property name="searchService">
<ref bean="SearchService"/>
</property>
<property name="nodeService">
<ref bean="NodeService"/>
</property>
<property name="transactionService">
<ref bean="transactionService" />
</property>
</bean>
public class SecurityRequirementBootstrap {
public void init() throws Exception{
AuthenticationUtil.runAs(new RunAsWork<String>() {
public String doWork() throws Exception {
transaction = transactionService.getUserTransaction();
transaction.begin();
NodeUtil.checkSecurityPreRequesite(searchService,nodeService);
transaction.commit();
return "";
}
}, "admin");
}
public synchronized static final Node acquireSequencesFolder(SearchService searchService){
NodeRef nodeRef = searchService.query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE,
SearchService.LANGUAGE_LUCENE,"@"+NamespaceService.CONTENT_MODEL_PREFIX+"\\:"+ContentModel.PROP_NAME.getLocalName()+":\""+Constants.SEQUENCES_FOLDER_NODE_NAME_STRING+"\"").getNodeRef(0);
if(nodeRef != null)
return new Node(nodeRef);
return null;
}
但此代码会抛出异常
aused by: java.lang.UnsupportedOperationException: Can not find {http://www.alfresco.org/model/system/1.0}base.Read
at org.alfresco.repo.security.permissions.impl.model.PermissionModel.getPermissionReference(PermissionModel.java:1321)
at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.getPermissionReference(PermissionServiceImpl.java:956)
at org.alfresco.repo.security.permissions.impl.PermissionServiceImpl.hasPermission(PermissionServiceImpl.java:976)
at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decideOld(ACLEntryAfterInvocationProvider.java:756)
at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:528)
at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:511)
at org.alfresco.repo.security.permissions.impl.acegi.ACLEntryAfterInvocationProvider.decide(ACLEntryAfterInvocationProvider.java:298)
at net.sf.acegisecurity.afterinvocation.AfterInvocationProviderManager.decide(AfterInvocationProviderManager.java:107)
at net.sf.acegisecurity.intercept.AbstractSecurityInterceptor.afterInvocation(AbstractSecurityInterceptor.java:329)
at net.sf.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor.invoke(MethodSecurityInterceptor.java:82)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.security.permissions.impl.ExceptionTranslatorMethodInterceptor.invoke(ExceptionTranslatorMethodInterceptor.java:44)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.alfresco.repo.audit.AuditMethodInterceptor.proceedWithAudit(AuditMethodInterceptor.java:217)
at org.alfresco.repo.audit.AuditMethodInterceptor.proceed(AuditMethodInterceptor.java:184)
at org.alfresco.repo.audit.AuditMethodInterceptor.invoke(AuditMethodInterceptor.java:137)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:107)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy36.query(Unknown Source)
at com.ds.ui.bean.dialog.util.NodeUtil.acquireSequencesFolder(NodeUtil.java:68)
at com.ds.ui.bean.dialog.util.NodeUtil.checkSequencesExistance(NodeUtil.java:327)
at com.ds.ui.bean.dialog.util.NodeUtil.checkSecurityPreRequesite(NodeUtil.java:455)
at com.ds.ui.bean.dialog.module.SecurityRequirementBootstrap$1.doWork(SecurityRequirementBootstrap.java:21)
at com.ds.ui.bean.dialog.module.SecurityRequirementBootstrap$1.doWork(SecurityRequirementBootstrap.java:1)
at org.alfresco.repo.security.authentication.AuthenticationUtil.runAs(AuthenticationUtil.java:508)
at com.ds.ui.bean.dialog.module.SecurityRequirementBootstrap.init(SecurityRequirementBootstrap.java:17)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
答案 0 :(得分:1)
该异常表示存储库找不到sys:base类型的读取权限。
您是否更改或覆盖过 露天/模型/ permissionDefinitions.xml?如果是,那么你很可能会有错误。
我注意到的另一件事是,您应该始终使用try finally pattern关闭您的lucene结果集。