AnsweredAssumed Answered

Regarding making web script call as https

Question asked by ruchi3 on Aug 29, 2009
Latest reply on Sep 1, 2009 by ruchi3
Hi! Team

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
    {
       try{
       // get the referenced incoming node
       NodeRef rootNodeRef = new NodeRef("avm://crweb–creator/-1;www;avm_webapps;ROOT;cms;83;NL");
       System.out.println("rootNodeRef:::"+rootNodeRef);
       // draw a random child
       NodeRef childNodeRef = randomChild(rootNodeRef);
       System.out.println("childNodeRef:::"+childNodeRef);
       // stream child back
       output(res, childNodeRef);
       }
       catch(Exception e){
          e.printStackTrace();
          
       }
    }
   
    protected NodeRef randomChild(NodeRef rootNodeRef)
    {
        // count the number of children
       NodeRef nodeRef  = null;
       try{
       System.out.println("call randomChild:::"+rootNodeRef);
        List<FileInfo> files = this.services.getFileFolderService().listFiles(rootNodeRef);
        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){
          e.printStackTrace();
          
       }
       
       return nodeRef;
    }   
   

   

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


}
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. Can I give it in my desc.xml file as parameters and then access them though req attribute in the controller java class? One more important thing is CAN I MAKE THIS CALL TO WEB SCRIPT AS HTTPS. Please help. Looking forward for your reply.
Thanks in advance.
Ruchi

Outcomes