getting Validation error "PropertyConstraintException:Duplicate item references are not allowed: customAttributes " on saving workItem -Server side plugin
It fails with the following exception :
//exception stack
2016-12-04 22:12:19,246 [http-bio-9443-exec-5 @@ 22:12 myadmin <com.ibm.team.repository.transport.client.RemoteTeamService spnego-enabled@127.0.0.1> /ccm/service/com.ibm.team.workitem.common.internal.IWorkItemRepositoryService] ERROR com.ibm.team.process.common - Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A]
Duplicate item references are not allowed: customAttributes
com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A]
Duplicate item references are not allowed: customAttributes
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.failIfNecessary(RdbRepositoryDataMediator.java:467)
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.validateItem(RdbRepositoryDataMediator.java:416)
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.validateItemWithPossibleRewrites(RdbRepositoryDataMediator.java:436)
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.createImmutablePersistentCopy(RdbRepositoryDataMediator.java:1688)
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.createImmutablePersistentCopyForSave(RdbRepositoryDataMediator.java:1651)
at com.ibm.team.repository.service.internal.RdbRepositoryDataMediator.saveAuditable(RdbRepositoryDataMediator.java:890)
…
.
Eg:
I have task WI whose parent is Feature and grand parent is Story .I have created three custom attributes mapped to each of these WI Types.
On save of task WI ,if the value of custom attribute has changed my participant in subject is trying to update another custom attribute of Feature which is successful but fails in updating the custom attribute of Story with the above mentioned exception .
I have followed the https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/ example and trying to update the custom attributes of the parent work items in the hierarchy.
Does any one can help why the exception occurs and how to resolve it ?
Thanks for the help in advance ..
One answer
Duplicate item references are not allowed: customAttributes
com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = WorkItem, itemId = [UUID _ISui0LobEeaQdoRl3qgW5A]
Duplicate item references are not allowed: customAttributes
Comments
Hi Ralph,
Thanks for the response !!
Please find the below code which is failing on saving the ‘grand-parent’ of current WI.
IWorkItem currentTWorkItem = // get from new state
While(true) {
IWorkItem parentHandle =findparentHandle(
<wbr>
currentTWorkItem);
if(parentHandle!=null) {
IWorkItem parentWorkItem = (IWorkItem) fWorkItemServer.
<wbr>
getAuditableCommon().
resolveAuditable(
<wbr>
parentWorkItemHandle,
IWorkItem.FULL_PROFILE, monitor).getWorkingCopy();
IAttribute parentAttributeObj = //find parentAttributeObject which We want to update
parentWorkItem.setValue(
<wbr>
parentAttributeObj,newValue);
IStatus status = fWorkItemServer.saveWorkItem2(
<wbr>
parentWorkItem, null,null);
if(status.isOK()){
System.out.println("Save successful");
} else {
//report error
}
currentTWorkItem = parentHandle //setting parent as current work item to find its parent (grand-parent)
} else {
//no parent ..break from loop
}
}
As we can see my parentHandle and parentAttributeObj is not same always.But still its throwing the subject line exception.
Thanks in advance!!

I am not going to debug your plugin. Sorry, but this is basically not possible.
However, I will say that the code above will cause various problems and will in fact also crash your RTC server. Each Work Item Save in the participant will cause another work item save and so forth. Each of those saves will trigger your operational behavior again. It will basically recursively go on and on until your server crashes.
See RTC Update Parent Duration Estimation and Effort Participant and other participants on that blog for how to prevent that.
I think this is probably a poor design and you might want to use the recursive behavior to set the attribute.
I don't know what attribute type you use and what actually causes the error.