Use os-indenpendent slashes in paths
-
Relevant for repositories of
-
documents
-
split-configurations
-
dialect-definitions
-
Problem on Windows
org.springframework.core.NestedIOException: Invalid URI [jar:file:C:\Users\abdulakm\.m2\repository\org\gesis\stardat\flatdb-dialectdefinitions\0.3.1-SNAPSHOT\flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!/flatdb/dialect-definitions/gesisGroup32.xml]; nested exception is java.net.URISyntaxException: Illegal character in opaque part at index 11: jar:file:C:\Users\abdulakm\.m2\repository\org\gesis\stardat\flatdb-dialectdefinitions\0.3.1-SNAPSHOT\flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!/flatdb/dialect-definitions/gesisGroup32.xml at org.springframework.core.io.AbstractResource.getURI(AbstractResource.java:104) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE] at org.springframework.core.io.UrlResource.getURI(UrlResource.java:198) ~[spring-core-4.3.3.RELEASE.jar:4.3.3.RELEASE] at org.gesis.stardat.ddiflatdb.core.repository.SpringResourceRepository.findUrisByLocation(SpringResourceRepository.java:190) ~[stardat-ddiflatdb-core-0.0.11.jar:na] at org.gesis.stardat.ddiflatdb.core.repository.ClasspathDialectDefinitionRepository$Builder.build(ClasspathDialectDefinitionRepository.java:152) [stardat-ddiflatdb-core-0.0.11.jar:na] ... Caused by: java.net.URISyntaxException: Illegal character in opaque part at index 11: jar:file:C:\Users\abdulakm\.m2\repository\org\gesis\stardat\flatdb-dialectdefinitions\0.3.1-SNAPSHOT\flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!/flatdb/dialect-definitions/gesisGroup32.xml at java.net.URI$Parser.fail(URI.java:2848) ~[na:1.8.0_101] at java.net.URI$Parser.checkChars(URI.java:3021) ~[na:1.8.0_101] at java.net.URI$Parser.parse(URI.java:3058) ~[na:1.8.0_101] at java.net.URI.<init>(URI.java:588) ~[na:1.8.0_101]
-
Illegal character in opaque part at index 11: jar:file:C:\Users\
package org.gesis.stardat.ddiflatdb.core.repository;
import static org.gesis.stardat.ddiflatdb.core.repository.ClasspathDialectDefinitionRepository.Builder.LOCATION;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
import java.net.URI;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import org.junit.jupiter.api.Test;
public class SpringResourceRepositoryTest
{
@Test
public void findUrisByLocation()
{
List<URI> expectedUris = Arrays.asList(
"file:/home/alex/ws/stardat-ddiflatdb-core/target/test-classes/classpath-1/flatdb/dialect-definitions/",
"file:/home/alex/ws/stardat-ddiflatdb-core/target/test-classes/classpath-2/flatdb/dialect-definitions/" )
.stream().map( uri -> URI.create( uri ) )
.collect( Collectors.toList() );
List<URI> actualUris = SpringResourceRepository.findUrisByLocation( LOCATION );
assertThat( actualUris, equalTo( expectedUris ) );
String basePath = "jar:file:C:\\Users\\abdulakm\\.m2\\repository\\org\\gesis\\stardat\\flatdb-dialectdefinitions\\0.3.1-SNAPSHOT\\flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!/flatdb/dialect-definitions/gesisGroup32.xml";
System.out.println( basePath );
basePath = basePath.replace( "\\", "/" );
System.out.println( basePath );
String path = "jar:file:C:/Users/abdulakm/.m2/repository/org/gesis/stardat/flatdb-dialectdefinitions/0.3.1-SNAPSHOT/flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!/flatdb/dialect-definitions/gesisGroup32.xml";
System.out.println( path );
URI uri = URI.create( path );
// basePath =
// "jar:file:C:\\Users\\abdulakm\\.m2\\repository\\org\\gesis\\stardat\\flatdb-dialectdefinitions\\0.3.1-SNAPSHOT\\flatdb-dialectdefinitions-0.3.1-SNAPSHOT.jar!\\flatdb\\dialect-definitions\\gesisGroup32.xml";
// uri = URI.create( basePath );
}
}
Edited by Alexander Mühlbauer