Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 151602 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/mylar/tasks/tests/WebRepositoryConnectorTest.java (-5 / +17 lines)
Lines 60-81 Link Here
60
	    Map<String, String> attributes = new HashMap<String, String>(template.getAttributes());
60
	    Map<String, String> attributes = new HashMap<String, String>(template.getAttributes());
61
	    for(Map.Entry<String, String> e : attributes.entrySet()) {
61
	    for(Map.Entry<String, String> e : attributes.entrySet()) {
62
	        String key = e.getKey();
62
	        String key = e.getKey();
63
	        if(key.startsWith(WebRepositoryConnector.PARAM_PREFIX)) {
63
//	        if(key.startsWith(WebRepositoryConnector.PARAM_PREFIX)) {
64
	            params.put(key, e.getValue());
64
	            params.put(key, e.getValue());
65
	        }
65
//	        }
66
	    }
66
	    }
67
67
68
        TaskRepository repository = new TaskRepository(WebTask.REPOSITORY_TYPE, template.repositoryUrl, params);
68
        TaskRepository repository = new TaskRepository(WebTask.REPOSITORY_TYPE, template.repositoryUrl, params);
69
        repository.setAuthenticationCredentials("user", "pwd");
69
        if(repository.getUrl().equals("http://demo.otrs.org")) {
70
        	// HACK: OTRS repository require auth 
71
        	repository.setAuthenticationCredentials("skywalker", "skywalker");
72
//        } else {
73
//        	repository.setAuthenticationCredentials("user", "pwd");
74
        }
70
75
71
        String taskQueryUrl = WebRepositoryConnector.evaluateParams(template.taskQueryUrl, repository);
76
        String taskQueryUrl = WebRepositoryConnector.evaluateParams(template.taskQueryUrl, repository);
72
        String buffer = WebRepositoryConnector.fetchResource(taskQueryUrl, null, null, null);
77
        String buffer = WebRepositoryConnector.fetchResource(taskQueryUrl, params, repository);
78
        assertTrue("Unable to fetch resource\n" + taskQueryUrl, buffer != null && buffer.length() > 0);
73
79
74
        String regexp = WebRepositoryConnector.evaluateParams(template.getAttribute(WebRepositoryConnector.PROPERTY_QUERY_REGEXP), repository);
80
        String regexp = WebRepositoryConnector.evaluateParams(template.getAttribute(WebRepositoryConnector.PROPERTY_QUERY_REGEXP), repository);
75
        IStatus resultingStatus = WebRepositoryConnector.performQuery(buffer, regexp, null, monitor, collector, repository);
81
        IStatus resultingStatus = WebRepositoryConnector.performQuery(buffer, regexp, null, monitor, collector, repository);
76
82
77
        assertTrue("Query failed\n"+taskQueryUrl+"\n"+regexp+"\n"+resultingStatus.toString(), queryStatus.isOK());
83
        assertTrue("Query failed\n"+taskQueryUrl+"\n"+regexp+"\n"+resultingStatus.toString(), queryStatus.isOK());
78
        assertTrue("Expected non-empty query result\n"+taskQueryUrl+"\n"+regexp, hits.size()>0);
84
        try {
85
			assertTrue("Expected non-empty query result\n" + taskQueryUrl + "\n" + regexp, hits.size() > 0);
86
		} catch (Exception e) {
87
			System.err.println(taskQueryUrl);
88
			System.err.println(buffer);
89
			System.err.println("--------------------------------------------------------");
90
		}
79
	}
91
	}
