Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 75035 - Difficult and non-obvious way to get config files
Difficult and non-obvious way to get config files
Status: RESOLVED DUPLICATE of bug 91534
Product: platform
Classification: Unclassified
Component: Filesystems
5.x
All All
: P3 (vote)
: 6.x
Assigned To: rmatous
issues@platform
api-usability
: API, API_REVIEW_FAST, ARCH, USABILITY
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-04-13 20:53 UTC by _ tboudreau
Modified: 2008-12-22 11:52 UTC (History)
3 users (show)

See Also:
Issue Type: ENHANCEMENT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2006-04-13 20:53:52 UTC
Repository.getDefault().getDefaultFileSystem().getRoot().getFileObject("/foo") 
is long and incredibly non-obvious, especially now that there is no concept of 
a Repository in the UI.  For new API users, a simple call would be much more 
friendly.

I suggest the following:

public static FileObject FileUtil.getConfigurationFile(String path) {
   return Repository.getDefault().getDefaultFileSystem().getRoot
().getFileObject("path");
}

and if possible, deprecate Repository.
Comment 1 Jesse Glick 2006-04-13 21:06:41 UTC
Deprecating Repository is not a good idea; there are circumstances where you
need to get the default FileSystem directly, e.g. for listeners. Using
FileUtil.getConfigFile("").getFileSystem() is possible but odd.

The correct body is

return Repository.getDefault().getDefaultFileSystem().findResource(path);

or perhaps

FileObject fo = Repository.getDefault().getDefaultFileSystem().findResource(path);
if (fo != null) {
  return fo;
} else {
  throw new FileNotFoundException(path);
}

on the assumption that the file/folder is usually expected to exist and most
people will forget to null-check.
Comment 2 Jesse Glick 2007-05-15 21:06:54 UTC
Some use cases now obsoleted by Lookups.forPath, some not.
Comment 3 Jesse Glick 2007-05-15 21:07:36 UTC
Filed twice indeed.

*** This issue has been marked as a duplicate of 91534 ***


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo