Skip to content

[SPIKE] Implement Open Folder Endpoint #33242

Closed
Closed

Description

@fabrizzio-dotCMS

Task Title

Implement Open Folder Endpoint

Description

We need a new endpoint called Open Folder.
The purpose is to retrieve all immediate child folders of a given folder path.
• Input: a folder path (passed in the request body, not in the URL).
• Output: a list of folders that are direct children of the folder in that path.
• No recursive/deep traversal is needed.
• No assets should be included in the response (only folders).

This endpoint will simplify and speed up the construction of folder paths by reducing the number of requests needed.

Acceptance Criteria

Must use POST for passing the path (never in the URL).
• Request body should contain:
• siteName (string)
• path (string)
• Return only the first-level children folders inside the given folder.
• Exclude assets and deeper descendant folders.
• Response should include folder metadata (e.g., identifier, name, title, path).
• Endpoint must be POST only (no GET, no query params).
• Request body includes siteName and path.
• Returns only folders (no assets).
• Returns only immediate children, no nested traversal.
• Includes folder metadata (identifier, name, title, path).
• Returns an empty list if the folder has no child folders.
• Returns a 404 if the folder/path does not exist.

Priority

Medium

Additional Context

Example Request:

POST /api/open-folder
Content-Type: application/json

{
  "siteName": "demo.dotcms.com",
  "path": "/assets"
}

Example Response:

{
  "entity": {
    "identifier": "folder123",
    "title": "Images",
    "name": "images",
    "path": "/assets/images",
    "hasChildren": true,
    "modDate": "2025-05-25T12:00:00Z",
    "allowedExtensions": ["jpg", "png"],
    "subFolders": [
      {
        "identifier": "subfolder1",
        "title": "Products",
        "name": "products",
        "path": "/assets/images/products",
        "hasChildren": false,
        "modDate": "2025-05-24T10:00:00Z",
        "allowedExtensions": ["jpg", "png"],
      },
      {
        "identifier": "subfolder2",
        "title": "Banners",
        "name": "banners",
        "path": "/assets/images/banners",
        "hasChildren": true,
        "modDate": "2025-05-23T15:30:00Z",
        "allowedExtensions": ["jpg", "png"],
      }
    ]
  },
  "errors": [],
  "messages": [],
  "i18nMessagesMap": {},
  "permissions": ["READ", "WRITE"],
  "pagination": null
}

Activity

  1. moved this from New to Current Sprint Backlog in dotCMS - Product Planningon Sep 10, 2025
  2. jdotcms commented on Sep 10, 2025

    @jdotcms
    Contributor

    isnt the BrowserResource such as this?

  3. fabrizzio-dotCMS commented on Sep 11, 2025

    @fabrizzio-dotCMS
    MemberAuthor

    Isn't the BrowserResource such as this?

    Perhaps it does. Looks like this might:

    @GET
        @Path ("/siteId/{siteId}/path/{path : .+}")
        @JSONP
        @NoCache
        @Produces({MediaType.APPLICATION_JSON})
        public final Response loadFolderAndSubFoldersByPath(@Context final HttpServletRequest httpServletRequest,
                                                          @Context final HttpServletResponse httpServletResponse,
                                                          @PathParam("siteId") final String siteId,
                                                          @PathParam("path") final String path) throws  DotDataException, DotSecurityException   {
    
            final InitDataObject initData =
                    new WebResource.InitBuilder(webResource)
                            .rejectWhenNoUser(true)
                            .requiredBackendUser(true)
                            .requiredFrontendUser(false)
                            .requestAndResponse(httpServletRequest, httpServletResponse)
                            .init();
            final User user = initData.getUser();
    
            return Response.ok(new ResponseEntityView(folderHelper.loadFolderAndSubFoldersByPath(siteId,path, user))).build(); // 200
        }
    

    need to investigate if this one does what we want.
    Thanks @jdotcms

  4. self-assigned this
    on Sep 11, 2025
  5. moved this from Current Sprint Backlog to In Progress in dotCMS - Product Planningon Sep 16, 2025
  6. fabrizzio-dotCMS commented on Sep 16, 2025

    @fabrizzio-dotCMS
    MemberAuthor

    After a quick research of both BrowserResource and FolderResource, I corroborate that we don't have an endpoint that fulfills what we want to accomplish here, as described in the requirements

    Here's a new explanation of what we want to accomplish that does not currently exist :

    We need to adjust the behavior of the new Open Folder endpoint.
    Given a path such as:
    //site/f1/f2/f3/

    the endpoint should return only the immediate child folders of each folder included in the path.

    In the above example, the response must include:
    • The direct children of f1
    • The direct children of f2
    • The direct children of f3

    This means that the endpoint should not traverse recursively beyond one level of depth per folder in the given path.

    Assuming a request like: //site/f1/f2/f3/
    The expected response must include only first-level sibiling folders within the path, like this:

    site
     └── f1
         ├── f1a
         ├── f1b
         └── f2
             ├── f2a
             └── f3
                 ├── f3a
                 └── f3b
    
  7. changed the title [-][TASK] Implement Open Folder Endpoint[/-] [+][SPIKE] Implement Open Folder Endpoint[/+] on Sep 19, 2025
  8. changed the issue type fromtoon Sep 19, 2025
  9. moved this from In Progress to Done in dotCMS - Product Planningon Sep 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions