Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 49312 Details for
Bug 155904
Support for Refresh http attribute to the web connector
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
implemented Refresh header handling
Clipboard-attachment (text/plain), 6.09 KB, created by
Eugene Kuleshov
on 2006-09-03 12:31:15 EDT
(
hide
)
Description:
implemented Refresh header handling
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2006-09-03 12:31:15 EDT
Size:
6.09 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.sandbox >Index: src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.sandbox/src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java,v >retrieving revision 1.15 >diff -u -r1.15 WebQueryWizardPage.java >--- src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java 31 Aug 2006 18:45:50 -0000 1.15 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebQueryWizardPage.java 3 Sep 2006 16:33:54 -0000 >@@ -57,7 +57,7 @@ > private Text regexpText; > private Table previewTable; > >- private StringBuffer webPage; >+ private String webPage; > > private TaskRepository repository; > private AbstractRepositoryConnector connector; >@@ -267,20 +267,17 @@ > active = true; > do { > final MultiStatus queryStatus = new MultiStatus(TasksUiPlugin.PLUGIN_ID, IStatus.OK, "Query result", null); >- final List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>(); >+ final List<AbstractQueryHit> queryHits = new ArrayList<AbstractQueryHit>(); > try { > if(webPage==null) { > webPage = WebRepositoryConnector.fetchResource(currentUrl); > } > > AbstractQueryHitCollector collector = new AbstractQueryHitCollector(TasksUiPlugin.getTaskListManager().getTaskList()) { >- > @Override > public void addMatch(AbstractQueryHit hit) { >- hits.add(hit); >- >+ queryHits.add(hit); > } >- > }; > > // TODO: Handle returned status >@@ -294,7 +291,6 @@ > "Parsing error: "+ex.getMessage(), null)); > } > >- final List<AbstractQueryHit> queryHits = hits; > Display.getDefault().asyncExec(new Runnable() { > public void run() { > updatePreviewTable(queryHits, queryStatus); >Index: src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java >=================================================================== >RCS file: /home/technology/org.eclipse.mylar/sandbox/org.eclipse.mylar.sandbox/src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java,v >retrieving revision 1.26 >diff -u -r1.26 WebRepositoryConnector.java >--- src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java 30 Aug 2006 03:10:57 -0000 1.26 >+++ src/org/eclipse/mylar/internal/sandbox/web/WebRepositoryConnector.java 3 Sep 2006 16:33:54 -0000 >@@ -11,21 +11,22 @@ > > package org.eclipse.mylar.internal.sandbox.web; > >-import java.io.BufferedReader; > import java.io.IOException; >-import java.io.InputStream; >-import java.io.InputStreamReader; >-import java.net.URL; >+import java.net.Proxy; > import java.util.Collections; > import java.util.List; > import java.util.Set; > import java.util.regex.Matcher; > import java.util.regex.Pattern; > >+import org.apache.commons.httpclient.Header; >+import org.apache.commons.httpclient.HttpClient; >+import org.apache.commons.httpclient.methods.GetMethod; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; >+import org.eclipse.mylar.internal.tasks.core.WebClientUtil; > import org.eclipse.mylar.internal.tasks.core.WebTask; > import org.eclipse.mylar.internal.tasks.ui.RetrieveTitleFromUrlJob; > import org.eclipse.mylar.tasks.core.AbstractRepositoryConnector; >@@ -179,7 +180,7 @@ > } > > >- public static IStatus performQuery(StringBuffer resource, String regexp, String taskPrefix, String repositoryUrl, IProgressMonitor monitor, IQueryHitCollector collector) { >+ public static IStatus performQuery(String resource, String regexp, String taskPrefix, String repositoryUrl, IProgressMonitor monitor, IQueryHitCollector collector) { > //List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>(); > > Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL | Pattern.UNICODE_CASE | Pattern.CANON_EQ); >@@ -215,42 +216,46 @@ > } > } > >- // TODO use commons http client >- public static StringBuffer fetchResource(String url) throws IOException { >- URL u = new URL(url); >- InputStream is = null; >+ public static String fetchResource(String url) throws IOException { >+ HttpClient client = new HttpClient(); >+ Proxy proxySettings = TasksUiPlugin.getDefault().getProxySettings(); >+ WebClientUtil.setupHttpClient(client, proxySettings, url); >+ >+ GetMethod get = new GetMethod(url); > try { >- is = u.openStream(); >- BufferedReader r = new BufferedReader(new InputStreamReader(is)); >- >- StringBuffer resource = new StringBuffer(); >- String line; >- while(true) { >- int retryCount = 0; >- do { >- if(retryCount>0) { >- try { >- Thread.sleep(1000L); >- } catch (InterruptedException ex) { >- // ignore >- } >- } >- line = r.readLine(); >- retryCount++; >- } while(line==null && retryCount<5); >- if(line==null) { >- break; >- } >- resource.append(line).append("\n"); >- } >- return resource; >- >- } finally { >- if(is!=null) { >- is.close(); >+ client.executeMethod(get); >+ >+ Header refreshHeader = get.getResponseHeader("Refresh"); >+ if(refreshHeader!=null) { >+ String value = refreshHeader.getValue(); >+ int n = value.indexOf(";url="); >+ if(n!=-1) { >+ value = value.substring(n + 5); >+ >+ int requestPath; >+ if(value.charAt(0)=='/') { >+ int colonSlashSlash = url.indexOf("://"); >+ requestPath = url.indexOf('/', colonSlashSlash + 3); >+ } else { >+ requestPath = url.lastIndexOf('/'); >+ } >+ >+ String refreshUrl; >+ if (requestPath==-1) { >+ refreshUrl = url + "/" + value; >+ } else { >+ refreshUrl = url.substring(0, requestPath+1) + value; >+ } >+ >+ get = new GetMethod(refreshUrl); >+ client.executeMethod(get); >+ } > } >+ >+ return get.getResponseBodyAsString(); >+ } finally { >+ get.releaseConnection(); > } >- > } > > @Override
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 155904
: 49312 |
49313