mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
RM-5309 - Remove shared link if exists when a record is declared
This commit is contained in:
@@ -133,6 +133,7 @@
|
|||||||
<property name="extendedSecurityService" ref="ExtendedSecurityService" />
|
<property name="extendedSecurityService" ref="ExtendedSecurityService" />
|
||||||
<property name="recordService" ref="RecordService" />
|
<property name="recordService" ref="RecordService" />
|
||||||
<property name="dispositionService" ref="DispositionService" />
|
<property name="dispositionService" ref="DispositionService" />
|
||||||
|
<property name="quickShareService" ref="QuickShareService"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="rma.recordComponentIdentifier" class="org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.RecordComponentIdentifierAspect" parent="rm.baseBehaviour">
|
<bean id="rma.recordComponentIdentifier" class="org.alfresco.module.org_alfresco_module_rm.model.rma.aspect.RecordComponentIdentifierAspect" parent="rm.baseBehaviour">
|
||||||
|
@@ -33,6 +33,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.model.ContentModel;
|
import org.alfresco.model.ContentModel;
|
||||||
|
import org.alfresco.model.QuickShareModel;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
import org.alfresco.module.org_alfresco_module_rm.RecordsManagementPolicies;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
|
import org.alfresco.module.org_alfresco_module_rm.model.behaviour.AbstractDisposableItem;
|
||||||
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
import org.alfresco.module.org_alfresco_module_rm.record.RecordService;
|
||||||
@@ -46,7 +47,9 @@ import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
|
|||||||
import org.alfresco.repo.policy.annotation.Behaviour;
|
import org.alfresco.repo.policy.annotation.Behaviour;
|
||||||
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
import org.alfresco.repo.policy.annotation.BehaviourBean;
|
||||||
import org.alfresco.repo.policy.annotation.BehaviourKind;
|
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.repo.security.authentication.AuthenticationUtil.RunAsWork;
|
||||||
|
import org.alfresco.service.cmr.quickshare.QuickShareService;
|
||||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.cmr.repository.ScriptService;
|
import org.alfresco.service.cmr.repository.ScriptService;
|
||||||
@@ -64,6 +67,7 @@ import org.alfresco.service.namespace.QName;
|
|||||||
)
|
)
|
||||||
public class RecordAspect extends AbstractDisposableItem
|
public class RecordAspect extends AbstractDisposableItem
|
||||||
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
implements NodeServicePolicies.OnCreateChildAssociationPolicy,
|
||||||
|
NodeServicePolicies.OnAddAspectPolicy,
|
||||||
RecordsManagementPolicies.OnCreateReference,
|
RecordsManagementPolicies.OnCreateReference,
|
||||||
RecordsManagementPolicies.OnRemoveReference,
|
RecordsManagementPolicies.OnRemoveReference,
|
||||||
NodeServicePolicies.OnMoveNodePolicy,
|
NodeServicePolicies.OnMoveNodePolicy,
|
||||||
@@ -81,6 +85,9 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
|
|
||||||
/** record service */
|
/** record service */
|
||||||
protected RecordService recordService;
|
protected RecordService recordService;
|
||||||
|
|
||||||
|
/** quickShare service */
|
||||||
|
private QuickShareService quickShareService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param extendedSecurityService extended security service
|
* @param extendedSecurityService extended security service
|
||||||
@@ -106,6 +113,15 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
this.recordService = recordService;
|
this.recordService = recordService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param quickShareService
|
||||||
|
*/
|
||||||
|
public void setQuickShareService(QuickShareService quickShareService)
|
||||||
|
{
|
||||||
|
this.quickShareService = quickShareService;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Behaviour to ensure renditions have the appropriate extended security.
|
* Behaviour to ensure renditions have the appropriate extended security.
|
||||||
*
|
*
|
||||||
@@ -336,4 +352,30 @@ public class RecordAspect extends AbstractDisposableItem
|
|||||||
extendedSecurityService.remove(targetNodeRef);
|
extendedSecurityService.remove(targetNodeRef);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Behaviour to remove the shared link when record is declared
|
||||||
|
*
|
||||||
|
* @see org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy#onAddAspect(org.alfresco.service.cmr.repository.NodeRef,
|
||||||
|
* org.alfresco.service.namespace.QName)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Behaviour(kind = BehaviourKind.CLASS, notificationFrequency = NotificationFrequency.TRANSACTION_COMMIT)
|
||||||
|
public void onAddAspect(final NodeRef nodeRef, final QName aspectTypeQName)
|
||||||
|
{
|
||||||
|
AuthenticationUtil.runAs(new RunAsWork<Void>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Void doWork()
|
||||||
|
{
|
||||||
|
String sharedId = (String) nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDID);
|
||||||
|
if (sharedId != null)
|
||||||
|
{
|
||||||
|
quickShareService.unshareContent(sharedId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}, AuthenticationUtil.getSystemUserName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user