80
92
81
	public String getName() {
93
	public String getName() {
(-)src/org/eclipse/mylar/internal/tasks/web/WebRepositorySettingsPage.java (-28 / +169 lines)
Lines 17-22 Link Here
17
import org.eclipse.jface.layout.GridDataFactory;
17
import org.eclipse.jface.layout.GridDataFactory;
18
import org.eclipse.jface.util.IPropertyChangeListener;
18
import org.eclipse.jface.util.IPropertyChangeListener;
19
import org.eclipse.jface.util.PropertyChangeEvent;
19
import org.eclipse.jface.util.PropertyChangeEvent;
20
import org.eclipse.jface.viewers.ComboViewer;
21
import org.eclipse.jface.viewers.IStructuredContentProvider;
22
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.jface.viewers.StructuredSelection;
24
import org.eclipse.jface.viewers.Viewer;
20
import org.eclipse.mylar.internal.tasks.ui.wizards.AbstractRepositorySettingsPage;
25
import org.eclipse.mylar.internal.tasks.ui.wizards.AbstractRepositorySettingsPage;
21
import org.eclipse.mylar.tasks.core.RepositoryTemplate;
26
import org.eclipse.mylar.tasks.core.RepositoryTemplate;
22
import org.eclipse.mylar.tasks.core.TaskRepository;
27
import org.eclipse.mylar.tasks.core.TaskRepository;
Lines 26-31 Link Here
26
import org.eclipse.swt.events.SelectionListener;
31
import org.eclipse.swt.events.SelectionListener;
27
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridData;
28
import org.eclipse.swt.layout.GridLayout;
33
import org.eclipse.swt.layout.GridLayout;
34
import org.eclipse.swt.widgets.Combo;
29
import org.eclipse.swt.widgets.Composite;
35
import org.eclipse.swt.widgets.Composite;
30
import org.eclipse.swt.widgets.Display;
36
import org.eclipse.swt.widgets.Display;
31
import org.eclipse.swt.widgets.Label;
37
import org.eclipse.swt.widgets.Label;
Lines 36-44 Link Here
36
import org.eclipse.ui.forms.widgets.FormToolkit;
42
import org.eclipse.ui.forms.widgets.FormToolkit;
37
import org.eclipse.ui.forms.widgets.Section;
43
import org.eclipse.ui.forms.widgets.Section;
38
44
45
import static org.eclipse.mylar.internal.tasks.web.Util.*;
46
47
39
/**
48
/**
40
 * Settings page for generic web-based repository connector
49
 * Settings page for generic web-based repository connector
41
 * 
50
 *
42
 * @author Eugene Kuleshov
51
 * @author Eugene Kuleshov
43
 */
52
 */
44
public class WebRepositorySettingsPage extends AbstractRepositorySettingsPage implements IPropertyChangeListener {
53
public class WebRepositorySettingsPage extends AbstractRepositorySettingsPage implements IPropertyChangeListener {
Lines 48-67 Link Here
48
	private static final String DESCRIPTION = "Select a server template example and modify the parameters to match the settings "
57
	private static final String DESCRIPTION = "Select a server template example and modify the parameters to match the settings "
49
			+ "for your project, usually found in the query URL.";
58
			+ "for your project, usually found in the query URL.";
50
59
60
	private ParametersEditor parametersEditor;
61
51
	private Text taskUrlText;
62
	private Text taskUrlText;
52
63
53
	private Text newTaskText;
64
	private Text newTaskText;
54
65
55
	private Text queryUrlText;
66
	private Text queryUrlText;
56
67
68
	private ComboViewer queryRequestMethod;
69
57
	private Text queryPatternText;
70
	private Text queryPatternText;
58
71
59
	private ParametersEditor parametersEditor;
72
	private Text loginFormUrlText;
73
74
	private Text loginTokenPatternText;
75
76
	private Text loginRequestUrlText;
77
78
	private ComboViewer loginRequestMethod;
79
60
80
61
	private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
81
	private FormToolkit toolkit = new FormToolkit(Display.getCurrent());
62
82
63
	private Map<String, String> oldProperties;
83
	private Map<String, String> oldProperties;
64
84
85
65
	public WebRepositorySettingsPage(AbstractRepositoryConnectorUi repositoryUi) {
86
	public WebRepositorySettingsPage(AbstractRepositoryConnectorUi repositoryUi) {
66
		super(TITLE, DESCRIPTION, repositoryUi);
87
		super(TITLE, DESCRIPTION, repositoryUi);
67
	}
88
	}
Lines 79-97 Link Here
79
				RepositoryTemplate template = connector.getTemplate(text);
100
				RepositoryTemplate template = connector.getTemplate(text);
80
				if (template != null) {
101
				if (template != null) {
81
					repositoryLabelEditor.setStringValue(template.label);
102
					repositoryLabelEditor.setStringValue(template.label);
82
					setUrl(template.repositoryUrl);
103
					setUrl(nvl(template.repositoryUrl));
83
					taskUrlText.setText(template.taskPrefixUrl);
104
84
					newTaskText.setText(template.newTaskUrl);
105
					taskUrlText.setText(nvl(template.taskPrefixUrl));
85
					queryUrlText.setText(template.taskQueryUrl);
106
					newTaskText.setText(nvl(template.newTaskUrl));
86
					queryPatternText.setText(template.getAttribute(WebRepositoryConnector.PROPERTY_QUERY_REGEXP));
107
108
					queryUrlText.setText(nvl(template.taskQueryUrl));
109
					selectMethod(queryRequestMethod, //
110
							template.getAttribute(WebRepositoryConnector.PROPERTY_QUERY_METHOD));
111
					queryPatternText.setText(nvl(template.getAttribute(WebRepositoryConnector.PROPERTY_QUERY_REGEXP)));
112
113
					loginRequestUrlText.setText(nvl(template.getAttribute(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_URL)));
114
					selectMethod(loginRequestMethod, //
115
							template.getAttribute(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_METHOD));
116
					loginFormUrlText
117
							.setText(nvl(template.getAttribute(WebRepositoryConnector.PROPERTY_LOGIN_FORM_URL)));
118
					loginTokenPatternText.setText(nvl(template
119
							.getAttribute(WebRepositoryConnector.PROPERTY_LOGIN_TOKEN_REGEXP)));
87
120
88
					parametersEditor.removeAll();
121
					parametersEditor.removeAll();
89
122
90
					for (Map.Entry<String, String> entry : template.getAttributes().entrySet()) {
123
					for (Map.Entry<String, String> entry : template.getAttributes().entrySet()) {
91
						String key = entry.getKey();
124
						String key = entry.getKey();
92
						if (key.startsWith(WebRepositoryConnector.PARAM_PREFIX)) {
125
						if (key.startsWith(WebRepositoryConnector.PARAM_PREFIX)) {
93
							parametersEditor.add(key.substring(WebRepositoryConnector.PARAM_PREFIX.length()), entry
126
							parametersEditor.add(key.substring(WebRepositoryConnector.PARAM_PREFIX.length()), //
94
									.getValue());
127
									entry.getValue());
95
						}
128
						}
96
					}
129
					}
97
130
Lines 107-131 Link Here
107
		});
140
		});
108
141
109
		Composite editor = getParameterEditor(parent);
142
		Composite editor = getParameterEditor(parent);
110
		GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 240).grab(true, true).span(2, 1).applyTo(editor);
143
		// GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 240).grab(true, true).span(2, 1).applyTo(editor);
111
144
		GridDataFactory.fillDefaults().hint(200, SWT.DEFAULT).span(2, SWT.DEFAULT).applyTo(editor);
145
		
112
		if (repository != null) {
146
		if (repository != null) {
113
			taskUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_TASK_URL));
147
			taskUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_TASK_URL));
114
			newTaskText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_TASK_CREATION_URL));
148
			newTaskText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_TASK_CREATION_URL));
149
150
			selectMethod(queryRequestMethod, getTextProperty(WebRepositoryConnector.PROPERTY_QUERY_METHOD));
115
			queryUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_QUERY_URL));
151
			queryUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_QUERY_URL));
116
			queryPatternText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP));
152
			queryPatternText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP));
117
153
154
			loginFormUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_LOGIN_FORM_URL));
155
			loginTokenPatternText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_LOGIN_TOKEN_REGEXP));
156
157
			selectMethod(loginRequestMethod, getTextProperty(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_METHOD));
158
			loginRequestUrlText.setText(getTextProperty(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_URL));
159
118
			oldProperties = repository.getProperties();
160
			oldProperties = repository.getProperties();
119
			parametersEditor.addParams(oldProperties, new LinkedHashMap<String, String>());
161
			parametersEditor.addParams(oldProperties, new LinkedHashMap<String, String>());
120
		}
162
		}
121
	}
163
	}
122
164
123
	private String getTextProperty(String name) {
165
	private void selectMethod(ComboViewer viewer, String method) {
124
		String value = repository.getProperty(name);
166
		if(!isPresent(method)) {
125
		if (value == null) {
167
			method = WebRepositoryConnector.REQUEST_GET;
126
			return "";
127
		}
168
		}
128
		return value;
169
		viewer.setSelection(new StructuredSelection(new Object[] {method}), true);
170
	}
171
172
	private String getTextProperty(String name) {
173
		return nvl(repository.getProperty(name));
129
	}
174
	}
