cancel
Showing results for 
Search instead for 
Did you mean: 

createSite tutorial build issues

jocylincouch
Champ in-the-making
Champ in-the-making
I have posted on the site, but the tutorial is http://ecmstuff.blogspot.co.uk/2012/03/creating-alfresco-share-sites-with.html?showComment=140543547...

It contains source code to programmaticaly create a working site. Now, having identified the key steps in creating a usable site programmatically I would like to use the code. However, I have no idea how to build it and then install it.

I would like to just write the post javascript webscript; however writing a post powered webscript keeps yielding the page where I'm told that I either don't have permission, or the page does not exist etc.

I would love to know the following:

How do I build the script?
What authentication should I be using for the posts?
How can I find up-to-date docs on the REST api for the services to add people and their roles to sites?
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
I'm confused about what you are asking. From the blog post it looks like you've already created a working web script. Are you now trying to refactor it somehow? If so, can you be more specific?

Regarding the up-to-date docs on the Public API, see http://docs.alfresco.com/4.2/pra/1/concepts/pra-resources.html.

Jeff

jocylincouch
Champ in-the-making
Champ in-the-making
Apologies: The issue is that I've no idea how to build it, and I want that particular one as I don't see how to add users and their roles to sites without using a webscript. It's a really simple issue; I have the directory containing the source code for the create site which contains createSites.post.desc.xml  createSites.post.html.ftl  createSites.post.js  CreateSitesWebScript.java  login.txt  services-context.xml as expected. However I can't work out how I should go about installing these files into my alfresco server.

Where I've put webscripts before (in /opt/alfresco-4.2.f/tomcat/webapps/share/WEB-INF/classes/alfresco/site-webscripts/org/alfresco/modules) contains no java, and I also dont' see how the java is linked in to the webscript system.

Could you elucidate on this please?

jpotts
World-Class Innovator
World-Class Innovator
Descriptors, templates, and controllers go in $TOMCAT_HOME/share/WEB-INF/classes/alfresco/web-extension/site-webscripts in your own package folder structure. Java classes go in a JAR file which is then placed in $TOMCAT_HOME/share/WEB-INF/lib. The compiled Java class does not have to be in the same package structure as your web script files.

The way you tell Alfresco to use your Java controller for your web script is through Spring configuration. Here is an example spring bean configuration taken from my <a href="http://ecmarchitect.com/alfresco-developer-series-tutorials/webscripts/tutorial/tutorial.html#postin...">webscripts tutorial</a>:


<bean id="webscript.com.someco.ratings.rating.post" class="com.someco.scripts.PostRating" parent="webscript">
    <property name="ratingBean">
        <ref bean="ratingBean" />      
    </property>
    <property name="nodeService">
        <ref bean="NodeService" />
    </property>
</bean>


You can see that this particular web script has two dependencies being injected.

The critical part is that the bean id, "webscript.com.someco.ratings.rating.post" matters. The first part, "webscript" tells Alfresco this bean is going to be pointing to a web script controller. The last part, "com.someco.ratings.rating.post" is the package folder structure where my web script descriptor (and any other web script files, like templates, etc.) resides, relative to the site-webscripts folder.

Packaging all of those files and putting them in your exploded WAR manually works, but it is a bad practice. Instead, you ought to use the Alfresco Maven SDK to build an AMP, then install the AMP into your WAR. The tutorial I referenced earlier includes <a href="https://github.com/jpotts/alfresco-developer-series/tree/master/webscripts">source code</a> that takes that approach if you want to see how that works.

Jeff

jocylincouch
Champ in-the-making
Champ in-the-making
Much appreciated. Thankyou so much for your reply. I'll be giving that a go today 🙂