cancel
Showing results for 
Search instead for 
Did you mean: 

Webscript in order to create folders automatically

rplana6
Champ in-the-making
Champ in-the-making
Hi to everybody,

I am trying to create folders automatically using a web script. I am completely new in Alfresco and I've been studying the documentation published in the official website: https://wiki.alfresco.com/wiki/Web_Scripts. Even having carefully studied all this documentation I cannot write a good script in order to automatically create folders with particular permissions. I tried to codify the file “.get.js” according to website https://wiki.alfresco.com/wiki/5.0_JavaScript_API using "Modifying and Creating API" but it doesn't work.

I've also looked up examples in the Internet but I didn't find anything useful. Is there anybody who can help me please? Giving me a whole example with all files needed (“get.config.xml”, “.get.desc.xml”, “.get.html.ftl”, “.get.js”…) would be really helpful.

Thaks in advance,
Roberto
5 REPLIES 5

resplin
Elite Collaborator
Elite Collaborator
The official documentation on this subject is pretty good:

http://docs.alfresco.com/5.0/concepts/ws-webscripts.html

You should also look at the examples in the DataDictionary folder of your repository.

And this tutorial:

http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html

rplana6
Champ in-the-making
Champ in-the-making
Hi resplin,

Sorry for not answering before but I've been really busy the last days and I couldn't respond properly. Thanks for all the information. It has been really helpful and I could design a webscript which works perfectly.

Right know I'd like to import data from a csv file via a webscript. My issue is to create some folders using names given via csv file. Is that possible? If the possibilities exists, could you please tell me the way to carry it out?

Thanks again!
Roberto

Hi Roberto,

I don't know if you did implement a Java-backed Web Script when you looked at Jeff Potts blog about it, if you did you are half way there already. In the Java controller, use something like Apache POI to open up the CSV file and read the folder names, then use FileFolder Service or Node Service to create the folder names.
If you implemented a JavaScript controller you will not be able to read the CSV so change to a Java-backed controller instead.

Let me know how you get along,

rplana6
Champ in-the-making
Champ in-the-making
Hi gravitonian,

First of all thank you for your quick answer. Unfortunately I implemented a JavaScript controller which works perfectly, I am pretty new in alfresco and I am not familiar with Java-backed Web Script at all. Could you please give me an example of how to implement it? I'll be very grateful.

I really appreciate any help you can provide.
Roberto

Hi,

See the following two blog posts for example of Java-backed controller for a Web Script:
http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#postin...
http://www.marversolutions.com/wordpress/2012/03/05/creating-alfresco-share-sites-with-javascript-2n...

If you don't have a build project setup yet now might be a good time to fix that. See https://github.com/Alfresco/alfresco-sdk/