Uploaded image for project: 'Nuxeo Platform'
  1. Nuxeo Platform
  2. NXP-29963

Enforce the FileManager overwrite behavior

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Automation

      Description

      When the overwrite=true parameter is passed to a FileManager operation, a check will be done on the title or name (or something else depending on the mimetype and eventual contributions).
      However, in a Nuxeo Drive context, we may want to allow the overwrite only if the dc:creator and the current user are the same (similar to what we do for auto-versioning).

      Details

      The FileManager will always do a NXQL query for each document, see here:

      // look for an existing document with same title or filename
      DocumentModel doc;
      if (isOverwriteByTitle()) {
          doc = FileManagerUtils.getExistingDocByTitle(session, path, title);
      } else {
          doc = FileManagerUtils.getExistingDocByFileName(session, path, filename);
      }
      

      isOverwriteByTitle() is evalued to false by default.

      And here are the revelant functions:

      public static DocumentModel getExistingDocByTitle(CoreSession documentManager, String path, String title) {
          return getExistingDocByPropertyName(documentManager, path, title, "dc:title");
      }
      
      public static DocumentModel getExistingDocByPropertyName(CoreSession documentManager, String path, String value,
              String propertyName) {
          value = Normalizer.normalize(value, Normalizer.Form.NFC);
          DocumentModel existing = null;
          String parentId = documentManager.getDocument(new PathRef(path)).getId();
          String query = "SELECT * FROM Document WHERE ecm:parentId = '" + parentId + "' AND " + propertyName + " = '"
                  + value.replace("'", "\\\'") + "' AND ecm:isTrashed = 0";
          DocumentModelList docs = documentManager.query(query, 1);
          if (docs.size() > 0) {
              existing = docs.get(0);
          }
          return existing;
      }
      

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:

                PagerDuty

                Error rendering 'com.pagerduty.jira-server-plugin:PagerDuty'. Please contact your Jira administrators.