cancel
Showing results for 
Search instead for 
Did you mean: 

How can I access repository objects from Share?

gronfelt
Champ in-the-making
Champ in-the-making
I'm trying to develop a simple webscript to extend Share and I would like to access some of the methods described in the JavaScript API. However, most of them don't seem to be accessible from the Share application. If I for instance try to adress an avm-method in a Freemarker template file I will only get a parsing error stating that avm is not defined.

So, what would be the proper way to access the repository from a Share webscript? Would I have to create an Explorer webscript and then call that from my Share webscript? Are there any examples showing how to do this?
4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Yes you put a web script that uses the local alfresco script API into the repo and call it from share. 

There's lots of examples already within share since this is how share works.    

Share uses an AVM repository to store its data so you may find that the scripts you need are already available.    Alternativly there's a set of WCM specific web scripts that may do what you need.

zoao
Champ in-the-making
Champ in-the-making
I do not know if I'm 100% correct, but the xxxx.get.html.ftl file is your template to format the data, he usually has access to data that are defined in the object "model". I think that the ftl files is processed in server side through Java and not Javascript. So the JavaScript API is not accessible in ftl.

Xxxx.get.js is the file (which is javascript that is processed in server side)  where put the javascript necessary to obtain and prepare the data for the template (prepare the model object). In this js file you must already have access to the Javascript API.

UPDATE: My post crossed with the post of mrogers

mrogers
Star Contributor
Star Contributor
If you look in the Remote API project you will find a bunch of web scripts which use the java script api and return data in JSON format.   For example (off the top of my head) /api/sites or /api/people

They will tend to be xxx.get.json.js

It's not mandatory to return data in json format, just useful and easiest.   You will also find scripts returning atom xml, html and raw text.

If you look into the Share code what you will see is that they get the results of these web scripts and then format the results for display.

gronfelt
Champ in-the-making
Champ in-the-making
Thanks to both of you for your informative answers, I believe I'm beginning to grasp how things are connected now.

Just to see if I understand things properly:

A Freemarker template cannot directly access the repository model objects and methods, so I would need to add js to do that. So, the proper way would be to create a web script, consisting of a js-file (typically a .get.js) that could access the repository, then create a model in the js-file, and use a freemarker template for presentation of the model. This web script could then be deployed in Share.

Is this correct, or am I still misunderstanding something?

Where are custom web scripts supposed to be placed in the Share filesystem? Is the folder structure site-webscripts/org/alfresco/ reserved for Alfresco provided web scripts?