Initial patch code to apply disposition fix to records

This commit is contained in:
Ross Gale
2019-11-13 15:52:29 +00:00
parent 211244279a
commit 098be4c2da
7 changed files with 277 additions and 5 deletions

View File

@@ -14,5 +14,17 @@
<property name="filePlanService" ref="filePlanService"/>
<property name="nodeService" ref="nodeService"/>
</bean>
<bean id="rm.dispositionInheritancePatch"
parent="rm.parentModulePatch"
class="org.alfresco.module.org_alfresco_module_rm.patch.v24.RMv24DispositionInheritancePatch">
<property name="description" value="Fix inheritance for existing records in a hold." />
<property name="fixesToSchema" value="2501" />
<property name="targetSchema" value="2502" />
<property name="dispositionService" ref="DispositionService" />
<property name="recordService" ref="RecordService" />
<property name="nodeService" ref="nodeService" />
<property name="recordsManagementQueryDAO" ref="recordsManagementQueryDAO" />
</bean>
</beans>

View File

@@ -7,8 +7,15 @@
<parameter property="qnameId" jdbcType="BIGINT" javaType="java.lang.Long"/>
<parameter property="idValue" jdbcType="BIGINT" javaType="java.lang.String"/>
</parameterMap>
<select id="select_CountRMIndentifier" parameterMap="parameter_CountRMIndentifier" resultType="java.lang.Integer">
<resultMap id="result_NodeRefEntity" type="org.alfresco.module.org_alfresco_module_rm.query.NodeRefEntity">
<result property="protocol" column="protocol" jdbcType="VARCHAR" javaType="java.lang.String" />
<result property="identifier" column="identifier" jdbcType="VARCHAR" javaType="java.lang.String" />
<result property="uuid" column="uuid" jdbcType="VARCHAR" javaType="java.lang.String" />
</resultMap>
<select id="select_CountRMIndentifier" parameterMap="parameter_CountRMIndentifier" resultType="java.lang.Integer">
select
count(*)
from
@@ -19,5 +26,27 @@
prop.string_value = ?
</select>
<!-- Get list of node ids which reference given content url query used for RMv24DispositionInheritancePatch-->
<select id="select_RecordFoldersWithSchedules"
resultMap="result_NodeRefEntity">
select alfs.protocol, alfs.identifier, alfn.uuid
from alf_node alfn,
alf_store alfs
where alfn.id in (
select node_id
from alf_node_properties
where qname_id = (
select id
from alf_qname
where local_name = 'recordSearchHasDispositionSchedule')
and boolean_value = true )
and type_qname_id = (
select id
from alf_qname
where local_name = 'recordFolder')
and alfn.store_id = alfs.id
</select>
</mapper>

View File

@@ -1,3 +1,3 @@
# RM Schema number
version.rm.schema=2501
version.rm.schema=2502

View File

@@ -0,0 +1,120 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2019 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.v24;
import static org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel.ASPECT_DISPOSITION_LIFECYCLE;
import java.util.List;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionSchedule;
import org.alfresco.module.org_alfresco_module_rm.disposition.DispositionService;
import org.alfresco.module.org_alfresco_module_rm.patch.AbstractModulePatch;
import org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO;
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* RM v2.4 patch that ensures that file plan root containers do not inherited rules, because this is no longer enforced
* in the service code anymore.
* <p>
* See https://issues.alfresco.com/jira/browse/RM-3154
*
* @author Roy Wetherall
* @since 2.4
*/
public class RMv24DispositionInheritancePatch extends AbstractModulePatch
{
private static Log logger = LogFactory.getLog(RMv24DispositionInheritancePatch.class);
private DispositionService dispositionService;
private RecordService recordService;
private NodeService nodeService;
private RecordsManagementQueryDAO recordsManagementQueryDAO;
public void setDispositionService(DispositionService dispositionService)
{
this.dispositionService = dispositionService;
}
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
public void setRecordService(RecordService recordService)
{
this.recordService = recordService;
}
public void setRecordsManagementQueryDAO(RecordsManagementQueryDAO recordsManagementQueryDAO)
{
this.recordsManagementQueryDAO = recordsManagementQueryDAO;
}
/**
* @see AbstractModulePatch#applyInternal()
* <p>
* Checks for records added to a disposition schedule pre MNT-19967 and applys disposition step and properties
*/
@Override
public void applyInternal()
{
logger.info("***********************recordsManagementQueryDAO.getNodeRefs()***************************");
logger.info(recordsManagementQueryDAO.getRecordFoldersWithSchedules());
logger.info("***********************RMv24DispositionInheritancePatch***************************");
List<NodeRef> folders = recordsManagementQueryDAO.getRecordFoldersWithSchedules();
logger.info("folders: " + folders);
for (NodeRef folder : folders)
{
DispositionSchedule schedule = dispositionService.getDispositionSchedule(folder);
logger.info("schedule: " + schedule);
if (schedule.isRecordLevelDisposition())
{
List<NodeRef> records = recordService.getRecords(folder);
logger.info("records: " + records);
for (NodeRef record : records)
{
if (!nodeService.hasAspect(record, ASPECT_DISPOSITION_LIFECYCLE))
{
logger.info("updating record: " + record);
dispositionService.updateNextDispositionAction(record);
}
}
}
}
}
}

