Merge remote-tracking branch 'remotes/origin/release/V2.6' into merge-2.7/MNT_20145_RM_6758_ChangesFrom2_6

This commit is contained in:
Rodica Sutu
2019-02-25 09:19:23 +02:00
9 changed files with 459 additions and 56 deletions

View File

@@ -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.
*
@@ -351,11 +335,7 @@ public class RecordAspect extends AbstractDisposableItem
/**
* On copy complete behaviour for record aspect.
*
* @param classRef
* @param sourceNodeRef
* @param targetNodeRef
* @param copyToNewNode
* @param copyMap
* @see org.alfresco.repo.copy.CopyServicePolicies.OnCopyCompletePolicy#onCopyComplete(QName, NodeRef, NodeRef, boolean, Map)
*/
@Override
@Behaviour
@@ -376,12 +356,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 +377,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 +397,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())
{
//disable 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());

View File

@@ -34,12 +34,14 @@ import org.alfresco.module.org_alfresco_module_rm.relationship.Relationship;
import org.alfresco.module.org_alfresco_module_rm.relationship.RelationshipService;
import org.alfresco.module.org_alfresco_module_rm.version.RecordableVersionService;
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;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.version.Version;
import org.alfresco.service.namespace.QName;
/**
* rmv:versionRecord behaviour bean
@@ -52,14 +54,15 @@ import org.alfresco.service.cmr.version.Version;
defaultType = "rmv:versionRecord"
)
public class VersionRecordAspect extends BaseBehaviourBean
implements NodeServicePolicies.BeforeDeleteNodePolicy
implements NodeServicePolicies.BeforeAddAspectPolicy,
NodeServicePolicies.BeforeDeleteNodePolicy
{
/** recordable version service */
private RecordableVersionService recordableVersionService;
/** relationship service */
private RelationshipService relationshipService;
/**
* @param recordableVersionService recordable version service
*/
@@ -75,7 +78,7 @@ public class VersionRecordAspect extends BaseBehaviourBean
{
this.relationshipService = relationshipService;
}
/**
* If the record is a version record then delete the associated version entry
*
@@ -129,4 +132,18 @@ public class VersionRecordAspect extends BaseBehaviourBean
});
}
}
/**
* Behaviour to duplicate the bin before declaring a version record
*
* @see org.alfresco.repo.node.NodeServicePolicies.BeforeAddAspectPolicy#beforeAddAspect(org.alfresco.service.cmr.repository.NodeRef,
* org.alfresco.service.namespace.QName)
*/
@Override
@Behaviour(kind = BehaviourKind.CLASS, notificationFrequency = NotificationFrequency.FIRST_EVENT)
public void beforeAddAspect(NodeRef nodeRef, QName qName)
{
//create a new content URL for the version record
createNewContentURL(nodeRef);
}
}

View File

@@ -31,6 +31,7 @@ import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
import org.alfresco.model.ContentModel;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanComponentKind;
import org.alfresco.module.org_alfresco_module_rm.fileplan.FilePlanService;
import org.alfresco.module.org_alfresco_module_rm.hold.HoldService;
@@ -38,6 +39,9 @@ import org.alfresco.module.org_alfresco_module_rm.model.RecordsManagementModel;
import org.alfresco.service.cmr.dictionary.DictionaryService;
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.ContentService;
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;
@@ -71,9 +75,12 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
/** authentication helper */
protected AuthenticationUtil authenticationUtil;
/** transactional resource helper */
protected TransactionalResourceHelper transactionalResourceHelper;
protected TransactionalResourceHelper transactionalResourceHelper;
/** Content service */
protected ContentService contentService;
/**
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
@@ -124,6 +131,16 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
this.transactionalResourceHelper = transactionalResourceHelper;
}
/**
* Set the content service
*
* @param contentService content service
*/
public void setContentService(ContentService contentService)
{
this.contentService = contentService;
}
/**
* Helper to get internal node service.
* <p>
@@ -537,4 +554,30 @@ public class ServiceBaseImpl implements RecordsManagementModel, ApplicationConte
result.add(nodeService.getType(nodeRef));
return result;
}
/**
* Helper to update the given content property for the node
*
* @param nodeRef the node
* @param contentProperty the property to be updated
*/
protected void updateContentProperty(NodeRef nodeRef, QName contentProperty)
{
ContentReader reader = contentService.getReader(nodeRef, contentProperty);
if (reader != null)
{
ContentWriter writer = contentService.getWriter(nodeRef, contentProperty, true);
writer.putContent(reader);
}
}
/**
* Helper to create a new content URL for the node
*
* @param nodeRef the node
*/
protected void createNewContentURL(NodeRef nodeRef)
{
updateContentProperty(nodeRef, ContentModel.PROP_CONTENT);
}
}