You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cayenne.apache.org by nt...@apache.org on 2019/08/13 09:24:58 UTC

[cayenne] branch STABLE-4.1 updated: CAY-2605 Modeler: Unable to save - java.nio.file.InvalidPathException

This is an automated email from the ASF dual-hosted git repository.

ntimofeev pushed a commit to branch STABLE-4.1
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/STABLE-4.1 by this push:
     new 6f76976  CAY-2605 Modeler: Unable to save - java.nio.file.InvalidPathException
6f76976 is described below

commit 6f76976c7cfc6e10ba0ddd22ef23c5a0d00077a8
Author: Nikita Timofeev <st...@gmail.com>
AuthorDate: Tue Aug 13 12:17:56 2019 +0300

    CAY-2605 Modeler: Unable to save - java.nio.file.InvalidPathException
    
    (cherry picked from commit fd1510e5088118da5723d7b82eb3e8306f2c9422)
---
 RELEASE-NOTES.txt                                                | 1 +
 .../main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java  | 9 ++++++++-
 .../main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java  | 9 ++++++++-
 3 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/RELEASE-NOTES.txt b/RELEASE-NOTES.txt
index b483e72..4a5c865 100644
--- a/RELEASE-NOTES.txt
+++ b/RELEASE-NOTES.txt
@@ -32,6 +32,7 @@ CAY-2595 ObjAttributes are not sorted in alphabetical ordering on save
 CAY-2596 DbImport xml config changes after dbImport plugin task execution
 CAY-2601 Modeler DbImport: result dialog issues
 CAY-2603 NPE reloading project in the model
+CAY-2605 Modeler: Unable to save - java.nio.file.InvalidPathException
 
 ----------------------------------
 Release: 4.1.B2
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
index 4d2f8e4..229f331 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenConfigHandler.java
@@ -18,11 +18,13 @@
  ****************************************************************/
 package org.apache.cayenne.gen.xml;
 
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.configuration.xml.NamespaceAwareNestedTagHandler;
 import org.apache.cayenne.gen.CgenConfiguration;
@@ -259,7 +261,12 @@ public class CgenConfigHandler extends NamespaceAwareNestedTagHandler{
 
     private Path buildRootPath(DataMap dataMap) {
         URL url = dataMap.getConfigurationSource().getURL();
-        Path resourcePath = Paths.get(url.getPath());
+        Path resourcePath;
+        try {
+            resourcePath = Paths.get(url.toURI());
+        } catch (URISyntaxException e) {
+            throw new CayenneRuntimeException("Unable to read cgen path", e);
+        }
         if(Files.isRegularFile(resourcePath)) {
             resourcePath = resourcePath.getParent();
         }
diff --git a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
index 5f381ea..8b19d2d 100644
--- a/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
+++ b/cayenne-cgen/src/main/java/org/apache/cayenne/gen/xml/CgenSaverDelegate.java
@@ -18,11 +18,13 @@
  ****************************************************************/
 package org.apache.cayenne.gen.xml;
 
+import org.apache.cayenne.CayenneRuntimeException;
 import org.apache.cayenne.configuration.xml.DataChannelMetaData;
 import org.apache.cayenne.gen.CgenConfiguration;
 import org.apache.cayenne.map.DataMap;
 import org.apache.cayenne.project.extension.BaseSaverDelegate;
 
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.nio.file.Files;
 import java.nio.file.Path;
@@ -56,7 +58,12 @@ public class CgenSaverDelegate extends BaseSaverDelegate{
         Path prevPath = cgenConfiguration.buildPath();
         URL url = getBaseDirectory().getURL();
         if(url != null) {
-            Path resourcePath = Paths.get(url.getPath());
+            Path resourcePath;
+            try {
+                resourcePath = Paths.get(url.toURI());
+            } catch (URISyntaxException e) {
+                throw new CayenneRuntimeException("Unable to resolve output path", e);
+            }
             if(Files.isRegularFile(resourcePath)) {
                 resourcePath = resourcePath.getParent();
             }