You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/11/27 10:55:24 UTC
[ofbiz-framework] 02/02: Reverted: Replace java.io.File::renameTo
by java.nio.file.Files::move (OFBIZ-12063)
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 <ja...@les7arts.com>
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 ->