PermissionModel initialization is now driven by context start

- It was using afterPropertiesSet, which was triggering early EHCache initialization
 - Not actually causing problems, but was masking deeper context issues


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19136 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2010-03-09 00:51:39 +00:00
parent ccd0614e8a
commit 22981d78a1
4 changed files with 78 additions and 85 deletions

View File

@@ -14,6 +14,22 @@
<beans> <beans>
<!-- ===================== -->
<!-- Permissions Model DAO -->
<!-- ===================== -->
<bean id='permissionsModelDAO' class="org.alfresco.repo.security.permissions.impl.model.PermissionModel">
<property name="model">
<value>alfresco/model/permissionDefinitions.xml</value>
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
</bean>
<!-- ======================= --> <!-- ======================= -->
<!-- Support for permissions --> <!-- Support for permissions -->
<!-- ========================--> <!-- ========================-->
@@ -109,22 +125,6 @@
</property> </property>
</bean> </bean>
<!-- ===================== -->
<!-- Permissions Model DAO -->
<!-- ===================== -->
<bean id='permissionsModelDAO' class="org.alfresco.repo.security.permissions.impl.model.PermissionModel">
<property name="model">
<value>alfresco/model/permissionDefinitions.xml</value>
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
</bean>
<!-- =========================== --> <!-- =========================== -->
<!-- Permissions Model Bootstrap --> <!-- Permissions Model Bootstrap -->
<!-- =========================== --> <!-- =========================== -->

View File

