Cannot create change set - workitem links from plain java client?
Hi,
I've done a lot of searching already, including within the SDK.
My code is like this
cs_itemRef = IReferenceFactory.INSTANCE.createReferenceToItem(cs);
wi_itemRef = IReferenceFactory.INSTANCE.createReferenceToItem(wi);
link = ILinkFactory.INSTANCE.createLink( ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID
, cs_itemRef
, wi_itemRef );
linkmgr.saveLink(link, null);
But I get this at the top of my exception stack, when calling linkmgr.saveLink(link, null);
com.ibm.team.repository.common.InternalRepositoryException: Links of this type may only be modified by the defining component.
Link Type: com.ibm.team.filesystem.workitems.change_set
Defining Component: com.ibm.team.filesystem.workitems
Requestor: remote client
at com.ibm.team.links.service.internal.ConstraintChecker.checkComponentPermission(ConstraintChecker.java:185)
at com.ibm.team.links.service.internal.RemoteLinkService.saveAuditableLink(RemoteLinkService.java:69)
Following an idea I got from the SDK, I even tried using an object of the ProviderFactory class, by calling .getLinkProvider().saveLink(link, null); on that. I get the same exception.
Reading the code for the failing function checkComponentPermission() it looks like this precise error text is associated with the case when the code is running on a client. In short, it looks possible that this facility is just not available to the Plain Java Client.
Is this true?
If not, please has someone got any ideas how to proceed to use the Plain Java Client to create work item <-> change set links please?
Also, what is the "defining component"? I don't see how to influence this thing in my application code.
Thanks
I've done a lot of searching already, including within the SDK.
My code is like this
cs_itemRef = IReferenceFactory.INSTANCE.createReferenceToItem(cs);
wi_itemRef = IReferenceFactory.INSTANCE.createReferenceToItem(wi);
link = ILinkFactory.INSTANCE.createLink( ILinkConstants.CHANGESET_WORKITEM_LINKTYPE_ID
, cs_itemRef
, wi_itemRef );
linkmgr.saveLink(link, null);
But I get this at the top of my exception stack, when calling linkmgr.saveLink(link, null);
com.ibm.team.repository.common.InternalRepositoryException: Links of this type may only be modified by the defining component.
Link Type: com.ibm.team.filesystem.workitems.change_set
Defining Component: com.ibm.team.filesystem.workitems
Requestor: remote client
at com.ibm.team.links.service.internal.ConstraintChecker.checkComponentPermission(ConstraintChecker.java:185)
at com.ibm.team.links.service.internal.RemoteLinkService.saveAuditableLink(RemoteLinkService.java:69)
Following an idea I got from the SDK, I even tried using an object of the ProviderFactory class, by calling .getLinkProvider().saveLink(link, null); on that. I get the same exception.
Reading the code for the failing function checkComponentPermission() it looks like this precise error text is associated with the case when the code is running on a client. In short, it looks possible that this facility is just not available to the Plain Java Client.
Is this true?
If not, please has someone got any ideas how to proceed to use the Plain Java Client to create work item <-> change set links please?
Also, what is the "defining component"? I don't see how to influence this thing in my application code.
Thanks
One answer
The links cannot be directly created by the using the link manager or link service.
The creation of link can only be done by the component that has defined the link.
There is a service called IFilesystemWorkItemService which has
public ILink[] createLink(final IWorkspaceHandle workspace,
final IChangeSetHandle changeSet,
final IWorkItemHandle[] workItems,
final IRepositoryProgressMonitor monitor)
throws TeamRepositoryException;
Check out if this is part of the SDK and you can use it.
Comments
Thanks, I will look at this more closely. But why is this a different approach from the example in https://jazz.net/wiki/bin/view/Main/ProgrammaticLinkCreation ? That is the approach I was using.
Additional feedback: I have just checked for IFilesystemWorkItemService and it's not in the javadoc or any of the jar files that come with the Plain Java Client.
What is the supported way to create the link? Thanks for your help.
Correction: that interface is in the jar files, but not in the javadoc. Sorry for my mistake. I'll open a work item asking for it to be included, on the assumption that it is intended to be part of the API.