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

@@ -35,12 +35,14 @@ import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
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
*/
public class LockOwnerDynamicAuthority implements DynamicAuthority, InitializingBean
public class LockOwnerDynamicAuthority extends AbstractLifecycleBean implements DynamicAuthority
{
private LockService lockService;
@@ -94,23 +96,14 @@ public class LockOwnerDynamicAuthority implements DynamicAuthority, Initializing
return PermissionService.LOCK_OWNER_AUTHORITY;
}
public void afterPropertiesSet() throws Exception
@Override
protected void onBootstrap(ApplicationEvent event)
{
if(lockService == null)
{
throw new IllegalStateException("The LockService must be set");
}
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
PropertyCheck.mandatory(this, "lockService", lockService);
PropertyCheck.mandatory(this, "nodeService", nodeService);
PropertyCheck.mandatory(this, "modelDAO", modelDAO);
// Build the permission set
if(requiredFor != null)
{
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
* @param lockService

View File

@@ -65,7 +65,9 @@ import org.alfresco.service.namespace.QName;
import org.alfresco.util.EqualsHelper;
import org.apache.commons.logging.Log;
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
@@ -73,10 +75,10 @@ import org.springframework.beans.factory.InitializingBean;
*
* @author andyh
*/
public class PermissionServiceImpl implements PermissionServiceSPI, InitializingBean
public class PermissionServiceImpl extends AbstractLifecycleBean implements PermissionServiceSPI
{
static SimplePermissionReference OLD_ALL_PERMISSIONS_REFERENCE = new SimplePermissionReference(QName.createQName("", PermissionService.ALL_PERMISSIONS),
static SimplePermissionReference OLD_ALL_PERMISSIONS_REFERENCE = new SimplePermissionReference(
QName.createQName("", PermissionService.ALL_PERMISSIONS),
PermissionService.ALL_PERMISSIONS);
private static Log log = LogFactory.getLog(PermissionServiceImpl.class);
@@ -247,49 +249,32 @@ public class PermissionServiceImpl implements PermissionServiceSPI, Initializing
accessCache.clear();
}
public void afterPropertiesSet() throws Exception
@Override
protected void onBootstrap(ApplicationEvent event)
{
if (dictionaryService == null)
{
throw new IllegalArgumentException("Property 'dictionaryService' has not been set");
}
if (modelDAO == null)
{
throw new IllegalArgumentException("Property 'modelDAO' has not been set");
}
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");
}
PropertyCheck.mandatory(this, "dictionaryService", dictionaryService);
PropertyCheck.mandatory(this, "modelDAO", modelDAO);
PropertyCheck.mandatory(this, "nodeService", nodeService);
PropertyCheck.mandatory(this, "permissionsDaoComponent", permissionsDaoComponent);
PropertyCheck.mandatory(this, "authorityService", authorityService);
PropertyCheck.mandatory(this, "accessCache", accessCache);
PropertyCheck.mandatory(this, "policyComponent", policyComponent);
PropertyCheck.mandatory(this, "aclDaoComponent", aclDaoComponent);
allPermissionReference = getPermissionReference(ALL_PERMISSIONS);
}
/**
* No-op
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
}
public void init()
{
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.Element;
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
@@ -61,7 +62,7 @@ import org.springframework.beans.factory.InitializingBean;
*
* @author andyh
*/
public class PermissionModel implements ModelDAO, InitializingBean
public class PermissionModel extends AbstractLifecycleBean implements ModelDAO
{
// IOC
@@ -166,17 +167,23 @@ public class PermissionModel implements ModelDAO, InitializingBean
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);
}
/**
* No-op
*/
@Override
protected void onShutdown(ApplicationEvent event)
{
}
/**
* Adds a permission model
*
@@ -213,10 +220,10 @@ public class PermissionModel implements ModelDAO, InitializingBean
// Namespaces
for (Iterator nsit = root.elementIterator(NAMESPACES); nsit.hasNext(); /**/)
for (Iterator<?> nsit = root.elementIterator(NAMESPACES); nsit.hasNext(); /**/)
{
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();
nspr.registerNamespace(nameSpaceElement.attributeValue(NAMESPACE_PREFIX), nameSpaceElement.attributeValue(NAMESPACE_URI));
@@ -225,7 +232,7 @@ public class PermissionModel implements ModelDAO, InitializingBean
// 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();
PermissionSet permissionSet = new PermissionSet();
@@ -238,7 +245,7 @@ public class PermissionModel implements ModelDAO, InitializingBean
// NodePermissions
for (Iterator npit = root.elementIterator(GLOBAL_PERMISSION); npit.hasNext(); /**/)
for (Iterator<?> npit = root.elementIterator(GLOBAL_PERMISSION); npit.hasNext(); /**/)
{
Element globalPermissionElement = (Element) npit.next();
GlobalPermissionEntry globalPermission = new GlobalPermissionEntry();