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

Change WI state by client plain java library.

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 ?

0 votes



5 answers

Permanent link
Hi Takehiko-san,

did you solve this?

0 votes


Permanent link
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.

0 votes


Permanent link
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());
}

0 votes


Permanent link
Thanks Kim.

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

0 votes


Permanent link
I tested with 3.0.1.2 and it was OK.

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,938

Question asked: Mar 14 '12, 2:40 a.m.

Question was seen: 6,318 times

Last updated: Mar 14 '12, 2:40 a.m.

Confirmation Cancel Confirm