From 6a68ff71afbbdb74ff10a8dd864e4b2afbfd4103 Mon Sep 17 00:00:00 2001 From: "lukas.steiger@siemens.com" Date: Fri, 2 Jun 2017 16:57:08 +0200 Subject: [PATCH] validate Category identifier to prevent assertation error --- .../bulkMover/helpers/CategoryHelpers.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugin/src/main/java/com/siemens/bt/jazz/services/WorkItemBulkMover/bulkMover/helpers/CategoryHelpers.java b/plugin/src/main/java/com/siemens/bt/jazz/services/WorkItemBulkMover/bulkMover/helpers/CategoryHelpers.java index 7a47877..062939e 100644 --- a/plugin/src/main/java/com/siemens/bt/jazz/services/WorkItemBulkMover/bulkMover/helpers/CategoryHelpers.java +++ b/plugin/src/main/java/com/siemens/bt/jazz/services/WorkItemBulkMover/bulkMover/helpers/CategoryHelpers.java @@ -4,6 +4,7 @@ import com.ibm.team.repository.common.TeamRepositoryException; import com.ibm.team.repository.service.IRepositoryItemService; import com.ibm.team.repository.service.TeamRawService; +import com.ibm.team.workitem.common.internal.util.CategoriesHelper; import com.ibm.team.workitem.common.model.CategoryId; import com.ibm.team.workitem.common.model.ICategory; import com.ibm.team.workitem.common.model.ICategoryHandle; @@ -32,9 +33,11 @@ public static final AttributeValue getCategory(Object t_val, public static final void setCategory(IWorkItem workItem, String categoryId, IWorkItemServer workItemServer, IProgressMonitor monitor) throws TeamRepositoryException { IProjectAreaHandle ipa = workItem.getProjectArea(); - CategoryId cid = CategoryId.createCategoryId(categoryId); - ICategoryHandle cat = workItemServer.findCategoryById2(ipa, cid, monitor); - workItem.setCategory(cat); + if(isValidCategoryId(categoryId)) { + CategoryId cid = CategoryId.createCategoryId(categoryId); + ICategoryHandle cat = workItemServer.findCategoryById2(ipa, cid, monitor); + workItem.setCategory(cat); + } } public static final List addCategoriesAsValues(IProjectAreaHandle pa, @@ -51,4 +54,8 @@ public static final List addCategoriesAsValues(IProjectAreaHandl } return values; } + + public static boolean isValidCategoryId(String string) { + return string.startsWith("/") && string.indexOf("/", "/".length()) != -1; + } }