Home » Eclipse Projects » Mylyn » Attach context for generic web connector based repostories
|
Re: Attach context for generic web connector based repostories [message #58868 is a reply to message #58817] |
Wed, 01 October 2008 06:21 |
Jörg Thönnes Messages: 229 Registered: July 2009 |
Senior Member |
|
|
On 10/01/08 01:08, Menon wrote:
> Is there a way to attach context for a task that was created using the
> templates for generic web connector based repository?
> My database has a way to save attachments, but if the genric web
> connector does not have a direct way to save it, is there a workaround?
The answer is simply NO, unless you are going to contribute this change to the Mylyn project.
I was missing this feature all the time. Therefore (and for other reasons) we move to Trac, which is
very well supported and quite extensible.
AFAIK, there is a generic JDBC connector in the works, which can directly query a database. So if
you have access to the database tables of your issue tracker, this may be a much better solution.
It also supports task editing, but I am not sure about attachments.
Cheers, Jörg
|
|
| | |
Re: Attach context for generic web connector based repostories [message #58942 is a reply to message #58918] |
Wed, 01 October 2008 19:04 |
Eugene Kuleshov Messages: 504 Registered: July 2009 |
Senior Member |
|
|
Jörg Thönnes wrote:
>> What is involved in adding this feature to generic web connector? How
>> much effort is it?
>>
> No idea, some of the Mylyn guys could tell you...
>
I am no longed a "Mylyn guy" and won't have time to work on this, but
I will try to answer question about what would it take to add such
feature. Maybe you guys could stick that into a bug report in case
someone would want to work on that.
So, it is relatively easy to implement support for attaching the task
context in the web connector. The only issue is how to generalize
required configuration. Other then that, api on mylyn side is more or
less straightforward.
Basically, in most cases, attaching something would require http post
call to some URL with content type set to multipart/form-data. The call
would need to have number of fields specified and should also include
field for the attachment body, which is usually declared in html like this:
<input name="data" type="file">
So, the easiest way to configure that would be to add additional
parameters to the connector configuration. It need to be an url with
number of parameters required by the web server in order to submit an
attachment. Values for some of those parameters would need to be
substituted from variables, such as ${Id} ${Description} and
${Attachment}, for example:
${serverUrl}/attach/?taskId=${Id}&description=${Descript ion}&data=${Attachment}&someOtherField=foo
Then attachment submission can parse that url and construct the
corresponding post request for submitting attachment. Generally not much
different from submitting requests for task queries.
regards,
Eugene
|
|
| | | |
Re: Attach context for generic web connector based repostories [message #61282 is a reply to message #60471] |
Mon, 03 November 2008 21:51 |
Menon Messages: 48 Registered: July 2009 |
Member |
|
|
Hi Eugene
I have been trying to implement the "add attachment functionality to the
web connector as you suggested for my repository.
Curently I am stuck with this code, and not able to post the URL. Ilooked
at the webconnector code where PostMethod is called and I have something
like this code for postContent(..) in the webtaskttachmentHandler. Any
idea what I am missing for the Post to succeed? I may be missing some
critical function call. I am passing the URlwith the aparametrs and the
Filename is from the source.
Thanks
Sunanda
@Override
public void postContent(TaskRepository repository, ITask task,
AbstractTaskAttachmentSource source, String
comment,
TaskAttribute attachmentAttribute, IProgressMonitor
monitor) throws CoreException {
try {
monitor.beginTask("Sending attachment",
IProgressMonitor.UNKNOWN);
String description = source.getDescription();
String contentType = source.getContentType();
String filename = source.getName();
boolean isPatch = false;
HttpClient client = new HttpClient();
WebUtil.configureHttpClient(client, repository.getProperty
(WebRepositoryConnector.getUserAgent()));
AbstractWebLocation location = new TaskRepositoryLocationUiFactory
().createWebLocation(repository);
HostConfiguration hostConfiguration = WebUtil.createHostConfiguration
(client, location, null);
String repositoryUrl = repository.getRepositoryUrl();
int n = (repository.getProperty
WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).indexOf
("}");
int nl = (repository.getProperty
(WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).length();
String key = (repository.getProperty
(WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).substring
(n + 1, nl);
String attachmentUrl = repositoryUrl + key;
PostMethod postMethod = new PostMethod(attachmentUrl);
postMethod.getParams().setBooleanParameter
(HttpMethodParams.USE_EXPECT_CONTINUE, true);
List<PartBase> parts = new ArrayList<PartBase>();
parts.add(new StringPart("bug_id", task.getTaskId(), "UTF-8"));
if (comment != null) {
parts.add(new StringPart("comment", comment, "UTF-8"));
}
parts.add(new FilePart("data", new AttachmentPartSource(source,
filename)));
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray
(new Part[1]), postMethod.getParams()));
postMethod.setDoAuthentication(true);
try {
try {
int status = WebUtil.execute(client, hostConfiguration,
postMethod, monitor);
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} finally {
postMethod.releaseConnection();
}
}
finally {
}
}
|
|
| | | | | | |
Re: Attach context for generic web connector based repostories [message #593715 is a reply to message #58817] |
Wed, 01 October 2008 06:21 |
Jörg Thönnes Messages: 229 Registered: July 2009 |
Senior Member |
|
|
On 10/01/08 01:08, Menon wrote:
> Is there a way to attach context for a task that was created using the
> templates for generic web connector based repository?
> My database has a way to save attachments, but if the genric web
> connector does not have a direct way to save it, is there a workaround?
The answer is simply NO, unless you are going to contribute this change to the Mylyn project.
I was missing this feature all the time. Therefore (and for other reasons) we move to Trac, which is
very well supported and quite extensible.
AFAIK, there is a generic JDBC connector in the works, which can directly query a database. So if
you have access to the database tables of your issue tracker, this may be a much better solution.
It also supports task editing, but I am not sure about attachments.
Cheers, Jörg
|
|
| | |
Re: Attach context for generic web connector based repostories [message #593745 is a reply to message #58918] |
Wed, 01 October 2008 19:04 |
Eugene Kuleshov Messages: 504 Registered: July 2009 |
Senior Member |
|
|
Jörg Thönnes wrote:
>> What is involved in adding this feature to generic web connector? How
>> much effort is it?
>>
> No idea, some of the Mylyn guys could tell you...
>
I am no longed a "Mylyn guy" and won't have time to work on this, but
I will try to answer question about what would it take to add such
feature. Maybe you guys could stick that into a bug report in case
someone would want to work on that.
So, it is relatively easy to implement support for attaching the task
context in the web connector. The only issue is how to generalize
required configuration. Other then that, api on mylyn side is more or
less straightforward.
Basically, in most cases, attaching something would require http post
call to some URL with content type set to multipart/form-data. The call
would need to have number of fields specified and should also include
field for the attachment body, which is usually declared in html like this:
<input name="data" type="file">
So, the easiest way to configure that would be to add additional
parameters to the connector configuration. It need to be an url with
number of parameters required by the web server in order to submit an
attachment. Values for some of those parameters would need to be
substituted from variables, such as ${Id} ${Description} and
${Attachment}, for example:
${serverUrl}/attach/?taskId=${Id}&description=${Descript ion}&data=${Attachment}&someOtherField=foo
Then attachment submission can parse that url and construct the
corresponding post request for submitting attachment. Generally not much
different from submitting requests for task queries.
regards,
Eugene
|
|
| | | |
Re: Attach context for generic web connector based repostories [message #594645 is a reply to message #60471] |
Mon, 03 November 2008 21:51 |
Menon Messages: 48 Registered: July 2009 |
Member |
|
|
Hi Eugene
I have been trying to implement the "add attachment functionality to the
web connector as you suggested for my repository.
Curently I am stuck with this code, and not able to post the URL. Ilooked
at the webconnector code where PostMethod is called and I have something
like this code for postContent(..) in the webtaskttachmentHandler. Any
idea what I am missing for the Post to succeed? I may be missing some
critical function call. I am passing the URlwith the aparametrs and the
Filename is from the source.
Thanks
Sunanda
@Override
public void postContent(TaskRepository repository, ITask task,
AbstractTaskAttachmentSource source, String
comment,
TaskAttribute attachmentAttribute, IProgressMonitor
monitor) throws CoreException {
try {
monitor.beginTask("Sending attachment",
IProgressMonitor.UNKNOWN);
String description = source.getDescription();
String contentType = source.getContentType();
String filename = source.getName();
boolean isPatch = false;
HttpClient client = new HttpClient();
WebUtil.configureHttpClient(client, repository.getProperty
(WebRepositoryConnector.getUserAgent()));
AbstractWebLocation location = new TaskRepositoryLocationUiFactory
().createWebLocation(repository);
HostConfiguration hostConfiguration = WebUtil.createHostConfiguration
(client, location, null);
String repositoryUrl = repository.getRepositoryUrl();
int n = (repository.getProperty
WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).indexOf
("}");
int nl = (repository.getProperty
(WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).length();
String key = (repository.getProperty
(WebRepositoryConnector.PROPERTY_ATTACHMENT_URL)).substring
(n + 1, nl);
String attachmentUrl = repositoryUrl + key;
PostMethod postMethod = new PostMethod(attachmentUrl);
postMethod.getParams().setBooleanParameter
(HttpMethodParams.USE_EXPECT_CONTINUE, true);
List<PartBase> parts = new ArrayList<PartBase>();
parts.add(new StringPart("bug_id", task.getTaskId(), "UTF-8"));
if (comment != null) {
parts.add(new StringPart("comment", comment, "UTF-8"));
}
parts.add(new FilePart("data", new AttachmentPartSource(source,
filename)));
postMethod.setRequestEntity(new MultipartRequestEntity(parts.toArray
(new Part[1]), postMethod.getParams()));
postMethod.setDoAuthentication(true);
try {
try {
int status = WebUtil.execute(client, hostConfiguration,
postMethod, monitor);
} catch (HttpException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} finally {
postMethod.releaseConnection();
}
}
finally {
}
}
|
|
| | | | | | |
Goto Forum:
Current Time: Sat Oct 19 11:41:50 GMT 2024
Powered by FUDForum. Page generated in 0.06971 seconds
|