Content Import/Export Plugin - Fix in dotCMS Core to not Remove Binary fields on Import with Override version
During Client tests for an enhancement introduced on content import/export plugin, an issue in dotCMS core's contentlet checkin method was discovered (ESContentletAPIImpl). This problem was fixed via hotfix mechanism but it may be fixed at dotCMS core level: Binary fields are being removed from contentlet when “Override existing version” is checked (from content import/export plugin).
Expected Behavior
When the user selects to override an existing version of the content (instead of creating a new version every time the import task runs), Binary fields should not be removed (that is, be preserved) when the import updates an already existing version.
Current Behavior
When the user selects to override an existing version of the content (instead of creating a new version every time the import task runs), Binary fields are being removed when the import updates an already existing version.
Possible Solution
Following is the exception thrown, which caused the Content Import task to remove a Binary field from existing contentlet version:
[08/03/17 13:08:24:988 EST] INFO quartz.DotJobStore: Handling 1 trigger(s) that missed their scheduled fire-time.
[08/03/17 13:08:25:195 EST] ERROR business.ESContentletAPIImpl: Error occurred while processing the file:/opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
com.dotmarketing.portlets.contentlet.business.DotContentletValidationException: Error occurred while processing the file:/opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:3042) [dotcms_3.7.0_ded9292.jar:?]
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkinWithoutVersioning(ESContentletAPIImpl.java:2572) [dotcms_3.7.0_ded9292.jar:?]
at com.dotmarketing.portlets.contentlet.business.ContentletAPIInterceptor.checkinWithoutVersioning(ContentletAPIInterceptor.java:295) [dotcms_3.7.0_ded9292.jar:?]
at org.dotcms.plugins.contentImporter.util.ContentletUtil.importLine(ContentletUtil.java:1155) [ContentletUtil.class:?]
at org.dotcms.plugins.contentImporter.util.ContentletUtil.importFile(ContentletUtil.java:204) [ContentletUtil.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.importInputStream(ContentImporterThread.java:378) [ContentImporterThread.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.importFromContent(ContentImporterThread.java:180) [ContentImporterThread.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.execute(ContentImporterThread.java:122) [ContentImporterThread.class:?]
at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [dot.quartz-all-1.8.6_2.jar:?]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [dot.quartz-all-1.8.6_2.jar:?]
Caused by: java.io.FileNotFoundException: /opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_121]
at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_121]
at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_121]
at com.liferay.util.FileUtil.copyFile(FileUtil.java:207) ~[dotcms_3.7.0_ded9292.jar:?]
at com.liferay.util.FileUtil.copyFile(FileUtil.java:140) ~[dotcms_3.7.0_ded9292.jar:?]
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:3026) ~[dotcms_3.7.0_ded9292.jar:?]
... 9 more
[08/03/17 13:08:25:195 EST] ERROR util.ImportUtil: Error occurred while processing the file:/opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
com.dotmarketing.portlets.contentlet.business.DotContentletValidationException: Error occurred while processing the file:/opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:3042) ~[dotcms_3.7.0_ded9292.jar:?]
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkinWithoutVersioning(ESContentletAPIImpl.java:2572) ~[dotcms_3.7.0_ded9292.jar:?]
at com.dotmarketing.portlets.contentlet.business.ContentletAPIInterceptor.checkinWithoutVersioning(ContentletAPIInterceptor.java:295) ~[dotcms_3.7.0_ded9292.jar:?]
at org.dotcms.plugins.contentImporter.util.ContentletUtil.importLine(ContentletUtil.java:1155) [ContentletUtil.class:?]
at org.dotcms.plugins.contentImporter.util.ContentletUtil.importFile(ContentletUtil.java:204) [ContentletUtil.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.importInputStream(ContentImporterThread.java:378) [ContentImporterThread.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.importFromContent(ContentImporterThread.java:180) [ContentImporterThread.class:?]
at org.dotcms.plugins.contentImporter.quartz.ContentImporterThread.execute(ContentImporterThread.java:122) [ContentImporterThread.class:?]
at org.quartz.core.JobRunShell.run(JobRunShell.java:223) [dot.quartz-all-1.8.6_2.jar:?]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549) [dot.quartz-all-1.8.6_2.jar:?]
Caused by: java.io.FileNotFoundException: /opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_121]
at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_121]
at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_121]
at com.liferay.util.FileUtil.copyFile(FileUtil.java:207) ~[dotcms_3.7.0_ded9292.jar:?]
at com.liferay.util.FileUtil.copyFile(FileUtil.java:140) ~[dotcms_3.7.0_ded9292.jar:?]
at com.dotcms.content.elasticsearch.business.ESContentletAPIImpl.checkin(ESContentletAPIImpl.java:3026) ~[dotcms_3.7.0_ded9292.jar:?]
... 9 more
[08/03/17 13:08:25:196 EST] INFO util.ImportUtil: Error line: 2 ("3913831"~"03/10/2017 20:00"~"03/10/2017 22:00"~"Symphonic Band and Jazz Band"~"1"~""~"CF*AUD"~"Covenant Fine Arts Center Auditorium" ). Line Ignored.
[08/03/17 13:08:25:362 EST] INFO util.ImportUtil: 3 lines read correctly. 1 errors found.
[08/03/17 13:08:25:445 EST] INFO guava.GuavaCache: *** Building Cache : velocitymenucache, size:1000,Concurrency:32
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread:
Error Found:
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: Line #3 Error occurred while processing the file:/opt/dotcms/data/assets/8/5/85d17a25-a373-4181-ab28-6dfad43f8b74/uploadableImage/band.jpeg (No such file or directory)
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: 1 input lines had errors.
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread:
Warnings Found:
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: The Content Type field Unique event ID is unique.
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: Not all the content types fields match the file headers. Some content fields could be left empty.
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: Line #2. The key fields chosen match 1 existing content(s) - more than one match suggests key(s) are not properly unique
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: Line #3. The key fields chosen match 1 existing content(s) - more than one match suggests key(s) are not properly unique
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: Line #4. The key fields chosen match 1 existing content(s) - more than one match suggests key(s) are not properly unique
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread:
Results:
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: 0 New "Event" were created.
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: 2 "Event" contentlets updated corresponding to 2 repeated contents based on the key provided
[08/03/17 13:08:25:445 EST] INFO quartz.ContentImporterThread: 1 contentlets were ignored due to invalid information
[08/03/17 13:08:25:445 EST] ERROR quartz.ContentImporterThread: java.io.IOException: No such file or directory
Following was the fix made, which may be incorporated as part of dotCMS's core (Added "&& !oldFile.equals(newFile)" as part of the else-if condition): https://github.com/dotCMS/core/blob/3.7.0/src/com/dotcms/content/elasticsearch/business/ESContentletAPIImpl.java#L3024
private Contentlet checkin( ... ) throws ... {
...
// we move files that have been newly uploaded or edited
if(oldFile==null || !oldFile.equals(incomingFile)){
...
} else if (oldFile.exists() && !oldFile.equals(newFile)) {
// otherwise, we copy the files as hardlinks
FileUtil.copyFile(oldFile, newFile);
...
}
...
}
Steps to Reproduce (for bugs)
- Add Binary field to Event content-type
- Set image to newly created binary field on existing Event contentlet
- Install Content Import/Export plugin
- Configure an import task over Event content-type on Content Import/Export plugin with "Override existing content version?" checked. Let the job execute
- Check the Binary field on existing/imported contentlets. Check that Binary field was cleared/removed
Context
Reported by client on dotCMS 3.7.0. https://my.dotcms.com/tickets/detail.dot?id=a84b29bc-3f0f-4933-b432-6a809acf73c7
Your Environment
- dotCMS version used: 3.7.0.
- Browser Name and version: Any Browser
- Operating System and version: Amazon Linux and Mac OSX
- Application Server and version: Apache Tomcat
- Database and version: Postgres and MySQL
The fix for this issue may be borrowed from hot-fix at https://github.com/dotCMS/support/tree/master/hotfixes/hotfix-GIT-10976_v3.7.0. Also, the original Support ticket may be accessed at https://my.dotcms.com/tickets/detail.dot?id=a84b29bc-3f0f-4933-b432-6a809acf73c7
This issue has been automatically marked as stale because it has not had activity within the past 90 days. It will be closed in 30 days no further activity occurs. Thank you.