Looking for a method to evict the cache while modify enumerations
My client attempted to use Java API to modify enumerations, while modify and save a com.ibm.team.process.common.IProjectArea; multiple times with different connections to RTC, they got com.ibm.team.repository.common.StaleDataException
https://jazz.net/forum/questions/206968/unable-to-save-the-same-projectareaworkingcopy-twice-in-a-row-stale-exception
It looks like RTC has 2 instances of the data one in the DB and another one that's cached. Is there a method to evict the cache, or synchronize these two copies? Also, is there a way to modify enumerations without encountering the StaleDataException(generated by the code below)?
boolean saveProcessArea = false;
final IProcessArea mutableProcessArea = (IProcessArea)
fCachedService.getMutableCopy(fProcessAreaState);
if (!fProcessAreaState.getStateId().equals
(((Auditable)mutableProcessArea).getWorkingCopyPredecessor())) {
// If the underlying item was changed in other places,
// we need to indicate the editor is stale.
throw new StaleDataException(mutableProcessArea, fProcessAreaState);
}
Any help on answering there will be much appreciated.
https://jazz.net/forum/questions/206968/unable-to-save-the-same-projectareaworkingcopy-twice-in-a-row-stale-exception
It looks like RTC has 2 instances of the data one in the DB and another one that's cached. Is there a method to evict the cache, or synchronize these two copies? Also, is there a way to modify enumerations without encountering the StaleDataException(generated by the code below)?
boolean saveProcessArea = false;
final IProcessArea mutableProcessArea = (IProcessArea)
fCachedService.getMutableCopy(fProcessAreaState);
if (!fProcessAreaState.getStateId().equals
(((Auditable)mutableProcessArea).getWorkingCopyPredecessor())) {
// If the underlying item was changed in other places,
// we need to indicate the editor is stale.
throw new StaleDataException(mutableProcessArea, fProcessAreaState);
}
Any help on answering there will be much appreciated.
One answer
Consider fetching the object before or after again after modification with a
IItemManager.REFRESH(not default) . Disconnect and get a new workingcopy manager after saving. See Understanding and Using the RTC Java Client API for some hints. Also see https://rsjazz.wordpress.com/2013/09/18/deploying-templates-and-creating-projects-using-the-plain-java-clients-library/ for some working code.