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

Image Editor changes are not applied if the title of the image is missing the extension

    Details

      Description

      Reproduction:

      1. Login as Admin
      2. Go to Content→Documents and Media→+symbol in the bottom right corner→Basic Document
      3. Upload the attached file (test.jpg)
      4. Change the title from test.jpg to test
      5. Click on Publish
      6. Go to Content→Web Content→kebab menu in the top right corner→Structures
      7. Click the + symbol in the bottom right corner
      8. Title: Test Structure
      9. Copy the content from the attached file testStructure.json into the Source tab→Save
      10. Go to Content→Web Content→+ symbol→Test Structure
      11. Click into the Content field→+ sign→leftmost button [Insert Image]→click on Test
      12. In the Item selector view, choose the Tab Documents and Media
      13. Click on Test.jpg
      14. Find the pencil button in the bottom right corner and click on it
      15. Edit the image (e.g. crop it) and click Apply when finished→Save
      • Expected Behavior*
        The image will be saved as a copy and added to the Web Content.
      • Actual Behavior*
        After clicking Save the loading image appears but the image window stays open. The image is not saved as a copy and added to the Web Content.

      Root cause:
      When we upload the file and remove the extension from the tile it is displayed correctly in documents and media. I can even edit the given image from here with the image-editor.(click kebab menu, click "edit with ImagEditor")

      When we access the documents from the item-selector(through our web-content), the title of the image will contain the extension. This is what causes the issue, as we will create a copy from the image and use the given title for saving the file later, and it will throw an exception when we validate the file in DLFileEntryLocalServiceImpl.java:

      public void validateFile(
      		long groupId, long folderId, long fileEntryId, String fileName,
      		String title)
      		throws PortalException {
      
      		_validateFolder(groupId, folderId, title);
      
      		DLFileEntry dlFileEntry = dlFileEntryPersistence.fetchByG_F_T(
      			groupId, folderId, title);
      
      		if ((dlFileEntry != null) &&
      			(dlFileEntry.getFileEntryId() != fileEntryId)) {
      
      			throw new DuplicateFileEntryException(
      				"A file entry already exists with title " + title);
      		}
      
      		dlFileEntry = dlFileEntryPersistence.fetchByG_F_FN(
      			groupId, folderId, fileName);
      
      		if ((dlFileEntry != null) &&
      			(dlFileEntry.getFileEntryId() != fileEntryId)) {
      
      			throw new DuplicateFileEntryException(
      				"A file entry already exists with file name " + title);
      		}
      	}
      

      We will fail the second if check, as our original image "fileName"(not the title) was indeed "test.jpg".

      Very similar to LPS-65890, the extension is the key to reproduce the issue and it was missing from the description.

        Attachments

        1. Reproduced.mp4
          26.19 MB
        2. Screenshot 2020-05-25 at 14.22.43.png
          Screenshot 2020-05-25 at 14.22.43.png
          712 kB
        3. Screenshot 2020-05-25 at 14.23.25.png
          Screenshot 2020-05-25 at 14.23.25.png
          436 kB
        4. test.jpg
          test.jpg
          7 kB

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  17 weeks ago

                  Packages

                  Version Package
                  7.0.0 DXP FP93
                  7.0.10.14 DXP SP14
                  7.0.X
                  7.1.10 DXP FP18
                  7.1.X
                  7.2.10 DXP FP6
                  7.2.X
                  7.3.3 CE GA4
                  Master