It's all about the answers!

Ask a question

Not able to get process configuration source using plain java API on RTC 6!

Prathamesh Dharangutte (261) | asked Aug 08 '18, 7:41 a.m.
edited Aug 08 '18, 7:54 a.m.

Hello ,

I am trying to get the process configuration source xml using java api through the code below:

IProcessClientService processClient = (IProcessClientService) teamRepository.getClientLibrary(IProcessClientService.class); 
 URI uri = URI.create(projectArea.replaceAll(" ", "%20")); 
 try { 
 processArea = (IProcessArea) processClient.findProcessArea(uri, null, null); 
catch (TeamRepositoryException e)
 IProcessItemService processItemService = (IProcessItemService) teamRepository.getClientLibrary(IProcessItemService.class); 
 IWorkingCopyManager workingCopyMgr = processItemService.getWorkingCopyManager(); IProjectAreaWorkingCopy projectAreaCopy = (IProjectAreaWorkingCopy) workingCopyMgr.createPrivateWorkingCopy(processArea);
 IDocument doc = projectAreaCopy.getProcessSpecification();
 String docXml = doc.get();

But, when i print the string returned by 'doc.get()' i get an empty string i.e. ""
I don't see any error or any exceptions anywhere and the user used to log in has access to process specification which i confirmed through the eclipse client.
The same code works with client 5 libraries for RTC 6.0.4 server but not with client 6 libraries. 
Am i missing something or is there something more to be done server side to make it compatible with version 6 libraries? I am quite new to extending RTC so please forgive me if there are any mistakes.

Prathamesh Dharangutte commented Aug 09 '18, 7:37 a.m.


When i try to get the xml source with a bit different code as below:

IContentManager icm = teamRepository.contentManager();
Map<?, ?> processData = processArea.getProcessData();
IContent processSource = (IContent)processData.get("");
OutputStream os = new ByteArrayOutputStream();
 try {
icm.retrieveContent(processSource, os, null);
} catch (TeamRepositoryException e) {

I get exception as below: The following header was missing from the server response: Content-Length.

Accepted answer

permanent link
Prathamesh Dharangutte (261) | answered Aug 21 '18, 12:59 a.m.

Thanks Ralph.

Just to update if anyone else comes around a similar issue, after debugging a little and reading around i found the issue to be similar to this defect: Defect 421308 

Ralph Schoon selected this answer as the correct answer

One other answer

permanent link
Ralph Schoon (61.5k33643) | answered Aug 09 '18, 8:26 a.m.

I have this snippet lying around. Don't ask me about details.

                            // get it
                            IProjectArea project = (IProjectArea) (repo
                                    IItemManager.DEFAULT, sPm));
                            System.out.println("have parent project name = "
                                    + project.getName());
                            // get the process data
                            Map<string, object=""> pd = ip.getProcessData();
        ////  here is the xml extract
                            // get the process config content object
                            IContent processSource = (IContent) pd.get(keyname);
                            if (processSource != null)
                                System.out.println("have xml source");
                                saveXMLSource(ip, processSource, icm, sPm);

Prathamesh Dharangutte commented Aug 10 '18, 1:57 a.m.
Thank you for your reply.
After trying, i get exception at:

icm.retrieveContent(processSource, os, null);

I get exception as below: The following header was missing from the server response: Content-Length. 

Ralph Schoon commented Aug 10 '18, 2:14 a.m.

As I said "Don't ask me about details.". I am pretty sure the code has worked. You could also search the SDK for how the code is used in the RTC client. I am not going to remote debug this.

For whatever reason the code you are using seems to miss a header in the REST calls it finally does. Search the SDK for how the calls are used in RTC and in the tests in the SDK.

Your answer

Register or to post your answer.