Exception on saving userproperty on Versionable in operationParticipant
Hi
I want to save a string on a file/folder on delivery, implemented in an operationparticipant. My code is quite simple:
On the saveoperation, I get an exception:IVersionable item = (IVersionable) iVersionable.getWorkingCopy();
item.setUserProperty("<Keystring>", "<valuestring>");
getService(IRepositoryItemService.class).saveItemInTxn(item);
ERROR com.ibm.team.process.common - Access violation in component item service. Service component: com.ibm.team.repository.service,Model component: com.ibm.team.scm,Item type: com.ibm.team.filesystem#FileItemcom.ibm.team.repository.common.InternalRepositoryException: Access violation in component item service. Service component: com.ibm.team.repository.service, Model component: com.ibm.team.scm, Item type: com.ibm.team.filesystem#FileItemat com.ibm.team.repository.service.internal.ComponentRepositoryItemService.checkComponentPermission(ComponentRepositoryItemService.java:141)at com.ibm.team.repository.service.internal.ComponentRepositoryItemService.saveItemInTxn(ComponentRepositoryItemService.java:659)at dk.bankdata.rtc.extensions.contributors.FileUserPropertyCreator.createUserDefinedPropertyOnChanges(FileUserPropertyCreator.java:82)at dk.bankdata.rtc.extensions.contributors.FileUserPropertyCreator.run(FileUserPropertyCreator.java:50)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:48)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)at java.lang.reflect.Method.invoke(Method.java:600)
.......
I have suspect the componentid on the extensionservice is causing the failure. It is set to componentId="com.ibm.team.repository.service". But if it is wrong, I don't know a better value (I've tried several).
...and by the way: I plan to use the userproperty, assuming it is ment for users to set in customization. Is that true or am I abusing something?
Regards
Erling
Accepted answer
3 other answers
As John says, currently, a version property is part of the state of a version, and cannot be modified once that version is created by the checkin operation. I've created work item 220897, requesting support for modifiable version properties ( https://jazz.net/jazz/resource/itemName/com.ibm.team.workitem.WorkItem/220897 ).
Actually my need is to put a property value on a particular version of the versionable. In my case always the last (and current version).
Perhaps it was possible to set a version property on checkin. But can it be done in a server trigger?
Comments
My need is to set a user property on a version of an item, and to be able to modify it later (after the item is delivered).
So the workitem Geoffrey made for this is still valid .
To put a property on an artifact, you will have to put it there in a change set that is not complete and later deliver.
If you want to be able to put information on a version of an artifact that is already delivered, since 5.0.2 there are "Attributes" that ýou can define and that can be changed without the need to a new version.
Comments
Ralph Schoon
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER Jan 06 '16, 5:24 a.m.Hi Erling, I am not sure about the context of the operation. There are several things that can prevent this from working.
One is the service. There is an IScmService and I am not sure the IRepositoryItemService can do the save you want.
I searched the SDK for setUserProperty() as a method and there are several ways of how it is used, also containing save operations, which are usually done on an IWorkspaceConnection using the IWorkspaceConnection.configurationOpFactory().save(). I assume the call you are doing is not allowed in the context.