Merge branch 'feature-3.4/APPS-659_Upgrade_issue' into MNT-21132_UpgradeIncorrectLinkToFolder

This commit is contained in:
estan
2021-01-08 11:51:56 +02:00
3 changed files with 148 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- RM v3.4 Patches -->
<bean id="rm.holdChildAssocPatch"
parent="rm.parentModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.v34.RMv34HoldNewChildAssocPatch">
<property name="description" value="Create new hold child association to link the record to the hold"/>
<property name="fixesFromSchema" value="3201" />
<property name="fixesToSchema" value="3410"/>
<property name="behaviourFilter" ref="policyBehaviourFilter" />
<property name="filePlanService" ref="filePlanService" />
<property name="holdService" ref="holdService" />
<property name="nodeService" ref="nodeService" />
</bean>
</beans>

View File

@@ -1,3 +1,3 @@
# RM Schema number
version.rm.schema=3300
version.rm.schema=3410

View File

@@ -0,0 +1,127 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2020 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* -
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
* -
* 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 <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.module.org_alfresco_module_rm.patch.v34;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
import org.alfresco.repo.policy.BehaviourFilter;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
/**
* Patch to create new hold child association to link the record to the hold
*
* See: https://alfresco.atlassian.net/browse/APPS-659
*
*
* @since 3.4.1
*/
public class RMv34HoldNewChildAssocPatch extends AbstractModulePatch
{
/**
* File plan service interface
*/
private FilePlanService filePlanService;
/**
* Hold service interface.
*/
private HoldService holdService;
/**
* Interface for public and internal node and store operations.
*/
private NodeService nodeService;
private BehaviourFilter behaviourFilter;
/**
* Setter for fileplanservice
* @param filePlanService File plan service interface
*/
public void setFilePlanService(FilePlanService filePlanService)
{
this.filePlanService = filePlanService;
}
/**
* Setter for hold service
* @param holdService Hold service interface.
*/
public void setHoldService(HoldService holdService)
{
this.holdService = holdService;
}
/**
* Setter for node service
* @param nodeService Interface for public and internal node and store operations.
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public BehaviourFilter getBehaviourFilter()
{
return behaviourFilter;
}
public void setBehaviourFilter(BehaviourFilter behaviourFilter)
{
this.behaviourFilter = behaviourFilter;
}
@Override
public void applyInternal()
{
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
try
{
for (NodeRef filePlan : filePlanService.getFilePlans())
{
for (NodeRef hold : holdService.getHolds(filePlan))
{
for (ChildAssociationRef ref : nodeService.getChildAssocs(hold))
{
holdService.removeFromHold(hold, ref.getChildRef());
holdService.addToHold(hold, ref.getChildRef());
}
}
}
}
finally
{
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
}
}
}