It's all about the answers!

Ask a question

The components I create in RTC source can to do download through an url?


Yang Xu (131) | asked Nov 08 '19, 12:20 a.m.

 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


permanent link
Ralph Schoon (63.1k33646) | answered Nov 11 '19, 3:05 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 The link you are using is a UI link and not a link to a resource. In general it would be possible to download.

Yang Xu selected this answer as the correct answer

Your answer


Register or 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.