1

我有alfresco share/repo 版本 5.2.3

我正在尝试使用https://github.com/Alfresco/Aikau/blob/1.0.101_hotfixes/aikau/src/main/resources/alfresco/documentlibrary上发布的修复来修改_AlfDndDocumentUploadMixin.js中的函数/_AlfDndDocumentUploadMixin.js

我尝试扩展附件-doclib.xml并获取 jsonmodul,但它给了我一个空指针。

我的代码如下

来自附件-doclib.get.js

var documentServices = model.jsonModel;
for (var i=0; i<documentServices.length; i++)
{
  if (documentServices[i] === "alfresco/documentlibrary")
  {
    documentServices[i] = "js/aikau/1.0.101.10/alfresco/documentlibrary/my-documentlibrary/_AlfDndDocumentUploadMixin-extension";
  }
  else if (documentServices[i].name === "alfresco/documentlibrary")
  {
    documentServices[i].name = "js/aikau/1.0.101.10/alfresco/documentlibrary/my-documentlibrary/_AlfDndDocumentUploadMixin-extension";
  }
}

来自 doclib-customizations.xml

<config evaluator="string-compare" condition="WebFramework" replace="false">
          <web-framework>
            <dojo-pages>
              <packages>
                <package name="documentlibrary" location="js/aikau/1.0.101.10/alfresco/documentlibrary" />
              </packages>
            </dojo-pages>
          </web-framework>
        </config>

来自 _alfDndDocumentUploadMixin-extended.js

