It's all about the answers!

Ask a question

Cannot create change set - workitem links from plain java client?


Martin Gompertz (48510) | asked Apr 15 '13, 8:13 p.m.
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

One answer



permanent link
Aradhya K (1.4k44345) | answered Apr 15 '13, 11:55 p.m.
JAZZ DEVELOPER
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
Martin Gompertz commented Apr 16 '13, 5:39 a.m.

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.


Martin Gompertz commented Apr 16 '13, 6:30 a.m.

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.


Martin Gompertz commented Apr 17 '13, 10:35 a.m.

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.

Your answer


Register or to post your answer.