130
175
131
	protected boolean isValidUrl(String name) {
176
	protected boolean isValidUrl(String name) {
Lines 153-162 Link Here
153
		gridData_1.minimumHeight = 80;
198
		gridData_1.minimumHeight = 80;
154
		parametersEditor.setLayoutData(gridData_1);
199
		parametersEditor.setLayoutData(gridData_1);
155
200
201
		createAdvancedComposite(parent, composite);
202
203
		return composite;
204
	}
205
206
	private void createAdvancedComposite(Composite parent, final Composite composite) {
156
		ExpandableComposite expComposite = toolkit.createExpandableComposite(composite, Section.COMPACT
207
		ExpandableComposite expComposite = toolkit.createExpandableComposite(composite, Section.COMPACT
157
				| Section.TWISTIE | Section.TITLE_BAR);
208
				| Section.TWISTIE | Section.TITLE_BAR);
158
		expComposite.clientVerticalSpacing = 0;
209
		expComposite.clientVerticalSpacing = 0;
159
		GridData gridData_2 = new GridData(SWT.FILL, SWT.FILL, true, false);
210
		GridData gridData_2 = new GridData(SWT.FILL, SWT.TOP, true, false);
160
		gridData_2.horizontalIndent = -5;
211
		gridData_2.horizontalIndent = -5;
161
		expComposite.setLayoutData(gridData_2);
212
		expComposite.setLayoutData(gridData_2);
162
		expComposite.setFont(parent.getFont());
213
		expComposite.setFont(parent.getFont());
Lines 164-177 Link Here
164
		expComposite.setText("Advanced &Configuration");
215
		expComposite.setText("Advanced &Configuration");
165
		expComposite.addExpansionListener(new ExpansionAdapter() {
216
		expComposite.addExpansionListener(new ExpansionAdapter() {
166
			public void expansionStateChanged(ExpansionEvent e) {
217
			public void expansionStateChanged(ExpansionEvent e) {
167
				composite.layout();
218
				getControl().getShell().pack();
168
			}
219
			}
169
		});
220
		});
170
		toolkit.paintBordersFor(expComposite);
221
		toolkit.paintBordersFor(expComposite);
171
222
172
		Composite composite2 = toolkit.createComposite(expComposite, SWT.BORDER);
223
		Composite composite2 = toolkit.createComposite(expComposite, SWT.BORDER);
173
		GridLayout gridLayout2 = new GridLayout();
224
		GridLayout gridLayout2 = new GridLayout();
174
		gridLayout2.numColumns = 2;
225
		gridLayout2.numColumns = 3;
175
		gridLayout2.verticalSpacing = 0;
226
		gridLayout2.verticalSpacing = 0;
176
		composite2.setLayout(gridLayout2);
227
		composite2.setLayout(gridLayout2);
177
		expComposite.setClient(composite2);
228
		expComposite.setClient(composite2);
Lines 180-208 Link Here
180
		taskUrlLabel.setLayoutData(new GridData());
231
		taskUrlLabel.setLayoutData(new GridData());
181
232
182
		taskUrlText = new Text(composite2, SWT.BORDER);
233
		taskUrlText = new Text(composite2, SWT.BORDER);
183
		taskUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
234
		taskUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
184
235
185
		Label newTaskLabel = toolkit.createLabel(composite2, "&New Task URL:", SWT.NONE);
236
		Label newTaskLabel = toolkit.createLabel(composite2, "&New Task URL:", SWT.NONE);
186
		newTaskLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
237
		newTaskLabel.setLayoutData(new GridData());
187
238
188
		newTaskText = new Text(composite2, SWT.BORDER);
239
		newTaskText = new Text(composite2, SWT.BORDER);
189
		newTaskText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
240
		newTaskText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
241
242
		final Label separatorLabel2 = new Label(composite2, SWT.HORIZONTAL | SWT.SEPARATOR);
243
		final GridData gridData_4 = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1);
244
		gridData_4.verticalIndent = 5;
245
		gridData_4.heightHint = 5;
246
		separatorLabel2.setLayoutData(gridData_4);
247
		toolkit.adapt(separatorLabel2, true, true);
190
248
191
		Label queryUrlLabel = toolkit.createLabel(composite2, "&Query URL:", SWT.NONE);
249
		Label queryUrlLabel = toolkit.createLabel(composite2, "&Query Request URL:", SWT.NONE);
192
		queryUrlLabel.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
250
		queryUrlLabel.setLayoutData(new GridData());
193
251
194
		queryUrlText = new Text(composite2, SWT.BORDER);
252
		queryUrlText = new Text(composite2, SWT.BORDER);
195
		queryUrlText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
253
		queryUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
254
255
		queryRequestMethod = new ComboViewer(composite2, SWT.BORDER | SWT.READ_ONLY);
256
		queryRequestMethod.setContentProvider(new MethodTypeContentProvider());
257
		queryRequestMethod.setInput("");
258
		{
259
			Combo combo = queryRequestMethod.getCombo();
260
			toolkit.adapt(combo, true, true);
261
			combo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
262
		}
196
263
197
		Label queryPatternLabel = toolkit.createLabel(composite2, "Query &Pattern:", SWT.NONE);
264
		Label queryPatternLabel = toolkit.createLabel(composite2, "Query &Pattern:", SWT.NONE);
198
		queryPatternLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.FILL, false, true));
265
		queryPatternLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
