•  
     
    story #24166 apply a naming pattern on files to enforce a convention
Summary
Empty
apply a naming pattern on files to enforce a convention

When users download files for local usage, they get something standard

This is done at docman level (not Documents because the behaviour must be consistent whether user rely on the old or the new interface).

Configuration

There is a new entry in docman administration: "File pattern" that allows to define the pattern:

  • by default no pattern is applied
  • the pattern is applied at upload
    • The original filename is not kept
    • The pattern only applies on new files (existing one are left un-touched)
  • pattern is defined with variables that comes from Tuleap. There are only 4 variables available:
    • Variables are either hard coded:
      • ${ID} => corresponds to document internal id
    • Or comes from document's properties:
      • ${TITLE} => corresponds to document title
      • ${STATUS} => corresponds to hard coded "Status" field (either "Draft", "Approved" or "Rejected").
    • Or comes from document's versions
      • ${VERSION_NAME} => corresponds to last uploaded "Version name" (see screenshot bellow)

  • The pattern only apply to the basename of the file. Basename being defined by "everything to the last dot of the filename". Examples:
    • review.pdf => basename: review, extension: pdf
    • some file.pdf.docx => basename: some file.pdf, extension: docx
    • my output_docx => basename: my output_docx, no extension

Administration page:

  • Only server side validation
  • One title, one help text, one string input & a save button
  • Uses the tab based organization of pages (as in Search story)

In Document interface:

  • When pattern is defined and drag'n drop to create a new file or a new version is used, the modal for creation (or new version accordingly) is raised to allow selection of the title.

Specific case of WebDav:

  • As we don't know how WebDav client will manage this server side rename we will do tests with some clients (Cyberduck, Nautilus, Cadaver) if they don't play well with this we will desactivate webdav for project that uses pattern.

Examples

Nominal case

  • Defined pattern: ${TITLE}_${ID}_${VERSION_NAME}_${STATUS} (any char is allowed in addition to the variables that are defined with ${}
  • Document
    • Title: "my foo bar"
    • Id: 12345
    • Version name: my v 2.0
    • Status: Approved
    • Original filename: output.35.pdf
  • Generated filename will be: my foo bar_12345_my v 2.0_Approved.pdf

Creation of document

Pitfall: at file creation, there is no ${VERSION_NAME}

  • Defined pattern: ${TITLE}_${ID}_${VERSION_NAME}_${STATUS}
  • Document
    • Title: "my foo bar"
    • Id: 12345
    • Status: Draft
    • Original filename: output.35.pdf
  • Generated filename will be: my foo bar_12345__Draft.pdf

Minimal pattern

There must be at least either ${TITLE} or ${ID} variable in the pattern.

Pattern like: ${VERSION_NAME}_${STATUS} are not allowed

Filename with extended characters

As of today, file names are stripped at download to avoid clash on non ISO-8859-1 chars. In order to support titles and status we should complete the support of internationalized characters as per https://www.rfc-editor.org/rfc/rfc6266#section-6

Original filename doesn't have extension

If the original file doesn't have an extention (no .pdf) hence the final file won't have an extension either

  • Defined pattern: ${TITLE}_${STATUS}
  • Document
    • Title: "my foo bar"
    • Status: Draft
    • Original filename: output.35
  • Generated filename will be: my foo bar_Draft

New version without version name

If Version name is not defined (field is not required) the result might be a hole in the name.

  • Defined pattern: ${TITLE}-tuleap#${ID}-${VERSION_NAME}-${STATUS}
  • Document
    • Title: "my foo bar"
    • Id: 12345
    • Version: `` (empty)
    • Status: Draft
    • Original filename: output.35.pdf
  • At download, filename will be: my foo bar-tuleap#12345--Draft.pdf
Empty
Status
Empty
Done
Development
  • [ ] Does it involves User Interface? 
  • [ ] Are there any mockups?
  • [ ] Are permissions checked?
  • [ ] Does it need Javascript development?
  • [ ] Does it need a forge upgrade bucket?
  • [ ] Does it need to execute things in system events?
  • [ ] Does it impact project creation (templates)?
  • [ ] Is it exploratory?
Empty
Details
#24166
Manuel Vacelet (vaceletm)
2022-03-30 14:40
2021-11-23 11:18
3610

References
Referencing story #24166

Git commit

tuleap/tuleap/stable

Introduce filename pattern in Docman da3360fc5d
Introduce filename pattern in Document e34604967e
Support the ${TITLE} variable 13bf4bfc63
Support the ${VERSION_NAME} and ${STATUS} variable 548a7292c6
Support the ${ID} variable b7ba28b6a0
Add minimal filename patterner validation b444717d05
Be able to save the filename pattern via the UI c45a7b2c5b
feat: Move filename pattern admin in extra tabs dff53d22bd
Displays the changelog modal when a file is updated via DnD fc1da2cf90
Add feature flag for filename pattern ba8d3d5a21
Downlad the right version when creating a new file version via the quick look 6259c1dcb8
Spawn a file creation modal when files are dropped b3654b6da3
fix: File extension from the filename was not taken in account e998568f06
feat: filename pattern for files uploaded via SOAP 954cb35bca
Revert "feat: filename pattern for files uploaded via SOAP" a5e3209183
feat: complete support of internationalized characters fbee3140d7
feat: filename pattern for files uploaded via SOAP 8e36c69b33
feat: Disable webdav if filename pattern is set 8437a11df1
refactor: Do not check validity of pattern when applying it 9213a819f5
refactor: Prepare the field to enforce filename pattern f202f99b25
Enhance "File pattern" translation menu eb4268d8a4
feat: Checkbox to enforce filename pattern f602d6ffe1
feat: Pimp my filename pattern administration a304170d50
feat: Filename pattern goes GA ? b7bc802b99
Enhance the error handling when user drag files according the filename 78ba63a985
Add the fact ${VERSION_NAME} may be empty ec67c26c69

Follow-ups

User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
  • Status changed from On going to Done
  • Category set to
User avatar

ID: Yes it's more related to the ID that is not known by end user when generating files. I'm wondering if Tuleap (who knows what is going to be the next ID) can display this information to end user, (in the place of displaying $ID, booking this ID to avoid it to be taken by another file.

No it's not possible without completely rewriting the way documents are created .

User avatar

ID: Yes it's more related to the ID that is not known by end user when generating files. I'm wondering if Tuleap (who knows what is going to be the next ID) can display this information to end user, (in the place of displaying $ID, booking this ID to avoid it to be taken by another file.

User avatar

Question : Can the the pattern be changed and are this change propagated to new documents ?

The pattern can be changed and changes only apply to new documents. Existing documents are not modified

Remark: An ID needs to be generated into the document filename at the document creation so for it's 1rst version

I'm not quite sure to understand your remark. Could it be related to the section "New file and ${ID} in pattern" in story #24192 ?

User avatar

Question : Can the the pattern be changed and are this change propagated to new documents ?

Remark: An ID needs to be generated into the document filename at the document creation so for it's 1rst version

User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes
User avatar
  • Acceptance criteria
    Something went wrong, the follow up content couldn't be loaded
    Only formatting have been changed, you should switch to markup to see the changes