From dc9ccc985e3de30bf3b7a932ba7bd212d25b4f08 Mon Sep 17 00:00:00 2001 From: Derek Hulley Date: Wed, 20 Feb 2008 13:14:05 +0000 Subject: [PATCH] Merged V2.2 to HEAD 7336: JMX-based admin: workaround for LinkValidationService circular reference (to allow unit tests to be run in Eclipse) 7419: Directory listings are filtered so that child directories without READ_CHILDREN permissions 7421: Update FOP from 0.92beta to 0.94 Fixed line endings for .classpath git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8337 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/core-services-context.xml | 1 - .../linkvalidation-service-context.xml | 6 +- .../alfresco/repo/admin/RepoServerMgmt.java | 15 +++- .../repo/avm/LayeredDirectoryNodeImpl.java | 78 +++++++++++++++---- .../repo/avm/PlainDirectoryNodeImpl.java | 17 ++++ 5 files changed, 97 insertions(+), 20 deletions(-) diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index c4e2a44923..417933cd6e 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -135,7 +135,6 @@ - ${server.maxusers} ${server.singleuseronly.name} diff --git a/config/alfresco/linkvalidation-service-context.xml b/config/alfresco/linkvalidation-service-context.xml index 326fd3513f..0a9170759e 100644 --- a/config/alfresco/linkvalidation-service-context.xml +++ b/config/alfresco/linkvalidation-service-context.xml @@ -218,7 +218,8 @@ + lazy-init="true" + init-method="register"> @@ -255,6 +256,9 @@ + + + diff --git a/source/java/org/alfresco/repo/admin/RepoServerMgmt.java b/source/java/org/alfresco/repo/admin/RepoServerMgmt.java index 37ceb19ca8..1b3f59b695 100644 --- a/source/java/org/alfresco/repo/admin/RepoServerMgmt.java +++ b/source/java/org/alfresco/repo/admin/RepoServerMgmt.java @@ -65,7 +65,8 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw this.authenticationService = authenticationService; } - public void setLinkValidationService(LinkValidationService linkValidationService) + // TODO - temporary workaround, can be removed when link validation is part of repo + public void registerLinkValidationService(LinkValidationService linkValidationService) { this.linkValidationService = linkValidationService; } @@ -344,6 +345,12 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw */ public void setLinkValidationDisabled(boolean disable) { + if (linkValidationService == null) + { + log.error("LinkValidationService not registered"); + throw new AlfrescoRuntimeException("LinkValidationService not registered"); + } + linkValidationService.setLinkValidationDisabled(disable); if (disable) { @@ -361,6 +368,12 @@ public class RepoServerMgmt implements RepoServerMgmtMBean, ApplicationContextAw */ public boolean isLinkValidationDisabled() { + if (linkValidationService == null) + { + log.error("LinkValidationService not registered"); + throw new AlfrescoRuntimeException("LinkValidationService not registered"); + } + return linkValidationService.isLinkValidationDisabled(); } } diff --git a/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java b/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java index 879dc871d9..9cdb7d2305 100644 --- a/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java +++ b/source/java/org/alfresco/repo/avm/LayeredDirectoryNodeImpl.java @@ -35,6 +35,7 @@ import org.alfresco.service.cmr.avm.AVMException; import org.alfresco.service.cmr.avm.AVMExistsException; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNotFoundException; +import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.util.Pair; /** @@ -373,27 +374,38 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec public Map getListing(Lookup lPath, boolean includeDeleted) { // Get the base listing from the thing we indirect to. - Map listing = null; - if (fOpacity) - { - listing = new HashMap(); - } - else + Map listing = new HashMap(); + if (!fOpacity) { Lookup lookup = AVMRepository.GetInstance().lookupDirectory(getUnderlyingVersion(lPath), getUnderlying(lPath)); if (lookup != null) { DirectoryNode dir = (DirectoryNode)lookup.getCurrentNode(); - listing = dir.getListing(lookup, includeDeleted); - } - else - { - // It's OK for an indirection to dangle. - listing = new HashMap(); + Map underListing = dir.getListing(lookup, includeDeleted); + for (Map.Entry entry : underListing.entrySet()) + { + if (entry.getValue().getType() == AVMNodeType.LAYERED_DIRECTORY || + entry.getValue().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(entry.getValue(), PermissionService.READ_CHILDREN)) + { + continue; + } + } + listing.put(entry.getKey(), entry.getValue()); + } } } for (ChildEntry entry : AVMDAOs.Instance().fChildEntryDAO.getByParent(this)) { + if (entry.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY || + entry.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(entry.getChild(), PermissionService.READ_CHILDREN)) + { + continue; + } + } if (!includeDeleted && entry.getChild().getType() == AVMNodeType.DELETED_NODE) { listing.remove(entry.getKey().getName()); @@ -416,6 +428,14 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec Map listing = new HashMap(); for (ChildEntry entry : AVMDAOs.Instance().fChildEntryDAO.getByParent(this)) { + if (entry.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY || + entry.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(entry.getChild(), PermissionService.READ_CHILDREN)) + { + continue; + } + } if (includeDeleted || entry.getChild().getType() != AVMNodeType.DELETED_NODE) { listing.put(entry.getKey().getName(), entry.getChild()); @@ -438,6 +458,14 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec for (ChildEntry child : children) { AVMNode childNode = child.getChild(); + if (childNode.getType() == AVMNodeType.LAYERED_DIRECTORY || + childNode.getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(childNode, PermissionService.READ_CHILDREN)) + { + continue; + } + } if (!includeDeleted && childNode.getType() == AVMNodeType.DELETED_NODE) { continue; @@ -471,18 +499,34 @@ class LayeredDirectoryNodeImpl extends DirectoryNodeImpl implements LayeredDirec { DirectoryNode dirNode = (DirectoryNode)lookup.getCurrentNode(); Map listing = dirNode.getListing(lookup, includeDeleted); - for (String name : listing.keySet()) + for (Map.Entry entry : listing.entrySet()) { - baseListing.put(name, - listing.get(name).getDescriptor(dir.getPath(), name, - lookup.getCurrentIndirection(), - lookup.getCurrentIndirectionVersion())); + if (entry.getValue().getType() == AVMNodeType.LAYERED_DIRECTORY || + entry.getValue().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(entry.getValue(), PermissionService.READ_CHILDREN)) + { + continue; + } + } + baseListing.put(entry.getKey(), + entry.getValue().getDescriptor(dir.getPath(), entry.getKey(), + lookup.getCurrentIndirection(), + lookup.getCurrentIndirectionVersion())); } } } List children = AVMDAOs.Instance().fChildEntryDAO.getByParent(this); for (ChildEntry child : children) { + if (child.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY || + child.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(child.getChild(), PermissionService.READ_CHILDREN)) + { + continue; + } + } if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE) { baseListing.remove(child.getKey().getName()); diff --git a/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java b/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java index 75adb45c0f..50025827fe 100644 --- a/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java +++ b/source/java/org/alfresco/repo/avm/PlainDirectoryNodeImpl.java @@ -34,6 +34,7 @@ import org.alfresco.service.cmr.avm.AVMBadArgumentException; import org.alfresco.service.cmr.avm.AVMExistsException; import org.alfresco.service.cmr.avm.AVMNodeDescriptor; import org.alfresco.service.cmr.avm.AVMNotFoundException; +import org.alfresco.service.cmr.security.PermissionService; import org.alfresco.util.Pair; /** @@ -110,6 +111,14 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory List children = AVMDAOs.Instance().fChildEntryDAO.getByParent(this); for (ChildEntry child : children) { + if (child.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY || + child.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(child.getChild(), PermissionService.READ_CHILDREN)) + { + continue; + } + } if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE) { continue; @@ -156,6 +165,14 @@ class PlainDirectoryNodeImpl extends DirectoryNodeImpl implements PlainDirectory List children = AVMDAOs.Instance().fChildEntryDAO.getByParent(this); for (ChildEntry child : children) { + if (child.getChild().getType() == AVMNodeType.LAYERED_DIRECTORY || + child.getChild().getType() == AVMNodeType.PLAIN_DIRECTORY) + { + if (!AVMRepository.GetInstance().can(child.getChild(), PermissionService.READ_CHILDREN)) + { + continue; + } + } if (!includeDeleted && child.getChild().getType() == AVMNodeType.DELETED_NODE) { continue;