cancel
Showing results for 
Search instead for 
Did you mean: 

Simple question concerning content rules

hbf
Champ on-the-rise
Champ on-the-rise
Hi,

I've just read an Alfresco Book where it is described how documents can be converted to other formats (e.g., doc to PDF) using Content Rules. I have two questions to this: Suppose I need to provide all documents as PDFs and ODFs, in addition to the source format.

    1. Is "the Alfresco way" for doing this to have two folders "PDFs" and "ODFs" in each (sub)space and add a Content Rule to generate a copy in PDF- and ODF-format in the folders "PDFs" and "ODFs", respectively? (It seems to me that having only two folders "PDFs" and "ODFs" somewhere at the root level is not enough as name collision might occur: "a.doc" occurs in a space and also in a subspace, for instance.)

    2. Does such a Content Rule take into account that content can be renamed? I.e., if "a.doc" is renamed to "b.doc", will "PDFs/a.pdf" automatically be renamed to "PDFs/b.pdf"? Are deletions handled, too? I suppose I have to add additional Content Rules for these tasks, right?
Thanks a lot for a short answer. I am especially interested in 1. as I am new to Alfresco and yet unsure how "things should be done".
Kaspar
5 REPLIES 5

hbf
Champ on-the-rise
Champ on-the-rise
2. Does such a Content Rule take into account that content can be renamed? I.e., if "a.doc" is renamed to "b.doc", will "PDFs/a.pdf" automatically be renamed to "PDFs/b.pdf"? Are deletions handled, too? I suppose I have to add additional Content Rules for these tasks, right?

I've given this a try: After renaming "a.doc" to "b.doc", a new file "PDFs/b.pdf" is generated but "PDFs/a.pdf" does not get removed. Also, I do not see an easy way to get rid of this file using another Content Rule. Any ideas how to tackle this?

Best,
Kaspar

kevinr
Star Contributor
Star Contributor
You can write a rule using JavaScript that performs renaming etc. as required. The Alfresco JavaScript API supports transforming documents etc. so you can write the entire rule and your business logic using JavaScript:
http://wiki.alfresco.com/wiki/JavaScript_API

Once you have created your script (and put it in "Company Home/Data Dictionary/Scripts") you choose the rule type of "Execute a script" and select your script.

Thanks,

Kevin

hbf
Champ on-the-rise
Champ on-the-rise
Kevin, thanks a lot for your reply. Very much appreciated! Now I feel like being on the right track again…

Thanks,
Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
You can write a rule using JavaScript that performs renaming etc. as required.

Is there a way for a transformed piece of content (like a PDF generated from a DOC) to get informed when its "source" (the DOC) gets edited/renamed/deleted? Does the Alfresco Java API provide such a facility? If so, could somebody (in a sentence or two) point me to the right place?

I am asking because transformations without renaming/deletion support seem like an incomplete feature to me: imagine a thousand rename operations that result in a thousand transformed files lying around uselessly. (When I say this, I don't want to criticise, of course. I have only seen a small part of Alfresco and yet so many nice things…) – So should a file a "feature request" or is it like this by design?

Thanks,
Kaspar

hbf
Champ on-the-rise
Champ on-the-rise
Has anybody tried to name transformations with the node-id of the original content item? I.e., the content item "Blabla.txt" with node-id 37cdb21b-5c92-11dc-85f4-35a2aa034c21 gets transformed to "ODF/37cdb21b-5c92-11dc-85f4-35a2aa034c21.odf".

(This approach solves the issues of file renaming: if "Blabla.txt" gets renamed, its node-id stays the same so there is no need to rename the transformations. The issue of deletion is easy to handle with a script.)

Has anybody tried this and made bad experiences?

Kaspar