You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@oodt.apache.org by ma...@apache.org on 2011/01/12 04:43:39 UTC

svn commit: r1057983 - in /oodt/trunk: ./ opendapps/src/main/java/org/apache/oodt/opendapps/

Author: mattmann
Date: Wed Jan 12 03:43:39 2011
New Revision: 1057983

URL: http://svn.apache.org/viewvc?rev=1057983&view=rev
Log:
- fix for OODT-111 Allow a file to be specified in the URL for the opendapp configurator

Modified:
    oodt/trunk/CHANGES.txt
    oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
    oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java
    oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileHandler.java

Modified: oodt/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/oodt/trunk/CHANGES.txt?rev=1057983&r1=1057982&r2=1057983&view=diff
==============================================================================
--- oodt/trunk/CHANGES.txt (original)
+++ oodt/trunk/CHANGES.txt Wed Jan 12 03:43:39 2011
@@ -4,6 +4,9 @@ Apache OODT Change Log
 Release 0.2 (Current Development)
 --------------------------------------------
 
+* OODT-111 Allow a file to be specified in the URL for the 
+  opendapp configurator (Victor Hwang via mattmann)
+
 * OODT-108 Ability for the file manager to ingest a file in 
   place (Faranak Davoodi via mattmann)
 

Modified: oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java?rev=1057983&r1=1057982&r2=1057983&view=diff
==============================================================================
--- oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java (original)
+++ oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/DatasetExtractor.java Wed Jan 12 03:43:39 2011
@@ -76,11 +76,11 @@ public class DatasetExtractor {
   public List<String> getDapUrls() {
     List<String> urls = null;
 
-    if (this.q.startsWith(FINDALL))
+    if (this.q.contains(FINDALL))
       urls = this.allUrls;
-    else if (this.q.startsWith(FINDSOME))
+    else if (this.q.contains(FINDSOME))
       urls = this.getFindSome();
-    else if (this.q.startsWith(FINDQUERY))
+    else if (this.q.contains(FINDQUERY))
       urls = this.getFindQuery();
 
     return urls;

Modified: oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java
URL: http://svn.apache.org/viewvc/oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java?rev=1057983&r1=1057982&r2=1057983&view=diff
==============================================================================
--- oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java (original)
+++ oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileElementExtractor.java Wed Jan 12 03:43:39 2011
@@ -50,6 +50,10 @@ public class OpendapProfileElementExtrac
     AttributeTable attTable = null;
     try {
       attTable = das.getAttributeTable(varname);
+      
+      // make variable names case insensitive
+      if(attTable == null) attTable = das.getAttributeTable(varname.toLowerCase());
+      if(attTable == null) attTable = das.getAttributeTable(varname.toUpperCase());
       if(attTable == null) throw new NoSuchAttributeException("Att table for ["+varname+"] is null!");
     } catch (NoSuchAttributeException e) {
       e.printStackTrace();

Modified: oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileHandler.java
URL: http://svn.apache.org/viewvc/oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileHandler.java?rev=1057983&r1=1057982&r2=1057983&view=diff
==============================================================================
--- oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileHandler.java (original)
+++ oodt/trunk/opendapps/src/main/java/org/apache/oodt/opendapps/OpendapProfileHandler.java Wed Jan 12 03:43:39 2011
@@ -24,6 +24,8 @@ import java.util.List;
 import java.util.Vector;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 //OPeNDAP/THREDDS imports
 import opendap.dap.DConnect;
@@ -55,20 +57,38 @@ public class OpendapProfileHandler imple
 
   private OpendapConfig conf;
 
-  public OpendapProfileHandler() throws InstantiationException,
-      FileNotFoundException, MalformedURLException {
-    String configFileLoc = System
-        .getProperty("org.apache.oodt.opendap.config.filePath");
-    if (configFileLoc == null)
-      throw new InstantiationException(
-          "Must specify System property opendap.config.filePath!");
-    this.conf = OpendapConfigReader.read(configFileLoc);
+  public OpendapProfileHandler(){
   }
 
   public List<Profile> findProfiles(XMLQuery xmlQuery) throws ProfileException {
+    String configFileLoc = null;
+    String q = xmlQuery.getKwdQueryString();
+    if (q.contains("ConfigUrl=")){
+    	Pattern parameterPattern = Pattern.compile("ConfigUrl=(.+?)( .*)?$");
+    	Matcher fileMatch = parameterPattern.matcher(q);
+    	while (fileMatch.find()) {
+    		configFileLoc = fileMatch.group(1);
+    	}
+    } else {
+    	configFileLoc = System.getProperty("org.apache.oodt.opendap.config.filePath");
+    }
+    
+    if (configFileLoc.isEmpty()){
+    	throw new ProfileException(
+    		"Configuration file not found. Please specify in System property opendap.config.filePath or as URL parameter ConfigUrl");
+    } else {
+    	try {
+    		this.conf = OpendapConfigReader.read(configFileLoc);
+    	} catch (FileNotFoundException e) {
+    		throw new ProfileException("FileNotFoundException: File not found!");
+    	} catch (MalformedURLException e) {
+    		throw new ProfileException("MalformedURLException: please fix file URL");
+    	}
+    }
+    
     List<Profile> profiles = new Vector<Profile>();
     List<DapRoot> roots = this.conf.getRoots();
-
+	  
     for (DapRoot root : roots) {
       DatasetExtractor d = new DatasetExtractor(xmlQuery, root.getCatalogUrl()
           .toExternalForm(), root.getDatasetUrl().toExternalForm());