Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



One answer

Permanent link
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.

0 votes

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.

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,944

Question asked: Apr 15 '13, 8:13 p.m.

Question was seen: 4,408 times

Last updated: Apr 17 '13, 10:35 a.m.

Confirmation Cancel Confirm