Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URIUtils.getURI to support resources #285

Closed
GoogleCodeExporter opened this issue Mar 16, 2015 · 6 comments
Closed

URIUtils.getURI to support resources #285

GoogleCodeExporter opened this issue Mar 16, 2015 · 6 comments

Comments

@GoogleCodeExporter
Copy link

URIUtils.getURI currently supports creating a URILocator from a filename or 
uri. My request is to extend this functionality to also support resources from 
classpath. Please find attached the diif I suggest. All tests pass with this 
change. Since some old bugs (#679 and #1006 from the closed source era) are 
mentioned, I'll wait for comments before committing this enhancement.

Original issue reported on code.google.com by p.kruijsen on 2 Aug 2010 at 6:06

Attachments:

@GoogleCodeExporter
Copy link
Author

Hmmmm. There's a small chance that this patch will also trigger the old bug 
#1006, which was that file access is not allowed in applets. Accessing .jar 
files should be OK, but you never know. So that would need to be tested. 
(Basically, just build the Vizlet, then try it out, taking great care to flush 
the browser cache thoroughly first.)

This method gets called from all over Ontopia, and so I worry a little that it 
may have a negative performance impact. Whether it really does I'm not sure.

Finally, I wonder what the use of the patch is. Where/when would we want to 
make URLs to resources on the classpath? (Note that I'm not saying we wouldn't 
do it. I'm just wondering what the benefit is.)

Original comment by lar...@gmail.com on 3 Aug 2010 at 12:09

  • Added labels: Component-Engine

@GoogleCodeExporter
Copy link
Author

The intended use of this patch is being able to use e.g. 
ImportExportUtils.getReader(String) with a classpath reference. Other methods 
might be adapted later to load files from classpath as well.

To avoid (most of the) overhead, and to be more explicit, I've updated the 
patch. It now checks if the argument starts with a "classpath:" prefix. That 
way it's both clear what the intention and result is and it makes less impact 
on performance. Also, StreamUtils.getResource will give an explicit error if 
the resource was not found on classpath.

This new patch will probably lower or even eliminate chances of triggering bug 
#1006. I haven't tested in yet. I will do that later and commit this new patch 
if no further comments or objections arise.

Original comment by p.kruijsen on 4 Aug 2010 at 7:58

Attachments:

@GoogleCodeExporter
Copy link
Author

I've updated the patch again and deleted the previous. It throws an 
OntopiaRuntimeException if the classpath resource does not exist.

Original comment by p.kruijsen on 4 Aug 2010 at 8:21

Attachments:

@GoogleCodeExporter
Copy link
Author

I've applied the proposed patch to the Maven branch in revision r1615. We're 
using it to reach test files from classpath references.

Original comment by p.kruijsen on 2 Feb 2011 at 12:54

@GoogleCodeExporter
Copy link
Author

Maven branch has been merged to trunk, so proposed fix is now in trunk.

Original comment by qsieb...@gmail.com on 28 May 2011 at 10:53

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

Original comment by qsieb...@gmail.com on 27 Jan 2012 at 10:42

  • Added labels: Release5.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant