Allow property datastore to find parent when a actual property file is supplied
-------------------------------------------------------------------------------

                 Key: GEOT-3034
                 URL: http://jira.codehaus.org/browse/GEOT-3034
             Project: GeoTools
          Issue Type: Improvement
          Components: data property
            Reporter: Jody Garnett
            Assignee: Jody Garnett
             Fix For: 2.6.4


PropertyDataStore cannot actually connect to a property file (instead it works 
as a directory datastore serving up all the property files in a folder). Now 
that directory datastore is working we could change this; however property 
datastore is now used in test cases everywhere :-P

For now what I will do is allow property datastore detect if a non directory is 
passed in; and if the non directory is a properties file it will use the 
property file parent directory instead:

{code}
    private File directoryLookup(Map params) throws IOException, 
FileNotFoundException,
            IllegalArgumentException {
        File directory = (File) DIRECTORY.lookUp(params);
        if (!directory.exists()) {
            File currentDir = new File(System.getProperty("user.dir"));
            directory = new File(currentDir, (String) 
params.get(DIRECTORY.key));
            if (!directory.exists()) {
                throw new FileNotFoundException(directory.getAbsolutePath());
            }
            if (!directory.isDirectory()) {
                throw new IllegalArgumentException(directory.getAbsolutePath()
                        + " is not a directory");
            }
        } else if (!directory.isDirectory()) {
            // check if they pointed to a properties file; and use the parent 
directory
            if( directory.getPath().endsWith(".properties")){
                return directory.getParentFile();
            }
            else {
                throw new IllegalArgumentException(directory.getAbsolutePath() 
+ " is not a directory");
            }
        }
        return directory;
    }
{code}

This will allow udig users to select a property file and get something.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Geotools-devel mailing list
Geotools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-devel

Reply via email to