199
266
200
		queryPatternText = new Text(composite2, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
267
		queryPatternText = new Text(composite2, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
201
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
268
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
269
		gridData.widthHint = 200;
202
		gridData.heightHint = 40;
270
		gridData.heightHint = 40;
203
		queryPatternText.setLayoutData(gridData);
271
		queryPatternText.setLayoutData(gridData);
204
272
205
		return composite;
273
		final Label separatorLabel1 = new Label(composite2, SWT.HORIZONTAL | SWT.SEPARATOR);
274
		final GridData gridData_3 = new GridData(SWT.FILL, SWT.CENTER, false, false, 3, 1);
275
		gridData_3.heightHint = 5;
276
		gridData_3.verticalIndent = 5;
277
		separatorLabel1.setLayoutData(gridData_3);
278
		toolkit.adapt(separatorLabel1, true, true);
279
280
		final Label loginrequestUrlLabel = new Label(composite2, SWT.NONE);
281
		loginrequestUrlLabel.setLayoutData(new GridData());
282
		toolkit.adapt(loginrequestUrlLabel, true, true);
283
		loginrequestUrlLabel.setText("Login &Request URL:");
284
285
		loginRequestUrlText = new Text(composite2, SWT.BORDER);
286
		toolkit.adapt(loginRequestUrlText, true, true);
287
		loginRequestUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
288
289
		loginRequestMethod = new ComboViewer(composite2, SWT.BORDER | SWT.READ_ONLY);
290
		loginRequestMethod.setContentProvider(new MethodTypeContentProvider());
291
		loginRequestMethod.setInput("");
292
		{
293
			Combo combo = loginRequestMethod.getCombo();
294
			toolkit.adapt(combo, true, true);
295
			combo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
296
		}
297
298
		Label loginPageLabel = toolkit.createLabel(composite2, "Login &Form URL:", SWT.NONE);
299
		loginPageLabel.setLayoutData(new GridData());
300
301
		loginFormUrlText = new Text(composite2, SWT.BORDER);
302
		loginFormUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
303
304
		Label loginTokenLabel = toolkit.createLabel(composite2, "Login &Token Pattern:", SWT.NONE);
305
		loginTokenLabel.setLayoutData(new GridData(SWT.LEFT, SWT.FILL, false, true));
306
307
		loginTokenPatternText = new Text(composite2, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
308
		final GridData gridData_1 = new GridData(SWT.FILL, SWT.FILL, false, true, 2, 1);
309
		gridData_1.widthHint = 200;
310
		gridData_1.heightHint = 30;
311
		loginTokenPatternText.setLayoutData(gridData_1);
312
206
	}
313
	}
207
314
208
	public void propertyChange(PropertyChangeEvent event) {
315
	public void propertyChange(PropertyChangeEvent event) {
Lines 216-223 Link Here
216
	public void updateProperties(TaskRepository repository) {
323
	public void updateProperties(TaskRepository repository) {
217
		repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_URL, taskUrlText.getText());
324
		repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_URL, taskUrlText.getText());
218
		repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_CREATION_URL, newTaskText.getText());
325
		repository.setProperty(WebRepositoryConnector.PROPERTY_TASK_CREATION_URL, newTaskText.getText());
326
219
		repository.setProperty(WebRepositoryConnector.PROPERTY_QUERY_URL, queryUrlText.getText());
327
		repository.setProperty(WebRepositoryConnector.PROPERTY_QUERY_URL, queryUrlText.getText());
220
		repository.setProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP, queryPatternText.getText());
328
		repository.setProperty(WebRepositoryConnector.PROPERTY_QUERY_REGEXP, queryPatternText.getText());
329
		repository.setProperty(WebRepositoryConnector.PROPERTY_QUERY_METHOD, getSelection(queryRequestMethod));
330
331
		String loginRequestUrl = loginRequestUrlText.getText();
332
		repository.setProperty(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_URL, loginRequestUrl);
333
		if(loginRequestUrl.length()>0) {
334
			repository.setProperty(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_METHOD, getSelection(loginRequestMethod));
335
		} else {
336
			repository.removeProperty(WebRepositoryConnector.PROPERTY_LOGIN_REQUEST_METHOD);
337
		}
338
		repository.setProperty(WebRepositoryConnector.PROPERTY_LOGIN_FORM_URL, loginFormUrlText.getText());
339
		repository.setProperty(WebRepositoryConnector.PROPERTY_LOGIN_TOKEN_REGEXP, loginTokenPatternText.getText());
221
340
222
		if (oldProperties != null) {
341
		if (oldProperties != null) {
223
			for (Map.Entry<String, String> e : oldProperties.entrySet()) {
342
			for (Map.Entry<String, String> e : oldProperties.entrySet()) {
Lines 233-236 Link Here
233
		}
352
		}
234
	}
353
	}
235
354
355
	private String getSelection(ComboViewer viewer) {
356
		return (String) ((IStructuredSelection) viewer.getSelection()).getFirstElement();
357
	}
358
359
360
	private static class MethodTypeContentProvider implements IStructuredContentProvider {
361
362
		private static final Object[] ELEMENTS = new Object[] { WebRepositoryConnector.REQUEST_GET,
363
				WebRepositoryConnector.REQUEST_POST };
364
365
		public Object[] getElements(Object inputElement) {
366
			return ELEMENTS;
367
		}
368
369
		public void dispose() {
370
		}
371
372
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
373
		}
374
375
	}
376
236
}
377
}
(-)src/org/eclipse/mylar/internal/tasks/web/WebRepositoryConnector.java (-63 / +187 lines)
Lines 25-31 Link Here
25
25
26
import org.apache.commons.httpclient.Header;
26
import org.apache.commons.httpclient.Header;
27
import org.apache.commons.httpclient.HttpClient;
27
import org.apache.commons.httpclient.HttpClient;
28
import org.apache.commons.httpclient.HttpException;
29
import org.apache.commons.httpclient.HttpMethod;
28
import org.apache.commons.httpclient.methods.GetMethod;
30
import org.apache.commons.httpclient.methods.GetMethod;
31
import org.apache.commons.httpclient.methods.PostMethod;
29
import org.eclipse.core.runtime.CoreException;
32
import org.eclipse.core.runtime.CoreException;
30
import org.eclipse.core.runtime.IProgressMonitor;
33
import org.eclipse.core.runtime.IProgressMonitor;
31
import org.eclipse.core.runtime.IStatus;
34
import org.eclipse.core.runtime.IStatus;
Lines 45-53 Link Here
45
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
48
import org.eclipse.mylar.tasks.core.TaskRepositoryManager;
46
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
49
import org.eclipse.mylar.tasks.ui.TasksUiPlugin;
47
50
51
import static org.eclipse.mylar.internal.tasks.web.Util.*;
52
53
48
/**
54
/**
49
 * Generic connector for web based issue tracking systems
55
 * Generic connector for web based issue tracking systems
50
 * 
56
 *
51
 * @author Eugene Kuleshov
57
 * @author Eugene Kuleshov
52
 */
58
 */
