I am trying to write some postfunction to execute some transitions back to back. I get the following error message when I click on the menu item for executing the 3 transitions back to back.
I am supposed to transition from open to fixed, then from fixed to tested and from tested to completed. The first transition works as expected but the second one is not working, I don't really know why, I have tried printing the list of error or warning messages but they are both empty. Anyone knows what the problem is?
Here is my code:
package CombineTransitions
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue;
import CombineTransitions.Configuration_CombineTransitions
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
def log1 = Logger.getLogger("atlassian-jira.log")
def combineTransitionsHashMap= Configuration_CombineTransitions.getCombineTransitionsHashMap()
def issueStatusTypeId = combineTransitionsHashMap["issueStatusTypeId"] as String;
def transitionFromOpentoFixed = combineTransitionsHashMap["transitionFromOpentoFixed"] as Integer;
def transitionFromFixedToTested = combineTransitionsHashMap["transitionFromFixedToTested"] as Integer;
def transitionFromTestedToCompleted = combineTransitionsHashMap["transitionFromTestedToCompleted"] as Integer;
def fixedStatusName = combineTransitionsHashMap["fixedStatusName"] as String;
def testedStatusName = combineTransitionsHashMap["testedStatusName"] as String;
def completedStatusName = combineTransitionsHashMap["completedStatusName"] as String;
def fixedStatusId = combineTransitionsHashMap["fixedStatusId"] as String;
def testedStatusId = combineTransitionsHashMap["testedStatusId"] as String;
def completedStatusId = combineTransitionsHashMap["completedStatusId"] as String;
if (issue.getStatus().getSimpleStatus().getId().equals(issueStatusTypeId)) {
def ok = false
ok=performTransition(transitionFromOpentoFixed, fixedStatusName, fixedStatusId);
log.warn("MOUNA first boolean "+ok +" "+fixedStatusName)
if(ok){
ok= performTransition(transitionFromFixedToTested, testedStatusName, testedStatusId);
log.warn("MOUNA second boolean "+ok +" "+testedStatusName)
if(ok){
ok= performTransition(transitionFromTestedToCompleted, completedStatusName, completedStatusId);
log.warn("MOUNA third boolean "+ok +" "+completedStatusName)
}
}
}
def performTransition(int transitionToBeDone, String destinationStatus, String statusId ) {
log.warn("MOUNA ORIGINAL STATUS "+ issue.getStatus() + "DEST STATUS "+ destinationStatus)
issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String issueKey = issue.getKey()
IssueService issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("Transitioning issue from status "+ issue.getStatus().getName()+" to status "+ destinationStatus );
TransitionValidationResult transitionValidationResult = issueService.validateTransition(currentUser, issue.id, transitionToBeDone, issueInputParameters)
log.warn("MOUNA transitionValidationResult: "+transitionValidationResult + " actionID "+transitionValidationResult.getActionId()+" transitionValidationResult.getAdditionInputs() "+transitionValidationResult.getAdditionInputs()+" transitionValidationResult.getFieldValuesHolder().toString() "+
transitionValidationResult.getFieldValuesHolder().toString() )
if (transitionValidationResult.isValid()) {
IssueResult transitionResult = issueService.transition(currentUser, transitionValidationResult)
issue.setStatusId(statusId)
log.warn("MOUNA STATUS "+ transitionResult.getIssue().getStatus().getName())
return true
}else{
log.warn("MOUNA 2 getErrorCollection() "+transitionValidationResult.getErrorCollection() )
log.warn("MOUNA 3 getWarningCollection() "+transitionValidationResult.getWarningCollection().getWarnings().toString() )
// log.warn("MOUNA 4 "+issue.getStatus().getName() +" transitionToBeDone "+ transitionToBeDone +" destinationStatus "+destinationStatus)
return false
}
}
This is my log file where I am printing some values for debugging:
2022-12-22 10:32:27,239+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA second boolean false Tested
2022-12-22 10:32:27,239+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA 3 getWarningCollection() []
2022-12-22 10:32:27,239+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA 2 getErrorCollection() Errors: {}
2022-12-22 10:32:27,239+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA transitionValidationResult: com.atlassian.jira.bc.issue.IssueService$TransitionValidationResult#5325f11e actionID 111 transitionValidationResult.getAdditionInputs() null transitionValidationResult.getFieldValuesHolder().toString() [formToken:null]
2022-12-22 10:32:27,223+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA ORIGINAL STATUS IssueConstantImpl[[GenericEntity:Status][sequence,8][statuscategory,4][name,Fixed][iconurl,/images/icons/status_fixed-sag.gif][description,][id,10001]]DEST STATUS Tested
2022-12-22 10:32:27,223+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA first boolean true Fixed
2022-12-22 10:32:27,223+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA STATUS Open
2022-12-22 10:32:26,457+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA transitionValidationResult: com.atlassian.jira.bc.issue.IssueService$TransitionValidationResult#294cb9b9 actionID 71 transitionValidationResult.getAdditionInputs() [commentProperty:null, originalAssigneeId:JIRAUSER59200, comment:Transitioning issue from status Open to status Fixed, roleLevel:null, commentLevel:null, userKey:JIRAUSER59200] transitionValidationResult.getFieldValuesHolder().toString() [fixVersions:[], customfield_10298:CustomFieldParams: Readme Text. Params: {null=[]}., customfield_10002:CustomFieldParams: QA/QE Owner. Params: {null=[]}., customfield_10211:CustomFieldParams: Phase Missed. Params: {null=[]}., customfield_10531:CustomFieldParams: Fix Build. Params: {null=[]}., customfield_10215:CustomFieldParams: Test Steps. Params: {null=[]}., customfield_10217:CustomFieldParams: Source Control Ref.. Params: {null=[]}., formToken:null, customfield_10219:CustomFieldParams: Solution Description. Params: {null=[bm]}., customfield_19380:CustomFieldParams: Related Product Standard. Params: {null=[]}., comment:[levelPresent:true, comment:Transitioning issue from status Open to status Fixed, groupLevel:null, roleLevel:null], worklog:com.atlassian.jira.issue.fields.WorklogSystemField$WorklogValue$Builder$1#3ea48487, assignee:mouh]
2022-12-22 10:32:26,426+0100 https-openssl-nio-443-exec-3 WARN mouh 632x4183x1 jj2112 10.248.75.15 /secure/CommentAssignIssue.jspa [c.o.scriptrunner.runner.ScriptBindingsManager] MOUNA ORIGINAL STATUS IssueConstantImpl[[GenericEntity:Status][sequence,4][statuscategory,4][name,Open][iconurl,/images/icons/statuses/open.png][description,null][id,1]]DEST STATUS Fixed
Related
I’m trying to connect to a webpage link using a Waveshare Sim7020 module through a Raspberry Pico, using https AT commands, but the connect command returns an error.
My final objective is to send a telegram message from it using a bot link for it like explained in https://core.telegram.org/bots/api#making-requests using this method:
https://api.telegram.org/bot\<token>/METHOD_NAME
This is not working for me, so thinking that maybe this is complex I’m trying to connect to google, bur the problem continues. I have also syncronized the time on the module with a server. I’m wondering that it could be a certificate problem? These are the functions used:
from machine import Pin, ADC
import os
import utime
import binascii
#import ujson
#print sys info
print(os.uname())
#using pin defined
ADC0= ADC(Pin(26))
sensor_temp = ADC(4)
led_pin =25 #onboard led
pwr_en = 14 #pin to control the power of sim7020x
uart_port = 0
uart_baute = 115200
APN = "cmnbiot"
i=0
reading=0
temperature=0
#indicate program started visually
led_onboard = machine.Pin(led_pin, machine.Pin.OUT)
def led_blink():
led_onboard.value(1)
utime.sleep(0.5)
led_onboard.value(0)
utime.sleep(0.5)
led_onboard.value(1)
utime.sleep(0.5)
led_onboard.value(0)
def hexStr_to_str(hex_str):
hex = hex_str.encode('utf-8')
str_bin = binascii.unhexlify(hex)
return str_bin.decode('utf-8')
def str_to_hexStr(string):
str_bin = string.encode('utf-8')
return binascii.hexlify(str_bin).decode('utf-8')
#power on the sim800c
def powerOn(pwr_en):
pwr_key = machine.Pin(pwr_en, machine.Pin.OUT)
pwr_key.value(1)
#power down the sim800c
def powerDown(pwr_en):
pwr_key = machine.Pin(pwr_en, machine.Pin.OUT)
pwr_key.value(0)
#2 sec timeout is arbitrarily chosen
def sendCMD_waitResp(cmd, timeout=2000):
print("CMD: " + cmd)
uart.write((cmd+'\r\n').encode())
waitResp(timeout)
print()
def waitResp(timeout=2000):
prvMills = utime.ticks_ms()
resp = b""
while (utime.ticks_ms()-prvMills)<timeout:
if uart.any():
resp = b"".join([resp, uart.read(1)])
print((resp).decode())
def sendCMD_waitRespLine(cmd, timeout=2000):
print("CMD: " + cmd)
uart.write((cmd+'\r\n').encode())
waitRespLine(timeout)
print()
def waitRespLine(timeout=2000):
prvMills = utime.ticks_ms()
while (utime.ticks_ms()-prvMills)<timeout:
if uart.any():
print((uart.readline()).decode())
#APN Manual configuration
def apnConfig(APN):
sendCMD_waitResp("AT+CFUN=0") #Disable RF
sendCMD_waitResp("AT*MCGDEFCONT=\"IP\",\""+ APN +"\"") #Set the APN manually
sendCMD_waitResp("AT+CFUN=1") #Enable RF
utime.sleep(1)
sendCMD_waitResp("AT+CGATT?") #Inquiry PS service
sendCMD_waitResp("AT+CGREG?")
sendCMD_waitResp("AT+CGCONTRDP") #Attached PS domain and got IP address automatically
Then this are the AT command tests and APN configuration:
#print uart info
uart = machine.UART(uart_port, uart_baute, bits=8, parity=None, stop=1)
print(uart)
#power on the board
powerOn(pwr_en)
#clear bufer in UART
waitResp()
#AT commands test
atCommandTest()
#APN Manual configuration
apnConfig(APN)
Then this is the time syncronization:
sendCMD_waitResp("AT+CSNTPSTART=\"[ntp.i2t.ehu.es](http://ntp.i2t.ehu.es/)\"")
sendCMD_waitResp("AT+CCLK?")
sendCMD_waitResp("AT+CSNTPSTOP")
sendCMD_waitResp("AT+CSNTPSTART=\"[ntp.i2t.ehu.es](http://ntp.i2t.ehu.es/)\",\"+01\"")
sendCMD_waitResp("AT+CCLK?")
sendCMD_waitResp("AT+CSNTPSTOP")
sendCMD_waitResp("AT+CURTC=1")
sendCMD_waitResp("AT+CRESET")
sendCMD_waitResp("AT+CURTC?")
sendCMD_waitResp("AT+CSNTPSTART=\"[ntp.i2t.ehu.es](http://ntp.i2t.ehu.es/)\"")
sendCMD_waitResp("AT+CCLK?")
sendCMD_waitResp("AT+CSNTPSTOP")
sendCMD_waitResp("AT+CURTC=1")
sendCMD_waitResp("AT+CURTC?")
sendCMD_waitResp("AT+CSNTPSTART=\"[ntp.i2t.ehu.es](http://ntp.i2t.ehu.es/)\",\"+01\"")
sendCMD_waitResp("AT+CCLK?")
sendCMD_waitResp("AT+CSNTPSTOP")
And this is the connection try out, where on create says OK but on connect says “ERROR”:
sendCMD_waitResp("AT+CHTTPCREATE=\"https://www.google.com/\"")
sendCMD_waitResp("AT+CHTTPCON=0")
sendCMD_waitRespLine("CAT+HTTPSEND=0,0,\"nextlink\"")
waitResp()
sendCMD_waitResp("CAT+HTTPDISCON=0")
sendCMD_waitResp("CAT+HTTPDESTROY=0")
Any ideas on what could be happening?
I am using scriptrunner postfunction and validator to perform 3 transitions back to back. The problem is that I receive an error message saying
[comment:Please, add a comment.] although a comment has actually been adde as you can see in the screenshot
Here is the code I have used, anyone knows how to fix this?
package CombineTransitions
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue;
import CombineTransitions.Configuration_CombineTransitions
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.jira.event.type.EventDispatchOption
import java.util.concurrent.TimeUnit
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.Executors
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.util.ErrorCollection
import com.atlassian.jira.workflow.WorkflowException
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.screen.FieldScreenRenderLayoutItem;
import com.atlassian.jira.issue.fields.screen.FieldScreenRenderTab;
import com.atlassian.jira.issue.fields.screen.FieldScreenRenderer;
def log1 = Logger.getLogger("atlassian-jira.log")
def combineTransitionsHashMap= Configuration_CombineTransitions.getCombineTransitionsHashMap()
def issueStatusTypeId = combineTransitionsHashMap["issueStatusTypeId"] as String;
def transitionFromOpentoFixed = combineTransitionsHashMap["transitionFromOpentoFixed"] as Integer;
def transitionFromFixedToTested = combineTransitionsHashMap["transitionFromFixedToTested"] as Integer;
def transitionFromTestedToCompleted = combineTransitionsHashMap["transitionFromTestedToCompleted"] as Integer;
def fixedStatusName = combineTransitionsHashMap["fixedStatusName"] as String;
def testedStatusName = combineTransitionsHashMap["testedStatusName"] as String;
def completedStatusName = combineTransitionsHashMap["completedStatusName"] as String;
def fixedStatusId = combineTransitionsHashMap["fixedStatusId"] as String;
def testedStatusId = combineTransitionsHashMap["testedStatusId"] as String;
def completedStatusId = combineTransitionsHashMap["completedStatusId"] as String;
def errorMessage = combineTransitionsHashMap["errorMessage"] as String;
if (issue.getStatus().getSimpleStatus().getId().equals(issueStatusTypeId)) {
def ok = false
ok=performTransition(transitionFromOpentoFixed, fixedStatusName, fixedStatusId, errorMessage);
log.warn("MOUNA first boolean "+ok +" "+fixedStatusName)
if(ok){
ok= performTransition(transitionFromFixedToTested, testedStatusName, testedStatusId, errorMessage);
log.warn("MOUNA second boolean "+ok +" "+testedStatusName)
if(ok){
ok= performTransition(transitionFromTestedToCompleted, completedStatusName, completedStatusId, errorMessage);
log.warn("MOUNA third boolean "+ok +" "+completedStatusName)
}
}
}
def performTransition(int transitionToBeDone, String destinationStatus, String statusId , String errorMessage) {
log.warn("MOUNA ORIGINAL STATUS "+ issue.getStatus() + "DEST STATUS "+ destinationStatus)
//issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
issue = transientVars.get("issue");
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String issueKey = issue.getKey()
IssueService issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("Transitioning issue from status "+ issue.getStatus().getName()+" to status "+ destinationStatus );
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setAction(transitionToBeDone)
//workflowTransitionUtil.addAdditionalInput(transientVars.get("comment"))
log.warn("MOUNA "+transientVars)
ErrorCollection errorCollection=workflowTransitionUtil.validate()
if (errorCollection.hasAnyErrors()) {
log.warn("MOUNA here 1 "+errorCollection.getErrorMessages().toString())
throw new InvalidInputException(errorCollection.getErrors().toString())
return false;
}else{
ErrorCollection progressErrorCollection=workflowTransitionUtil.progress()
if(progressErrorCollection.hasAnyErrors()){
log.warn("MOUNA here 2 "+progressErrorCollection.getErrors().toString())
throw new InvalidInputException(progressErrorCollection.getErrors().toString())
return true;
}else{
return true;
}
}
}
//#SuppressWarnings("rawtypes")
// Map getPopulatedFieldValuesHolder(WorkflowTransitionUtil workflowTransitionUtil, MutableIssue issue) throws Exception{
// Map fieldValuesHolder = new HashMap();
// FieldScreenRenderer fieldScreenRenderer = workflowTransitionUtil.getFieldScreenRenderer();
// for (FieldScreenRenderTab fieldScreenRenderTab in fieldScreenRenderer.getFieldScreenRenderTabs())
// for (FieldScreenRenderLayoutItem fieldScreenRenderLayoutItem in fieldScreenRenderTab.getFieldScreenRenderLayoutItems())
// if (fieldScreenRenderLayoutItem.isShow(issue)) {
// fieldScreenRenderLayoutItem.populateFromIssue(fieldValuesHolder, issue);
// log.warn("fieldScreenRenderLayoutItem MOUNA "+fieldScreenRenderLayoutItem.getFieldScreenLayoutItem().getFieldScreenTab().getFieldScreen().getName())
// }
// return fieldValuesHolder;
// }
// String getError(String error){
// return error;
// }
I have an error message that is thrown when I try to execute a postfunction, the error message is:
org.ofbiz.core.entity.GenericTransactionException: Commit failed, rollback previously requested by nested transaction.
You can see the error message in this screenshot:
In my code, I am using the line :
log.warn("MOUNA here 2 "+progressErrorCollection.getErrors().toString()) which is displaying a more meaninful message to the user which is: fixVersions:Fix Version/s is required. I would like to print this message instead to the user instead of org.ofbiz.core.entity.GenericTransactionException: Commit failed, rollback previously requested by nested transaction.
How can I enforce this? I have tried using
UserMessageUtil.error(progressErrorCollection.getErrors().toString()) but it is not working. Anyone knows? Here is my code below:
package CombineTransitions
import com.onresolve.scriptrunner.runner.util.UserMessageUtil
import com.atlassian.jira.issue.Issue;
import org.apache.log4j.Logger
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.Issue;
import CombineTransitions.Configuration_CombineTransitions
import com.atlassian.jira.bc.issue.IssueService.IssueResult
import com.atlassian.jira.bc.issue.IssueService.TransitionValidationResult
import com.atlassian.jira.event.type.EventDispatchOption
import java.util.concurrent.TimeUnit
import java.util.concurrent.ScheduledExecutorService
import java.util.concurrent.Executors
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.util.ErrorCollection
import com.atlassian.jira.workflow.WorkflowException
def log1 = Logger.getLogger("atlassian-jira.log")
def combineTransitionsHashMap= Configuration_CombineTransitions.getCombineTransitionsHashMap()
def issueStatusTypeId = combineTransitionsHashMap["issueStatusTypeId"] as String;
def transitionFromOpentoFixed = combineTransitionsHashMap["transitionFromOpentoFixed"] as Integer;
def transitionFromFixedToTested = combineTransitionsHashMap["transitionFromFixedToTested"] as Integer;
def transitionFromTestedToCompleted = combineTransitionsHashMap["transitionFromTestedToCompleted"] as Integer;
def fixedStatusName = combineTransitionsHashMap["fixedStatusName"] as String;
def testedStatusName = combineTransitionsHashMap["testedStatusName"] as String;
def completedStatusName = combineTransitionsHashMap["completedStatusName"] as String;
def fixedStatusId = combineTransitionsHashMap["fixedStatusId"] as String;
def testedStatusId = combineTransitionsHashMap["testedStatusId"] as String;
def completedStatusId = combineTransitionsHashMap["completedStatusId"] as String;
if (issue.getStatus().getSimpleStatus().getId().equals(issueStatusTypeId)) {
def ok = false
ok=performTransition(transitionFromOpentoFixed, fixedStatusName, fixedStatusId);
log.warn("MOUNA first boolean "+ok +" "+fixedStatusName)
if(ok){
ok= performTransition(transitionFromFixedToTested, testedStatusName, testedStatusId);
log.warn("MOUNA second boolean "+ok +" "+testedStatusName)
if(ok){
ok= performTransition(transitionFromTestedToCompleted, completedStatusName, completedStatusId);
log.warn("MOUNA third boolean "+ok +" "+completedStatusName)
}
}
}
def performTransition(int transitionToBeDone, String destinationStatus, String statusId ) {
log.warn("MOUNA ORIGINAL STATUS "+ issue.getStatus() + "DEST STATUS "+ destinationStatus)
issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
String issueKey = issue.getKey()
IssueService issueService = ComponentAccessor.getIssueService()
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("Transitioning issue from status "+ issue.getStatus().getName()+" to status "+ destinationStatus );
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
workflowTransitionUtil.setIssue(issue)
workflowTransitionUtil.setAction(transitionToBeDone)
ErrorCollection errorCollection=workflowTransitionUtil.validate()
if (errorCollection.hasAnyErrors()) {
log.warn("MOUNA here 1 "+errorCollection.getErrorMessages().toString())
return false;
}else{
ErrorCollection progressErrorCollection=workflowTransitionUtil.progress()
if(progressErrorCollection.hasAnyErrors()){
log.warn("MOUNA here 2 "+progressErrorCollection.getErrors().toString())
// throw new WorkflowException(progressErrorCollection.getErrors().toString());
UserMessageUtil.error(progressErrorCollection.getErrors().toString())
return false;
}else{
return true;
}
}
}
I am using a Custom script post-function [ScriptRunner] that is triggered after clicking on the transition "MounaCompleted" located in my menu item (last item in the menu).
I am using the following code to transition an issue after clicking on the "Completed" menu item.
Initially, my issue is in the status "Open" and I would like to transition my issue from "Open" to "Fixed". I am using the following code which does not work. My problem is that
if (validationResult.isValid())
evaluates to false and I end up printing
Failed to transition subtask 7 com.atlassian.jira.bc.issue.IssueService$TransitionValidationResult#105aff4d
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.workflow.WorkflowManager
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
def log = Logger.getLogger("atlassian-jira.log")
log.warn("This is the last action ")
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager();
def issueService = ComponentAccessor.getIssueService()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (issue.status.name == "Open") {
log.warn("Failed to transition subtask 1"+issue.status.name)
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.with {
log.warn("Failed to transition subtask 2")
setResolutionId("10001") // resolution of "Fixed"
setComment("*Resolving* as a result of the *Resolve* action being applied to the parent.")
setSkipScreenCheck(true)
}
// validate and transition subtask
log.warn("Failed to transition subtask 10 "+ user+" "+ issue.getId()+" "+ 10001+" "+ issueInputParameters)
def validationResult = null
try{
validationResult = issueService.validateTransition(user, issue.getId(), 10001, issueInputParameters)
}
catch(Exception e){
log.warn("Failed to transition subtask 3 "+e)
}
if (validationResult.isValid()) {
def issueResult = issueService.transition(user, validationResult)
log.warn("Failed to transition subtask 4")
if (!issueResult.isValid()) {
log.warn("Failed to transition subtask 5")
log.warn("Failed to transition subtask ${issue.getId()}, errors: ${issueResult.errorCollection}")
}else{
log.warn("Failed to transition subtask 6")
log.warn("success")
}
} else {
log.warn("Failed to transition subtask 7 "+validationResult)
log.warn("Could not transition subtask ${issue.getId()}, errors: ${validationResult.errorCollection}")
}
}else {
log.warn("Failed to transition subtask 8")
log.warn("Failed to transition subtask ")
log.warn("Failed to transition subtask3333 "+issue.getId())
}
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.Issue;
import java.util.HashMap;
import java.util.List;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
import org.apache.log4j.Logger
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.changehistory.ChangeHistoryItem
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.bc.issue.IssueService.IssueValidationResult
import com.atlassian.jira.user.ApplicationUser
import com.opensymphony.module.propertyset.PropertySet;
import com.opensymphony.workflow.WorkflowException;
import com.opensymphony.workflow.loader.ActionDescriptor;
import com.opensymphony.workflow.loader.StepDescriptor;
import com.opensymphony.workflow.spi.SimpleStep;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.config.ConstantsManager
def log = Logger.getLogger("atlassian-jira.log")
if (issue.getStatus().getSimpleStatus().getId().equals("1")) {
log.warn("MOUNA 1");
int transitionFromOpentoFixed = 71;
int transitionFromFixedToTested = 111;
int transitionFromTestedToCompleted = 131;
log.warn("MOUNA 100 transitionFromOpentoFixed " + issue.getStatus());
transition(transitionFromOpentoFixed, "Fixed");
log.warn("MOUNA 101 transitionFromFixedToTested " + issue.getStatus());
transition(transitionFromFixedToTested, "Tested");
log.warn("MOUNA 102 transitionFromTestedToCompleted " + issue.getStatus());
transition(transitionFromTestedToCompleted, "Completed");
}
void transition(int transitionToBeDone, String destinationStatus) {
issue = ComponentAccessor.getIssueManager().getIssueObject(issue.id)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
log.warn("MOUNA 5 STATUS " + issue.getStatus());
log.warn("MOUNA 6 ");
String issueKey = issue.getKey()
log.warn("MOUNA 7 ");
IssueService issueService = ComponentAccessor.getIssueService()
log.warn("MOUNA 8");
log.warn("MOUNA 9 ");
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setComment("Transitioning issue from status "+ issue.getStatus().getName()+" to status "+ destinationStatus );
transitionValidationResult = issueService.validateTransition(currentUser, issue.id, transitionToBeDone, issueInputParameters)
log.warn("MOUNA 10");
if (transitionValidationResult.isValid()) {
log.warn("MOUNA 11 transition is valid");
def transitionResult = issueService.transition(currentUser, transitionValidationResult)
log.warn("MOUNA 12 ");
if (transitionResult.isValid()) {
log.warn("MOUNA 13 " + issue.getStatus());
} else {
log.warn("MOUNA 14 transitionResult not valid");
}
}
}
After upgrading security version to 4.2.4,
we are getting below exception for url which contains semicolon
ex:
https://url/name=somevalue;value=somevalue
org.springframework.security.web.firewall.RequestRejectedException: The request was rejected because the URL contained a potentially malicious String ";"
at org.springframework.security.web.firewall.StrictHttpFirewall.rejectedBlacklistedUrls(StrictHttpFirewall.java:140) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.firewall.StrictHttpFirewall.getFirewalledRequest(StrictHttpFirewall.java:120) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilterInternal(FilterChainProxy.java:193) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:185) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:116) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
at org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:331) ~[spring-security-web-4.2.4.RELEASE.jar:4.2.4.RELEASE]
So, we did some configuration to custom implement of httpfirewall
#Bean
public HttpFirewall allowUrlEncodedSlashHttpFirewall()
{
StrictHttpFirewall firewall = new StrictHttpFirewall();
firewall.setAllowUrlEncodedSlash(true);
firewall.setAllowSemicolon(true);
return firewall;
}
and
#Override
public void configure(WebSecurity web) throws Exception
{
super.configure(web);
web.httpFirewall(this.httpFirewall);
}
After configured, we are facing same issues.
Then I debugged the in-built class StrictHttpFirewall.getFirewalledRequest(HttpServletRequest request)
Sometimes we are getting nested request like :
firewalledRequest[ firewallwedRequest [ … (request).
and I checked the dofilter() method in filterchainProxy
It’s not clearing SecurityContextHolder, and so FilterChainProxy actually occurs twice in the chain.