onDndUploadDrop: function alfresco_documentlibrary__AlfDndDocumentUploadMixin__onDndUploadDrop(evt) {
         try
         {
            // Only perform a file upload if the user has *actually* dropped some files!
            this.alfLog("log", "Upload drop detected", evt);
            if (evt.dataTransfer.files !== undefined && evt.dataTransfer.files !== null && evt.dataTransfer.files.length > 0)
            {
               this.removeDndHighlight();
               var destination = this._currentNode ? this._currentNode.nodeRef : null;
               var config = this.getUploadConfig();
               var defaultConfig = {
                  destination: destination,
                  siteId: null,
                  containerId: null,
                  uploadDirectory: null,
                  updateNodeRef: null,
                  description: "",
                  overwrite: false,
                  thumbnails: "doclib",
                  username: null
               };
               var updatedConfig = lang.mixin(defaultConfig, config);
           var walkFileSystem = lang.hitch(this, function alfresco_documentlibrary__AlfDndDocumentUploadMixin__onDndUploadDrop__walkFileSystem(directory, callback, error) {

              callback.limit = this.dndMaxFileLimit;
              callback.pending = callback.pending || 0;
              callback.files = callback.files || [];

              // get a dir reader and cleanup file path
              var reader = directory.createReader(),
                  relativePath = directory.fullPath.replace(/^\//, "");

              var repeatReader = function alfresco_documentlibrary__AlfDndDocumentUploadMixin__onDndUploadDrop__walkFileSystem__repeatReader() {

                 // about to start an async callback function
                 callback.pending++;

                 reader.readEntries(function alfresco_documentlibrary__AlfDndDocumentUploadMixin__onDndUploadDrop__walkFileSystem__repeatReader__readEntries(entries) {

                    // processing an async callback function
                    callback.pending--;

                    array.forEach(entries, function(entry) {
                       if (entry.isFile)
                       {
                          // about to start an async callback function
                          callback.pending++;

                          entry.file(function(File) {
                             // add the relativePath property to each file - this can be used to rebuild the contents of
                             // a nested tree folder structure if an appropriate API is available to do so
                             File.relativePath = relativePath;
                             callback.files.push(File);
                             if (callback.limit && callback.files.length > callback.limit)
                             {
                                throw new Error("Maximum dnd file limit reached: " + callback.limit);
                             }

                             // processing an async callback function
                             if (--callback.pending === 0)
                             {
                                // fall out here if last item processed is a file entry
                                callback(callback.files);
                             }
                          }, error);
                       }
                       else
                       {
                          walkFileSystem(entry, callback, error);
                       }
                    });

                    // the reader API is a little esoteric,from the MDN docs:
                    // "Continue calling readEntries() until an empty array is returned.
                    //  You have to do this because the API might not return all entries in a single call."
                    if (entries.length !== 0)
                    {
                       repeatReader();
                    }

                    // fall out here if last item processed is a dir entry e.g. empty dir
                    if (callback.pending === 0)
                    {
                       callback(callback.files);
                    }
                 }, error);
              };
              repeatReader();
           });

           var addSelectedFiles = lang.hitch(this, function alfresco_documentlibrary__AlfDndDocumentUploadMixin__onDndUploadDrop__addSelectedFiles(files) {

              if (this.dndMaxFileLimit && files.length > this.dndMaxFileLimit)
              {
                 throw new Error("Maximum dnd file limit reached: " + this.dndMaxFileLimit);
              }

              // Check to see whether or not the generated upload configuration indicates
              // that an existing node will be created or not. If node is being updated then
              // we need to generate an intermediary step to capture version and comments...
              if (updatedConfig.overwrite === false)
              {
                 // Set up a response topic for receiving notifications that the upload has completed...
                 var responseTopic = this.generateUuid();
                 this._uploadSubHandle = this.alfSubscribe(responseTopic, lang.hitch(this, this.onFileUploadComplete), true);

                 this.alfPublish(topics.UPLOAD_REQUEST, {
                    alfResponseTopic: responseTopic,
                    files: files,
                    targetData: updatedConfig
                 }, true);
              }
              else
              {
                 // TODO: Check that only one file has been dropped and issue error...
                 this.publishUpdateRequest(updatedConfig, files);
              }
           });

           var items = evt.dataTransfer.items || [], firstEntry;
           // webkitGetAsEntry is a marker for determining FileSystem API support.
           // SHA-2164 - Firefox claims support, but different impl. rather than code around differences, fallback.
           if (items[0] && items[0].webkitGetAsEntry && !has("ff") && (firstEntry = items[0].webkitGetAsEntry()))
           {
              walkFileSystem(firstEntry.filesystem.root, function(files) {
                    addSelectedFiles(files);
                 }, function() {
                    // fallback to standard way if error happens
                    addSelectedFiles(evt.dataTransfer.files);
                 }
              );
           }
           else
           {
              // fallback to standard way if no support for filesystem API
              addSelectedFiles(evt.dataTransfer.files);
           }
        }
        else
        {
           this.alfLog("error", "A drop event was detected, but no files were present for upload: ", evt.dataTransfer);
        }
     }
     catch(exception)
     {
        this.alfLog("error", "The following error occurred when files were dropped onto the Document List: ", exception);
     }
     // Remove the drag highlight...
     this.removeDndHighlight();

     // Destroy the overlay node (required for views that will re-render all the contents)...
     domConstruct.destroy(this.dragAndDropOverlayNode);
     this.dragAndDropOverlayNode = null;

     evt.stopPropagation();
     evt.preventDefault();
  },

  /**
   * This function publishes an update version request. It will request that a new dialog
   * be displayed containing the form controls defined in
   * [widgetsForUpdate]{@link module:alfresco/documentlibrary/_AlfDndDocumentUploadMixin#widgetsForUpdate}.
   *
   * @instance
   * @param {object} uploadConfig
   *
   * @fires ALF_CREATE_FORM_DIALOG_REQUEST
   */
  publishUpdateRequest: function alfresco_documentlibrary__AlfDndDocumentUploadMixin__publishUpdateRequest(uploadConfig, files) {
     // TODO: Work out the next minor and major increment versions...
     // TODO: Localization required...

     // Set up a response topic for receiving notifications that the upload has completed...
     var responseTopic = this.generateUuid();
     this._uploadSubHandle = this.alfSubscribe(responseTopic, lang.hitch(this, this.onFileUploadComplete), true);

     // To avoid the issue with processing payloads containing files with native
     // code in them, it is necessary to temporarily store the files in the data model...
     var filesRef = this.generateUuid();
     this.alfSetData(filesRef, files);

     this.alfPublish("ALF_CREATE_FORM_DIALOG_REQUEST", {
        dialogTitle: "Update",
        dialogConfirmationButtonTitle: "Continue Update",
        dialogCancellationButtonTitle: "Cancel",
        formSubmissionTopic: topics.UPLOAD_REQUEST,
        formSubmissionPayloadMixin: {
           alfResponseTopic: responseTopic,
           filesRefs: filesRef,
           targetData: uploadConfig
        },
        fixedWidth: true,
        widgets: lang.clone(this.widgetsForUpdate)
     }, true);
  },

Expect:所有被拖放的文件被上传。

实际:只上传一个文件

4

0 回答 0