-
Type:
Bug
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: 7.0.X, Master
-
Fix Version/s: 7.0.0 DXP FP42, 7.0.6 CE GA7, 7.0.0 DXP SP8, 7.0.X, 7.1.0 M2, 7.1.X, Master
-
Component/s: Staging > Resource Importer
-
Branch Version/s:7.0.x
-
Backported to Branch:Committed
-
Story Points:1
-
Fix Priority:3
-
Git Pull Request:
Description
The resources importer fails to import files properly if it encounters a pair of files that have the same title but different extensions (e.g. testFile.jpg and testFile.png). In this case, the second file to be imported will be considered as a "duplicate" (since the title is the same), which will cause Liferay to merely update the first file, incrementing its version. This leads to exceptions being thrown later on if other things in the resources importer reference the file since they expect it to be a previous version.
Liferay should be able to import multiple files as long as they have different file names. We should modify the code to modify the title to an appropriate value if it detects a duplicate title but different file names.
Steps to Reproduce
1. Create your own theme with the following characteristics (or just use the attached test-theme.war file):
- The resources importer contains two documents that have the same base name but different extensions.
- The resources importer contains a structure with a Documents and Media field, as well as a template using this structure.
- The resources importer contains an article using this structure that references one of the documents from the first bullet point.
2. Deploy the theme and observe the logs.
Expected Result: The theme deploys successfully with no errors.
Actual Result: The following error occurs during the deployment of the theme:
2018-03-12 18:56:34.201 ERROR [liferay/hot_deploy-1][SerialDestination:61] Unable to process message {destinationName=liferay/hot_deploy, response=null, responseDestinationName=null, responseId=null, payload=null, values={companyId=0, groupId=0, command=deploy, servletContextName=test-theme}} com.liferay.portal.kernel.messaging.MessageListenerException: com.liferay.document.library.kernel.exception.NoSuchFileVersionException: No DLFileVersion exists with the key {fileEntryId=36590, version=1.0} at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:32) at com.liferay.portal.kernel.messaging.InvokerMessageListener.receive(InvokerMessageListener.java:74) at com.liferay.portal.kernel.messaging.SerialDestination$1.run(SerialDestination.java:58) at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask._runTask(ThreadPoolExecutor.java:756) at com.liferay.portal.kernel.concurrent.ThreadPoolExecutor$WorkerTask.run(ThreadPoolExecutor.java:667) at java.lang.Thread.run(Thread.java:748) Caused by: com.liferay.document.library.kernel.exception.NoSuchFileVersionException: No DLFileVersion exists with the key {fileEntryId=36590, version=1.0} at com.liferay.portlet.documentlibrary.service.persistence.impl.DLFileVersionPersistenceImpl.findByF_V(DLFileVersionPersistenceImpl.java:3629) at com.liferay.portlet.documentlibrary.service.impl.DLFileVersionLocalServiceImpl.getFileVersion(DLFileVersionLocalServiceImpl.java:79) at sun.reflect.GeneratedMethodAccessor1078.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:163) at com.liferay.portal.spring.transaction.DefaultTransactionExecutor.execute(DefaultTransactionExecutor.java:54) at com.liferay.portal.spring.transaction.TransactionInterceptor.invoke(TransactionInterceptor.java:58) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137) at com.liferay.portal.spring.aop.ChainableMethodAdvice.invoke(ChainableMethodAdvice.java:56) at com.liferay.portal.spring.aop.ServiceBeanMethodInvocation.proceed(ServiceBeanMethodInvocation.java:137) at com.liferay.portal.spring.aop.ServiceBeanAopProxy.invoke(ServiceBeanAopProxy.java:169) at com.sun.proxy.$Proxy128.getFileVersion(Unknown Source) at com.liferay.document.library.kernel.service.DLFileVersionLocalServiceUtil.getFileVersion(DLFileVersionLocalServiceUtil.java:300) at com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl.getFileVersion(DLFileEntryImpl.java:193) at com.liferay.portlet.documentlibrary.model.impl.DLFileEntryImpl.getFileVersion(DLFileEntryImpl.java:188) at com.liferay.portal.repository.liferayrepository.model.LiferayFileEntry.getFileVersion(LiferayFileEntry.java:202) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.replaceFileEntryURL(FileSystemImporter.java:1732) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.addJournalArticles(FileSystemImporter.java:930) at com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.addJournalArticles(ResourceImporter.java:393) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.addDDMTemplates(FileSystemImporter.java:730) at com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.addDDMTemplates(ResourceImporter.java:281) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.addDDMStructures(FileSystemImporter.java:564) at com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.addDDMStructures(ResourceImporter.java:254) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.setUpAssets(FileSystemImporter.java:1857) at com.liferay.exportimport.resources.importer.internal.util.FileSystemImporter.doImportResources(FileSystemImporter.java:1422) at com.liferay.exportimport.resources.importer.internal.util.ResourceImporter.importResources(ResourceImporter.java:110) at com.liferay.exportimport.resources.importer.internal.messaging.ResourcesImporterHotDeployMessageListener._importResources(ResourcesImporterHotDeployMessageListener.java:260) at com.liferay.exportimport.resources.importer.internal.messaging.ResourcesImporterHotDeployMessageListener.initialize(ResourcesImporterHotDeployMessageListener.java:151) at com.liferay.exportimport.resources.importer.internal.messaging.ResourcesImporterHotDeployMessageListener.onDeploy(ResourcesImporterHotDeployMessageListener.java:164) at com.liferay.portal.kernel.messaging.HotDeployMessageListener.doReceive(HotDeployMessageListener.java:55) at com.liferay.portal.kernel.messaging.BaseMessageListener.receive(BaseMessageListener.java:26) ... 5 more