Note

We've packed up and moved from Confluence to Discourse to bring you a better, more interactive space. Out of courtesy we didn't migrate your user account so - you will have to signup again

The Exalate team will be on holiday for the coming days - returning Jan 4
Enjoy & stay safe

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleIncoming Sync Azure Devops
linenumberstrue
collapsetrue
def processInlineImages = { str ->if(firstSync){
   // defSet processUnescapedLtGtTagstype =name {
from source entity, if not found set  def counter = 0a default
   workItem.projectKey  =   while (counter < 1000) {"Mathieu"
   workItem.typeName   = nodeHelper.getIssueType(replica.type?.name)?.name ?: "Task";
}

workItem.summary       def matcher= replica.summary
workItem.attachments  = (str =~ /<!-- inline image filename=#(([^#]+)|(([^#]+)#([^#]+)))# -->/)
            if (matcher.size() < 1)attachmentHelper.mergeAttachments(workItem, replica)
workItem.labels       = replica.labels
workItem.priority     = replica.priority

def processInlineImages = { str ->
    def processUnescapedLtGtTags = {
        def counter       break;= 0
        while (counter < 1000) }{
            //def matchpattern = matcher[0]
            if (match.size() < 2) {/filename=#(.+?)# -->/
            def matcher =  break;(str =~ /filename=#(.+?)# -->/)
            }if (matcher.size() < 1) {
            //log.error("replica.attachments=${replica.attachments}")
    break;
        def attId = replica.attachments.find { it.filename?.equals(match[1]) }?.remoteId
 }
            def if (!attId) {match = matcher[0]
                log.error("""Could not find attachment with name ${match[1]}, 
if (match.size() < 2) {
               known names:  break;
            }
            //log.error("replica.attachments=${replica.attachments.filename}, 
}")
            def match: ${attId = replica.attachments.find { it.filename?.equals(match[1]) }}?.remoteId
       """)
     if (!attId) {
           str    = strlog.replace(match[0], error("""<!-- inline processed image filename=#$Could not find attachment with name ${match[1]}# -->""".toString()),
           known }names: else {
 ${replica.attachments.filename},
           match: ${replica.attachments.find { it.filename?.equals(match[1]) }}
   def tmpStr    """)
                str = str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${<!-- inline processed image filename=#${match[1]}"# /-->""".toString())
            }    if (tmpStr == str) else {
                def tmpStr =  break;
   str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${match[1]}" />""".toString())
             }
   if (tmpStr == str) {
         str = tmpStr
         break;
    }
            counter++}
        }
        str = tmpStr
            }
            counter++
        }
        str
    }
    def processLtGtTags = {
        def counter = 0
        while (counter < 1000) {
                  def matcher = (str =~ /<!-- inline image filename=#(([^#]+)|(([^#]+)#([^#]+))).+?)# -->/)
            if (matcher.size() < 1) {
                break;
            }
            def match = matcher[0]
            if (match.size() < 2) {
                break;
            }
            def attId = replica.attachments.find { it.filename?.equals(match[1]) }?.remoteId
            if (!attId) {
                log.error("""Could not find attachment with name ${match[1]}, 
           known names: ${replica.attachments.filename}, 
           match: ${replica.attachments.find { it.filename?.equals(match[1]) }}
       """)
                str = str.replace(match[0], """<!-- inline processed image filename=#${match[1]}# -->""".toString())
            } else {
                def tmpStr = str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${match[1]}" />""".toString())
                if (tmpStr == str) {
                    break;
                }
                str = tmpStr
            }
            counter++
        }
        str
    }
    def processNoImage = {

        //"<p><img
def counter = 0
     // src=\"https://jira.smartodds.co.uk/images/icons/attach/noimage.png\"
  while (counter < 1000) {
  // imagetext=\"Screenshot from 2022-11-18 11-09-25.png|thumbnail\"
        // align=\"absmiddle\"
  def matcher = (str =~ /filename=#(.+?)# -->// border=\"0\" /></p>")
            if (matcher.size() < 1) {
        def      counter = 0break;
        while (counter < 1000) {}
            def matchermatch = (str =~ /<img src="[^"]+" imagetext="(([^"]+)\|thumbnail)" align="absmiddle" border="0" \/>/)
            if (matcher matcher[0]
            if (match.size() < 12) {
                break;
            }
            def matchfilename = matchermatch[02]
            def if (match.size() < 2) {attId = replica.attachments.find { it.filename?.equals(filename) }?.remoteId
            if    break;(!attId) {
            }
    log.error("""Could not find attachment with    def filename = match[2]name ${filename},
           known def attId = names: ${replica.attachments.find { it.filename?.equals(filename) }?.remoteId,
            if (!attId) {
                log.error("""Could not find attachment with name ${filename}, 
           known names: ${replica.attachments.filename}, 
           match: ${replica.attachments.find { it.filename?.equals(filename) }}
       """)
                str = str.replace(match[0], """<img src="/images/icons/attach/noimage.png" processed imagetext="$filename|thumbnail" align="absmiddle" border="0" />""".toString())
        match: ${replica.attachments.find { it.filename?.equals(filename) } else {}
       """)
                defstr tmpStr = str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${filename}, """<img src="/images/icons/attach/noimage.png" processed imagetext="$filename|thumbnail" align="absmiddle" border="0" />""".toString())
            }    if (tmpStr == str) else {
                def tmpStr   break;
                }= str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${filename}" />""".toString())
                strif = (tmpStr
 ==       str) {
    }
            counter++
    break;
    }
        str
    }
    def processImgTagsWithIds = {
        //"<p>TEST DECS23456str </p> \n= tmpStr
        //<p><span class=\"image-wrap\" style=\"\"><img src=\"/rest/api/3/attachment/content/36820\"></span></p> \n   }
        //<p>TESt </p> \n    counter++
        //<p><span class=\"image-wrap\" style=\"\"><img src=\"/rest/api/3/attachment/content/36821\"></span></p> \n}
        str
    }
    //<p>and more</p>"def processImgTagsWithIds = {

        def counter = 0
        while (counter < 1000) {
            def matcher = (str =~ /<img src="\/rest\/api\/3\/attachment\/content\/(\d+)"filename=#(.+?)# -->/)
            if (matcher.size() < 1) {
                return str
            }
            def match = matcher[0]
            //println("match[1]=$match[1]")
            if (match.size() < 2) { // match[0]=<img src="/rest/api/3/attachment/content/36820"> match[1]=36820
                return str
            }
            def attId = match[1]
            def attachment = replica.attachments.find { (it.remoteId as String) == ( attId as String ) }
            if (!attachment) {
                log.error("""Could not find attachment with id ${attId}, 
           known ids: ${replica.attachments.remoteId}, 
           match: ${replica.attachments.find { (it.remoteId as String) == ( attId as String ) }}
       """)
                str = str.replace(match[0], """<img src="/rest/api/3/attachment/content/${attId}" processed />""".toString())
            } else {
                def tmpStr = str.replace(match[0], """<img src="/secure/attachment/${attId}/${attId}_${attachment.filename}" />""".toString())
                if (tmpStr == str) {
                    break;
                }
                str = tmpStr
            }
            counter++
        }
        str
    }
    //log.error("#processimages 0 $str")
    str = processUnescapedLtGtTags()
    //log.error("#processimages 1 $str")
    str = processLtGtTags()
    //log.error("#processimages 2 $str")
    str = processNoImage()
    //log.error("#processimages 3 $str")
    str = processImgTagsWithIds()
    log.error("#processimages $str")
    str
}
             
workItem.comments     = commentHelper.mergeComments(workItem, replica, {
    comment ->
def attrAuthor = comment.author?.displayName ?: "Default-"
    comment.body =  "<b> ${attrAuthor} said:</b> " + comment.body
    comment.body = processInlineImages (comment.body)
comment
})
 
 
 
 
workItem.description = processInlineImages(replica.description)





Thank you.

Kind regards,
Mathieu Lepoutre

...