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

Headless API structured-content-folders/{folderId}/structured-contents fails if an image used in an article is deleted

    Details

      Description

      Steps to Reproduce

      1. Create a structure named TESTSTRUCTURE with an Image Field named IMAGE;
      2. Upload an image file named TESTIMAGE.png to the Documents & Media;
      3. Create a Web Content Folder named TESTFOLDER;
      4. Inside TESTFOLDER create a Web Content named TESTCONTENT based on the structure TESTSTRUCTURE;
      5. Select TESTIMAGE.png on the IMAGE field;
      6. Save the Web Content;
      7. Perform a headless API call as bellow (replacing folderId with the folderId of TESTFOLDER:
        curl -u test@liferay.com:test "http://localhost:8080/o/headless-delivery/v1.0/structured-content-folders/{folderId}/structured-contents?pageSize=0&fields=contentFie​lds.name"
        
      8. Delete TESTIMAGE.png from Documents & Media;
      9. Clear the Recycle Bin.
      10. Perform a headless API call as bellow:
        curl -u test@liferay.com:test "http://localhost:8080/o/headless-delivery/v1.0/structured-content-folders/{forlderId}/structured-contents?pageSize=0&fields=contentFie​lds.name"
        

      Expected Results

      The API returns the information of the available Web Contents on steps 6 and 9 as below:

      {
        "items" : [ {
          "contentFields" : [ {
            "name" : "Imagee0fm",
            "repeatable" : false,
            "value" : {
              "image" : {
                "contentUrl" : "/documents/20124/0/TESTIMAGE.png/73ddb1b7-ead3-32cf-1d63-285ddcc35dd1?t=1585144590517",
                "encodingFormat" : "image/png",
                "fileExtension" : "png",
                "id" : 34868,
                "sizeInBytes" : 3439,
                "title" : "/34907"
              }
            }
          } ]
        } ],
        "lastPage" : 1,
        "page" : 0,
        "pageSize" : 0,
        "totalCount" : 1
      }
      

      Actual Results

      The headless API returns the list on step 6. After deleting the image from both D&M and the Recycle Bin, the headless API now fails to list any content, returning only:

      com.liferay.document.library.kernel.exception.NoSuchFileEntryException: No FileEntry exists with the key {fileEntryId=34868}
      

      On Master, the same error occurs, but on a JSON format:

      {
        "status" : "INTERNAL_SERVER_ERROR",
        "title" : "com.liferay.document.library.kernel.exception.NoSuchFileEntryException: No FileEntry exists with the key {fileEntryId=35023}"
      
      }
      

      On the logs, the following stacktrace is shown (master too):

      2020-03-25 13:56:43.661 ERROR [http-nio-7280-exec-6][ExceptionMapper:31] java.lang.RuntimeException: com.liferay.document.library.kernel.exception.NoSuchFileEntryException: No FileEntry exists with the key {fileEntryId=34868}
      java.lang.RuntimeException: com.liferay.document.library.kernel.exception.NoSuchFileEntryException: No FileEntry exists with the key {fileEntryId=34868}
              at com.liferay.portal.vulcan.util.TransformUtil.transform(TransformUtil.java:48)
              at com.liferay.portal.vulcan.util.TransformUtil.transformToArray(TransformUtil.java:68)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter._toContentFields(StructuredContentDTOConverter.java:228)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter.access$700(StructuredContentDTOConverter.java:88)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter$1.<init>(StructuredContentDTOConverter.java:112)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter.toDTO(StructuredContentDTOConverter.java:104)
              at com.liferay.headless.delivery.internal.resource.v1_0.StructuredContentResourceImpl._toStructuredContent(StructuredContentResourceImpl.java:872)
              at com.liferay.headless.delivery.internal.resource.v1_0.StructuredContentResourceImpl.lambda$_getStructuredContentsPage$7(StructuredContentResourceImpl.java:725)
              at com.liferay.portal.vulcan.util.SearchUtil.search(SearchUtil.java:107)
              at com.liferay.headless.delivery.internal.resource.v1_0.StructuredContentResourceImpl._getStructuredContentsPage(StructuredContentResourceImpl.java:708)
              at com.liferay.headless.delivery.internal.resource.v1_0.StructuredContentResourceImpl.getStructuredContentFolderStructuredContentsPage(StructuredContentResourceImpl.java:266)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179)
              at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96)
              at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:192)
              at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:103)
              at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)
              at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96)
              at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:308)
              at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)
              at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267)
              at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234)
              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208)
              at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:160)
              at org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:216)
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:301)
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:225)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
              at org.apache.cxf.transport.servlet.AbstractHTTPServlet.service(AbstractHTTPServlet.java:276)
              at org.eclipse.equinox.http.servlet.internal.registration.EndpointRegistration.service(EndpointRegistration.java:153)
              at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:50)
              at com.liferay.portal.security.auth.verifier.internal.tracker.AuthVerifierFilterTracker$RemoteAccessFilter.doFilter(AuthVerifierFilterTracker.java:165)
              at org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration.doFilter(FilterRegistration.java:121)
              at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:45)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)
              at com.liferay.portal.servlet.filters.authverifier.AuthVerifierFilter.processFilter(AuthVerifierFilter.java:198)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
              at org.eclipse.equinox.http.servlet.internal.registration.FilterRegistration.doFilter(FilterRegistration.java:121)
              at org.eclipse.equinox.http.servlet.internal.servlet.FilterChainImpl.doFilter(FilterChainImpl.java:45)
              at org.eclipse.equinox.http.servlet.internal.servlet.ResponseStateHandler.processRequest(ResponseStateHandler.java:70)
              at org.eclipse.equinox.http.servlet.internal.context.DispatchTargets.doDispatch(DispatchTargets.java:120)
              at org.eclipse.equinox.http.servlet.internal.HttpServiceRuntimeImpl.doDispatch(HttpServiceRuntimeImpl.java:373)
              at org.eclipse.equinox.http.servlet.internal.servlet.ProxyServlet.service(ProxyServlet.java:70)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
              at com.liferay.portal.module.framework.ModuleFrameworkServletAdapter.service(ModuleFrameworkServletAdapter.java:52)
              at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:124)
              at com.liferay.portal.servlet.filters.password.modified.PasswordModifiedFilter.processFilter(PasswordModifiedFilter.java:62)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)
              at com.liferay.portal.sharepoint.SharepointFilter.processFilter(SharepointFilter.java:88)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
              at com.liferay.portal.kernel.servlet.BaseFilter.processFilter(BaseFilter.java:147)
              at com.liferay.portal.servlet.filters.virtualhost.VirtualHostFilter.processFilter(VirtualHostFilter.java:268)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
              at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
              at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
              at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
              at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:389)
              at com.liferay.portal.servlet.filters.urlrewrite.UrlRewriteFilter.processFilter(UrlRewriteFilter.java:65)
              at com.liferay.portal.kernel.servlet.BaseFilter.doFilter(BaseFilter.java:49)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDoFilter(InvokerFilterChain.java:215)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:116)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:175)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.processDirectCallFilter(InvokerFilterChain.java:196)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilterChain.doFilter(InvokerFilterChain.java:99)
              at com.liferay.portal.kernel.servlet.filters.invoker.InvokerFilter.doFilter(InvokerFilter.java:104)
              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
              at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
              at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
              at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
              at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
              at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
              at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
              at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
              at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
              at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
              at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:834)
              at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1415)
              at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
              at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
              at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
              at java.lang.Thread.run(Thread.java:748)
      Caused by: com.liferay.document.library.kernel.exception.NoSuchFileEntryException: No FileEntry exists with the key {fileEntryId=34868}
              at com.liferay.portal.repository.RepositoryProviderImpl.getFileEntryRepository(RepositoryProviderImpl.java:121)
              at com.liferay.portlet.documentlibrary.service.impl.DLAppServiceImpl.getFileEntry(DLAppServiceImpl.java:1169)
              at sun.reflect.GeneratedMethodAccessor531.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
              at com.sun.proxy.$Proxy470.getFileEntry(Unknown Source)
              at com.liferay.document.library.kernel.service.DLAppServiceWrapper.getFileEntry(DLAppServiceWrapper.java:893)
              at sun.reflect.GeneratedMethodAccessor531.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
              at com.sun.proxy.$Proxy471.getFileEntry(Unknown Source)
              at com.liferay.document.library.kernel.service.DLAppServiceWrapper.getFileEntry(DLAppServiceWrapper.java:893)
              at sun.reflect.GeneratedMethodAccessor531.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
              at com.sun.proxy.$Proxy471.getFileEntry(Unknown Source)
              at com.liferay.document.library.kernel.service.DLAppServiceWrapper.getFileEntry(DLAppServiceWrapper.java:893)
              at sun.reflect.GeneratedMethodAccessor531.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.portal.kernel.bean.ClassLoaderBeanHandler.invoke(ClassLoaderBeanHandler.java:66)
              at com.sun.proxy.$Proxy471.getFileEntry(Unknown Source)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
              at java.lang.reflect.Method.invoke(Method.java:498)
              at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:50)
              at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:69)
              at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
              at com.liferay.portal.kernel.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:64)
              at com.liferay.portal.spring.aop.AopMethodInvocationImpl.proceed(AopMethodInvocationImpl.java:57)
              at com.liferay.portal.spring.aop.AopInvocationHandler.invoke(AopInvocationHandler.java:49)
              at com.sun.proxy.$Proxy95.getFileEntry(Unknown Source)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter$7.<init>(StructuredContentDTOConverter.java:354)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter._toValue(StructuredContentDTOConverter.java:351)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter.access$1700(StructuredContentDTOConverter.java:88)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter$2.<init>(StructuredContentDTOConverter.java:197)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter._toContentField(StructuredContentDTOConverter.java:184)
              at com.liferay.headless.delivery.internal.dto.v1_0.converter.StructuredContentDTOConverter.lambda$_toContentFields$0(StructuredContentDTOConverter.java:230)
              at com.liferay.portal.vulcan.util.TransformUtil.transform(TransformUtil.java:38)
              ... 105 more
      Caused by: com.liferay.portal.kernel.repository.InvalidRepositoryIdException: No repository associated with file entry 34868
              at com.liferay.portal.repository.RepositoryProviderImpl.getFileEntryRepositoryId(RepositoryProviderImpl.java:454)
              at com.liferay.portal.repository.RepositoryProviderImpl.getFileEntryRepository(RepositoryProviderImpl.java:112)
              ... 147 more
      

      Reproduced on:

      • DXP 7.2 SP1
      • Master Commit: a3cca7261acc2992d2fdd7e0e0bc2ae8aac1c14b (Updated on: Sun Mar 22 23:41:34 2020 -0700)

        Attachments

          Activity

            People

            Assignee:
            lino.alves Lino Alves
            Reporter:
            lino.alves Lino Alves
            Participants of an Issue:
            Recent user:
            Jason Pince
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              28 weeks, 5 days ago

                Packages

                Version Package
                7.2.10 DXP FP5
                7.2.10.2 DXP SP2
                7.2.X
                7.3.10 DXP GA1
                Master