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 53697 Details for
Bug 164219
Missing error handling on 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]
Added page validation to query configuration page
Clipboard-attachment (text/plain), 8.14 KB, created by
Eugene Kuleshov
on 2006-11-11 17:00:43 EST
(
hide
)
Description:
Added page validation to query configuration page
Filename:
MIME Type:
Creator:
Eugene Kuleshov
Created:
2006-11-11 17:00:43 EST
Size:
8.14 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylar.tasks.web >Index: src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.web/src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java,v >retrieving revision 1.3 >diff -u -r1.3 WebRepositoryConnector.java >--- src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 11 Nov 2006 07:37:08 -0000 1.3 >+++ src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java 11 Nov 2006 22:04:06 -0000 >@@ -12,7 +12,9 @@ > package org.eclipse.mylar.internal.tasks.web; > > import java.io.IOException; >+import java.io.UnsupportedEncodingException; > import java.net.Proxy; >+import java.net.URLDecoder; > import java.util.ArrayList; > import java.util.Collections; > import java.util.List; >@@ -156,7 +158,6 @@ > public IStatus performQuery(AbstractRepositoryQuery query, TaskRepository repository, Proxy proxySettings, > IProgressMonitor monitor, QueryHitCollector resultCollector) { > if (query instanceof WebQuery) { >- String repositoryUrl = repository.getUrl(); > String repositoryUser = repository.getUserName(); > String repositoryPassword = repository.getPassword(); > >@@ -169,7 +170,7 @@ > try { > // if (regexp != null && regexp.trim().length() > 0) { > return performQuery(fetchResource(queryUrl, repositoryUser, repositoryPassword), queryPattern, >- taskPrefix, repositoryUrl, monitor, resultCollector); >+ taskPrefix, monitor, resultCollector, repository); > // } else { > // return performRssQuery(queryUrl, taskPrefix, repositoryUrl, repositoryUser, repositoryPassword, > // monitor, resultCollector); >@@ -204,11 +205,7 @@ > // ignore > } > >- public static IStatus performQuery(String resource, String regexp, String taskPrefix, String repositoryUrl, >- IProgressMonitor monitor, QueryHitCollector collector) { >- >- // List<AbstractQueryHit> hits = new ArrayList<AbstractQueryHit>(); >- >+ public static IStatus performQuery(String resource, String regexp, String taskPrefix, IProgressMonitor monitor, QueryHitCollector collector, TaskRepository repository) { > Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL > | Pattern.UNICODE_CASE | Pattern.CANON_EQ); > Matcher matcher = p.matcher(resource); >@@ -224,9 +221,10 @@ > } > if (matcher.groupCount() >= 1) { > String id = matcher.group(1); >- String description = matcher.groupCount() > 1 ? matcher.group(2) : null; >+ String description = matcher.groupCount() > 1 ? cleanup(matcher.group(2), repository) : null; > try { >- collector.accept(new WebQueryHit(TasksUiPlugin.getTaskListManager().getTaskList(), repositoryUrl, description, id, taskPrefix)); >+ collector.accept(new WebQueryHit(TasksUiPlugin.getTaskListManager().getTaskList(), >+ repository.getUrl(), description, id, taskPrefix)); > } catch (CoreException e) { > return new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, > "Unable collect results.", e); >@@ -243,6 +241,17 @@ > } > } > >+ private static String cleanup(String text, TaskRepository repository) { >+ try { >+ text = URLDecoder.decode(text, repository.getCharacterEncoding()); >+ } catch (UnsupportedEncodingException ex) { >+ // ignore >+ } >+ >+ text = text.replaceAll("<!--.+?-->", ""); >+ return text.trim(); >+ } >+ > /* > public static IStatus performRssQuery(String queryUrl, String taskPrefix, String repositoryUrl, > String repositoryUser, String repositoryPassword, IProgressMonitor monitor, QueryHitCollector collector) { >Index: src/org/eclipse/mylar/internal/tasks/web/WebQueryWizardPage.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.mylar/org.eclipse.mylar.tasks.web/src/org/eclipse/mylar/internal/tasks/web/WebQueryWizardPage.java,v >retrieving revision 1.1 >diff -u -r1.1 WebQueryWizardPage.java >--- src/org/eclipse/mylar/internal/tasks/web/WebQueryWizardPage.java 10 Nov 2006 02:29:02 -0000 1.1 >+++ src/org/eclipse/mylar/internal/tasks/web/WebQueryWizardPage.java 11 Nov 2006 22:04:05 -0000 >@@ -49,16 +49,16 @@ > > /** > * Wizard page for configuring and preview web query >- * >+ * > * @author Eugene Kuleshov > */ > public class WebQueryWizardPage extends AbstractRepositoryQueryPage { > private Text queryUrlText; > private Text queryPatternText; > private Table previewTable; >- >+ > private String webPage; >- >+ > private TaskRepository repository; > private WebQuery query; > private UpdatePreviewJob updatePreviewJob; >@@ -66,8 +66,8 @@ > private FormToolkit toolkit = new FormToolkit(Display.getCurrent()); > private ParametersEditor parametersEditor; > private Map<String, String> oldProperties; >- >- >+ >+ > public WebQueryWizardPage(TaskRepository repository) { > this(repository, null); > } >@@ -116,7 +116,7 @@ > // } > // }); > // queryTitleText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); >- >+ > parametersEditor = new ParametersEditor(composite, SWT.NONE); > GridData gridData1 = new GridData(SWT.FILL, SWT.FILL, true, true); > gridData1.heightHint = 80; >@@ -160,7 +160,7 @@ > GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false); > gridData.heightHint = 45; > queryPatternText.setLayoutData(gridData); >- >+ > // regexpText.addModifyListener(new ModifyListener() { > // public void modifyText(final ModifyEvent e) { > // if(webPage!=null) { >@@ -178,7 +178,7 @@ > updatePreview(); > } > }); >- >+ > previewTable = new Table(composite1, SWT.BORDER); > GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, false, true, 3, 1); > gridData2.heightHint = 60; >@@ -195,15 +195,15 @@ > colDescription.setText("Description"); > > setControl(composite); >- >+ > LinkedHashMap<String, String> vars = new LinkedHashMap<String, String>(); > Map<String, String> params = new LinkedHashMap<String, String>(); > if(repository!=null) { >- >- >+ >+ > queryUrlText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_URL))); > queryPatternText.setText(addVars(vars, repository.getProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP))); >- >+ > oldProperties = repository.getProperties(); > params.putAll(oldProperties); > } >@@ -245,14 +245,20 @@ > if(!updatePreviewJob.isActive()) { > updatePreviewJob.schedule(); > } >- > } >- >+ >+ public boolean isPageComplete() { >+ if(getErrorMessage()!=null) { >+ return false; >+ } >+ return super.isPageComplete(); >+ } >+ > void updatePreviewTable(List<AbstractQueryHit> hits, MultiStatus queryStatus) { > if(previewTable.isDisposed()) { > return; > } >- >+ > previewTable.removeAll(); > > if(hits!=null) { >@@ -279,7 +285,7 @@ > setPageComplete(false); > } > } >- >+ > private final class UpdatePreviewJob extends Job { > private volatile String url; > private volatile String regexp; >@@ -289,7 +295,7 @@ > private UpdatePreviewJob(String name) { > super(name); > } >- >+ > public boolean isActive() { > return active; > } >@@ -319,10 +325,12 @@ > queryHits.add(hit); > } > }; >- >- // TODO: Handle returned status >- WebRepositoryConnector.performQuery(webPage, evaluatedRegexp, null, null, monitor, collector); >- >+ >+ IStatus status = WebRepositoryConnector.performQuery(webPage, evaluatedRegexp, null, monitor, collector, repository); >+ if(!status.isOK()) { >+ queryStatus.add(status); >+ } >+ > } catch (final IOException ex) { > queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, > "Unable to fetch resource: "+ex.getMessage(), null)); >@@ -330,7 +338,7 @@ > queryStatus.add(new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, > "Parsing error: "+ex.getMessage(), null)); > } >- >+ > Display.getDefault().asyncExec(new Runnable() { > public void run() { > updatePreviewTable(queryHits, queryStatus); >@@ -341,6 +349,6 @@ > return Status.OK_STATUS; > } > } >- >+ > }
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 164219
: 53697 |
53698
|
53887