It's all about the answers!

Ask a question

Change WI state by client plain java library.


Takehiko Amano (1.3k3741) | asked Mar 14 '12, 2:40 a.m.
JAZZ DEVELOPER
I'm looking for a method how to work around the problem I get in this code.

WorkItemWorkingCopy wc = wcm.getWorkingCopy(workItem);
wc.setWorkflowAction(newState);
wc.save(monitor);

When I run this code (standalone Java application) I get serious error message:

--
com.ibm.team.repository.client.util.ThreadCheck checkLongOpsAllowed
Long-running operations prohibited on this thread
at com.ibm.team.repository.client.util.ThreadCheck.checkLongOpsAllowed(ThreadCheck.java:118)

--

Note that workitem state is actually changed to expected state. I searched previous post in the forum which is suggesting to run in back ground using Job class. so I tried like this:

Job job = new Job("Workitem Save") {
@Override
protected IStatus run(IProgressMonitor monitor) {
System.out.println("Workitem Save operation start");
wc.save(monitor);
return Status.OK_STATUS;
}
};
job.schedule();

Still I get the the same error message. Previous posts have no conclusive answer for this problem.

Do you have any suggestion how to work around this problem ?

5 answers



permanent link
Ralph Schoon (63.3k33646) | answered Mar 23 '12, 6:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Hi Takehiko-san,

did you solve this?

permanent link
Takehiko Amano (1.3k3741) | answered Mar 25 '12, 9:52 p.m.
JAZZ DEVELOPER
Hi Takehiko-san,

did you solve this?


Partly. I've raised as a defect, because repository should defect whether this is under UI or command line.

"201976: Change state result in "Long-running operations prohibited on this thread" exception in client plain java library. "

The work around that customer used was to absorb stack trace to NULL stream which is like this:

PrintStream normalErr = System.err;
System.setErr(new PrintStream(new FileOutputStream("NUL:")));

// Change state

System.setErr(normalErr);

State is actually changed to expected one, so we assume absorbing message during state change is harmless.

Please let me know if there is any better way.

permanent link
Dong Young Kim (1931920) | answered Mar 26 '12, 5:12 a.m.
JAZZ DEVELOPER
Have a look at the following code...

"New" Status -> "In Progress" Status by "Start Working" Action
-------------------------------------------------------------------------

IWorkItemClient workItemClient = (IWorkItemClient) repo.getClientLibrary(IWorkItemClient.class);
IWorkItemWorkingCopyManager copyManager = workItemClient.getWorkItemWorkingCopyManager();
IWorkItemHandle workItemHandle = workItemClient.findWorkItemById(workItemNumber, IWorkItem.FULL_PROFILE, null);
copyManager.connect(workItemHandle, IWorkItem.FULL_PROFILE, null);
WorkItemWorkingCopy workItemCopy = copyManager.getWorkingCopy(workItemHandle);
IWorkItem workItem = workItemCopy.getWorkItem();
IWorkflowInfo workflowInfo = workItemClient.findWorkflowInfo(workItem, null);
Identifier<IWorkflowAction> actionIds[] = workflowInfo.getAllActionIds();
String actionString = null;
for(Identifier<IWorkflowAction> actionId : actionIds)
{
if(workflowInfo.getActionName(actionId).equalsIgnoreCase("Start Working"))
{
//System.out.println(actionId.getStringIdentifier());
actionString = actionId.getStringIdentifier();
}
}
workItemCopy.setWorkflowAction(actionString);
IDetailedStatus detailedStatus = workItemCopy.save(null);
copyManager.disconnect(workItemHandle);
if (!detailedStatus.isOK()) {
throw new TeamRepositoryException(detailedStatus.getDetails());
//System.out.println("Save Fail = " + detailedStatus.getDetails());
}

permanent link
Takehiko Amano (1.3k3741) | answered Mar 26 '12, 11:25 p.m.
JAZZ DEVELOPER
Thanks Kim.

The code is exactly same as mine. Still throws exception (I think this is defect - 201976).

permanent link
Dong Young Kim (1931920) | answered Mar 31 '12, 5:19 a.m.
JAZZ DEVELOPER
I tested with 3.0.1.2 and it was OK.

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.