core icon indicating copy to clipboard operation
core copied to clipboard

Content Drive BE: Folders CRUD

Open zJaaal opened this issue 7 months ago • 0 comments

🧩 Overview

This issue tracks the backend implementation of Folder CRUD operations for the new Content Drive experience in dotCMS. The goal is to support site-scoped, infinitely nested folders that behave like a modern file manager, with user-friendly metadata and permission-aware access.

For more context and information about each endpoint refer to this document.

📐 Folder Data Structure

type Folder = {
  identifier: string;              // Unique ID
  title: string;                   // User-facing label (can be duplicated)
  name: string;                    // Slug, must be unique within parent
  path: string;                    // Full path to this folder (e.g. "siteA/folder/subfolder")
  order: number;                   // Sibling sort order
  showOnMenu: boolean;             // Shown in navigation menu
  authorName: string;              // Last modified by
  modDate: string;                 // ISO8601 format ("2025-05-25T12:00:00Z")
  defaultType: 'images' | 'file';  // Type of assets supported
  allowedExtensions: string[];     // e.g. ["jpg", "png", "pdf"]
  hasChildren: boolean;            // Whether this folder has children (lazy-loaded)
  children?: Folder[];             // Only populated when explicitly fetched
};

🔐 Permissions

  • Requires a valid token — no anonymous access
  • Users will only see folders they have access to
  • Unauthorized access should return a 401 or exclude the folders from the response

🧭 Folder Hierarchy & Scope

  • Folder trees are scoped by site (e.g. site1/, site2/)
  • Supports infinite nesting
  • Child folders are lazy-loaded per path (avoid full recursion)

🌐 API Endpoints

Method Endpoint Description
GET /api/v1/folders?path=<site>/<folder> Lists folders at given path
POST /api/v1/folders Creates a new folder (in root or nested)
PUT /api/v1/folders?path=<site>/<folder> Updates folder fields
DELETE /api/v1/folders?path=<site>/<folder> Deletes folder and all contained content
PUT /api/v1/folders/move?from=<site>/<folder>&to=<site>/<folder> Moves folder and contents
PUT /api/v1/folders/copy?from=<site>/<folder>&to=<site>/<folder> Copies folder and contents

✅ Validations

  • name (slug) must be unique within the same parent
  • Field types must be validated (e.g., allowedExtensions must be an array)
  • Invalid or unauthorized actions should fail gracefully and provide enough context for the user

zJaaal avatar Jun 03 '25 13:06 zJaaal