53
public class WebRepositoryConnector extends AbstractRepositoryConnector {
59
public class WebRepositoryConnector extends AbstractRepositoryConnector {
Lines 58-65 Link Here
58
64
59
	public static final String PROPERTY_QUERY_URL = "queryUrl";
65
	public static final String PROPERTY_QUERY_URL = "queryUrl";
60
66
67
	public static final String PROPERTY_QUERY_METHOD = "queryMethod";
68
61
	public static final String PROPERTY_QUERY_REGEXP = "queryPattern";
69
	public static final String PROPERTY_QUERY_REGEXP = "queryPattern";
62
70
71
	public static final String PROPERTY_LOGIN_FORM_URL = "loginFormUrl";
72
73
	public static final String PROPERTY_LOGIN_TOKEN_REGEXP = "loginTokenPattern";
74
75
	public static final String PROPERTY_LOGIN_REQUEST_METHOD = "loginRequestMethod";
76
77
	public static final String PROPERTY_LOGIN_REQUEST_URL = "loginRequestUrl";
78
63
	public static final String PARAM_PREFIX = "param_";
79
	public static final String PARAM_PREFIX = "param_";
64
80
65
	public static final String PARAM_SERVER_URL = "serverUrl";
81
	public static final String PARAM_SERVER_URL = "serverUrl";
Lines 68-73 Link Here
68
84
69
	public static final String PARAM_PASSWORD = "password";
85
	public static final String PARAM_PASSWORD = "password";
70
86
87
	public static final String PARAM_LOGIN_TOKEN = "loginToken";
88
89
	public static final String REQUEST_POST = "POST";
90
91
	public static final String REQUEST_GET = "GET";
92
93
94
71
	public String getRepositoryType() {
95
	public String getRepositoryType() {
72
		return WebTask.REPOSITORY_TYPE;
96
		return WebTask.REPOSITORY_TYPE;
73
	}
97
	}
Lines 151-159 Link Here
151
	public IStatus performQuery(AbstractRepositoryQuery query, TaskRepository repository, IProgressMonitor monitor,
175
	public IStatus performQuery(AbstractRepositoryQuery query, TaskRepository repository, IProgressMonitor monitor,
152
			QueryHitCollector resultCollector) {
176
			QueryHitCollector resultCollector) {
153
		if (query instanceof WebQuery) {
177
		if (query instanceof WebQuery) {
154
			String repositoryUser = repository.getUserName();
155
			String repositoryPassword = repository.getPassword();
156
157
			WebQuery webQuery = (WebQuery) query;
178
			WebQuery webQuery = (WebQuery) query;
158
			Map<String, String> queryParameters = webQuery.getQueryParameters();
179
			Map<String, String> queryParameters = webQuery.getQueryParameters();
159
			String queryUrl = evaluateParams(query.getUrl(), queryParameters, repository);
180
			String queryUrl = evaluateParams(query.getUrl(), queryParameters, repository);
Lines 162-168 Link Here
162
183
163
			try {
184
			try {
164
				// if (regexp != null && regexp.trim().length() > 0) {
185
				// if (regexp != null && regexp.trim().length() > 0) {
165
				return performQuery(fetchResource(queryUrl, repositoryUser, repositoryPassword, repository.getProxy()), queryPattern,
186
				return performQuery(fetchResource(queryUrl, queryParameters, repository), queryPattern,
166
						taskPrefix, monitor, resultCollector, repository);
187
						taskPrefix, monitor, resultCollector, repository);
167
				// } else {
188
				// } else {
168
				// return performRssQuery(queryUrl, taskPrefix, repositoryUrl,
189
				// return performRssQuery(queryUrl, taskPrefix, repositoryUrl,
Lines 199-204 Link Here
199
		// ignore
220
		// ignore
200
	}
221
	}
201
222
223
	@Override
224
	public void updateTask(TaskRepository repository, AbstractRepositoryTask repositoryTask) throws CoreException {
225
	}
226
227
228
	// utility methods
229
202
	public static IStatus performQuery(String resource, String regexp, String taskPrefix, IProgressMonitor monitor,
230
	public static IStatus performQuery(String resource, String regexp, String taskPrefix, IProgressMonitor monitor,
203
			QueryHitCollector collector, TaskRepository repository) {
231
			QueryHitCollector collector, TaskRepository repository) {
204
		Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL
232
		Pattern p = Pattern.compile(regexp, Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL
Lines 247-318 Link Here
247
		return text.trim();
275
		return text.trim();
248
	}
276
	}
249
277
250
	/*
251
	 * public static IStatus performRssQuery(String queryUrl, String taskPrefix,
252
	 * String repositoryUrl, String repositoryUser, String repositoryPassword,
253
	 * IProgressMonitor monitor, QueryHitCollector collector) { SyndFeedInput
254
	 * input = new SyndFeedInput(); try { SyndFeed feed = input.build(new
255
	 * XmlReader(new URL(queryUrl)));
256
	 * 
257
	 * SimpleDateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
258
	 * 
259
	 * for (Iterator it = feed.getEntries().iterator(); it.hasNext(); ) {
260
	 * SyndEntry entry = (SyndEntry) it.next();
261
	 * 
262
	 * Date date = entry.getUpdatedDate(); if(date==null) { date =
263
	 * entry.getPublishedDate(); } if(date==null) { DCModule module = (DCModule)
264
	 * entry.getModule("http://purl.org/dc/elements/1.1/"); date =
265
	 * module.getDate(); } if(date==null) { // TODO }
266
	 * 
267
	 * String entryUri = entry.getUri(); if(entryUri.startsWith(taskPrefix)) {
268
	 * String id = df.format(date); // entryUri.substring(taskPrefix.length());
269
	 * 
270
	 * try { collector.accept(new WebQueryHit(id, id+": "+entry.getTitle(),
271
	 * taskPrefix, repositoryUrl)); } catch (CoreException e) { return new
272
	 * Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR, "Unable
273
	 * collect results.", e); } } } return Status.OK_STATUS; } catch (Exception
274
	 * ex) { return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.OK,
275
	 * "Could not fetch resource: " + queryUrl, ex); } }
276
	 */
277
278
278
	public static String fetchResource(String url, String user, String password, Proxy proxySettings) throws IOException {
279
//	 public static IStatus performRssQuery(String queryUrl, String taskPrefix, String repositoryUrl,
280
//			String repositoryUser, String repositoryPassword, IProgressMonitor monitor, QueryHitCollector collector) {
281
//		SyndFeedInput input = new SyndFeedInput();
282
//		try {
283
//			SyndFeed feed = input.build(new XmlReader(new URL(queryUrl)));
284
//
285
//			SimpleDateFormat df = new SimpleDateFormat("MMM dd, HH:mm");
286
//
287
//			for (Iterator it = feed.getEntries().iterator(); it.hasNext();) {
288
//				SyndEntry entry = (SyndEntry) it.next();
289
//
290
//				Date date = entry.getUpdatedDate();
291
//				if (date == null) {
292
//					date = entry.getPublishedDate();
293
//				}
294
//				if (date == null) {
295
//					DCModule module = (DCModule) entry.getModule("http://purl.org/dc/elements/1.1/");
296
//					date = module.getDate();
297
//				}
298
//				if (date == null) {
299
//					// TODO
300
//				}
301
//
302
//				String entryUri = entry.getUri();
303
//				if (entryUri.startsWith(taskPrefix)) {
304
//					String id = df.format(date); // entryUri.substring(taskPrefix.length());
305
//
306
//					try {
307
//						collector.accept(new WebQueryHit(id, id + ": " + entry.getTitle(), taskPrefix, repositoryUrl));
308
//					} catch (CoreException e) {
309
//						return new Status(IStatus.ERROR, TasksUiPlugin.PLUGIN_ID, IStatus.ERROR,
310
//								"Unable collect results.", e);
311
//					}
312
//				}
313
//			}
314
//			return Status.OK_STATUS;
315
//		} catch (Exception ex) {
316
//			return new Status(IStatus.OK, TasksUiPlugin.PLUGIN_ID, IStatus.OK, "Could not fetch resource: " + queryUrl,
317
//					ex);
318
//		}
319
//	}
320
321
322
	public static String fetchResource(String url, Map<String, String> params, TaskRepository repository) throws IOException {
279
		HttpClient client = new HttpClient();
323
		HttpClient client = new HttpClient();
280
		WebClientUtil.setupHttpClient(client, proxySettings, url, user, password);
324
		WebClientUtil.setupHttpClient(client, repository.getProxy(), url, //
325
				repository.getUserName(), repository.getPassword());
281
326
282
		GetMethod get = new GetMethod(url);
327
		loginRequestIfNeeded(client, params, repository);
283
		try {
284
			client.executeMethod(get);
285
			Header refreshHeader = get.getResponseHeader("Refresh");
286
328
287
			if (refreshHeader != null) {
329
		GetMethod method = new GetMethod(url);
288
				String value = refreshHeader.getValue();
330
		method.setFollowRedirects(false);
289
				int n = value.indexOf(";url=");
331
		return requestResource(url, client, method);
290
				if (n != -1) {
332
	}
291
					value = value.substring(n + 5);
333
292
					int requestPath;
334
	private static void loginRequestIfNeeded(HttpClient client, Map<String, String> params, TaskRepository repository)
293
					if (value.charAt(0) == '/') {
335
			throws HttpException, IOException {
294
						int colonSlashSlash = url.indexOf("://");
336
		if (!isPresent(repository.getUserName()) || !isPresent(repository.getPassword())
295
						requestPath = url.indexOf('/', colonSlashSlash + 3);
337
				|| !isPresent(repository.getProperty(PROPERTY_LOGIN_REQUEST_URL))) {
296
					} else {
338
			return;
297
						requestPath = url.lastIndexOf('/');
339
		}
298
					}
340
341
		String loginFormUrl = evaluateParams(repository.getProperty(PROPERTY_LOGIN_FORM_URL), params, repository);
342
		String loginToken = evaluateParams(repository.getProperty(PROPERTY_LOGIN_TOKEN_REGEXP), params, repository);
343
		if (isPresent(loginFormUrl) || isPresent(loginToken)) {
344
			GetMethod method = new GetMethod(loginFormUrl);
345
			method.setFollowRedirects(false);
346
			String loginFormPage = requestResource(loginFormUrl, client, method);
347
			if (loginFormPage != null) {
348
				Pattern p = Pattern.compile(loginToken);
349
				Matcher m = p.matcher(loginFormPage);
350
				if (m.find()) {
351
					params.put(PARAM_PREFIX + PARAM_LOGIN_TOKEN, m.group(1));
352
				}
353
			}
354
		}
299
355
300
					String refreshUrl;
356
		String loginRequestUrl = evaluateParams(repository.getProperty(PROPERTY_LOGIN_REQUEST_URL), params, repository);
301
					if (requestPath == -1) {
357
		String loginRequestMethod = repository.getProperty(PROPERTY_LOGIN_REQUEST_METHOD);
302
						refreshUrl = url + "/" + value;
303
					} else {
304
						refreshUrl = url.substring(0, requestPath + 1) + value;
305
					}
306
358
307
					get = new GetMethod(refreshUrl);
359
		HttpMethod method = null;
308
					client.executeMethod(get);
360
		if (REQUEST_POST.equals(loginRequestMethod)) {
361
			int n = loginRequestUrl.indexOf('?');
362
			if (n == -1) {
363
				method = new PostMethod(loginRequestUrl);
364
			} else {
365
				PostMethod postMethod = new PostMethod(loginRequestUrl.substring(0, n - 1));
366
				// TODO this does not take into account escaped values
367
				String[] requestParams = loginRequestUrl.substring(n + 1).split("&");
368
				for (String requestParam : requestParams) {
369
					String[] nv = requestParam.split("=");
370
					postMethod.addParameter(nv[0], nv.length == 1 ? "" : nv[1]);
371
				}
372
				method = postMethod;
373
			}
374
		} else {
375
			method = new GetMethod(loginRequestUrl);
376
			method.setFollowRedirects(false);
377
		}
378
379
		requestResource(loginRequestUrl, client, method);
380
	}
381
382
	private static String requestResource(String url, HttpClient client, HttpMethod method) throws IOException,
383
			HttpException {
384
		String refreshUrl = null;
385
		try {
386
			client.executeMethod(method);
387
388
			if(method.getStatusCode()==302) {
389
				Header location = method.getResponseHeader("Location");
390
				if (location!=null) {
391
					refreshUrl = location.getValue();
309
				}
392
				}
310
			}
393
			}
311
			return get.getResponseBodyAsString();
394
			if(refreshUrl == null) {
395
				refreshUrl = getRefreshUrl(url, method);
396
			}
397
			if (refreshUrl == null) {
398
				return method.getResponseBodyAsString();
399
			}
312
400
313
		} finally {
401
		} finally {
314
			get.releaseConnection();
402
			method.releaseConnection();
315
		}
403
		}
404
405
		if (refreshUrl != null) {
406
			method = new GetMethod(refreshUrl);
407
			try {
408
				client.executeMethod(method);
409
				return method.getResponseBodyAsString();
410
			} finally {
411
				method.releaseConnection();
412
			}
413
		}
414
		return null;
415
	}
416
417
	private static String getRefreshUrl(String url, HttpMethod method) {
418
		Header refreshHeader = method.getResponseHeader("Refresh");
419
		if (refreshHeader == null) {
420
			return null;
421
		}
422
		String value = refreshHeader.getValue();
423
		int n = value.indexOf(";url=");
424
		if (n == -1) {
425
			return null;
426
		}
427
		value = value.substring(n + 5);
428
		int requestPath;
429
		if (value.charAt(0) == '/') {
430
			int colonSlashSlash = url.indexOf("://");
431
			requestPath = url.indexOf('/', colonSlashSlash + 3);
432
		} else {
433
			requestPath = url.lastIndexOf('/');
434
		}
435
436
		String refreshUrl;
437
		if (requestPath == -1) {
438
			refreshUrl = url + "/" + value;
439
		} else {
440
			refreshUrl = url.substring(0, requestPath + 1) + value;
441
		}
442
		return refreshUrl;
316
	}
443
	}
317
444
318
	public static String evaluateParams(String value, Map<String, String> params, TaskRepository repository) {
445
	public static String evaluateParams(String value, Map<String, String> params, TaskRepository repository) {
Lines 352-358 Link Here
352
		return vars;
479
		return vars;
353
	}
480
	}
354
481
355
	@Override
356
	public void updateTask(TaskRepository repository, AbstractRepositoryTask repositoryTask) throws CoreException {
357
	}
358
}
482
}
(-)src/org/eclipse/mylar/internal/tasks/web/WebQueryWizardPage.java (-3 / +6 lines)
Lines 133-139 Link Here
133
		expComposite.setText("Advanced &Configuration");
133
		expComposite.setText("Advanced &Configuration");
134
		expComposite.addExpansionListener(new ExpansionAdapter() {
134
		expComposite.addExpansionListener(new ExpansionAdapter() {
135
			public void expansionStateChanged(ExpansionEvent e) {
135
			public void expansionStateChanged(ExpansionEvent e) {
136
				composite.layout();
136
				getControl().getShell().pack();
137
			}
137
			}
138
		});
138
		});
139
		toolkit.paintBordersFor(expComposite);
139
		toolkit.paintBordersFor(expComposite);
Lines 145-151 Link Here
145
		toolkit.createLabel(composite1, "&Query URL:", SWT.NONE);
145
		toolkit.createLabel(composite1, "&Query URL:", SWT.NONE);
146
146
147
		queryUrlText = new Text(composite1, SWT.BORDER);
147
		queryUrlText = new Text(composite1, SWT.BORDER);
148
		queryUrlText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
148
		final GridData gridData_2 = new GridData(SWT.FILL, SWT.CENTER, true, false);
149
		gridData_2.widthHint = 200;
150
		queryUrlText.setLayoutData(gridData_2);
149
		queryUrlText.addModifyListener(new ModifyListener() {
151
		queryUrlText.addModifyListener(new ModifyListener() {
150
			public void modifyText(final ModifyEvent e) {
152
			public void modifyText(final ModifyEvent e) {
151
				webPage = null;
153
				webPage = null;
Lines 158-163 Link Here
158
160
159
		queryPatternText = new Text(composite1, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
161
		queryPatternText = new Text(composite1, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.WRAP);
160
		GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
162
		GridData gridData = new GridData(SWT.FILL, SWT.TOP, true, false);
163
		gridData.widthHint = 200;
161
		gridData.heightHint = 45;
164
		gridData.heightHint = 45;
162
		queryPatternText.setLayoutData(gridData);
165
		queryPatternText.setLayoutData(gridData);
163
166
Lines 316-322 Link Here
316
				final List<AbstractQueryHit> queryHits = new ArrayList<AbstractQueryHit>();
319
				final List<AbstractQueryHit> queryHits = new ArrayList<AbstractQueryHit>();
317
				try {
320
				try {
318
					if(webPage==null) {
321
					if(webPage==null) {
319
						webPage = WebRepositoryConnector.fetchResource(evaluatedUrl, repository.getUserName(), repository.getPassword(), repository.getProxy());
322
						webPage = WebRepositoryConnector.fetchResource(evaluatedUrl, params, repository);
320
					}
323
					}
321
324
322
					QueryHitCollector collector = new QueryHitCollector(TasksUiPlugin.getTaskListManager().getTaskList()) {
325
					QueryHitCollector collector = new QueryHitCollector(TasksUiPlugin.getTaskListManager().getTaskList()) {
(-)src/org/eclipse/mylar/internal/tasks/web/WebQuery.java (-6 / +7 lines)
Lines 8-13 Link Here
8
8
9
package org.eclipse.mylar.internal.tasks.web;
9
package org.eclipse.mylar.internal.tasks.web;
10
10
11
import java.util.LinkedHashMap;
11
import java.util.Map;
12
import java.util.Map;
12
13
13
import org.eclipse.mylar.internal.tasks.core.WebTask;
14
import org.eclipse.mylar.internal.tasks.core.WebTask;
Lines 15-22 Link Here
15
import org.eclipse.mylar.tasks.core.TaskList;
16
import org.eclipse.mylar.tasks.core.TaskList;
16
17
17
/**
18
/**
18
 * Represents pattern-based query on repository web page  
19
 * Represents pattern-based query on repository web page
19
 * 
20
 *
20
 * @author Eugene Kuleshov
21
 * @author Eugene Kuleshov
21
 */
22
 */
22
public class WebQuery extends AbstractRepositoryQuery {
23
public class WebQuery extends AbstractRepositoryQuery {
Lines 25-31 Link Here
25
	private final String queryPattern;
26
	private final String queryPattern;
26
	private final Map<String, String> params;
27
	private final Map<String, String> params;
27
28
28
	public WebQuery(TaskList taskList, String description, 
29
	public WebQuery(TaskList taskList, String description,
29
			String queryUrl, String queryPattern, String taskPrefix,
30
			String queryUrl, String queryPattern, String taskPrefix,
30
			String repositoryUrl, Map<String, String> params) {
31
			String repositoryUrl, Map<String, String> params) {
31
		super(description, taskList);
32
		super(description, taskList);
Lines 45-57 Link Here
45
	public String getTaskPrefix() {
46
	public String getTaskPrefix() {
46
		return this.taskPrefix;
47
		return this.taskPrefix;
47
	}
48
	}
48
	
49
49
	public String getQueryPattern() {
50
	public String getQueryPattern() {
50
		return this.queryPattern;
51
		return this.queryPattern;
51
	}
52
	}
52
	
53
53
	public Map<String, String> getQueryParameters() {
54
	public Map<String, String> getQueryParameters() {
54
		return this.params;
55
		return new LinkedHashMap<String, String>(this.params);
55
	}
56
	}
56
57
57
}
58
}
(-)plugin.xml (-5 / +70 lines)
Lines 81-90 Link Here
81
            label="ASM (GForge)"
81
            label="ASM (GForge)"
82
            urlRepository="http://forge.objectweb.org/tracker"
82
            urlRepository="http://forge.objectweb.org/tracker"
83
            urlTask="${serverUrl}/?group_id=${group_id}&amp;func=detail&amp;atid=${atid}&amp;aid="
83
            urlTask="${serverUrl}/?group_id=${group_id}&amp;func=detail&amp;atid=${atid}&amp;aid="
84
            urlNewTask="${serverUrl}?group_id=${group_id}&amp;func=add"
84
            urlNewTask="${serverUrl}/?group_id=${group_id}&amp;func=add"
85
            urlTaskQuery="${serverUrl}?group_id=${group_id}&amp;atid=${atid}">
85
            urlTaskQuery="${serverUrl}/?group_id=${group_id}&amp;atid=${atid}&amp;_status=100&amp;set=custom">
86
        <attribute name="param_group_id" value="23"/>
86
        <attribute name="param_group_id" value="23"/>
87
        <attribute name="param_atid" value="350023"/>
87
        <attribute name="param_atid" value="100023"/>
88
        <attribute name="queryPattern"
88
        <attribute name="queryPattern"
89
                   value="&lt;a class=&quot;tracker&quot; href=&quot;/tracker/index.php\?func=detail&amp;aid=(.+?)&amp;group_id=${group_id}&amp;atid=${atid}&quot;&gt;(.+?)&lt;/a&gt;&lt;/td&gt;"/>
89
                   value="&lt;a class=&quot;tracker&quot; href=&quot;/tracker/index.php\?func=detail&amp;aid=(.+?)&amp;group_id=${group_id}&amp;atid=${atid}&quot;&gt;(.+?)&lt;/a&gt;&lt;/td&gt;"/>
90
     </repository>
90
     </repository>
Lines 93-100 Link Here
93
            label="Azureus (SourceForge)"
93
            label="Azureus (SourceForge)"
94
            urlRepository="http://sourceforge.net/tracker"
94
            urlRepository="http://sourceforge.net/tracker"
95
            urlTask="${serverUrl}/?group_id=${group_id}&amp;func=detail&amp;atid=${atid}&amp;aid="
95
            urlTask="${serverUrl}/?group_id=${group_id}&amp;func=detail&amp;atid=${atid}&amp;aid="
96
            urlNewTask="${serverUrl}?group_id=${group_id}&amp;func=add"
96
            urlNewTask="${serverUrl}/?group_id=${group_id}&amp;func=add"
97
            urlTaskQuery="${serverUrl}?group_id=${group_id}&amp;atid=${atid}">
97
            urlTaskQuery="${serverUrl}/?group_id=${group_id}&amp;atid=${atid}">
98
        <attribute name="param_group_id" value="84122"/>
98
        <attribute name="param_group_id" value="84122"/>
99
        <attribute name="param_atid" value="575154"/>
99
        <attribute name="param_atid" value="575154"/>
100
        <attribute name="queryPattern"
100
        <attribute name="queryPattern"
Lines 141-146 Link Here
141
        <attribute name="queryPattern"
141
        <attribute name="queryPattern"
142
                   value="&lt;tr .+?&lt;a href=&quot;view.php\?id=(.+?)&quot;&gt;.+?&lt;td class=&quot;left&quot;&gt;(.+?)&lt;/td&gt;&lt;/tr&gt;"/>
142
                   value="&lt;tr .+?&lt;a href=&quot;view.php\?id=(.+?)&quot;&gt;.+?&lt;td class=&quot;left&quot;&gt;(.+?)&lt;/td&gt;&lt;/tr&gt;"/>
143
     </repository>
143
     </repository>
144
     <!--
145
     <repository
146
           anonymous="true"
147
           label="ChangeLogic (anonymous)"
148
           repositoryKind="web"
149
           urlNewTask="${serverUrl}/index.php?event=Add_task"
150
           urlRepository="http://changelogic.araneaframework.org"
151
           urlTask="${serverUrl}/index.php?event=Show_public_task&amp;task_id="
152
           urlTaskQuery="${serverUrl}/index.php?event=Show_public_task_list">
153
        <attribute name="queryPattern"
154
              value="&lt;a href=&quot;index.php\?event\=Show_public_task&amp;amp;task_id\=.+?&amp;amp;project_id\=0&quot;&gt;(.+?)&lt;/a&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;(.+?)&lt;/td&gt;"/>
155
     </repository>
156
     -->
157
     <repository
158
           anonymous="false"
159
           label="Aranea Framework (ChangeLogic)"
160
           repositoryKind="web"
161
           urlRepository="http://changelogic.araneaframework.org"
162
           urlTask="${serverUrl}/index.php?event=Show_task&amp;task_id="
163
           urlNewTask="${serverUrl}/index.php?event=Add_task&amp;project_id=${project_id}"
164
           urlTaskQuery="${serverUrl}/index.php?event=Show_public_task_list&amp;project_id=${project_id}&amp;page=-1&amp;cookietest=2">
165
        <attribute
166
              name="loginFormUrl"
167
              value="${serverUrl}">
168
        </attribute>
169
        <attribute name="loginTokenPattern"
170
              value="&lt;form name=&quot;Login_form&quot; method=&quot;POST&quot; action=&quot;index.php\?event\=Login&amp;amp;project_id\=0&amp;amp;link_uid\=(\p{Alnum}+?)\&quot;(?:.*?)&gt;"/>
171
        <attribute name="loginRequestMethod" value="POST"/>
172
        <attribute name="loginRequestUrl"
173
              value="${serverUrl}/index.php?event=Login&amp;link_uid=${loginToken}&amp;username=${userId}&amp;password=${password}"/>
174
        <attribute name="queryPattern"
175
              value="&lt;a href=&quot;index.php\?event\=Show_.+?task.+?task_id=(.+?)&amp;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;.+?&lt;/td&gt;.+?&lt;td&gt;(.+?)&lt;/td&gt;"/>
176
        <attribute name="param_project_id" value="1"/>
177
     </repository>
178
179
     <repository
180
			anonymous="false"
181
			label="OTRS"
182
			repositoryKind="web"
183
			urlRepository="http://demo.otrs.org"
184
			urlNewTask="${serverUrl}/otrs/index.pl?Action=AgentTicketPhone"
185
			urlTask="${serverUrl}/otrs/index.pl?Action=AgentTicketZoom&amp;TicketID="
186
			urlTaskQuery="${serverUrl}/otrs/index.pl?Action=AgentTicketMailbox">
187
		<attribute name="queryPattern"
188
                value="&lt;a href=\&quot;/otrs/index.pl\?Action=AgentTicketZoom&amp;TicketID=(.+?)&quot;.+?&lt;b&gt;Subject:&lt;/b&gt;.+?&lt;div title=&quot;.+?&quot;&gt;(.+?)&lt;/div&gt;&lt;/td&gt;"/>
189
		<attribute name="loginRequestUrl"
190
		        value="${serverUrl}/otrs/index.pl?Action=Login&amp;User=${userId}&amp;Password=${password}"/>
191
     </repository>
192
193
     <repository
194
			anonymous="false"
195
			label="JavaForge (CodeLogic)"
196
			repositoryKind="web"
197
			urlRepository="http://www.javaforge.com/proj/tracker"
198
			urlTask="${serverUrl}/itemDetails.do?navigation=true&amp;task_id="
199
			urlNewTask="${serverUrl}/submitNew.do?tracker_id=${tracker_id}"
200
			urlTaskQuery="${serverUrl}/browseAllTrackers.do?proj_id=${proj_id}&amp;tracker_type_id=${tracker_type_id}&amp;onlyOpen=false&amp;pagesize=0">
201
		<attribute
202
				name="queryPattern"
203
                value="&lt;a href=&quot;/proj/tracker/itemDetails.do\?.+?task_id=(\d+?)&quot;&gt;(.+?)&lt;/a&gt;"/>
204
        <attribute name="param_tracker_id" value="41"/>
205
        <attribute name="param_tracker_type_id" value="2"/>
206
        <attribute name="param_proj_id" value="11"/>
207
     </repository>
208
144
   </extension>
209
   </extension>
145
210
146
</plugin>
211
</plugin>
(-)src/org/eclipse/mylar/internal/tasks/web/Util.java (+26 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2004 - 2006 Mylar committers and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *******************************************************************************/
8
9
package org.eclipse.mylar.internal.tasks.web;
10
11
/**
12
 * Utility methods
13
 *
14
 * @author Eugene Kuleshov
15
 */
16
public class Util {
17
18
	public static boolean isPresent(String value) {
19
		return value != null && value.length() > 0;
20
	}
21
22
	public static String nvl(String value) {
23
		return value == null ? "" : value;
24
	}
25
26
}

Return to bug 151602