Obtaining an issue via an old issue key

/**
     * Search the change logs to find the issue that used to be called 'key'
     *
     * @return The new Issue, null if none exists
     * @throws GenericEntityException if an unexpected error occurs
     */
    private GenericValue findMovedIssue(final String origKey) throws GenericEntityException
    {
        String key = origKey.toUpperCase();
        GenericValue changeItem = null;
        try
        {
            GenericDelegator delegator = CoreFactory.getGenericDelegator();
            List changeItems = delegator.findByLike("ChangeItem", EasyMap.build("field", "Key", "oldstring", key), EasyList.build("group desc"));
            changeItem = getLastChangeItem(changeItems);
        }
        catch (Throwable e) //Fixes JRA-5067
        {
            log.debug("Error retrieving ChangeItems to search for moved issues. Exception message: " + e.getMessage());
            return null;
        }

        if (changeItem == null) return null;
        GenericValue changeGroup = changeItem.getRelatedOne("ParentChangeGroup");
        if (changeGroup == null) return null;
        return changeGroup.getRelatedOne("ParentIssue");
    }

Labels

 
(None)