This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a change to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git. from ce0b890 Fixed: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) new 7400899 Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) new 9b45ab7 Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) The 2 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "add" were already present in the repository and have only been added to this reference. Summary of changes: .../groovyScripts/catalog/category/EditCategory.groovy | 7 +------ .../catalog/config/EditProductConfigItemContent.groovy | 7 ++----- .../catalog/imagemanagement/ImageUpload.groovy | 8 +++----- .../catalog/imagemanagement/SetDefaultImage.groovy | 13 +++++++------ .../catalog/product/EditProductContent.groovy | 15 ++++++--------- 5 files changed, 19 insertions(+), 31 deletions(-) |
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git commit 7400899b58b5d1ce84fd175093bc1349160f27a1 Author: Jacques Le Roux <[hidden email]> AuthorDate: Fri Nov 27 11:47:57 2020 +0100 Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) This reverts commit 2c86f9a8c0219fe8779dcb5620ee29e3efa1df86. Actually the problem was due to another WIP where 2 streams were not closed --- .../groovyScripts/catalog/product/EditProductContent.groovy | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy index 4a43c25..938687b 100644 --- a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy +++ b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy @@ -115,8 +115,8 @@ if (fileType) { imageUrl = imageUrlPrefix + "/" + filePathPrefix + java.net.URLEncoder.encode(filenameToUse, characterEncoding) try { - defaultFile = new File(imageServerPath + "/" + filePathPrefix, defaultFileName) - fileToUse = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) + file = new File(imageServerPath + "/" + filePathPrefix, defaultFileName) + file1 = new File(imageServerPath + "/" + filePathPrefix, filenameToUse) try { // Delete existing image files File targetDir = new File(imageServerPath + "/" + filePathPrefix) @@ -140,9 +140,8 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - // OFBIZ-12063: on Windows neither file.renameTo(), Files.move() nor FileUtils.moveFile() works - Files.copy(defaultFile.toPath(), fileToUse.toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING) - defaultFile.delete(); + Path source = file.toPath() + Files.move(source, source.resolveSibling(filenameToUse)) } catch (Exception e) { Debug.logError(e, module) } |
In reply to this post by jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch release17.12 in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git commit 9b45ab7affd1b2e0e0edd7ac4e4edeed8be832b0 Author: Jacques Le Roux <[hidden email]> AuthorDate: Fri Nov 27 11:52:54 2020 +0100 Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063) This reverts commit 1be480b68c52b8c8403b7c935b35981e943f5057. Actually the problem was due to another WIP where 2 streams were not closed --- .../groovyScripts/catalog/category/EditCategory.groovy | 7 +------ .../catalog/config/EditProductConfigItemContent.groovy | 7 ++----- .../catalog/imagemanagement/ImageUpload.groovy | 8 +++----- .../catalog/imagemanagement/SetDefaultImage.groovy | 13 +++++++------ .../groovyScripts/catalog/product/EditProductContent.groovy | 10 ++++------ 5 files changed, 17 insertions(+), 28 deletions(-) diff --git a/applications/product/groovyScripts/catalog/category/EditCategory.groovy b/applications/product/groovyScripts/catalog/category/EditCategory.groovy index 6b78774..7d8edd0 100644 --- a/applications/product/groovyScripts/catalog/category/EditCategory.groovy +++ b/applications/product/groovyScripts/catalog/category/EditCategory.groovy @@ -17,9 +17,6 @@ * under the License. */ -import java.nio.file.Files -import java.nio.file.Path - import org.apache.ofbiz.base.util.* import org.apache.ofbiz.base.util.string.* import org.apache.ofbiz.entity.util.EntityUtilProperties @@ -111,9 +108,7 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - - Path source = file.toPath() - Files.move(source, source.resolveSibling(filenameToUse)) + file.renameTo(file1) } catch (Exception e) { Debug.logError(e, module) } diff --git a/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy b/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy index 608d077..f2f9a02 100644 --- a/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy +++ b/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy @@ -17,11 +17,9 @@ * under the License. */ -import java.nio.file.Files -import java.nio.file.Path - import org.apache.ofbiz.base.util.* import org.apache.ofbiz.base.util.string.* +import org.apache.ofbiz.entity.* import org.apache.ofbiz.entity.util.EntityUtilProperties module = "EditProductConfigItemContent.groovy" @@ -120,8 +118,7 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - Path source = file.toPath() - Files.move(source, source.resolveSibling(filenameToUse)) + file.renameTo(file1) } catch (Exception e) { Debug.logError(e, module) } diff --git a/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy b/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy index 574864d..6a348fd 100644 --- a/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy +++ b/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy @@ -17,13 +17,12 @@ * under the License. */ -import java.nio.file.Files -import java.nio.file.Path - +import org.apache.ofbiz.entity.* import org.apache.ofbiz.base.util.* import org.apache.ofbiz.base.util.string.* import org.apache.ofbiz.entity.util.EntityUtilProperties import org.apache.ofbiz.product.image.ScaleImage +import org.apache.ofbiz.entity.condition.* module = "ImageUpload.groovy" @@ -122,8 +121,7 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - Path source = file.toPath() - Files.move(source, source.resolveSibling(filenameToUse)) + file.renameTo(file1) } catch (Exception e) { Debug.logError(e, module) } diff --git a/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy b/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy index 2dae8b8..85fda41 100644 --- a/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy +++ b/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy @@ -19,14 +19,16 @@ import java.awt.image.BufferedImage import java.awt.image.RenderedImage -import java.nio.file.Files -import java.nio.file.Path +import java.io.File +import java.util.List import javax.imageio.ImageIO +import org.apache.ofbiz.entity.* +import org.apache.ofbiz.entity.util.EntityUtil +import org.apache.ofbiz.entity.util.EntityUtilProperties import org.apache.ofbiz.base.util.* import org.apache.ofbiz.base.util.string.* -import org.apache.ofbiz.entity.util.EntityUtilProperties import org.apache.ofbiz.product.image.ScaleImage module = "SetDefaultImage.groovy" @@ -146,7 +148,7 @@ if (fileType) { File[] files = targetDir.listFiles() for(File file : files) { if (file.isFile() && !file.getName().equals(defaultFileName)) file.delete() - } + } // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! } else { File[] files = targetDir.listFiles() @@ -157,8 +159,7 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - Path source = file.toPath() - Files.move(source, source.resolveSibling(filenameToUse)) + file.renameTo(file1) } catch (Exception e) { Debug.logError(e, module) } diff --git a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy index 938687b..8c3873e 100644 --- a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy +++ b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy @@ -17,9 +17,7 @@ * under the License. */ -import java.nio.file.Files -import java.nio.file.Path - +import org.apache.ofbiz.entity.* import org.apache.ofbiz.base.util.* import org.apache.ofbiz.base.util.string.* import org.apache.ofbiz.entity.util.EntityUtilProperties @@ -129,7 +127,7 @@ if (fileType) { } else if(file.isFile() && "original".equals(fileType) && !file.getName().equals(defaultFileName)) { file.delete() } - } + } // Images aren't ordered by productId (${location}/${viewtype}/${sizetype}/${id}) !!! BE CAREFUL !!! } else { File[] files = targetDir.listFiles() @@ -140,8 +138,7 @@ if (fileType) { } catch (Exception e) { Debug.logError(e, "error deleting existing file (not neccessarily a problem)", module) } - Path source = file.toPath() - Files.move(source, source.resolveSibling(filenameToUse)) + file.renameTo(file1) } catch (Exception e) { Debug.logError(e, module) } @@ -154,6 +151,7 @@ if (fileType) { if ("original".equals(fileType)) { context.delegator = delegator result = ScaleImage.scaleImageInAllSize(context, filenameToUse, "main", "0") + if (result.containsKey("responseMessage") && "success".equals(result.get("responseMessage"))) { imgMap = result.get("imageUrlMap") imgMap.each() { key, value -> |
Free forum by Nabble | Edit this page |