[ofbiz-framework] branch trunk updated (2c86f9a -> 19ef23a)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] branch trunk updated (2c86f9a -> 19ef23a)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git.


    from 2c86f9a  Fixed: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063)
     new f81bd88  Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063)
     new 19ef23a  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(-)

Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] 02/02: Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063)

jleroux@apache.org
This is an automated email from the ASF dual-hosted git repository.

jleroux pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 19ef23a3e270c512f00847b5e40be3587a15fbf0
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 ed7529d..47d690f 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
@@ -109,9 +106,7 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            
-            Path source = file.toPath()
-            Files.move(source, source.resolveSibling(filenameToUse))
+            file.renameTo(file1)
         } catch (Exception e) {
             logError(e, module)
         }
diff --git a/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy b/applications/product/groovyScripts/catalog/config/EditProductConfigItemContent.groovy
index 0d284d9..034be19 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
 
 // make the image file formats
@@ -118,8 +116,7 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            Path source = file.toPath()
-            Files.move(source, source.resolveSibling(filenameToUse))
+            file.renameTo(file1)
         } catch (Exception e) {
             logError(e, module)
         }
diff --git a/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy b/applications/product/groovyScripts/catalog/imagemanagement/ImageUpload.groovy
index 602b997..6a18c67 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.*
 
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString()
 
@@ -120,8 +119,7 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            Path source = file.toPath()
-            Files.move(source, source.resolveSibling(filenameToUse))
+            file.renameTo(file1)
         } catch (Exception e) {
             logError(e, module)
         }
diff --git a/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy b/applications/product/groovyScripts/catalog/imagemanagement/SetDefaultImage.groovy
index 2dfb38b..446e74c 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
 
 context.nowTimestampString = UtilDateTime.nowTimestamp().toString()
@@ -144,7 +146,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()
@@ -155,8 +157,7 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            Path source = file.toPath()
-            Files.move(source, source.resolveSibling(filenameToUse))
+            file.renameTo(file1)
         } catch (Exception e) {
             logError(e, module)
         }
diff --git a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy
index f4b1fe8..71f3c0c 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
@@ -127,7 +125,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()
@@ -138,8 +136,7 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            Path source = file.toPath()
-            Files.move(source, source.resolveSibling(filenameToUse))
+            file.renameTo(file1)
         } catch (Exception e) {
             logError(e, module)
         }
@@ -152,6 +149,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 ->

Reply | Threaded
Open this post in threaded view
|

[ofbiz-framework] 01/02: Reverted: Replace java.io.File::renameTo by java.nio.file.Files::move (OFBIZ-12063)

jleroux@apache.org
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 trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit f81bd885257dfeef35508c16787f0e889ae09c74
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 e180352..f4b1fe8 100644
--- a/applications/product/groovyScripts/catalog/product/EditProductContent.groovy
+++ b/applications/product/groovyScripts/catalog/product/EditProductContent.groovy
@@ -113,8 +113,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)
@@ -138,9 +138,8 @@ if (fileType) {
             } catch (Exception e) {
                 logError(e, "error deleting existing file (not neccessarily a problem)")
             }
-            // 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) {
             logError(e, module)
         }