12-04-2013 04:25 AM
public class DocumentBehavior implements NodeServicePolicies.BeforeDeleteNodePolicy {
private Behaviour beforeDeleteNode;
@Override
public void beforeDeleteNode(NodeRef nodeRef) {
//In this function I'm searching others nodes and then I'm trying delete them.
String type = (String)nodeService.getProperty(nodeRef, QName.createQName("kn", "docType"););
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
SearchParameters sp = new SearchParameters();
sp.addStore(storeRef);
sp.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
sp.setQuery("SELECT d.* FROM kn:document AS d WHERE d.cmis:objectId <> '" + nodeRef.toString() + "' AND d.kn:docType= '" + type + "'");
ResultSet resultSet = searchService.query(sp);
List<NodeRef> nodes = resultSet.getNodeRefs();
for (NodeRef node : nodes) {
if (nodeService.exists(node)) {
nodeService.deleteNode(node);
}
}
}
public void init() {
this.beforeDeleteNode = new JavaBehaviour(this, "beforeDeleteNode", NotificationFrequency.EVERY_EVENT);
this.policyComponent.bindClassBehaviour(QName.createQName(
NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), QName.createQName("kn", "document"),
this.beforeDeleteNode);
}
}
12-04-2013 04:49 AM
12-04-2013 05:03 AM
12-04-2013 08:07 AM
12-04-2013 09:37 AM
sp.setQuery("SELECT d.* FROM kn:document AS d WHERE d.cmis:objectId <> '" + nodeRef.toString() + "' AND d.kn:docType= '" + type + "'");
NamespaceService.ALFRESCO_URI, "beforeDeleteNode"), QName.createQName("kn", "document"),
this.beforeDeleteNode);
Your behaviour is bound to type "kn:document.12-04-2013 10:30 AM
12-04-2013 10:48 AM
12-04-2013 11:54 AM
12-05-2013 03:46 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.