It's all about the answers!

Ask a question

How to create Work Item using Javascript within an OpenSocial Gadget?


1
1
Tuan Nguyen Minh (69721) | asked Dec 02 '15, 9:45 p.m.
I want to develop an OpenSocial Gadget that can create Work Item automatically with the logged in credential. I've tried several approaches but have no positive result until now.
AFAIK, there is no RTC Javascript API for doing this, so I use OSLC API. To create a Work Item, I send a POST request to the creation factory URL with the Work Item RDF description. A header  "X-Jazz-CSRF-Prevent" has to be added into the request for a successful creation, the value of this header is the value of JSESSIONID cookie. The problem is within Javascript, it is not allowed to retrieve the value of JSESSIONID programmatically due to security reason (I use Firefox as my web client).
--> Is there any work around for this problem?
--> If no, then is there any other approach to create a Work Item using Javascript within an OpenSocial Gadget?

Comments
Donald Nong commented Dec 04 '15, 2:21 a.m.

What are you trying to do? What is the use case? If the logged-in use has the permission and license to submit a work item, why not just do it the usual way?


Tuan Nguyen Minh commented Dec 06 '15, 10:43 p.m. | edited Dec 06 '15, 10:43 p.m.

I have a real use case where work item should be created automatically from dedicated user inputs, work item attributes (filed against, plan for, etc...) are calculated and assigned base on these inputs. Work Item customization is not preferred since I'm using Process Sharing.
Now I'm trying to find a technical solution for it, the preferred client is Web client.


Thomas Kirstätter commented Dec 15 '15, 8:24 a.m. | edited Dec 15 '15, 8:25 a.m.

Hi all,
I am working together with Tuan. Our UseCase:
We want to setup a central Project Area for Process Method and Tools Development. We whish that every user can create a WI in this Area for requesting changes or problem reports. So far nothing special. But since this Area is covering a large number of topics and to make sure that the WI are getting addressed as precise as possible (using Categories and tags) we wanted to create an Widget that guides the Users in the creation of these workitems by a set of questions and drop down menues. In addition we use this input information to show already existing WI that have been created using the same input to make sure as less as possible duplicates are produced.
So this solves the issues of:
- Our Users do not need to know the concrete category and Tag structure of the Process Method and Tools Development,
- Users get support to find already created WI

I hope that helps as background.


1
Dr. Hans-Joachim Pross commented Jan 26 '16, 3:36 a.m. | edited Jan 26 '16, 3:36 a.m.
JAZZ DEVELOPER

Tuan, try to use Chrome. I saw a sample widget written by a partner, which created a WI from a Dashboard. But it only runs in Chrome Browser...


Thomas Kirstätter commented Jan 26 '16, 3:37 p.m. | edited Jan 26 '16, 3:38 p.m.

unfortunately we cannot use chrome...
And I believe there is a fundamental difference between a Widget and a Gadget w.r.t. authentication.


Thomas Kirstätter commented Jan 27 '16, 3:22 a.m. | edited Jan 27 '16, 3:23 a.m.

I wanted to edit my comment but I can't sorry.
@Mr. Pross: I wanted to thank you for your hint, since I missed that out in my comment,
And I am not sure what you refer to with Widget, an custom native Widget (iWidget) or an Open Social Widget/Gadget (iGadget).

showing 5 of 6 show 1 more comments

Accepted answer


permanent link
Stefan Hufnagl (29411619) | answered Jan 28 '16, 3:19 a.m.
Morning Gentlemens,

I worked the last 6 months with Open Social Widgets (Javascript/JQuery) to create hundreds of new Workitems with Input from DNG Artefacts and link them together. For this job I used OSLC and other CLM REST APIs. If you take care about some minor differences...it works on Firefox and Chrome.

Authentification is not necessary because when you use a Open Social Widget/Gadget you are still logged in. With every GET/PUT/POST Request to the same domain, the browser send the necessary information (inside the header) to the CLM Server.
If you want I can give you code snippets do to the task.

BTW, currently I'm working on a new and better way to extend the CLM Webinterface, because Widget have their limitation too. No hack!
:-)

Thx

Stefan


Tuan Nguyen Minh selected this answer as the correct answer

Comments
Tuan Nguyen Minh commented Mar 01 '16, 4:08 a.m.

Hello Stefan,

Thanks. I also used OSLC POST to create new WI. But I received 403 Forbidden error every time. I'm really interested in your code snippets to do the task. Could you please share it?
Another point, how did you set up/deploy your Open Social Gadget? In my case, I placed the javascript gadget inside my Tomcat server installation & used it to host the gadget.

BTW, what is the better CLM Web Interface that you mention? :)

Regards,
Tuan


Tuan Nguyen Minh commented Mar 03 '16, 2:20 a.m.

Hi, finally I got the issue solved. It was my mistake to misunderstand the meaning of the status code: 403 Forbidden. It was caused because the content in the POST request is invalid. After correcting it, everything works fine.

Thanks everyone.

2 other answers



permanent link
Thomas Kirstätter (162113) | answered Jan 26 '16, 3:34 p.m.
can this somehow be useful: https://jazz.net/forum/questions/170030/rtc-oslc-authenticate-with-javascript...


permanent link
Stefan Hufnagl (29411619) | answered Mar 03 '16, 3:02 a.m.
Hi Tuan,

great that you find the solution.

Open Social Gadget Deployment:
* With Tomcat it is simple...place it inside the C:\IBM\JazzTeamServer\server\tomcat\webapps\extensions\... and the URL would be https://server:9443/extensions/.../status.xml
* WAS needs a WAR File with static content, create it with "jar cvf keyfile.war ." (you need java sdk installed) inside your extension folder.
Stefan

Your answer


Register or to post your answer.