cancel
Showing results for 
Search instead for 
Did you mean: 

Perform action/behaviour before content, on share download

otb
Champ in-the-making
Champ in-the-making
Hello,

I am rather new in alfresco, and would like to know a little more about its limitations.

To be precise, I would like to know if there is a way to perform a task over an uploaded/created content before it is stored on the file system. Complementing this task, I would like to know if there is a way to do it reverse. So a task is performed over the content to be downloaded, without modifying the file system copy.

I have thought about linking a behaviour to a custom type so it triggers on one of the beforeX policies. But don't know if the task will be executed before the filesystem content is stored or one has to modify/override the alfresco source code to do so (I hope not).

On the same side, I don't know how to perform a task before download. I can do it on every read operation with a content read policy, but it seems too much. Also, it may be that it is a Share question, and the task has to be executed on Share instead of alfresco core itself.

So here is my question. Could anybody give me a hint or two on how do behaviour/actions/share tasks relate to storage and download operations? Can tasks be executed at this point on the operation flow? Or should I execute them on the client app before the alfresco transactions have started?

Thanks


(If this topic does not belong to this forum list, sorry. Re-locate as needed)
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

executing actions / behaviors in reaction to read / download events (e.g. before or on download) are rather unusual requirements and this type of processing is currently not possible using the Alfresco policy mechanism. So in this instance, you would usually provide a special access operation (web script) that would deal with the necessary processing itself (either directly or by delegation to service / policy). This way, you could actually make sure that you only react to the correct event, since a lower level event like OnContentRead (as an alternative) would always be invoked when the content is accessed, not just when it is downloaded (e.g. for indexing purposes).

In terms of executing logic before content is stored in the file system, you have to understand the architecture of Alfresco. There is - from a purely behaviour-oriented technical perspective - no way to perform any kind of operation on content before it is stored in "a" file system. In the strictest sense, there isn't even the possibility for such logic irregardless of the approach used, as Alfresco will at least store the uploaded content as a temporary file on the local file system, before any further logic is invoked.

What you want to do is have some additional processing logic executed before it is stored in the final, backend storage. This you could achieve by implementing a custom Alfresco content store and content store writer. Based on your use case, you could implement this custom content store as a proxy / decorator which processes the content before, while and/or after it is being transferred to the backend storage.
Unfortunately, using this approach you are also not able to distinguish between uploads and internal content store moves, which may occur based on some business rules (e.g. moving from the default store to an archive store via XAM). An alternative would be to provide a special upload operation interface similar to a special download operation interface in which you are free to fully customize the way content is handled before passing it off to any storage, but can ensure you only react to proper upload requests.

I hope I this is of some help to you. The short form of this reply could be summarized as: "Using behaviours, you can only act on low-level content events, usually only after the basic logic (storage) has been executed, and may end up reacting to the wrong events due to difficulties in distinguishing real user from system internal events. Alternatives are possible, but require some custom code development."

Regards
Axel

otb
Champ in-the-making
Champ in-the-making
Sorry for the late reply. Other projects required my attention for some time and had to forget about Alfresco for about a month.

Your response has been very helpful.

It's a pity there is no "extension" way of implementing a task-before-storage layer. I was relying on Alfresco's modularity to be able to extend already existent Alfresco deployments with the functionality I am developing.

The content store writer solution was one of the initial paths I followed to try to solve the problems, but due to the limitations you just commented, the apparent ease to distribute extension solutions and the fact that these were much more specific, I switched to them. With the facts derived from your response, it looks like I will have to recover all the work on that direction.

Thanks for your help. I will comment again if I am able to find any solution for this issue.