The components I create in RTC source can to do download through an url?
I use Rational Jazz Team Server 6.0.6.1, I want to implement the download of the files in the component by URL. I get the download address of the software like "http://192.168.0.20:9080/ccm/service/com.ibm.team.filesystem.service.internal.rest.IFilesystemContentService/_N5qZIAHSEeq8jv66f4XIqA/_N9ODfwHSEeq8jv66f4XIqA/?itemId=_N9ODgwHSEeq8jv66f4XIqA&itemType=com.ibm.team.scm.Folder&contextType=com.ibm.team.scm.Stream&format=zip&platformLineDelimiter=CRLF&iframe=true&", but it can't be realized when using the code to download. Is there any good way to look forward to your? Help, thank you!
SSLContext mySSLContext = SSLContext.getInstance("SSL");
mySSLContext.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(mySSLContext.getSocketFactory());
// Authenticate credentials
DefaultHttpClient httpclient = new DefaultHttpClient();
CookieStore cookieStore = new BasicCookieStore();
HttpContext localContext = new BasicHttpContext();
localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
HttpGet httpGetID = new HttpGet(
httpclient.execute(httpGetID, localContext);
httpGetID.abort();
List<Cookie> cookies1 = cookieStore.getCookies();
for (Cookie cookie : cookies1) {
System.out.println("\t" + cookie.getName() + " : " + cookie.getValue());
}
//
List<NameValuePair> authFormParams = new ArrayList<NameValuePair>();
authFormParams.add(new BasicNameValuePair("j_username", "jtsadmin"));
authFormParams.add(new BasicNameValuePair("j_password", "avic123"));
// Listing 2. Build an UrlEncodedFormEntity
UrlEncodedFormEntity encodedentity = new UrlEncodedFormEntity(authFormParams,
"UTF-8");
HttpPost httpPostAuth = new HttpPost(
httpPostAuth.setEntity(encodedentity);
httpclient.execute(httpPostAuth, localContext);
List<Cookie> cookies2 = cookieStore.getCookies();
for (Cookie cookie : cookies2) {
System.out.println("\t" + cookie.getName() + " : " + cookie.getValue());
}
// Listing 3. Retrieve information about a work item
// READ BY ID
InputStream in=null;
OutputStream out = null;
httpclient = new DefaultHttpClient();
// // IMPORTANT STUFF
httpclient.setCookieStore(cookieStore);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entityPut = response.getEntity();
in=entityPut.getContent();
long length=entityPut.getContentLength();
if (length <= 0) {
System.out.println("下载文件不存在!");
return;
}
Accepted answer
The link you are using is a UI link and not a link to a resource. In general it would be possible to download.
The Java API ca be found here: http://thescmlounge.blogspot.com/2013/08/getting-your-stuff-using-rtc-sdk-to-zip.html