Page tree
Skip to end of metadata
Go to start of metadata

1. Problem: naming frenzy

  • DAM assets have 3–4 names "attributes", only initially deduced from one
  • We keep trying to keep them in sync from all sorts of different ends
  • Those name attributes have different constraints
  • Upload, zip upload, import, rename, duplicate, copy-pasta... all behave slightly differently

Name attributes & constraints

  1. node name
    • cannot contain JCR-illegal characters
    • cannot contain URI-illegal characters due to URI2RepositoryMappings
      • the latter (consumer) should probably do the URI-safety job instead of forcing itself onto JCR
  2. asset name (property)
    • friendly "display name" without the file extension
    • may contain JCR-illegal characters
  3. underlying jcr:content node > fileName property
    • strictly faithful to the uploaded file name
  4. underlying jcr:content node > extension property
    • may or may not exist

DAM 2.x Canonical structure

  • master-with-spaces.png [mgnl:asset]
    • name: "master with spaces"
    • jcr:content [mgnl:resource]
      • extension: "png"
      • fileName: "master with spaces.png"

Past conventions and deviations

  • in dam 1.x, extension was stripped from fileName, hence in node name as well
  • in dam 2.0, extension was kept if fileName, but still stripped from node name
    • MGNLDAM-428 - Getting issue details... STATUS
    • inconsistent behavior between upload & zip upload; one of them preserved the extension in node name
  • in dam 2.0.2, this inconsistency was lifted
  • for some reason, many travel-demo assets contain the extension everywhere (incl. in the asset name prop)

 

2. Effect of actions

ActionAs of DAM 2.2Proposed
Upload & Zip Upload
  • start with fileName
    • (1) => validate => unique (increment at end) => node name
    • (2) => trim extension => asset name
  • start with fileName
    • (1) validate => get next increment => node name
    • (2) trim extension => append increment => asset name
  • leave fileName untouched

Duplication

(CreateAssetVariantAction)

  • start with node name => unique (increment before extension)
    • (1) => trim extension => asset name prop
    • (2) => fileName
Copy & Paste
  • start with node name => unique (increment at end)
  • currently does not update asset name or fileName
Rename
  • independent editing of node name and asset name prop
  • fileName is untouched
  • node name is ensured unique (increment at end)
  • prevent name collision early, probably by validation means
Import
  • as is—which is OK
  • import twice => error reports about same UUID whereas UUIDs don't conflict, path does
-

 

3. Ideas & Proposals

  • Unified naming process based on fileName (see table above)
  • Split unique naming constraint vs. bound properties (aka pre-save sync operations)
    • On (content) naming strategy:
      • Each content-type should decide what naming strategy to use (case-sensitivity, illegal chars...)
      • Whole concept spans much further than just DAM (more on another concept eventually)
        • users workspaces would be another example
      • ... but could be tested/implemented in DAM first
      • Inject naming strategy instead of calling Path#getValidated/UniqueLabel in different ways everywhere
      • How about strategy providing the raw "next available index"—for application to naming attributes in different ways
    • Bound properties // pre-save sync operations
      • Should be abstracted away from actions—dev shouldn't have to do/call anything
      • Could/should be done on session level, ContentDecorators to the rescue
      • Support for locking dynamically bound properties together vs. unlocking?
  • Ditch the asset name property
    • —use column formatter instead to do the extension trim
  • Stop considering spaces illegal in JCR, they're not
    • —worth an update to info.magnolia.cms.core.Path#getValidatedLabel

Side notes

  • Asset title is barely used
  • Original idea for asset variants was NOT to duplicate the binary unless modified
    • speaks for leaving fileName untouched
    • copy-paste should ALSO create a variant
  • What are suffixes for in the first place?
    • avoid JCR same-name siblings
    • give user a visible differentiator
  • We keep zip extension on directory for zip upload—doesn't make much sense
  • We never display confirmation dialogs upon conflicting pastes/renames

Resources

 

  • No labels