You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Xavier Dury (JIRA)" <ji...@apache.org> on 2015/01/28 13:49:34 UTC
[jira] [Commented] (VFS-444) ResourceFileProvider "res://" failed
to obtain FileObject from resolved FileName
[ https://issues.apache.org/jira/browse/VFS-444?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14295105#comment-14295105 ]
Xavier Dury commented on VFS-444:
---------------------------------
I've got a similar problem, {{resolveFile()}} does not accept names starting with {{res:/}} or {{res://}} but well with {{res:}} while {{resolveURI()}} does the opposite (it does not accept {{res:}} but well {{res:/}} or {{res:///////////}}) which is totally inconsistent.
I'm trying to resolve an URI relative to an other (which returns something like {{res:///}}) but as soon as I try to resolve it as file through {{resolveFile}} it fails as no slash is allowed after {{res:}}
{code}
@Test
public void resolveFullPathURI0() throws Exception {
VFS.getManager().resolveURI("res:META-INF/config.xml"); // not an absolute file name
}
@Test
public void resolveFullPathFile0() throws Exception {
VFS.getManager().resolveFile("res:META-INF/config.xml"); // OK
}
@Test
public void resolveFullPathURI1() throws Exception {
VFS.getManager().resolveURI("res:/META-INF/config.xml"); // OK (res:///META-INF/config.xml)
}
@Test
public void resolveFullPathFile1() throws Exception {
VFS.getManager().resolveFile("res:/META-INF/config.xml"); // badly formed URI
}
@Test
public void resolveFullPathURI2() throws Exception {
VFS.getManager().resolveURI("res://META-INF/config.xml"); // OK (res:///META-INF/config.xml)
}
@Test
public void resolveFullPathFile2() throws Exception {
VFS.getManager().resolveFile("res://META-INF/config.xml"); // badly formed URI
}
@Test
public void resolvePartialPath1() throws Exception {
VFS.getManager().resolveURI("res:META-INF"); // not an absolute file name
}
@Test
public void resolvePartialPath2() throws Exception {
FileName root = VFS.getManager().resolveURI("res:/META-INF"); // OK
FileName file = VFS.getManager().resolveName(root, "config.xml"); // OK
String uri = file.getURI(); // OK (res:///META-INF/config.xml)
VFS.getManager().resolveFile(uri); // badly formed URI
}
{code}
> ResourceFileProvider "res://" failed to obtain FileObject from resolved FileName
> --------------------------------------------------------------------------------
>
> Key: VFS-444
> URL: https://issues.apache.org/jira/browse/VFS-444
> Project: Commons VFS
> Issue Type: Bug
> Affects Versions: 2.0
> Environment: java version "1.6.0_26"
> Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
> Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)
> Linux x 2.6.32-5-amd64 #1 SMP Sun May 6 04:00:17 UTC 2012 x86_64 GNU/Linux
> Reporter: Walter Eaves
> Labels: common-configuration
> Fix For: 2.0
>
> Original Estimate: 168h
> Remaining Estimate: 168h
>
> Given
> // See if we can find it in the resources.
> String s0 = "res://config.xml";
> FileName n0 = mgr.resolveURI(s0);
> FileObject c1 = mgr.resolveFile(new File(n0.getBaseName()), n0.getPath());
> logger.info("c1: " + c1 + " : " + c1.exists());
> The code seems to have worked because, I can see the logger has the right URL in the SoftResFilesCache
> 12:43:29,734 DEBUG [StandardFileSystemManager] Skipping provider "org.apache.commons.vfs2.provider.webdav.WebdavFileProvider" because required class "org.apache.jackrabbit.webdav.client.methods.DavMethod" is not available.
> 12:43:29,765 DEBUG [SoftRefFilesCache] putFile: file:///misc/build2/fpstats0/fpstats-experimental/config.xml
> 12:43:29,767 DEBUG [SoftRefFilesCache] putFile: file:///config.xml
> 12:43:29,767 INFO [Version] c1: file:///config.xml : false
> The file is there!
> But I cannot get a FileObject that gives me the absolute path.
> This would be useful for me. I want to be able to resolve a file out of the resources: jar files and classes/ directories. And keep that in reserve as I try and resolve the same file in -Duser.home and elsewhere.
> If it worked, and I believed it, I could then use the "res://config.xml" it for commons-configuration.
> But I can't.
> I just don't understand the API - is it complete? I can resolve a URL and get a FileName, but it won't tell me the FileSystem(s) without that I can't resolve it in this SoftResFilesCache.
> If it were me, I would just open the SoftResFilesCache and add a search for the base filename of a URL across all FileSystems.
> I use a filesystems to find things. I give it a hint where I saw it last and I want to track if it is still there and whether it has changed.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)