dotCMS / core

Headless/Hybrid Content Management System for Enterprises
http://dotcms.com
Other
864 stars 467 forks source link

website viewtool doesn't return subfolder for root #28166

Closed waqasakramdot closed 1 month ago

waqasakramdot commented 7 months ago

Parent Issue

No response

Problem Statement

website viewtool to get the first tier sub-folder using root ('/') it always returns an empty list.

Steps to Reproduce

#set($f= $website.getFolder('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))

#set($ff= $website.getSubFolders($f))

$ff // here empty list

#set($f= $website.getSubFolders('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))

$f // here empty list as well

Acceptance Criteria

It should return all first-tier subfolders that live under root.

dotCMS Version

23., 24. - 24.04.05

Proposed Objective

Customer Support

Proposed Priority

Priority 4 - Trivial

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.

https://dotcms.zendesk.com/agent/tickets/115683

The workaround would be to use REST API to get first-tier subfolders, then use website viewtool.

#set($headers = $contents.getEmptyMap())
#set($discard = $headers.put("Content-Type", "application/json"))
#set($discard = $headers.put("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOExYjEiLCJlQys7DmmpXsVVGBWHzcVtpaIdvwG5eefQ"))
#set($data = '{
    "path":"//demo.dotcms.com/"
}')
#set($results = $json.post("https://demo.dotcms.com/api/v1/folder/byPath", $headers, $data))

#foreach ($e in $results.entity)

$e.path

#end

Assumptions & Initiation Needs

No response

Quality Assurance Notes & Workarounds

No response

Sub-Tasks & Estimates

No response

dsolistorres commented 2 months ago

The behavior is expected in the first case:

#set($f= $website.getFolder('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))
#set($ff= $website.getSubFolders($f))
$ff // here empty list

dotCMS by design doesn't return a different root folder for every site, it only uses one system folder that is the one root folder on the system, and it belong to the System Host. So this line:

#set($f= $website.getFolder('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))

Returns the system folder, and this other line:

#set($ff= $website.getSubFolders($f))

Returns an empty list of sub folders for the system folder, as expected.

On the other hand, for the second case, it is a bug because this code should return the sub folder list under the host root path:

#set($f= $website.getSubFolders('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))
$f // here empty list as well
gortiz-dotcms commented 3 weeks ago

Passed internal QA

The second case that was a bug is returning the correct sub folder list

screenshot screenshot2
josemejias11 commented 3 weeks ago

Approved: Tested on trunk_9af96d6, Docker, macOS 14.5, FF v126.0.1

#set($f= $website.getFolder('/', '48190c8c-42c4-46af-8d1a-0cd5db894797'))
$f
com.dotmarketing.portlets.folders.model.Folder@67202dd2[
    identifier=bc9a1d37-dd2d-4d49-a29d-0c9be740bfaf,
    name=system folder,
    sortOrder=0,
    showOnMenu=false,
    hostId=SYSTEM_HOST,
    type=folder,
    title=System folder,
    filesMasks=,
    defaultFileType=33888b6f-7a8e-4069-b1b6-5c1aa9d0a48d,
    modDate=2017-03-07 18:25:58.116,
    owner=system,
    iDate=2009-10-08 20:27:18.0,
    inode=SYSTEM_FOLDER,
    path=/
]