Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-75260

Item selector javascript isn't prepared for custom DL exceptions

    Details

      Description

      Current item selector javascript prints any possible error messages that can arise when uploading files.

      Unfortunately it only prints the message returned by server only if error is an AntivirusException (494). This makes impossible to send a custom error message to be printed, unless this AntivirusException error code is sent.

      Current code is (from https://github.com/liferay/liferay-portal/blob/master/modules/apps/collaboration/item-selector/item-selector-taglib/src/main/resources/META-INF/resources/image_selector/js/image_selector.js#L445 ) :

       

      if (errorType === STATUS_CODE.SC_FILE_ANTIVIRUS_EXCEPTION) {
      							message = error.message;
      						}
      						else if (errorType === STATUS_CODE.SC_FILE_EXTENSION_EXCEPTION) {
      							message = Lang.sub(Liferay.Language.get('please-enter-a-file-with-a-valid-extension-x'), [instance.get('validExtensions')]);
      						}
      						else if (errorType === STATUS_CODE.SC_FILE_NAME_EXCEPTION) {
      							message = Liferay.Language.get('please-enter-a-file-with-a-valid-file-name');
      						}
      						else if (errorType === STATUS_CODE.SC_FILE_SIZE_EXCEPTION) {
      							message = Lang.sub(Liferay.Language.get('please-enter-a-file-with-a-valid-file-size-no-larger-than-x'), [instance.formatStorage(instance.get('maxFileSize'))]);
      						}
      						else if (errorType === STATUS_CODE.SC_UPLOAD_REQUEST_SIZE_EXCEPTION) {
      							var maxUploadRequestSize = Liferay.PropsValues.UPLOAD_SERVLET_REQUEST_IMPL_MAX_SIZE;
      
      							message = Lang.sub(Liferay.Language.get('request-is-larger-than-x-and-could-not-be-processed'), [instance.formatStorage(maxUploadRequestSize)]);
      						}
      

       

      In previous source code custom error message from server (error.message) is only returned when using antivirus exception. There is a custom error code for custom exception cases (ServletResponseConstants.SC_FILE_CUSTOM_EXCEPTION with 499 value).

       

       

        Attachments

          Activity

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Days since last comment:
                15 weeks, 1 day ago

                Packages

                Version Package
                7.2.10 DXP FP1
                7.2.X
                Master