View File

@@ -0,0 +1,77 @@
/*
* #%L
* Alfresco Records Management Module
* %%
* Copyright (C) 2005 - 2019 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.query;
/**
* NodeRef Entity - used by {@link RecordsManagementQueryDAOImpl}.
*
* @author Tom Page
* @since 2.5.0.4
*/
public class NodeRefEntity
{
private String protocol;
private String identifier;
private String uuid;
/**
* Default constructor.
*/
public NodeRefEntity()
{
}
public String getProtocol()
{
return protocol;
}
public void setProtocol(String protocol)
{
this.protocol = protocol;
}
public String getIdentifier()
{
return identifier;
}
public void setIdentifier(String identifier)
{
this.identifier = identifier;
}
public String getUuid()
{
return uuid;
}
public void setUuid(String uuid)
{
this.uuid = uuid;
}
}

View File

@@ -27,6 +27,10 @@
package org.alfresco.module.org_alfresco_module_rm.query;
import java.util.List;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Records management query DAO
*
@@ -46,4 +50,11 @@ public interface RecordsManagementQueryDAO
* @return int count
*/
int getCountRmaIdentifier(String identifierValue);
/**
* Returns a list of nodeRef for all record folders in the system
* that have the property recordSearchHasDispositionSchedule:true
* @return List of nodeRefs
*/
public List<NodeRef> getRecordFoldersWithSchedules();
}

View File

@@ -27,11 +27,14 @@
package org.alfresco.module.org_alfresco_module_rm.query;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.repo.domain.qname.QNameDAO;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
import org.alfresco.util.Pair;
import org.mybatis.spring.SqlSessionTemplate;
@@ -45,6 +48,7 @@ import org.mybatis.spring.SqlSessionTemplate;
public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO, RecordsManagementModel
{
private static final String COUNT_IDENTIFIER = "alfresco.query.rm.select_CountRMIndentifier";
private static final String SCHEDULED_FOLDERS = "alfresco.query.rm.select_RecordFoldersWithSchedules";
/** SQL session template */
protected SqlSessionTemplate template;
@@ -97,4 +101,23 @@ public class RecordsManagementQueryDAOImpl implements RecordsManagementQueryDAO,
return result;
}
/**
* @see org.alfresco.module.org_alfresco_module_rm.query.RecordsManagementQueryDAO#getRecordFoldersWithSchedules()
*/
@Override
public List<NodeRef> getRecordFoldersWithSchedules()
{
List<NodeRefEntity> entities = template.selectList(SCHEDULED_FOLDERS);
List<NodeRef> results = new ArrayList<>();
// convert the entities to NodeRefs
for (NodeRefEntity nodeRefEntity : entities)
{
results.add(new NodeRef(nodeRefEntity.getProtocol(), nodeRefEntity.getIdentifier(), nodeRefEntity.getUuid()));
}
return results;
}
}