AnsweredAssumed Answered

Accessing WCM repository from JSP or JS scripts?

Question asked by alrice on Jun 2, 2008
Latest reply on Jun 4, 2008 by janv
Hi, I am developing a WCM site in Alfresco 2.1.2. It is apparently not possible to access the repository directly from JSP scripts, without writing custom Java code (e.g. the press releases class in the alfrescodemo project). So I am trying to use a Web Script (Javascript) instead to access the repository.

As I understand it, this method of using Web Scripts is also recommended in this thread http://forums.alfresco.com/viewtopic.php?f=29&t=12424&p=41109

I have used Web Scripts before to access the Alfresco repository; it works fine. However it is not working in this WCM context. Please advise what am I doing wrong here? I have a WCM Web project named "update". In the web client, it is listed in Company Home / Web Projects / update. There is a sub-folder named "articles". In Data Dictionary/Web Scripts I have put a test script to access the repository:
article.get.desc.xml :
<webscript>
  <shortname>SFI Update article (xml)</shortname>
  <description>Fetch an article from the repository</description>
  <url>/update/article?guest=true</url>
  <authentication>guest</authentication>
  <format default="xml"></format>
</webscript>
article.get.js:
 var tArticlesSpace = companyhome.childByNamePath( "Web Projects/update/articles" );
    if(tArticlesSpace == null)
   {
       throw "not found: Web Projects/update/articles";
   }
When I hit the web script in my browser http://myserver:8080/alfresco/service/update/article?guest=true
I get a 500 error indicating that childByNamePath could not locate the space in the repository and returned null. Where are the repository spaces, then, for WCM Web Projects ? Should the guest access work as well?

Outcomes