cancel
Showing results for 
Search instead for 
Did you mean: 

Is a Web Script the answer?

ndtreviv
Champ in-the-making
Champ in-the-making
Hi,

I'm totally 100% new to Alfresco. I have some training as a Java developer. What I need is something to grab the physical location of a file, and all of it's details and meta data and send that information off to an external application. That external application will then return a success indicator, which I want to register amongst the file's meta data.

Would I use a Web Script to do this? Or write my own custom action?

I've been reading around the wiki and trying to get my newbie head around the various terminologies - as a result I'm feeling very stupid today  Smiley Sad

Any help would be very much appreciated!

Thanks.
4 REPLIES 4

jbarmash
Champ in-the-making
Champ in-the-making
Welcome to Alfresco. 

It sounds from what you are saying is that you need Alfresco to initiate the action.  Since web scripts is request-response, then a custom action might be better.  The user can then trigger the action manually, or you can also configure that action to act as a rule to that space, and automatically get triggered when new content is posted, if this is something you need to do. 

By the way, as you look through things, check out this page - http://wiki.alfresco.com/wiki/Special:Categories.  I've been spending a bunch of time to improve categorization of the pages, I think it's a good way to find information you need, especially when you are not sure what to search for yet.

Also, Jeff Potts from Optaros wrote some great tutorials - check out http://www.ecmarchitect.com.  Also, for creating custom action, the SDK contains a Sample to get you started. 

Cheers,

Jean

ndtreviv
Champ in-the-making
Champ in-the-making
Unfortunately I have no experience with the Spring framework, which I think is getting me down. Also, the more I try and get my head around stuff the more confused I get.

For example, I've tried writing my own Web Script. It all works perfectly until I add a js file, when it stops working. I don't understand how the js file and the tpl relate to each other at all. Normally we'd stick js either in an external file or in with the display information, therefore blurring the lines between js and tpl. How does the script relate to the template in real-time with this system?

I followed the example for backing up a file that was on the wiki, but made some changes to create a folder. The problem is that half the objects don't exist and I don't know how to create them. eg:
space.childByNamePath("Backup")
throws the exception describing that space is not an object.

I'm guessing that the web script needs to run in context of the full application, so viewing my web script directly as suggested in http://wiki.alfresco.com/wiki/Web_Scripts#Invoking_a_Web_Script is useless because it doesn't work.

What I need is an "Alfresco for Nonces" or something that explains it from the viewpoint of someone coming from a "simpler" (err…stupid-er?) background. I've developed for and used a number of different CMS's and we've even written our own DMS' in the past, so it's not like I'm a complete idiot. I absolutely KNOW that this application contains everything we need and more, but unless I can start to make sense of it within the deadlines I have, I'm really not going to persuade my boss' that it's the right thing.

The How-To on that site does look good - I'm guessing you mean this one: http://www.ecmarchitect.com/images/articles/alfresco-actions/actions-article.pdf except that - as it admits - it doesn't really do a lot more than the built-in move, and on top of that it doesn't really explain the objects it's using, such as the magical nodeService object…? 

Errr…think I'm gonna quit and become a bin-man or something Smiley Sad

Nothing for it. I'm installing the SDK. Or attempting to…

jbarmash
Champ in-the-making
Champ in-the-making
I am a bit confused - are you trying to write a web script, or an action?

Unfortunately I have no experience with the Spring framework, which I think is getting me down. Also, the more I try and get my head around stuff the more confused I get.

It definitely takes a little bit to have your head wrapped around Spring framework - although taking the time to understand it is a good investment, since it's pretty much an industry standard for enterprise apps.   Just think of it as a configuration language, and try to follow patterns in the xml files. 

For example, I've tried writing my own Web Script. It all works perfectly until I add a js file, when it stops working. I don't understand how the js file and the tpl relate to each other at all. Normally we'd stick js either in an external file or in with the display information, therefore blurring the lines between js and tpl. How does the script relate to the template in real-time with this system?

For the Model-View-Controller, Script is the controller - it sets up the model, which Alfresco passes to the View (which can be Freemarker, XSLT, etc), which displays the model. 
Check out Jeff Pott's (ecmarchitect.com) tutorial on web scripts - I think it's a great explanation. 

I'm guessing that the web script needs to run in context of the full application, so viewing my web script directly as suggested in http://wiki.alfresco.com/wiki/Web_Scripts#Invoking_a_Web_Script is useless because it doesn't work.

The article you site assumes that you will deploy your web script before you try to invoke it - how would you expect it to work otherwise?   You start up Alfresco, and then you can invoke the script. 

What I need is an "Alfresco for Nonces" or something that explains it from the viewpoint of someone coming from a "simpler" (err…stupid-er?) background. I've developed for and used a number of different CMS's and we've even written our own DMS' in the past, so it's not like I'm a complete idiot. I absolutely KNOW that this application contains everything we need and more, but unless I can start to make sense of it within the deadlines I have, I'm really not going to persuade my boss' that it's the right thing.
The How-To on that site does look good - I'm guessing you mean this one: http://www.ecmarchitect.com/images/articles/alfresco-actions/actions-article.pdf except that - as it admits - it doesn't really do a lot more than the built-in move, and on top of that it doesn't really explain the objects it's using, such as the magical nodeService object…?

You are trying to do several things at the same time.  ECMArchitect assumes some basic familiarity with Alfresco such as core services, of which NodeService is one.   I suggest you check out the Wiki to learn more about core services, and SDK has some good samples.  Here are the Core Services - http://wiki.alfresco.com/w/index.php?title=Category:Core_Repository_Services

rdanner
Champ in-the-making
Champ in-the-making
The key here is to not get frustrated.  Break down each of your needs and try to handle them singularly. You will probably have better support in the forums if you can attack one issue at a time.

Spring is complex and at the same time – it's not so complex.  Once you get it, you'll just get it.   What is the most confusing aspect of spring to you?

Check the javascript documentation in the wiki for what model objects are available when a webscript executes.  For example, if you need to get a hold of a particular space reference you can either hard code that space in to the script or pass it in as part of the URL or a query string.  You can then use the model to get a handle to that space.