Use actual key parsing methods to make sure we can get a key before claiming we'll be able to open a URL.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@2026 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Tom Morris 2011-02-23 20:28:56 +00:00
parent c5312a2e6a
commit 3a9ea77b5c

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, Thomas F. Morris * Copyright (c) 2010,2011. Thomas F. Morris
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -410,7 +410,7 @@ public class GDataImporter implements UrlImporter {
@Override @Override
public boolean canImportData(URL url) { public boolean canImportData(URL url) {
return isSpreadsheetURL(url) | isFusionTableURL(url); return isSpreadsheetURL(url) || isFusionTableURL(url);
} }
private boolean isSpreadsheetURL(URL url) { private boolean isSpreadsheetURL(URL url) {
@ -420,7 +420,9 @@ public class GDataImporter implements UrlImporter {
query = ""; query = "";
} }
// http://spreadsheets.google.com/ccc?key=tI36b9Fxk1lFBS83iR_3XQA&hl=en // http://spreadsheets.google.com/ccc?key=tI36b9Fxk1lFBS83iR_3XQA&hl=en
return host.endsWith(".google.com") && host.contains("spreadsheet") && query.contains("key="); return host.endsWith(".google.com")
&& host.contains("spreadsheet")
&& getSpreadsheetKey(url) != null;
} }
private boolean isFusionTableURL(URL url) { private boolean isFusionTableURL(URL url) {
@ -431,7 +433,7 @@ public class GDataImporter implements UrlImporter {
} }
return url.getHost().endsWith(".google.com") return url.getHost().endsWith(".google.com")
&& url.getPath().startsWith("/fusiontables/DataSource") && url.getPath().startsWith("/fusiontables/DataSource")
&& query.contains("dsrcid="); && getFusionTableKey(url) != null;
} }
// Modified version of FeedURLFactor.getSpreadsheetKeyFromUrl() // Modified version of FeedURLFactor.getSpreadsheetKeyFromUrl()