From 753d072f51244b9955fdace8e186b25c6619b24d Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Wed, 10 Feb 2016 12:02:37 +1100 Subject: [PATCH 01/16] Initial implementation --- .../ModuleCompatibilityComponent.java | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java new file mode 100644 index 0000000000..84fb4e7a26 --- /dev/null +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2005-2016 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode; +import org.alfresco.service.cmr.module.ModuleService; +import org.alfresco.service.descriptor.DescriptorService; +import org.springframework.context.ApplicationListener; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.event.ContextStartedEvent; + +/** + * @author Roy Wetherall + */ +public class ModuleCompatibilityComponent implements ApplicationListener +{ + private static final String RM_ENT_MODULE_ID = "alfresco-rm-enterprise-repo"; + + private DescriptorService descriptorService; + + private ModuleService moduleService; + + @Override + public void onApplicationEvent(ContextStartedEvent contextStartedEvent) + { + // get the license mode + LicenseMode licenseMode = descriptorService.getLicenseDescriptor().getLicenseMode(); + if (LicenseMode.ENTERPRISE.equals(licenseMode)) + { + // ensure RM enterprise module is installed + if (moduleService.getModule(RM_ENT_MODULE_ID) == null) + { + // log something + + // report an error + + // close the application context! + ((ConfigurableApplicationContext)contextStartedEvent.getApplicationContext()).close(); + } + } + } +} From 3d9f2b0d7b6387aa27145ab6886e60b133de6bd1 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 11 Feb 2016 14:42:23 +1100 Subject: [PATCH 02/16] Spring configuration for module compatibility component. --- .../org_alfresco_module_rm/module-context.xml | 6 ++ .../ModuleCompatibilityComponent.java | 77 ++++++++++++++++--- 2 files changed, 72 insertions(+), 11 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml index b0317256f9..c53b8475d4 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -7,6 +7,12 @@ http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd "> + + + + + + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java index 84fb4e7a26..d86a0cfb8a 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java @@ -21,38 +21,93 @@ package org.alfresco.module.org_alfresco_module_rm.bootstrap; import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode; import org.alfresco.service.cmr.module.ModuleService; import org.alfresco.service.descriptor.DescriptorService; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.event.ContextStartedEvent; /** + * Module compatibility component. + *

+ * Checks that the currently installed RM AMP licence mode matches that of the + * underlying repository. + * * @author Roy Wetherall + * @since 2.4 */ public class ModuleCompatibilityComponent implements ApplicationListener { + /** Logger */ + private static Log logger = LogFactory.getLog(ModuleCompatibilityComponent.class); + + // TODO get this from somewhere private static final String RM_ENT_MODULE_ID = "alfresco-rm-enterprise-repo"; + /** descriptor service */ private DescriptorService descriptorService; + /** module service */ private ModuleService moduleService; + /** + * @param descriptorService descriptor service + */ + public void setDescriptorService(DescriptorService descriptorService) + { + this.descriptorService = descriptorService; + } + + /** + * @param moduleService module service + */ + public void setModuleService(ModuleService moduleService) + { + this.moduleService = moduleService; + } + + /** + * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) + */ @Override public void onApplicationEvent(ContextStartedEvent contextStartedEvent) { // get the license mode LicenseMode licenseMode = descriptorService.getLicenseDescriptor().getLicenseMode(); - if (LicenseMode.ENTERPRISE.equals(licenseMode)) + + if (LicenseMode.ENTERPRISE.equals(licenseMode) && + moduleService.getModule(RM_ENT_MODULE_ID) == null) { - // ensure RM enterprise module is installed - if (moduleService.getModule(RM_ENT_MODULE_ID) == null) - { - // log something - - // report an error - - // close the application context! - ((ConfigurableApplicationContext)contextStartedEvent.getApplicationContext()).close(); - } + // running enterprise rm on community core so close application context + closeApplicationContext(contextStartedEvent.getApplicationContext(), + "Running Community Records Management Module on Enterprise Alfresco One is not a supported configuration."); + + } + else if (!LicenseMode.ENTERPRISE.equals(licenseMode) && + moduleService.getModule(RM_ENT_MODULE_ID) != null) + { + // running community rm on enterprise core so close application context + closeApplicationContext(contextStartedEvent.getApplicationContext(), + "Running Enterprise Records Management module on Community Alfresco One is not a supported configuration."); } } + + /** + * Close application context, logging message. + * + * @param applicationContext application context + * @param message closure message + */ + private void closeApplicationContext(ApplicationContext applicationContext, String message) + { + // log closure message + if (logger.isErrorEnabled()) + { + logger.error(message); + } + + // close the application context! + ((ConfigurableApplicationContext)applicationContext).close(); + } } From 19b36d664fa0da6f6770252d580f1d53e84ab5d9 Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 18 Feb 2016 12:18:00 +0200 Subject: [PATCH 03/16] RM-2937 - The destruction of records can not be completed if the metadata is set to be maintained after destruction. - ExtendedContentDestructionComoponent uses the NodeService interface which enforces capability check. ExtendedContentDestructionComoponent extends ContentDestructionComoponent from community which uses the nodeService implementation. I fixed it by using the implementation directly. - After fixing the issue I noticed the renditions nodes are not deleted which is a regression from 2.3 and there is no comment to specify this was intended so I deleted the rendition node. --- .../content/ContentDestructionComponent.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java index ee60e787ad..fc28255978 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java @@ -179,6 +179,9 @@ public class ContentDestructionComponent { // destroy renditions content destroyContent(child.getChildRef(), false); + + //delete the rendition node + getNodeService().deleteNode(child.getChildRef()); } } } From dbf123af839a139531e1ad3f6b52ff8240118d5e Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Fri, 19 Feb 2016 13:31:17 +0200 Subject: [PATCH 04/16] RM-2937 - The destruction of records can not be completed if the metadata is set to be maintained after destruction. - removed nodeService and eagerContentStoreCleaner from rm.contentDestructionComponent bean as they are already set on contentDestructionComponent - fixed the ignored boolean --- .../content/ContentDestructionComponent.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java index fc28255978..01982b6665 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/content/ContentDestructionComponent.java @@ -168,8 +168,9 @@ public class ContentDestructionComponent // We want to remove the rn:renditioned aspect, but due to the possibility // that there is Alfresco 3.2-era data with the cm:thumbnailed aspect // applied, we must consider removing it too. - if (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) || - getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED)) + if (includeRenditions + && (getNodeService().hasAspect(nodeRef, RenditionModel.ASPECT_RENDITIONED) + || getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_THUMBNAILED))) { // get the rendition assoc types Set childAssocTypes = dictionaryService.getAspect(RenditionModel.ASPECT_RENDITIONED).getChildAssociations().keySet(); From 1c3a369faace88c0fe4b108e610860a0834ed7d1 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Thu, 25 Feb 2016 12:02:13 +1100 Subject: [PATCH 05/16] Use context refresh event to ensure handler is called --- .../org_alfresco_module_rm/log4j.properties | 7 ++- .../org_alfresco_module_rm/module-context.xml | 2 +- .../ModuleCompatibilityComponent.java | 46 ++++++++++++++----- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties index 7a14ca27f5..4ea7c2623a 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -55,4 +55,9 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info # # Job debug # -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug \ No newline at end of file +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug + +# +# Module compatibility debug +# +log4j.logger.org.alfresco.module.org_alfresco_module_rm.bootstrap.ModuleCompatibilityComponent=debug \ No newline at end of file diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml index c53b8475d4..50e505c39f 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/module-context.xml @@ -10,7 +10,7 @@ - + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java index d86a0cfb8a..4833a1b282 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java @@ -26,7 +26,7 @@ import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; -import org.springframework.context.event.ContextStartedEvent; +import org.springframework.context.event.ContextRefreshedEvent; /** * Module compatibility component. @@ -37,7 +37,7 @@ import org.springframework.context.event.ContextStartedEvent; * @author Roy Wetherall * @since 2.4 */ -public class ModuleCompatibilityComponent implements ApplicationListener +public class ModuleCompatibilityComponent implements ApplicationListener { /** Logger */ private static Log logger = LogFactory.getLog(ModuleCompatibilityComponent.class); @@ -71,28 +71,52 @@ public class ModuleCompatibilityComponent implements ApplicationListener Date: Thu, 25 Feb 2016 19:37:14 +0200 Subject: [PATCH 06/16] RM-2994 : fixed issue - issue title: Copy/Move/Link actions don't take place and errors are thrown when running rules that perform them. - regression caused by RM-2072 merged forward from v2.2 - the retrying transaction helper was missing from copyTo, moveTo and linkTo beans and was causing NullPointerException - createOrResolvePath method calls getContext on a node created in the current transaction which is not visible in the new transaction and it throws a FileNotFoundException - solution: I moved the creation of the new transaction after the context was retrieved as the concurrency exception reported in RM-2072 was being caused by property updates --- .../rm-action-context.xml | 3 ++ .../impl/CopyMoveLinkFileToBaseAction.java | 47 +++++++++---------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml index 342e5dff92..0c2510f0a8 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/rm-action-context.xml @@ -791,6 +791,7 @@ + @@ -819,6 +820,7 @@ + @@ -847,6 +849,7 @@ + diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java index abc881889f..8ba3b055b1 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/action/impl/CopyMoveLinkFileToBaseAction.java @@ -116,7 +116,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr * @see org.alfresco.repo.action.executer.ActionExecuterAbstractBase#executeImpl(org.alfresco.service.cmr.action.Action, org.alfresco.service.cmr.repository.NodeRef) */ @Override - protected synchronized void executeImpl(final Action action, final NodeRef actionedUponNodeRef) + protected synchronized void executeImpl(Action action, final NodeRef actionedUponNodeRef) { String actionName = action.getActionDefinitionName(); if (isOkToProceedWithAction(actionedUponNodeRef, actionName)) @@ -139,24 +139,7 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr if (recordFolder == null) { final boolean finaltargetIsUnfiledRecords = targetIsUnfiledRecords; - recordFolder = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() - { - public NodeRef execute() throws Throwable - { - NodeRef result = null; - try - { - // get the reference to the record folder based on the relative path - result = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); - } - catch (DuplicateChildNodeNameException ex) - { - throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); - } - - return result; - } - }, false, true); + recordFolder = createOrResolvePath(action, actionedUponNodeRef, finaltargetIsUnfiledRecords); } // now we have the reference to the target folder we can do some final checks to see if the action is valid @@ -282,23 +265,39 @@ public abstract class CopyMoveLinkFileToBaseAction extends RMActionExecuterAbstr * @param targetisUnfiledRecords true is the target is in unfiled records * @return */ - private NodeRef createOrResolvePath(Action action, NodeRef actionedUponNodeRef, boolean targetisUnfiledRecords) + private NodeRef createOrResolvePath(final Action action, final NodeRef actionedUponNodeRef, final boolean targetisUnfiledRecords) { // get the starting context - NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); + final NodeRef context = getContext(action, actionedUponNodeRef, targetisUnfiledRecords); NodeRef path = context; // get the path we wish to resolve String pathParameter = (String)action.getParameterValue(PARAM_PATH); - String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); + final String[] pathElementsArray = StringUtils.tokenizeToStringArray(pathParameter, "/", false, true); if((pathElementsArray != null) && (pathElementsArray.length > 0)) { // get the create parameter Boolean createValue = (Boolean)action.getParameterValue(PARAM_CREATE_RECORD_PATH); - boolean create = createValue == null ? false : createValue.booleanValue(); + final boolean create = createValue == null ? false : createValue.booleanValue(); // create or resolve the specified path - path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, create, false); + path = retryingTransactionHelper.doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback() + { + public NodeRef execute() throws Throwable + { + NodeRef path = null; + try + { + path = createOrResolvePath(action, context, actionedUponNodeRef, Arrays.asList(pathElementsArray), targetisUnfiledRecords, + create, false); + } + catch (DuplicateChildNodeNameException ex) + { + throw new ConcurrencyFailureException("Cannot create or resolve path.", ex); + } + return path; + } + }, false, true); } return path; } From 0f80b9f992999a44845eab530c494a1e55763d91 Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Fri, 26 Feb 2016 11:51:08 +1100 Subject: [PATCH 07/16] Unit test for module compatibility component --- .../ModuleCompatibilityComponentUnitTest.java | 170 ++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponentUnitTest.java diff --git a/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponentUnitTest.java b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponentUnitTest.java new file mode 100644 index 0000000000..1e01b83837 --- /dev/null +++ b/rm-community/rm-community-repo/unit-test/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponentUnitTest.java @@ -0,0 +1,170 @@ +/* + * Copyright (C) 2005-2016 Alfresco Software Limited. + * + * This file is part of Alfresco + * + * Alfresco is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Alfresco is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ +package org.alfresco.module.org_alfresco_module_rm.bootstrap; + +import static org.mockito.Matchers.anyString; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode; +import org.alfresco.service.cmr.module.ModuleDetails; +import org.alfresco.service.cmr.module.ModuleService; +import org.alfresco.service.descriptor.Descriptor; +import org.alfresco.service.descriptor.DescriptorService; +import org.junit.Before; +import org.junit.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.springframework.context.ConfigurableApplicationContext; +import org.springframework.context.event.ContextRefreshedEvent; + +/** + * Module compatibility component unit test + * + * @author Roy Wetherall + * @since 2.4 + */ +public class ModuleCompatibilityComponentUnitTest +{ + /** mocks */ + @Mock private DescriptorService mockedDescriptorService; + @Mock private ModuleService mockedModuleService; + @Mock private ContextRefreshedEvent mockedContextRefreshedEvent; + @Mock private ConfigurableApplicationContext mockedApplicationContext; + @Mock private ModuleDetails mockedModuleDetails; + @Mock private Descriptor mockedDescriptor; + + /** object under test */ + @InjectMocks private ModuleCompatibilityComponent moduleCompatibilityComponent; + + /** + * Before test execution + */ + @Before + public void before() + { + MockitoAnnotations.initMocks(this); + + when(mockedContextRefreshedEvent.getApplicationContext()) + .thenReturn(mockedApplicationContext); + when(mockedDescriptorService.getServerDescriptor()) + .thenReturn(mockedDescriptor); + } + + /** + * Given that core community is installed + * And that RM community is installed + * When the application context is loaded + * Then it is successful + */ + @Test + public void communityOnCommunity() + { + // community core installed + when(mockedDescriptor.getLicenseMode()) + .thenReturn(LicenseMode.UNKNOWN); + + // community RM installed + when(mockedModuleService.getModule(anyString())) + .thenReturn(null); + + // on app context refresh + moduleCompatibilityComponent.onApplicationEvent(mockedContextRefreshedEvent); + + // verify close never called + verify(mockedApplicationContext, never()).close(); + + } + + /** + * Given that core community is installed + * And that RM enterprise is installed + * When the application context is loaded + * Then it fails + */ + @Test + public void enterpriseOnCommunity() + { + // community core installed + when(mockedDescriptor.getLicenseMode()) + .thenReturn(LicenseMode.UNKNOWN); + + // enterprise RM installed + when(mockedModuleService.getModule(anyString())) + .thenReturn(mockedModuleDetails); + + // on app context refresh + moduleCompatibilityComponent.onApplicationEvent(mockedContextRefreshedEvent); + + // verify close is called + verify(mockedApplicationContext).close(); + + } + + /** + * Given that core enterprise is installed + * And that RM community is installed + * When the application context is loaded + * Then it fails + */ + @Test + public void communityOnEnterprise() + { + // enterprise core installed + when(mockedDescriptor.getLicenseMode()) + .thenReturn(LicenseMode.ENTERPRISE); + + // community RM installed + when(mockedModuleService.getModule(anyString())) + .thenReturn(null); + + // on app context refresh + moduleCompatibilityComponent.onApplicationEvent(mockedContextRefreshedEvent); + + // verify close is called + verify(mockedApplicationContext).close(); + } + + /** + * Given that core enterprise is installed + * And that RM enterprise is installed + * When the application context is loaded + * Then it is successful + */ + @Test + public void enterpriseOnEnterprise() + { + // enterprise core installed + when(mockedDescriptor.getLicenseMode()) + .thenReturn(LicenseMode.ENTERPRISE); + + // enterprise RM installed + when(mockedModuleService.getModule(anyString())) + .thenReturn(mockedModuleDetails); + + // on app context refresh + moduleCompatibilityComponent.onApplicationEvent(mockedContextRefreshedEvent); + + // verify close never called + verify(mockedApplicationContext, never()).close(); + + } +} From e5e5597efc96edae7b3e6151850b707f3e29a1cc Mon Sep 17 00:00:00 2001 From: Roy Wetherall Date: Mon, 29 Feb 2016 13:52:17 +1100 Subject: [PATCH 08/16] Fixed issues with detecting correct license --- .../bootstrap/ModuleCompatibilityComponent.java | 10 +++++++++- .../ModuleCompatibilityComponentUnitTest.java | 8 ++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java index 4833a1b282..95fb4e8082 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java @@ -21,6 +21,7 @@ package org.alfresco.module.org_alfresco_module_rm.bootstrap; import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode; import org.alfresco.service.cmr.module.ModuleService; import org.alfresco.service.descriptor.DescriptorService; +import org.alfresco.service.license.LicenseDescriptor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.context.ApplicationContext; @@ -73,11 +74,18 @@ public class ModuleCompatibilityComponent implements ApplicationListener Date: Thu, 3 Mar 2016 10:50:16 +1100 Subject: [PATCH 09/16] Review feedback --- .../org_alfresco_module_rm/log4j.properties | 7 +- .../ModuleCompatibilityComponent.java | 203 +++++++++--------- 2 files changed, 103 insertions(+), 107 deletions(-) diff --git a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties index 4ea7c2623a..7a14ca27f5 100644 --- a/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties +++ b/rm-community/rm-community-repo/config/alfresco/module/org_alfresco_module_rm/log4j.properties @@ -55,9 +55,4 @@ log4j.logger.org.alfresco.module.org_alfresco_module_rm.patch=info # # Job debug # -#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug - -# -# Module compatibility debug -# -log4j.logger.org.alfresco.module.org_alfresco_module_rm.bootstrap.ModuleCompatibilityComponent=debug \ No newline at end of file +#log4j.logger.org.alfresco.module.org_alfresco_module_rm.job=debug \ No newline at end of file diff --git a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java index 95fb4e8082..c5fedd96c4 100644 --- a/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java +++ b/rm-community/rm-community-repo/source/java/org/alfresco/module/org_alfresco_module_rm/bootstrap/ModuleCompatibilityComponent.java @@ -16,6 +16,7 @@ * You should have received a copy of the GNU Lesser General Public License * along with Alfresco. If not, see . */ + package org.alfresco.module.org_alfresco_module_rm.bootstrap; import org.alfresco.service.cmr.admin.RepoUsage.LicenseMode; @@ -40,106 +41,106 @@ import org.springframework.context.event.ContextRefreshedEvent; */ public class ModuleCompatibilityComponent implements ApplicationListener { - /** Logger */ + /** Logger */ private static Log logger = LogFactory.getLog(ModuleCompatibilityComponent.class); - - // TODO get this from somewhere - private static final String RM_ENT_MODULE_ID = "alfresco-rm-enterprise-repo"; - - /** descriptor service */ - private DescriptorService descriptorService; - - /** module service */ - private ModuleService moduleService; - - /** - * @param descriptorService descriptor service - */ - public void setDescriptorService(DescriptorService descriptorService) - { - this.descriptorService = descriptorService; - } - - /** - * @param moduleService module service - */ - public void setModuleService(ModuleService moduleService) - { - this.moduleService = moduleService; - } - - /** - * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) - */ - @Override - public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) - { - // license mode - LicenseMode licenseMode = LicenseMode.UNKNOWN; - - // grab the application context - ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext(); - - // get the license mode - LicenseDescriptor license = descriptorService.getLicenseDescriptor(); - if (license != null) - { - licenseMode = license.getLicenseMode(); - } - - // determine whether RM Enterprise is installed or not - boolean isRMEnterprise = isRMEnterprise(); - - // debug log - if (logger.isDebugEnabled()) - { - logger.debug("Module compatibility information:"); - logger.debug(" Repository licence mode = " + licenseMode.toString()); - logger.debug(" RM Enterprise installed = " + isRMEnterprise); - } - - if (LicenseMode.ENTERPRISE.equals(licenseMode) && !isRMEnterprise) - { - // running enterprise rm on community core so close application context - closeApplicationContext( - applicationContext, - "Running Community Records Management Module on Enterprise Alfresco One is not a supported configuration."); - - } - else if (!LicenseMode.ENTERPRISE.equals(licenseMode) && isRMEnterprise) - { - // running community rm on enterprise core so close application context - closeApplicationContext( - applicationContext, - "Running Enterprise Records Management module on Community Alfresco One is not a supported configuration."); - } - } - - /** - * Indicates whether RM Enterprise module is installed or not. - * - * @return boolean true if RM Enterprise is installed, false otherwise - */ - private boolean isRMEnterprise() - { - return (moduleService.getModule(RM_ENT_MODULE_ID) != null); - } - - /** - * Close application context, logging message. - * - * @param applicationContext application context - * @param message closure message - */ - private void closeApplicationContext(ApplicationContext applicationContext, String message) - { - // log closure message - if (logger.isErrorEnabled()) - { - logger.error(message); - } - - // close the application context! - ((ConfigurableApplicationContext)applicationContext).close(); - } + + // TODO get this from somewhere + private static final String RM_ENT_MODULE_ID = "alfresco-rm-enterprise-repo"; + + /** descriptor service */ + private DescriptorService descriptorService; + + /** module service */ + private ModuleService moduleService; + + /** + * @param descriptorService descriptor service + */ + public void setDescriptorService(DescriptorService descriptorService) + { + this.descriptorService = descriptorService; + } + + /** + * @param moduleService module service + */ + public void setModuleService(ModuleService moduleService) + { + this.moduleService = moduleService; + } + + /** + * @see org.springframework.context.ApplicationListener#onApplicationEvent(org.springframework.context.ApplicationEvent) + */ + @Override + public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) + { + // license mode + LicenseMode licenseMode = LicenseMode.UNKNOWN; + + // grab the application context + ApplicationContext applicationContext = contextRefreshedEvent.getApplicationContext(); + + // get the license mode + LicenseDescriptor license = descriptorService.getLicenseDescriptor(); + if (license != null) + { + licenseMode = license.getLicenseMode(); + } + + // determine whether RM Enterprise is installed or not + boolean isRMEnterprise = isRMEnterprise(); + + // debug log + if (logger.isDebugEnabled()) + { + logger.debug("Module compatibility information:"); + logger.debug(" Repository licence mode = " + licenseMode.toString()); + logger.debug(" RM Enterprise installed = " + isRMEnterprise); + } + + if (LicenseMode.ENTERPRISE.equals(licenseMode) && !isRMEnterprise) + { + // running enterprise rm on community core so close application + // context + closeApplicationContext(applicationContext, + "Running Community Records Management Module on Enterprise Alfresco One is not a supported configuration."); + + } + else if (!LicenseMode.ENTERPRISE.equals(licenseMode) && isRMEnterprise) + { + // running community rm on enterprise core so close application + // context + closeApplicationContext(applicationContext, + "Running Enterprise Records Management module on Community Alfresco One is not a supported configuration."); + } + } + + /** + * Indicates whether RM Enterprise module is installed or not. + * + * @return boolean true if RM Enterprise is installed, false otherwise + */ + private boolean isRMEnterprise() + { + return (moduleService.getModule(RM_ENT_MODULE_ID) != null); + } + + /** + * Close application context, logging message. + * + * @param applicationContext application context + * @param message closure message + */ + private void closeApplicationContext(ApplicationContext applicationContext, String message) + { + // log closure message + if (logger.isErrorEnabled()) + { + logger.error(message); + } + + // close the application context! + ((ConfigurableApplicationContext) applicationContext).close(); + } } From c71c602a7d58a7a0f8148b57f504f37d51436df2 Mon Sep 17 00:00:00 2001 From: Tom Page Date: Thu, 3 Mar 2016 11:20:26 +0000 Subject: [PATCH 10/16] RM-3099 Upgrade data prep library to 1.8. This should fix the Activiti error seen when inviting users to a site. --- rm-automation/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rm-automation/pom.xml b/rm-automation/pom.xml index 3e2907907c..0b6ec0be43 100644 --- a/rm-automation/pom.xml +++ b/rm-automation/pom.xml @@ -72,7 +72,7 @@ org.alfresco.test dataprep - 1.4 + 1.8 org.alfresco.test From c8bdafe3b4e55565a64aa1f6aa34bbfd0d3b38be Mon Sep 17 00:00:00 2001 From: Ana Bozianu Date: Thu, 3 Mar 2016 18:17:17 +0200 Subject: [PATCH 11/16] RM-2770 - run check on transaction commit when the encryption key will also be stored --- .../caveat/RMCaveatConfigComponentImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java index 3462c5028c..c2733a9c98 100644 --- a/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java +++ b/rm-community/rm-community-repo/source/compatibility/org/alfresco/module/org_alfresco_module_rm/caveat/RMCaveatConfigComponentImpl.java @@ -45,6 +45,7 @@ import org.alfresco.repo.cache.SimpleCache; import org.alfresco.repo.content.ContentServicePolicies; import org.alfresco.repo.content.MimetypeMap; import org.alfresco.repo.node.NodeServicePolicies; +import org.alfresco.repo.policy.Behaviour.NotificationFrequency; import org.alfresco.repo.policy.annotation.Behaviour; import org.alfresco.repo.policy.annotation.BehaviourBean; import org.alfresco.repo.policy.annotation.BehaviourKind; @@ -219,9 +220,14 @@ public class RMCaveatConfigComponentImpl implements ContentServicePolicies.OnCon /** * @see org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy#onContentUpdate(org.alfresco.service.cmr.repository.NodeRef, boolean) + * RM-2770 - this method has to be fired on transaction commit to be able to validate the content when the content store is encrypted */ @Override - @Behaviour(kind = BehaviourKind.CLASS) + @Behaviour + ( + kind = BehaviourKind.CLASS, + notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT + ) public void onContentUpdate(NodeRef nodeRef, boolean newContent) { if (logger.isInfoEnabled()) From b1c18bb2bf1c42cb6af29a3a1f447f6bd03eeb13 Mon Sep 17 00:00:00 2001 From: onechiforescu Date: Thu, 3 Mar 2016 22:00:41 +0200 Subject: [PATCH 12/16] Trying to fix builds. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 9b7c5144b8..51db33c1af 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ ${alfresco.groupId} alfresco-platform-distribution - ${alfresco.version} + 5.1-20160302.012107-260 pom import From 33c3d219ce114bf0abc1bcd13ad2d04a5942088a Mon Sep 17 00:00:00 2001 From: onechiforescu Date: Thu, 3 Mar 2016 22:07:47 +0200 Subject: [PATCH 13/16] Trying to fix the builds. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ba6897da96..c30b3eba07 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ ${alfresco.groupId} alfresco-platform-distribution - ${alfresco.version} + 5.1-20160302.012107-260 pom import From bbf737db649ca0a1f376f4e581aa757d48d6741a Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 4 Mar 2016 08:20:45 +0000 Subject: [PATCH 14/16] Revert "Trying to fix builds." This reverts commit b1c18bb2bf1c42cb6af29a3a1f447f6bd03eeb13. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 51db33c1af..9b7c5144b8 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ ${alfresco.groupId} alfresco-platform-distribution - 5.1-20160302.012107-260 + ${alfresco.version} pom import From 18b3e62255ef61cdbc89c1313c0c6e7c289e9b6e Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 4 Mar 2016 08:18:55 +0000 Subject: [PATCH 15/16] RM-3110 Upgrade to Alfresco 5.1. This will currently break local builds, but should fix Bamboo builds. Local builds should start to pass again once 5.1 has been released. --- pom.xml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pom.xml b/pom.xml index 9b7c5144b8..eb79faaa84 100644 --- a/pom.xml +++ b/pom.xml @@ -43,11 +43,6 @@ alfresco-internal https://artifacts.alfresco.com/nexus/content/groups/private - - - alfresco-internal-staging - https://artifacts.alfresco.com/nexus/content/repositories/5.1-EA - From 8d62b3919a251e7ad7b8ee75f2fc31297510bcaf Mon Sep 17 00:00:00 2001 From: Tom Page Date: Fri, 4 Mar 2016 08:27:48 +0000 Subject: [PATCH 16/16] Revert "Trying to fix the builds." This reverts commit 33c3d219ce114bf0abc1bcd13ad2d04a5942088a. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c30b3eba07..ba6897da96 100644 --- a/pom.xml +++ b/pom.xml @@ -73,7 +73,7 @@ ${alfresco.groupId} alfresco-platform-distribution - 5.1-20160302.012107-260 + ${alfresco.version} pom import