mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
MNT-20145 Duplicate the content url when declaring node as record, version as record, classifying or securing if the node has copies or it is a copy
This commit is contained in:
@@ -143,7 +143,6 @@
|
||||
<property name="recordService" ref="RecordService" />
|
||||
<property name="dispositionService" ref="DispositionService" />
|
||||
<property name="quickShareService" ref="QuickShareService"/>
|
||||
<property name="fileFolderService" ref="FileFolderService"/>
|
||||
</bean>
|
||||
|
||||
<bean id="rma.recordComponentIdentifier" class="org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.RecordComponentIdentifierAspect" parent="rm.baseBehaviour">
|
||||
|
@@ -45,6 +45,7 @@
|
||||
<property name="authenticationUtil" ref="rm.authenticationUtil"/>
|
||||
<property name="transactionalResourceHelper" ref="rm.transactionalResourceHelper" />
|
||||
<property name="renditionService" ref="RenditionService" />
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
</bean>
|
||||
|
||||
<!-- Records Management Service Registry -->
|
||||
|
@@ -16,7 +16,6 @@
|
||||
<bean id="rmv.versionRecord" class="org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.VersionRecordAspect" parent="rm.baseBehaviour">
|
||||
<property name="recordableVersionService" ref="RecordableVersionService" />
|
||||
<property name="relationshipService" ref="RelationshipService" />
|
||||
<property name="fileFolderService" ref="FileFolderService"/>
|
||||
</bean>
|
||||
|
||||
<!-- extended version service bean definition -->
|
||||
|
@@ -215,21 +215,16 @@ public class ContentDestructionComponent
|
||||
// get content data
|
||||
ContentData dataContent = (ContentData)entry.getValue();
|
||||
|
||||
// destroy the node's content properties only if it doesn't have copies or it is a copy
|
||||
if (getNodeService().getTargetAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty() &&
|
||||
getNodeService().getSourceAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty())
|
||||
// if enabled cleanse content
|
||||
if (isCleansingEnabled())
|
||||
{
|
||||
// if enabled cleanse content
|
||||
if (isCleansingEnabled())
|
||||
{
|
||||
// register for cleanse then immediate destruction
|
||||
getEagerContentStoreCleaner().registerOrphanedContentUrlForCleansing(dataContent.getContentUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
// register for immediate destruction
|
||||
getEagerContentStoreCleaner().registerOrphanedContentUrl(dataContent.getContentUrl(), true);
|
||||
}
|
||||
// register for cleanse then immediate destruction
|
||||
getEagerContentStoreCleaner().registerOrphanedContentUrlForCleansing(dataContent.getContentUrl());
|
||||
}
|
||||
else
|
||||
{
|
||||
// register for immediate destruction
|
||||
getEagerContentStoreCleaner().registerOrphanedContentUrl(dataContent.getContentUrl(), true);
|
||||
}
|
||||
|
||||
// clear the property
|
||||
|
@@ -51,13 +51,9 @@ import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.quickshare.QuickShareService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.ScriptService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -98,9 +94,6 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
/** quickShare service */
|
||||
private QuickShareService quickShareService;
|
||||
|
||||
/** File folder service */
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
/** I18N */
|
||||
private static final String MSG_CANNOT_UPDATE_RECORD_CONTENT = "rm.service.update-record-content";
|
||||
|
||||
@@ -137,15 +130,6 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
this.quickShareService = quickShareService;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Behaviour to ensure renditions have the appropriate extended security.
|
||||
*
|
||||
@@ -376,12 +360,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
extendedSecurityService.remove(targetNodeRef);
|
||||
|
||||
//create a new content URL for the copy
|
||||
ContentReader reader = fileFolderService.getReader(targetNodeRef);
|
||||
if (reader != null)
|
||||
{
|
||||
ContentWriter writer = fileFolderService.getWriter(targetNodeRef);
|
||||
writer.putContent(reader);
|
||||
}
|
||||
createNewContentURL(targetNodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -402,6 +381,7 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
|
||||
/**
|
||||
* Behaviour to remove the shared link before declare a record
|
||||
* and to create new bin if the node is a copy or has copies
|
||||
*
|
||||
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy#beforeAddAspect(org.alfresco.service.cmr.repository.NodeRef,
|
||||
* org.alfresco.service.namespace.QName)
|
||||
@@ -421,6 +401,26 @@ public class RecordAspect extends AbstractDisposableItem
|
||||
quickShareService.unshareContent(sharedId);
|
||||
}
|
||||
|
||||
// if the node has a copy or is a copy of an existing node
|
||||
if (!nodeService.getTargetAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty() ||
|
||||
!nodeService.getSourceAssocs(nodeRef, ContentModel.ASSOC_ORIGINAL).isEmpty())
|
||||
{
|
||||
//disabling versioning and auditing
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.disableBehaviour(ContentModel.ASPECT_VERSIONABLE);
|
||||
try
|
||||
{
|
||||
//create a new content URL for the copy/original node
|
||||
createNewContentURL(nodeRef);
|
||||
}
|
||||
finally
|
||||
{
|
||||
//enable versioning and auditing
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_AUDITABLE);
|
||||
behaviourFilter.enableBehaviour(ContentModel.ASPECT_VERSIONABLE);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}, AuthenticationUtil.getSystemUserName());
|
||||
|
@@ -39,9 +39,6 @@ import org.alfresco.repo.policy.annotation.Behaviour;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.version.Version;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -66,9 +63,6 @@ public class VersionRecordAspect extends BaseBehaviourBean
|
||||
/** relationship service */
|
||||
private RelationshipService relationshipService;
|
||||
|
||||
/** File folder service */
|
||||
private FileFolderService fileFolderService;
|
||||
|
||||
/**
|
||||
* @param recordableVersionService recordable version service
|
||||
*/
|
||||
@@ -85,15 +79,6 @@ public class VersionRecordAspect extends BaseBehaviourBean
|
||||
this.relationshipService = relationshipService;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* If the record is a version record then delete the associated version entry
|
||||
*
|
||||
@@ -159,11 +144,6 @@ public class VersionRecordAspect extends BaseBehaviourBean
|
||||
public void beforeAddAspect(NodeRef nodeRef, QName qName)
|
||||
{
|
||||
//create a new content URL for the version record
|
||||
ContentReader reader = fileFolderService.getReader(nodeRef);
|
||||
if (reader != null)
|
||||
{
|
||||
ContentWriter writer = fileFolderService.getWriter(nodeRef);
|
||||
writer.putContent(reader);
|
||||
}
|
||||
createNewContentURL(nodeRef);
|
||||
}
|
||||
}
|
||||
|
@@ -36,8 +36,11 @@ 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.model.RecordsManagementModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.model.FileFolderService;
|
||||
import org.alfresco.service.cmr.rendition.RenditionService;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
@@ -73,7 +76,10 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
|
||||
protected AuthenticationUtil authenticationUtil;
|
||||
|
||||
/** transactional resource helper */
|
||||
protected TransactionalResourceHelper transactionalResourceHelper;
|
||||
protected TransactionalResourceHelper transactionalResourceHelper;
|
||||
|
||||
/** File folder service */
|
||||
protected FileFolderService fileFolderService;
|
||||
|
||||
/**
|
||||
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
|
||||
@@ -124,6 +130,16 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
|
||||
this.transactionalResourceHelper = transactionalResourceHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the file folder service
|
||||
*
|
||||
* @param fileFolderService file folder service
|
||||
*/
|
||||
public void setFileFolderService(FileFolderService fileFolderService)
|
||||
{
|
||||
this.fileFolderService = fileFolderService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to get internal node service.
|
||||
* <p>
|
||||
@@ -537,4 +553,15 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
|
||||
result.add(nodeService.getType(nodeRef));
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void createNewContentURL(NodeRef nodeRef)
|
||||
{
|
||||
//create a new content URL for the copy
|
||||
ContentReader reader = fileFolderService.getReader(nodeRef);
|
||||
if (reader != null)
|
||||
{
|
||||
ContentWriter writer = fileFolderService.getWriter(nodeRef);
|
||||
writer.putContent(reader);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user