mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
Merged DEV to HEAD
- ALF-8806 RINF 41: Lucene Removal: Fix CopyService - ALF-9028: RINF 41: Fix Aspect cm:copiedFrom - ALF-9029 RINF 49: Lucene Removal: CheckOutCheckInService API - ALF-9032: RINF 49: fixes to cm:workingcopy aspect 28996: Dev branch for De-Lucene work pending patches 29004: Evaluator runs in read-only txn 29006: Additional PermissionCheckedCollection.create method - Use an existing collection's permission check data (cut-off, etc) to wrap a new collection 29007: CopyService and CheckOutCheckInService refactors to remove Lucene CopyService: Removed cm:source property from cm:copiedfrom aspect and replaced with a cm:original association. Added CQ-based APIs to query for copies Added APIs to support bi-directional walking of copy association Fixed sundry uses of cm:copiedfrom esp. all uses related to cm:workingcopy CheckOutCheckInService: Check-out now creates a source aspect cm:checkedOut with 1:1 relationship to cm:workingcopy via cm:workingcopylink Removed explicit use of cm:workingcopy aspect and replaced it with calls to COCI API 29083: Audit tests fail when indexing is turned off. Also removed a getReader() call during rule evaluation, leading to a 'sub-action' read being recorded. 29113: NodeDAO.getNodesWithAspects supports paging 29135: Removed unused patch queries 29139: Basic patch (still terminates with error) to upgrade cm:copiedfrom and cm:workingcopy 29157: Tested patch for cm:copiedfrom and cm:workingcopy aspects git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29159 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -28,42 +28,30 @@ import org.alfresco.repo.copy.CopyBehaviourCallback;
|
||||
import org.alfresco.repo.copy.CopyDetails;
|
||||
import org.alfresco.repo.copy.CopyServicePolicies;
|
||||
import org.alfresco.repo.copy.DefaultCopyBehaviourCallback;
|
||||
import org.alfresco.repo.node.NodeServicePolicies;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
|
||||
import org.alfresco.service.cmr.lock.LockService;
|
||||
import org.alfresco.service.cmr.lock.LockStatus;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.GUID;
|
||||
|
||||
public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
{
|
||||
/**
|
||||
* Policy component
|
||||
*/
|
||||
private PolicyComponent policyComponent;
|
||||
|
||||
/**
|
||||
* The node service
|
||||
*/
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* The lock service
|
||||
*/
|
||||
private LockService lockService;
|
||||
private CheckOutCheckInService checkOutCheckInService;
|
||||
|
||||
/**
|
||||
* The working copy aspect copy behaviour callback.
|
||||
* */
|
||||
*/
|
||||
private WorkingCopyAspectCopyBehaviourCallback workingCopyAspectCopyBehaviourCallback = new WorkingCopyAspectCopyBehaviourCallback();
|
||||
|
||||
/**
|
||||
* Sets the policy component
|
||||
*
|
||||
* @param policyComponent the policy component
|
||||
*/
|
||||
public void setPolicyComponent(PolicyComponent policyComponent)
|
||||
{
|
||||
@@ -72,8 +60,6 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
|
||||
/**
|
||||
* Set the node service
|
||||
*
|
||||
* @param nodeService the node service
|
||||
*/
|
||||
public void setNodeService(NodeService nodeService)
|
||||
{
|
||||
@@ -82,14 +68,20 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
|
||||
/**
|
||||
* Set the lock service
|
||||
*
|
||||
* @param lockService the lock service
|
||||
*/
|
||||
public void setLockService(LockService lockService)
|
||||
{
|
||||
this.lockService = lockService;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param checkOutCheckInService the service dealing with working copies
|
||||
*/
|
||||
public void setCheckOutCheckInService(CheckOutCheckInService checkOutCheckInService)
|
||||
{
|
||||
this.checkOutCheckInService = checkOutCheckInService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise method
|
||||
*/
|
||||
@@ -97,19 +89,24 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
{
|
||||
// Register copy behaviour for the working copy aspect
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
|
||||
CopyServicePolicies.OnCopyNodePolicy.QNAME,
|
||||
ContentModel.TYPE_CMOBJECT,
|
||||
new JavaBehaviour(this, "getCopyCallback"));
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "getCopyCallback"),
|
||||
CopyServicePolicies.OnCopyNodePolicy.QNAME,
|
||||
ContentModel.ASPECT_WORKING_COPY,
|
||||
new JavaBehaviour(this, "getCopyCallback"));
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
CopyServicePolicies.OnCopyNodePolicy.QNAME,
|
||||
ContentModel.ASPECT_CHECKED_OUT,
|
||||
new JavaBehaviour(this, "getCopyCallback"));
|
||||
|
||||
// register onBeforeDelete class behaviour for the working copy aspect
|
||||
this.policyComponent.bindClassBehaviour(
|
||||
QName.createQName(NamespaceService.ALFRESCO_URI, "beforeDeleteNode"),
|
||||
NodeServicePolicies.BeforeDeleteNodePolicy.QNAME,
|
||||
ContentModel.ASPECT_WORKING_COPY,
|
||||
new JavaBehaviour(this, "beforeDeleteNode"));
|
||||
new JavaBehaviour(this, "beforeDeleteWorkingCopy"));
|
||||
// register onBeforeDelete class behaviour for the checked-out aspect
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,23 +114,13 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
*
|
||||
* @param nodeRef the node reference about to be deleted
|
||||
*/
|
||||
public void beforeDeleteNode(NodeRef nodeRef)
|
||||
public void beforeDeleteWorkingCopy(NodeRef nodeRef)
|
||||
{
|
||||
// Prior to deleting a working copy the lock on the origional node should be released
|
||||
// Note: we do not call cancelCheckOut since this will also attempt to delete the node is question
|
||||
if (this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY) == true &&
|
||||
this.nodeService.hasAspect(nodeRef, ContentModel.ASPECT_COPIEDFROM) == true)
|
||||
NodeRef checkedOutNodeRef = checkOutCheckInService.getCheckedOut(nodeRef);
|
||||
if (checkedOutNodeRef != null)
|
||||
{
|
||||
// Get the origional node
|
||||
NodeRef origNodeRef = (NodeRef)this.nodeService.getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE);
|
||||
if (origNodeRef != null)
|
||||
{
|
||||
if (this.lockService.getLockStatus(origNodeRef).equals(LockStatus.NO_LOCK) == false)
|
||||
{
|
||||
// Release the lock on the origional node
|
||||
this.lockService.unlock(origNodeRef);
|
||||
}
|
||||
}
|
||||
lockService.unlock(checkedOutNodeRef);
|
||||
nodeService.removeAspect(checkedOutNodeRef, ContentModel.ASPECT_CHECKED_OUT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +162,9 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
* Prevents copying off the {@link ContentModel#PROP_NAME <b>cm:name</b>} property.
|
||||
*/
|
||||
@Override
|
||||
public Map<QName, Serializable> getCopyProperties(QName classQName, CopyDetails copyDetails,
|
||||
public Map<QName, Serializable> getCopyProperties(
|
||||
QName classQName,
|
||||
CopyDetails copyDetails,
|
||||
Map<QName, Serializable> properties)
|
||||
{
|
||||
if (classQName.equals(ContentModel.ASPECT_WORKING_COPY))
|
||||
@@ -187,13 +176,12 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
// Generate a new name for a new copy of a working copy
|
||||
String newName = null;
|
||||
|
||||
// This is a copy of a working copy to a new node (not a check in). Try to derive a new name from the
|
||||
// node it is checked out from
|
||||
if (copyDetails.isTargetNodeIsNew() && copyDetails.getSourceNodeAspectQNames().contains(ContentModel.ASPECT_COPIEDFROM))
|
||||
if (copyDetails.isTargetNodeIsNew())
|
||||
{
|
||||
NodeRef checkedOutFrom = (NodeRef) copyDetails.getSourceNodeProperties().get(
|
||||
ContentModel.PROP_COPY_REFERENCE);
|
||||
if (nodeService.exists(checkedOutFrom))
|
||||
// This is a copy of a working copy to a new node (not a check in). Try to derive a new name from the
|
||||
// node it is checked out from
|
||||
NodeRef checkedOutFrom = checkOutCheckInService.getCheckedOut(copyDetails.getSourceNodeRef());
|
||||
if (checkedOutFrom != null)
|
||||
{
|
||||
String oldName = (String) nodeService.getProperty(checkedOutFrom, ContentModel.PROP_NAME);
|
||||
int extIndex = oldName.lastIndexOf('.');
|
||||
@@ -201,6 +189,10 @@ public class WorkingCopyAspect implements CopyServicePolicies.OnCopyNodePolicy
|
||||
+ "_" + GUID.generate() + oldName.substring(extIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a check-in i.e. a copy to an existing node, so keep a null cm:name
|
||||
}
|
||||
|
||||
if (newName == null)
|
||||
{
|
||||
|
Reference in New Issue
Block a user