cancel
Showing results for 
Search instead for 
Did you mean: 

Is that possible to access HTML (static/dynamc) page on alfresco from application ?

prabakaran
Champ in-the-making
Champ in-the-making
Hi Guys,

Below is my scenario,

@RequestMapping(value = "/sample", method = RequestMethod.GET)
public String sampleMethod(Model model) {
      // Code here
      return "test/sample";
   }

here is that possible to point my HTML page on Alfresco, like below

@RequestMapping(value = "/sample", method = RequestMethod.GET)
public String sampleMethod(Model model) {
      // Code here
      return "http://localhost:8080/alfresco/d/d/workspace/SpacesStore/123f412-b1b2-4378-8b9k-16b3ed40caf8/sample";
                (or)
                return "http://localhost:8080/alfresco/public/alfresco/versions/1/sites/'+ parentFolder.getPath() + "/" + fileName;
   }

Thanks
4 REPLIES 4

marsbard
Champ in-the-making
Champ in-the-making
It looks to me like you want to read the content of the node and return that, unless I'm misreading your requirement.

Try here:

http://wiki.alfresco.com/wiki/NodeRef_cookbook#Reading_the_data_content_of_a_NodeRef_.28plain_text.2...

prabakaran
Champ in-the-making
Champ in-the-making
Thanks for your reply. In detail, I have my HTML file (sample.html) and uploaded into alfresco (into sites or user homes). Now I need to point that HTML file to render UI of my application.

muralidharand
Star Contributor
Star Contributor
Hi,
We also had similar requirement, where the business team will upload the static html files and images into specific report folder.
From Share, we will call  abstract webscript by sending the site name and file name.
Where the webscript will read the corresponding file from the report folder and returns the raw file content.

<java>

  /* This webscript on the following directory structure:
    *  - Document Library folder
    *    - Reports folder
    *      - HTML_PAGES folder
    *      - IMAGES folder
    */
    /* Identify the site */
    SiteInfo siteInfo = siteService.getSite(siteName);
   
    // Fetch the document library node
    NodeRef documentLibNodeRef = nodeService.getChildByName(siteInfo.getNodeRef(), ContentModel.ASSOC_CONTAINS, SiteService.DOCUMENT_LIBRARY);

    // Fetch the report folder node
    NodeRef reportRoot = nodeService.getChildByName(documentLibNodeRef,ContentModel.ASSOC_CONTAINS, REPORTS_ROOT);

    String fileType = null;
    if (fileName.contains(".htm"))
    {
        // Report HTML file
        fileType = HTML_PAGES;
    }
    else
    {
        // Assume everything else is an Image
        fileType = IMAGES;         
    }

    // Get the containing folder
    NodeRef fileRoot = nodeService.getChildByName(reportRoot, ContentModel.ASSOC_CONTAINS, fileType);

    // Get the file, if possible
    NodeRef fileNodeRef = nodeService.getChildByName(fileRoot, ContentModel.ASSOC_CONTAINS, fileName);

    ContentReader contentReader =  fileFolderService.getReader(fileNodeRef);
    res.setContentType (contentReader.getContentData().getMimetype());
    contentReader.getContent(res.getOutputStream());

</java>