mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
RM-1980 (Can't delete version record if it is the last version of the document)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/modules/recordsmanagement/BRANCHES/V2.3@98190 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -223,7 +223,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
|
|
||||||
/** Relationship service */
|
/** Relationship service */
|
||||||
private RelationshipService relationshipService;
|
private RelationshipService relationshipService;
|
||||||
|
|
||||||
/** Disposition service */
|
/** Disposition service */
|
||||||
private DispositionService dispositionService;
|
private DispositionService dispositionService;
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
this.dispositionService = dispositionService;
|
this.dispositionService = dispositionService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param recordsManagementContainerType records management container type
|
* @param recordsManagementContainerType records management container type
|
||||||
*/
|
*/
|
||||||
@@ -527,8 +527,8 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// store information about the 'new' record in the transaction
|
// store information about the 'new' record in the transaction
|
||||||
// @since 2.3
|
// @since 2.3
|
||||||
// @see https://issues.alfresco.com/jira/browse/RM-1956
|
// @see https://issues.alfresco.com/jira/browse/RM-1956
|
||||||
if (bNew)
|
if (bNew)
|
||||||
{
|
{
|
||||||
Set<NodeRef> newRecords = transactionalResourceHelper.getSet(KEY_NEW_RECORDS);
|
Set<NodeRef> newRecords = transactionalResourceHelper.getSet(KEY_NEW_RECORDS);
|
||||||
@@ -544,7 +544,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
validateLinkConditions(nodeRef, parentNodeRef);
|
validateLinkConditions(nodeRef, parentNodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// create and file the content as a record
|
// create and file the content as a record
|
||||||
file(nodeRef);
|
file(nodeRef);
|
||||||
}
|
}
|
||||||
@@ -1716,7 +1716,7 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
{
|
{
|
||||||
ParameterCheck.mandatory("record", record);
|
ParameterCheck.mandatory("record", record);
|
||||||
ParameterCheck.mandatory("recordFolder", recordFolder);
|
ParameterCheck.mandatory("recordFolder", recordFolder);
|
||||||
|
|
||||||
// ensure we are linking a record to a record folder
|
// ensure we are linking a record to a record folder
|
||||||
if(isRecord(record) && isRecordFolder(recordFolder))
|
if(isRecord(record) && isRecordFolder(recordFolder))
|
||||||
{
|
{
|
||||||
@@ -1730,13 +1730,13 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
throw new RecordLinkRuntimeException("Can not link a record to the same record folder more than once");
|
throw new RecordLinkRuntimeException("Can not link a record to the same record folder more than once");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// validate link conditions
|
// validate link conditions
|
||||||
validateLinkConditions(record, recordFolder);
|
validateLinkConditions(record, recordFolder);
|
||||||
|
|
||||||
// get the current name of the record
|
// get the current name of the record
|
||||||
String name = nodeService.getProperty(record, ContentModel.PROP_NAME).toString();
|
String name = nodeService.getProperty(record, ContentModel.PROP_NAME).toString();
|
||||||
|
|
||||||
// create a secondary link to the record folder
|
// create a secondary link to the record folder
|
||||||
nodeService.addChild(
|
nodeService.addChild(
|
||||||
recordFolder,
|
recordFolder,
|
||||||
@@ -1750,14 +1750,14 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
throw new RecordLinkRuntimeException("Can only link a record to a record folder.");
|
throw new RecordLinkRuntimeException("Can only link a record to a record folder.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param record
|
* @param record
|
||||||
* @param recordFolder
|
* @param recordFolder
|
||||||
*/
|
*/
|
||||||
private void validateLinkConditions(NodeRef record, NodeRef recordFolder)
|
private void validateLinkConditions(NodeRef record, NodeRef recordFolder)
|
||||||
{
|
{
|
||||||
// ensure that the linking record folders have compatible disposition schedules
|
// ensure that the linking record folders have compatible disposition schedules
|
||||||
DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record);
|
DispositionSchedule recordDispositionSchedule = dispositionService.getDispositionSchedule(record);
|
||||||
if (recordDispositionSchedule != null)
|
if (recordDispositionSchedule != null)
|
||||||
@@ -1815,14 +1815,24 @@ public class RecordServiceImpl extends BaseBehaviourBean
|
|||||||
)
|
)
|
||||||
public void beforeDeleteNode(NodeRef nodeRef)
|
public void beforeDeleteNode(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
NodeRef versionedNodeRef = (NodeRef) nodeService.getProperty(nodeRef, PROP_VERSIONED_NODEREF);
|
final NodeRef versionedNodeRef = (NodeRef) nodeService.getProperty(nodeRef, PROP_VERSIONED_NODEREF);
|
||||||
if (versionedNodeRef != null)
|
if (versionedNodeRef != null)
|
||||||
{
|
{
|
||||||
String versionLabel = (String) nodeService.getProperty(nodeRef, PROP_VERSION_LABEL);
|
String versionLabel = (String) nodeService.getProperty(nodeRef, PROP_VERSION_LABEL);
|
||||||
if (isNotBlank(versionLabel))
|
if (isNotBlank(versionLabel))
|
||||||
{
|
{
|
||||||
Version version = versionService.getVersionHistory(versionedNodeRef).getVersion(versionLabel);
|
final Version version = versionService.getVersionHistory(versionedNodeRef).getVersion(versionLabel);
|
||||||
versionService.deleteVersion(versionedNodeRef, version);
|
|
||||||
|
AuthenticationUtil.runAsSystem(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork()
|
||||||
|
{
|
||||||
|
versionService.deleteVersion(versionedNodeRef, version);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user