cancel
Showing results for 
Search instead for 
Did you mean: 

Regarding making web script call as https

ruchi3
Champ in-the-making
Champ in-the-making
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
2 REPLIES 2

rogier_oudshoor
Champ in-the-making
Champ in-the-making
You can use HTTPS by either configuring your appserver (tomcat?) to do so or by using an HTTPS apache proxy with mod_jk or mod_proxy_ajp.

ruchi3
Champ in-the-making
Champ in-the-making
Thanks a lot for the reply. So, it means that if my alfresco instance is made to run on https then i can access the webscripts too as https. We do not require to do any configuration in desc.xml or nay where specific to Web Script in ALfresco to make the call as https.