Google docs delete reliability improved

- Google doc remove now happens at the end of the transaction when its commited to help ensure the Alfresco state and google doc state are more likely insync
- Changed behaviour to remove content when object is deleted.  Ensures correct behaviour on check-in, cancel check-in and if a object (inlcuding folder) is deleted.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@20223 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Roy Wetherall
2010-05-13 13:10:01 +00:00
parent f9b7237eab
commit af449962c4
2 changed files with 98 additions and 48 deletions

View File

@@ -27,6 +27,7 @@ import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.BeforeCancelCheckOu
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckIn;
import org.alfresco.repo.coci.CheckOutCheckInServicePolicies.OnCheckOut;
import org.alfresco.repo.node.NodeServicePolicies;
import org.alfresco.repo.node.NodeServicePolicies.BeforeDeleteNodePolicy;
import org.alfresco.repo.node.NodeServicePolicies.OnAddAspectPolicy;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
@@ -45,7 +46,8 @@ import org.alfresco.service.namespace.QName;
public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPolicy,
CheckOutCheckInServicePolicies.OnCheckOut,
CheckOutCheckInServicePolicies.OnCheckIn,
CheckOutCheckInServicePolicies.BeforeCancelCheckOut
NodeServicePolicies.BeforeDeleteNodePolicy
//CheckOutCheckInServicePolicies.BeforeCancelCheckOut
{
/** Indicates whether behaviour is enabled or not */
boolean enabled = false;
@@ -130,9 +132,9 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
policyComponent.bindClassBehaviour(OnCheckIn.QNAME,
GoogleDocsModel.ASPECT_GOOGLEEDITABLE,
new JavaBehaviour(this, "onCheckIn", NotificationFrequency.FIRST_EVENT));
policyComponent.bindClassBehaviour(BeforeCancelCheckOut.QNAME,
GoogleDocsModel.ASPECT_GOOGLEEDITABLE,
new JavaBehaviour(this, "beforeCancelCheckOut", NotificationFrequency.FIRST_EVENT));
policyComponent.bindClassBehaviour(BeforeDeleteNodePolicy.QNAME,
GoogleDocsModel.ASPECT_GOOGLERESOURCE,
new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.FIRST_EVENT));
}
}
@@ -188,19 +190,30 @@ public class GoogleEditableAspect implements NodeServicePolicies.OnAddAspectPoli
writer.putContent(is);
// Delete the associated google resource
googleDocsService.deleteGoogleResource(nodeRef);
//googleDocsService.deleteGoogleResource(nodeRef);
nodeService.removeAspect(nodeRef, GoogleDocsModel.ASPECT_GOOGLERESOURCE);
}
}
public void beforeDeleteNode(NodeRef nodeRef)
{
if (nodeService.exists(nodeRef) == true)
{
// Delete the associated google resource
googleDocsService.deleteGoogleResource(nodeRef);
}
}
/**
* @see org.alfresco.repo.coci.CheckOutCheckInServicePolicies.BeforeCancelCheckOut#beforeCancelCheckOut(org.alfresco.service.cmr.repository.NodeRef)
*/
public void beforeCancelCheckOut(NodeRef workingCopyNodeRef)
{
if (nodeService.exists(workingCopyNodeRef) == true)
{
// Delete the associated google resource
googleDocsService.deleteGoogleResource(workingCopyNodeRef);
}
}
// public void beforeCancelCheckOut(NodeRef workingCopyNodeRef)
// {
// if (nodeService.exists(workingCopyNodeRef) == true)
// {
// // Delete the associated google resource
// googleDocsService.deleteGoogleResource(workingCopyNodeRef);
// }
// }
}