AnsweredAssumed Answered

Chnaging the user authentication to NONE  for wcmweb scripts

Question asked by ruchi3 on Sep 1, 2009
Latest reply on Sep 23, 2009 by ruchi3
Hi! All

The requirement is that I want to access alfresco's wcm content stored in avm repository using web scripts. I am able to do it using following code
public class RandomSelectWebScript extends AbstractRepositoryWebScript
    public void execute(WebScriptRequest req, WebScriptResponse res)
        throws IOException
       // get the referenced incoming node
       NodeRef rootNodeRef = new NodeRef("avm://crweb–creator/-1;www;avm_webapps;ROOT;cms;83;NL");
       // draw a random child
       NodeRef childNodeRef = randomChild(rootNodeRef);
       // stream child back
       output(res, childNodeRef);
       catch(Exception e){
    protected NodeRef randomChild(NodeRef rootNodeRef)
        // count the number of children
       NodeRef nodeRef  = null;
       System.out.println("call randomChild:::"+rootNodeRef);
        List<FileInfo> files =;
        int fileCount = files.size();
        System.out.println("call fileCount:::"+fileCount);
        // draw random number
        int draw = (int) ((double)Math.random() * (double)fileCount);
        System.out.println("call draw:::"+draw);
        // our draw
        FileInfo fileInfo = (FileInfo) files.get(draw);
        System.out.println("call fileInfo:::"+fileInfo);
       nodeRef = fileInfo.getNodeRef();
        System.out.println("call nodeRef:::"+nodeRef);
       catch(Exception e){
       return nodeRef;


    protected void output(WebScriptResponse res, NodeRef nodeRef)
       System.out.println("call output:::"+nodeRef);
       ContentReader reader =, ContentModel.PROP_CONTENT);
        // stream back
            System.out.println("call output:::"+ res.getOutputStream());
        catch (Exception e)
           throw new WebScriptException("Unable to stream output");

The description xml is:
  <shortname>Streams a random content item</shortname>
  <description>Streams a random content item</description>
  <format default="">argument</format>
and the mapping file *context.xml is
<?xml version='1.0' encoding='UTF-8'?>


    <bean id=""
   <property name="serviceRegistry" ref="ServiceRegistry" />
Now the requirement is that I want to access this content using REST based approach in web script, providing parmeters to search the content the way it is given in this path : cms, then 83, etc –>avm://crweb–creator/-1;www;avm_webapps;ROOT;cms;83;NL. Now the problem is I want to make the user authentication for this webscript as NONE or GUEST, so that it can be even accessed by my guest users, without requiring any authentication. If I make it NONE in my description file, it doesnt allow to read the content in the AVM Node. How can I achieve it? Please help. Looking forward for your reply.
Thanks in advance.