Best way to check for bad links via the REST API?
I am writing an app to check the entire repository for bad links via the REST API. Unfortunately, the current method is:
https://SERVER:9443/jazz/oslc/workitems/WORKITEMID/rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.children.xml
and look for error "CRJAZ0215E" in the result.
For EVERY work item. In addition, I have to do this for each of the following link types:
.parentworkitem.children
.parentworkitem.parent
.relatedworkitem.related
.textualReference.textuallyReferenced
.relatedartifact.relatedArtifact
.attachment.attachment
.copiedworkitem.copies
.copiedworkitem.copiedFrom
.duplicateworkitem.duplicates
.duplicateworkitem.duplicateOf
.blocksworkitem.blocks
.blocksworkitem.dependsOn
That's 12 queries each for 50,000 work items. Is there a faster way to do this via the REST API?
https://SERVER:9443/jazz/oslc/workitems/WORKITEMID/rtc_cm:com.ibm.team.workitem.linktype.parentworkitem.children.xml
and look for error "CRJAZ0215E" in the result.
For EVERY work item. In addition, I have to do this for each of the following link types:
.parentworkitem.children
.parentworkitem.parent
.relatedworkitem.related
.textualReference.textuallyReferenced
.relatedartifact.relatedArtifact
.attachment.attachment
.copiedworkitem.copies
.copiedworkitem.copiedFrom
.duplicateworkitem.duplicates
.duplicateworkitem.duplicateOf
.blocksworkitem.blocks
.blocksworkitem.dependsOn
That's 12 queries each for 50,000 work items. Is there a faster way to do this via the REST API?
3 answers
I'm not sure there is a faster way AT ALL..
I certainly wouldn't do this via REST anyhow.
write a query, all workitems that have links (of types if you care),
fetch the query results, get all their links, and check the ends..but you will have to check each one, one at a time.
why would a link be bad? only the ones added by users in the comments/description should be subject to error)
but queries are by project, not repository wide.
Comments
I have completed my app for link checking in RTC. If anyone else is suffering from bad link issues (or thinks they might be or wants to make sure they aren't), let me know and I will send you my app. The app does not do any writing to RTC, only reading. You will still need to edit the work items in 4.0.6 or later to remove the bad links.
I found a MUCH faster way of checking for bad links.
First, run this REST API command for each work item:
https://SERVER:PORT/jazz/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItemDTO2?id=WORKITEMID&includeAttributes=false&includeLinks=true&includeApprovals=false&includeHistory=false
Then parse the results.
<linkTypes></linkTypes> contains each link type
<displayName></displayName> within each link type is the name of the link type, such as "Parent".
multiple <linkDTOs></linkDTOs> within each link type are your individual links.
<comment></comment> within each linkDTOs is your link name. The link name will be different if the link is bad.
For example:
Good Link: "Epic 24766: Field length change LDAP_ID"
Bad Link: "24766: Field length change LDAP_ID"
The type of work item of the bad link is missing. You'll need to ignore some types of link types that are not work items, such as "Attachments" and "Included in Builds".
I have switched my application to use the new method. Also, the old method would not list the number of bad links of a particular type.
By the way, you would not believe the number of bad "Mentions" and "Mentioned By" links that you probably all have!
First, run this REST API command for each work item:
https://SERVER:PORT/jazz/service/com.ibm.team.workitem.common.internal.rest.IWorkItemRestService/workItemDTO2?id=WORKITEMID&includeAttributes=false&includeLinks=true&includeApprovals=false&includeHistory=false
Then parse the results.
<linkTypes></linkTypes> contains each link type
<displayName></displayName> within each link type is the name of the link type, such as "Parent".
multiple <linkDTOs></linkDTOs> within each link type are your individual links.
<comment></comment> within each linkDTOs is your link name. The link name will be different if the link is bad.
For example:
Good Link: "Epic 24766: Field length change LDAP_ID"
Bad Link: "24766: Field length change LDAP_ID"
The type of work item of the bad link is missing. You'll need to ignore some types of link types that are not work items, such as "Attachments" and "Included in Builds".
I have switched my application to use the new method. Also, the old method would not list the number of bad links of a particular type.
By the way, you would not believe the number of bad "Mentions" and "Mentioned By" links that you probably all have!