Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Access RTC with OSLC using Javascript

 Hi,

Below article explains how to connect/authenticate RTC using Java. 

http://www.ibm.com/developerworks/rational/library/rational-team-concert-oslc/

I would like to know if there is a way I can convert the above given code to Javascript. Can anybody please assist me with the code.

Thank You.

Regards,
Usman


0 votes

Comments

Apologies for the late reply. Really overwhelmed to see all the replies.


@Donald. I would like to show RTC work item details on a browser as an extension to RTC. So, I was thinking javascript could be the best way.

@Tamir & @Jim. I had a good look on both the things.

@Stefan, You are right Stefan, when I say javascript I mean inside the browser.









4 answers

Permanent link
 Have you checked this RTC - JS article?

Regards,
Tamir Gefen, ALMtoolbox

0 votes


Permanent link
I am not a big fan of such idea. What do you want to do using OSLC within some JavaScript codes? Remember that when you are using JavaScript, you are already dealing with HTTP sessions. Do you want to open new HTTP connections for the OSLC requests? If not, you're probably looking at XHR, but I don't see the RTC JavaScript extension offers such capability (explicitly).

0 votes


Permanent link
Here's some sample JavaScript code that connects to an OSLC server and gets the service provider catalog, which requires authentication. Note that the authentication challenge may occur at any time, so all requests should be prepared for the challenge.
/**
 * Connect to the server with the given credentials
*
* @param {string} userName - the user name or authentication ID of the user
* @param {string} password - the user's password credentials
* @param callback(err) - called when the connection is established
*/
OSLCServer.prototype.connect = function(userName, password, callback) {
var _self = this; // needed to refer to this inside nested callback functions
_self.userName = userName;
_self.password = password;

// Get the Jazz rootservices document for OSLC v2
// This does not require authentication
request.get(_self.serverURI+'/rootservices', function gotRootServices(err, response, body) {
if (err || response.statusCode != 200)
return console.error('Failed to read the Jazz rootservices resource '+err);
_self.rootServices = new RootServices(_self.serverURI+'/rootservices', body);

// Now get the ServiceProviderCatalog so that we know what services are provided
var catalogURI = _self.rootServices.serviceProviderCatalogURI(OSLCCM());
//require('request-debug')(request);
// This request will require authentication through FORM based challenge response
request.get(catalogURI, gotServiceProviderCatalog);
});

// Parse the service provider catalog, it will be needed for any other request.
function gotServiceProviderCatalog(err, response, body) {
if (response && response.headers['x-com-ibm-team-repository-web-auth-msg'] === 'authrequired') {
return request.post(_self.serverURI+'/j_security_check?j_username='+_self.userName+'&j_password='+_self.password, gotServiceProviderCatalog);
} else if (!response || response.statusCode != 200) {
return console.error('Failed to read the CM ServiceProviderCatalog '+err);
}
_self.serviceProviderCatalog = new ServiceProviderCatalog(response.request.uri.href, body);
callback(null); // call the callback with no error
}
}

0 votes


Permanent link
 Hi Usman,

I worked the last 6 month with Javascript inside a Open Social Widget.
When you say Javascript do you mean:
* Inside a Browser?
* NodeJS?

I ask because there are some differences you have to think about when you use a Browser:
* CORS
* Async Requests

If you work with a Browser I would recommend Chrome because he has the perfect Dev Tools.
BTW, OSLC isn't the only possibility. Have a look at my Blog clmpractice.org. 
My personal opinion is that Javascript is the future because everything runs in the Browser 
(except the RTC Client) and most of the other CLM Tools has no Java SDK.

Thx

Stefan

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,935
× 515
× 152
× 62

Question asked: Jan 24 '16, 5:09 a.m.

Question was seen: 7,184 times

Last updated: Jan 27 '16, 9:59 p.m.

Confirmation Cancel Confirm