Re: Copy and Move macro events - a question
Robert r. Sanders wrote: You could try using a ThreadLocal... they kind of worry me, but I've seen a lot of people use them for data passing when there isn't a more straightforward way. That only keeps an object local to the current thread, so unless these things are actually executed in different threads I don't think there would be any difference. And here's the problem - the Move macro operation is performed as the combination of the Copy and Delete operations. So a _Copy_ macro event is fired whenever a _Move_ action happens. Therefore, the moved resource's ID property is changed by the Copy event handler! Sound like a design flaw to me. I haven't seen the code in that area, but would it not be possible to refactor out the common code from the copy macro and call it from both macros? The copy event could then be fired only in the copy-specific macro (that would also call the new common function for performing the actual copying). Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Copy and Move macro events - a question
Hi there! I have a problem with Macro events handling, wonder if anybody can suggest a solution. The case is rather simple. Every Webdav resource needs to have an unique ID. So when a new resource is created this property is added to its descriptor. Easily implemented using the Create content event listener. OK, now when a resource is copied the destination resource should have its ID property changed. At the same time when a resource is moved its ID property's value should not be modified. And here's the problem - the Move macro operation is performed as the combination of the Copy and Delete operations. So a _Copy_ macro event is fired whenever a _Move_ action happens. Therefore, the moved resource's ID property is changed by the Copy event handler! So the first question is - is there any easy way to determine if this Copy event is in fact issued by the Move action? I've tried a couple of alternative approaches as well. First, I attempted to restore the ID in the Move event handler. But the source's revision descriptor isn't available directly at the MacroEvent and when I try to retrieve it like this: NamespaceAccessToken nat = Domain.accessNamespace( new SecurityToken(this), event.getNamespace().getName()); SlideToken token = event.getToken(); token.setForceStoreEnlistment(true); try { NodeRevisionDescriptors sourceNrds = nat.getContentHelper(). retrieve(token, event.getSourceURI()); ... I get the org.apache.slide.structure.ObjectNotFoundException. I also tried to analyze event collections but wasn't able to figure out how to catch the moment when the Move action is committed. So I'm lost at the moment and would really appreciate any help. Thanks. Yours sincerely, Andrey. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Copy and Move macro events - a question
I have a problem with Macro events handling, wonder if anybody can suggest a solution. The case is rather simple. Every Webdav resource needs to have an unique ID. So when a new resource is created this property is added to its descriptor. Easily implemented using the Create content event listener. OK, now when a resource is copied the destination resource should have its ID property changed. At the same time when a resource is moved its ID property's value should not be modified. And here's the problem - the Move macro operation is performed as the combination of the Copy and Delete operations. So a _Copy_ macro event is fired whenever a _Move_ action happens. Therefore, the moved resource's ID property is changed by the Copy event handler! So the first question is - is there any easy way to determine if this Copy event is in fact issued by the Move action? Well, the simple solution is to analyze a stack trace... not quite elegant though so I still think I might miss something about the events... Yours sincerely, Andrey. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Copy and Move macro events - a question
You could try using a ThreadLocal... they kind of worry me, but I've seen a lot of people use them for data passing when there isn't a more straightforward way. Andrey Shulinsky wrote: Hi there! I have a problem with Macro events handling, wonder if anybody can suggest a solution. The case is rather simple. Every Webdav resource needs to have an unique ID. So when a new resource is created this property is added to its descriptor. Easily implemented using the Create content event listener. OK, now when a resource is copied the destination resource should have its ID property changed. At the same time when a resource is moved its ID property's value should not be modified. And here's the problem - the Move macro operation is performed as the combination of the Copy and Delete operations. So a _Copy_ macro event is fired whenever a _Move_ action happens. Therefore, the moved resource's ID property is changed by the Copy event handler! So the first question is - is there any easy way to determine if this Copy event is in fact issued by the Move action? I've tried a couple of alternative approaches as well. First, I attempted to restore the ID in the Move event handler. But the source's revision descriptor isn't available directly at the MacroEvent and when I try to retrieve it like this: NamespaceAccessToken nat = Domain.accessNamespace( new SecurityToken(this), event.getNamespace().getName()); SlideToken token = event.getToken(); token.setForceStoreEnlistment(true); try { NodeRevisionDescriptors sourceNrds = nat.getContentHelper(). retrieve(token, event.getSourceURI()); ... I get the org.apache.slide.structure.ObjectNotFoundException. I also tried to analyze event collections but wasn't able to figure out how to catch the moment when the Move action is committed. So I'm lost at the moment and would really appreciate any help. Thanks. Yours sincerely, Andrey. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Robert r. Sanders Chief Technologist iPOV (334) 821-5412 www.ipov.net - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]