@@ -35,12 +35,14 @@ 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.repository.datatype.DefaultTypeConverter; import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.service.cmr.security.PermissionService;
import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.springframework.extensions.surf.util.PropertyCheck;
/** /**
* LockOwnerDynamicAuthority * LockOwnerDynamicAuthority
*/ */
public class LockOwnerDynamicAuthority implements DynamicAuthority, InitializingBean public class LockOwnerDynamicAuthority extends AbstractLifecycleBean implements DynamicAuthority
{ {
private LockService lockService; private LockService lockService;
@@ -94,23 +96,14 @@ public class LockOwnerDynamicAuthority implements DynamicAuthority, Initializing
return PermissionService.LOCK_OWNER_AUTHORITY; return PermissionService.LOCK_OWNER_AUTHORITY;
} }
public void afterPropertiesSet() throws Exception @Override
protected void onBootstrap(ApplicationEvent event)
{ {
if(lockService == null) PropertyCheck.mandatory(this, "lockService", lockService);
{ PropertyCheck.mandatory(this, "nodeService", nodeService);
throw new IllegalStateException("The LockService must be set"); PropertyCheck.mandatory(this, "modelDAO", modelDAO);
}
if(nodeService == null)
{
throw new IllegalStateException("The NodeService service must be set");
}
if(modelDAO == null)
{
throw new IllegalStateException("The ModelDAO service must be set");
}
// buld the permission set
// Build the permission set
if(requiredFor != null) if(requiredFor != null)
{ {
whenRequired = new HashSet<PermissionReference>(); whenRequired = new HashSet<PermissionReference>();
@@ -123,6 +116,14 @@ public class LockOwnerDynamicAuthority implements DynamicAuthority, Initializing
} }
} }
/**
* No-op
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
}
/** /**
* Set the lock service * Set the lock service
* @param lockService * @param lockService

View File

@@ -65,7 +65,9 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper; import org.alfresco.util.EqualsHelper;
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.beans.factory.InitializingBean; import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
import org.springframework.extensions.surf.util.PropertyCheck;
/** /**
* The Alfresco implementation of a permissions service against our APIs for the permissions model and permissions * The Alfresco implementation of a permissions service against our APIs for the permissions model and permissions
@@ -73,10 +75,10 @@ import org.springframework.beans.factory.InitializingBean;
* *
* @author andyh * @author andyh
*/ */
public class PermissionServiceImpl implements PermissionServiceSPI, InitializingBean public class PermissionServiceImpl extends AbstractLifecycleBean implements PermissionServiceSPI
{ {
static SimplePermissionReference OLD_ALL_PERMISSIONS_REFERENCE = new SimplePermissionReference(
static SimplePermissionReference OLD_ALL_PERMISSIONS_REFERENCE = new SimplePermissionReference(QName.createQName("", PermissionService.ALL_PERMISSIONS), QName.createQName("", PermissionService.ALL_PERMISSIONS),
PermissionService.ALL_PERMISSIONS); PermissionService.ALL_PERMISSIONS);
private static Log log = LogFactory.getLog(PermissionServiceImpl.class); private static Log log = LogFactory.getLog(PermissionServiceImpl.class);
@@ -247,49 +249,32 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
accessCache.clear(); accessCache.clear();
} }
public void afterPropertiesSet() throws Exception @Override
protected void onBootstrap(ApplicationEvent event)
{ {
if (dictionaryService == null) PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
{ PropertyCheck.mandatory(this, "modelDAO", modelDAO);
throw new IllegalArgumentException("Property 'dictionaryService' has not been set"); PropertyCheck.mandatory(this, "nodeService", nodeService);
} PropertyCheck.mandatory(this, "permissionsDaoComponent", permissionsDaoComponent);
if (modelDAO == null) PropertyCheck.mandatory(this, "authorityService", authorityService);
{ PropertyCheck.mandatory(this, "accessCache", accessCache);
throw new IllegalArgumentException("Property 'modelDAO' has not been set"); PropertyCheck.mandatory(this, "policyComponent", policyComponent);
} PropertyCheck.mandatory(this, "aclDaoComponent", aclDaoComponent);
if (nodeService == null)
{
throw new IllegalArgumentException("Property 'nodeService' has not been set");
}
if (permissionsDaoComponent == null)
{
throw new IllegalArgumentException("Property 'permissionsDAO' has not been set");
}
if (authorityService == null)
{
throw new IllegalArgumentException("Property 'authorityService' has not been set");
}
if (accessCache == null)
{
throw new IllegalArgumentException("Property 'accessCache' has not been set");
}
if (policyComponent == null)
{
throw new IllegalArgumentException("Property 'policyComponent' has not been set");
}
if (aclDaoComponent == null)
{
throw new IllegalArgumentException("Property 'aclDaoComponent' has not been set");
}
allPermissionReference = getPermissionReference(ALL_PERMISSIONS); allPermissionReference = getPermissionReference(ALL_PERMISSIONS);
}
/**
* No-op
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
} }
public void init() public void init()
{ {
policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), ContentModel.TYPE_BASE, new JavaBehaviour(this, "onMoveNode")); policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onMoveNode"), ContentModel.TYPE_BASE, new JavaBehaviour(this, "onMoveNode"));
} }
// //

View File

@@ -53,7 +53,8 @@ import org.dom4j.Document;
import org.dom4j.DocumentException; import org.dom4j.DocumentException;
import org.dom4j.Element; import org.dom4j.Element;
import org.dom4j.io.SAXReader; import org.dom4j.io.SAXReader;
import org.springframework.beans.factory.InitializingBean; import org.springframework.context.ApplicationEvent;
import org.springframework.extensions.surf.util.AbstractLifecycleBean;
/** /**
* The implementation of the model DAO Reads and stores the top level model information Encapsulates access to this * The implementation of the model DAO Reads and stores the top level model information Encapsulates access to this
@@ -61,7 +62,7 @@ import org.springframework.beans.factory.InitializingBean;
* *
* @author andyh * @author andyh
*/ */
public class PermissionModel implements ModelDAO, InitializingBean public class PermissionModel extends AbstractLifecycleBean implements ModelDAO
{ {
// IOC // IOC
@@ -166,17 +167,23 @@ public class PermissionModel implements ModelDAO, InitializingBean
this.nodeService = nodeService; this.nodeService = nodeService;
} }
/*
* Initialise from file (non-Javadoc)
*
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
public void afterPropertiesSet() /**
* Adds the {@link #setModel(String) model}.
*/
protected void onBootstrap(ApplicationEvent event)
{ {
addPermissionModel(this.model); addPermissionModel(this.model);
} }
/**
* No-op
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
}
/** /**
* Adds a permission model * Adds a permission model
* *
@@ -213,10 +220,10 @@ public class PermissionModel implements ModelDAO, InitializingBean
// Namespaces // Namespaces
for (Iterator nsit = root.elementIterator(NAMESPACES); nsit.hasNext(); /**/) for (Iterator<?> nsit = root.elementIterator(NAMESPACES); nsit.hasNext(); /**/)
{ {
Element namespacesElement = (Element) nsit.next(); Element namespacesElement = (Element) nsit.next();
for (Iterator it = namespacesElement.elementIterator(NAMESPACE); it.hasNext(); /**/) for (Iterator<?> it = namespacesElement.elementIterator(NAMESPACE); it.hasNext(); /**/)
{ {
Element nameSpaceElement = (Element) it.next(); Element nameSpaceElement = (Element) it.next();
nspr.registerNamespace(nameSpaceElement.attributeValue(NAMESPACE_PREFIX), nameSpaceElement.attributeValue(NAMESPACE_URI)); nspr.registerNamespace(nameSpaceElement.attributeValue(NAMESPACE_PREFIX), nameSpaceElement.attributeValue(NAMESPACE_URI));
@@ -225,7 +232,7 @@ public class PermissionModel implements ModelDAO, InitializingBean
// Permission Sets // Permission Sets
for (Iterator psit = root.elementIterator(PERMISSION_SET); psit.hasNext(); /**/) for (Iterator<?> psit = root.elementIterator(PERMISSION_SET); psit.hasNext(); /**/)
{ {
Element permissionSetElement = (Element) psit.next(); Element permissionSetElement = (Element) psit.next();
PermissionSet permissionSet = new PermissionSet(); PermissionSet permissionSet = new PermissionSet();
@@ -238,7 +245,7 @@ public class PermissionModel implements ModelDAO, InitializingBean
// NodePermissions // NodePermissions
for (Iterator npit = root.elementIterator(GLOBAL_PERMISSION); npit.hasNext(); /**/) for (Iterator<?> npit = root.elementIterator(GLOBAL_PERMISSION); npit.hasNext(); /**/)
{ {
Element globalPermissionElement = (Element) npit.next(); Element globalPermissionElement = (Element) npit.next();
GlobalPermissionEntry globalPermission = new GlobalPermissionEntry(); GlobalPermissionEntry globalPermission = new GlobalPermissionEntry();