From 7fbccecd71a484c10c176425dcedb97f7fa5e7af Mon Sep 17 00:00:00 2001 From: Dave Ward Date: Fri, 28 Aug 2009 15:26:15 +0000 Subject: [PATCH] MOB-1073: RM Ghosted Records - The setting on model class definitions (controlling archival on node deletion) is now paid attention to for aspects as well as types - Archive is on by default for aspects and off by default for types - If a node's type or any of its aspects has archiving off then it will be purged rather than archived - Only the cm:content and cm:folder types currently have archiving switched on - RM subtypes of cm:content and cm:folder plus rm:record aspect switch off archiving - A module can now include global property overrides in classpath*:alfresco/module/*/alfresco-global.properties - The RM module currently sets two global properties: system.content.eagerOrphanCleanup=true # Switches on synchronous content purging rm.ghosting.enabled=true # Enables the new RM ghosting functionality - When ghosting is switched on, for nodes with the rma:record aspect the DestroyAction synchronously removes all content properties and applies the rma:ghosted aspect - TODO: Any properties required for rma:ghosted? git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@15990 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/core-services-context.xml | 2 + config/alfresco/model/contentModel.xml | 2 + config/alfresco/model/systemModel.xml | 2 + .../repo/dictionary/M2ClassDefinition.java | 24 ++++------- .../repo/node/db/DbNodeServiceImpl.java | 41 +++++++++++-------- 5 files changed, 40 insertions(+), 31 deletions(-) diff --git a/config/alfresco/core-services-context.xml b/config/alfresco/core-services-context.xml index 34396a9a69..cc93252202 100644 --- a/config/alfresco/core-services-context.xml +++ b/config/alfresco/core-services-context.xml @@ -22,6 +22,8 @@ classpath:alfresco/repository.properties classpath:alfresco/domain/transaction.properties + + classpath*:alfresco/module/*/alfresco-global.properties classpath*:alfresco-global.properties diff --git a/config/alfresco/model/contentModel.xml b/config/alfresco/model/contentModel.xml index 49bf9dbffc..c77f28a7a3 100644 --- a/config/alfresco/model/contentModel.xml +++ b/config/alfresco/model/contentModel.xml @@ -792,6 +792,8 @@ Working Copy + + false d:text diff --git a/config/alfresco/model/systemModel.xml b/config/alfresco/model/systemModel.xml index aba1b51b9b..3e8b6b89d6 100644 --- a/config/alfresco/model/systemModel.xml +++ b/config/alfresco/model/systemModel.xml @@ -143,6 +143,8 @@ Temporary + + false diff --git a/source/java/org/alfresco/repo/dictionary/M2ClassDefinition.java b/source/java/org/alfresco/repo/dictionary/M2ClassDefinition.java index 1996e43c04..712eae4a05 100644 --- a/source/java/org/alfresco/repo/dictionary/M2ClassDefinition.java +++ b/source/java/org/alfresco/repo/dictionary/M2ClassDefinition.java @@ -312,7 +312,7 @@ import org.alfresco.service.namespace.QName; if (parentClass != null && archive == null) { // archive not explicitly set on this class and there is a parent class - inheritedArchive = ((M2ClassDefinition)parentClass).isArchive(); + inheritedArchive = ((M2ClassDefinition)parentClass).getArchive(); } } @@ -375,23 +375,17 @@ import org.alfresco.service.namespace.QName; } /** - * @return Returns the archive flag, which defaults to false + * @return Returns the archive flag, which defaults to true for aspects and false for other classes */ public boolean isArchive() { - if (archive == null) - { - if (inheritedArchive != null) - { - return inheritedArchive.booleanValue(); - } - else - { - // default to false - return false; - } - } - return archive; + Boolean isArchive = getArchive(); + return isArchive == null ? isAspect() : isArchive.booleanValue(); + } + + protected Boolean getArchive() + { + return archive == null ? inheritedArchive : archive; } /* (non-Javadoc) diff --git a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java index d3123d4534..1b7aa16dfa 100644 --- a/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java +++ b/source/java/org/alfresco/repo/node/db/DbNodeServiceImpl.java @@ -93,8 +93,6 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl private static Log loggerPaths = LogFactory.getLog(DbNodeServiceImpl.class.getName() + ".paths"); private NodeDaoService nodeDaoService; - /** A set of aspects, the presence of which indicate that nodes must not be archived */ - private Set ignoreArchiveAspects; private StoreArchiveMap storeArchiveMap; private NodeService avmNodeService; private NodeIndexer nodeIndexer; @@ -745,24 +743,35 @@ public class DbNodeServiceImpl extends AbstractNodeServiceImpl Set nodeAspectQNames = nodeDaoService.getNodeAspects(nodeId); // check if we need to archive the node - StoreRef archiveStoreRef = null; - if (nodeAspectQNames.contains(ContentModel.ASPECT_TEMPORARY) || - nodeAspectQNames.contains(ContentModel.ASPECT_WORKING_COPY)) + StoreRef storeRef = nodeRef.getStoreRef(); + StoreRef archiveStoreRef = storeArchiveMap.get(storeRef); + + if (archiveStoreRef == null) { - // The node is either temporary or a working copy. - // It can not be archived. - requiresDelete = true; + requiresDelete = true; } else { - StoreRef storeRef = nodeRef.getStoreRef(); - archiveStoreRef = storeArchiveMap.get(storeRef); - // get the type and check if we need archiving - TypeDefinition typeDef = dictionaryService.getType(nodeTypeQName); - if (typeDef == null || !typeDef.isArchive() || archiveStoreRef == null) - { - requiresDelete = true; - } + // get the type and check if we need archiving. + TypeDefinition typeDef = dictionaryService.getType(nodeTypeQName); + if (typeDef == null || !typeDef.isArchive()) + { + requiresDelete = true; + } + else + { + // If the type wants archiving, check whether any applied aspects have explicitly turned off the + // archive flag + for (QName nodeAspectQName : nodeAspectQNames) + { + typeDef = dictionaryService.getType(nodeAspectQName); + if (typeDef != null && !typeDef.isArchive()) + { + requiresDelete = true; + break; + } + } + } } if (requiresDelete)