Program: 14073
Project: 14073
Buggy source:
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    final User user=ctx.getUser();
    final String userId=user.getUserId();
    final String accountId=user.getAccountNumber();
    final String accountAlias=ctx.getAccountAlias();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    List<Parameter> nextParameters=null;
    if (request.getParameters() != null && request.getParameters().getMember() != null) {
      nextParameters=request.getParameters().getMember();
    }
    final ArrayList<String> nextCapabilities=Lists.newArrayList();
    if (request.getCapabilities() != null && request.getCapabilities().getMember() != null) {
      nextCapabilities.addAll(request.getCapabilities().getMember());
    }
    final String nextStackPolicyBody=request.getStackPolicyBody();
    final String nextStackPolicyUrl=request.getStackPolicyURL();
    final String nextStackPolicyText=validateAndGetStackPolicy(user,nextStackPolicyBody,nextStackPolicyUrl);
    final String tempStackPolicyBody=request.getStackPolicyDuringUpdateBody();
    final String tempStackPolicyUrl=request.getStackPolicyDuringUpdateURL();
    final String tempStackPolicyText=validateAndGetStackPolicyDuringUpdate(user,tempStackPolicyBody,tempStackPolicyUrl);
    final String nextTemplateBody=request.getTemplateBody();
    if (nextTemplateBody != null) {
      if (nextTemplateBody.getBytes().length > Limits.REQUEST_TEMPLATE_BODY_MAX_LENGTH_BYTES) {
        throw new ValidationErrorException("String_Node_Str" + Limits.REQUEST_TEMPLATE_BODY_MAX_LENGTH_BYTES + "String_Node_Str");
      }
    }
    final String nextTemplateUrl=request.getTemplateURL();
    final boolean usePreviousTemplate=(request.getUsePreviousTemplate() == null) ? false : request.getUsePreviousTemplate().booleanValue();
    if (usePreviousTemplate && (nextTemplateBody != null || nextTemplateUrl != null)) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (nextTemplateBody != null && nextTemplateUrl != null)     throw new ValidationErrorException("String_Node_Str");
    if (!usePreviousTemplate && (nextTemplateBody == null && nextTemplateUrl == null)) {
      throw new ValidationErrorException("String_Node_Str");
    }
    checkStackPermission(ctx,stackName,accountId);
    final StackEntity previousStackEntity=StackEntityManager.getNonDeletedStackByNameOrId(stackName,accountId);
    if (previousStackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    final String stackId=previousStackEntity.getStackId();
    stackName=previousStackEntity.getStackName();
    if (previousStackEntity.getStackStatus() != Status.CREATE_COMPLETE && previousStackEntity.getStackStatus() != Status.UPDATE_COMPLETE && previousStackEntity.getStackStatus() != Status.UPDATE_ROLLBACK_COMPLETE) {
      throw new ValidationErrorException("String_Node_Str" + stackId + "String_Node_Str"+ previousStackEntity.getStackStatus().toString()+ "String_Node_Str");
    }
    int previousStackVersion=previousStackEntity.getStackVersion();
    if (request.getTags() != null && request.getTags().getMember() != null) {
      for (      Tag tag : request.getTags().getMember()) {
        if (Strings.isNullOrEmpty(tag.getKey()) || Strings.isNullOrEmpty(tag.getValue())) {
          throw new ValidationErrorException("String_Node_Str");
        }
 else         if (tag.getKey().startsWith("String_Node_Str")) {
          throw new ValidationErrorException("String_Node_Str");
        }
 else         if (tag.getKey().startsWith("String_Node_Str")) {
          throw new ValidationErrorException("String_Node_Str");
        }
      }
    }
    final PseudoParameterValues nextPseudoParameterValues=new PseudoParameterValues();
    nextPseudoParameterValues.setAccountId(accountId);
    nextPseudoParameterValues.setStackName(stackName);
    nextPseudoParameterValues.setStackId(stackId);
    ArrayList<String> nextNotificationArns=null;
    if (request.getNotificationARNs() != null && request.getNotificationARNs().getMember() != null) {
      nextNotificationArns=Lists.newArrayList();
      for (      String notificationArn : request.getNotificationARNs().getMember()) {
        nextNotificationArns.add(notificationArn);
      }
      nextPseudoParameterValues.setNotificationArns(nextNotificationArns);
    }
    nextPseudoParameterValues.setRegion(getRegion());
    final String nextTemplateText=(usePreviousTemplate ? previousStackEntity.getTemplateBody() : (nextTemplateBody != null) ? nextTemplateBody : extractTemplateTextFromURL(nextTemplateUrl,user));
    final List<Parameter> previousParameters=convertToParameters(StackEntityHelper.jsonToParameters(previousStackEntity.getParametersJson()));
    validateAndUpdateParameters(previousParameters,nextParameters);
    final String previousTemplateText=previousStackEntity.getTemplateBody();
    List<String> previousCapabilities=StackEntityHelper.jsonToCapabilities(previousStackEntity.getCapabilitiesJson());
    PseudoParameterValues previousPseudoParameterValues=getPseudoParameterValues(previousStackEntity);
    final Template previousTemplate=new TemplateParser().parse(previousTemplateText,previousParameters,previousCapabilities,previousPseudoParameterValues,userId);
    final Template nextTemplate=new TemplateParser().parse(nextTemplateText,nextParameters,nextCapabilities,nextPseudoParameterValues,userId);
    List<String> changedTypeResources=Lists.newArrayList();
    for (    String resourceName : previousTemplate.getResourceInfoMap().keySet()) {
      if (previousTemplate.getResourceInfoMap().get(resourceName).getAllowedByCondition() == Boolean.TRUE && nextTemplate.getResourceInfoMap().containsKey(resourceName) && nextTemplate.getResourceInfoMap().get(resourceName).getAllowedByCondition() == Boolean.TRUE && !previousTemplate.getResourceInfoMap().get(resourceName).getType().equals(nextTemplate.getResourceInfoMap().get(resourceName).getType())) {
        changedTypeResources.add(resourceName);
      }
    }
    if (!changedTypeResources.isEmpty()) {
      throw new ValidationErrorException("String_Node_Str" + changedTypeResources);
    }
    boolean requiresUpdate=false;
    Multiset<String> previousNotificationArnsMS=HashMultiset.create();
    List<String> previousNotificationArns=StackEntityHelper.jsonToNotificationARNs(previousStackEntity.getNotificationARNsJson());
    if (previousNotificationArns != null) {
      previousNotificationArnsMS.addAll(previousNotificationArns);
    }
    Multiset<String> nextNotificationArnsMS=HashMultiset.create();
    if (nextPseudoParameterValues.getNotificationArns() != null) {
      nextNotificationArnsMS.addAll(nextPseudoParameterValues.getNotificationArns());
    }
    if (!previousNotificationArnsMS.equals(nextNotificationArnsMS)) {
      requiresUpdate=true;
    }
 else     if (stackPolicyIsDifferent(previousStackEntity.getStackPolicy(),nextStackPolicyText)) {
      requiresUpdate=true;
    }
 else     if (!previousTemplate.getResourceInfoMap().keySet().equals(nextTemplate.getResourceInfoMap().keySet())) {
      requiresUpdate=true;
    }
 else     if (tagsHaveChanged(request,previousStackEntity)) {
      requiresUpdate=true;
    }
 else {
      for (      String fieldName : previousTemplate.getResourceInfoMap().keySet()) {
        JsonNode previousMetadataJson=tryEvaluateFunctionsInMetadata(previousTemplate,fieldName,userId);
        JsonNode nextMetadataJson=tryEvaluateFunctionsInMetadata(nextTemplate,fieldName,userId);
        if (!equalsJson(previousMetadataJson,nextMetadataJson)) {
          requiresUpdate=true;
          break;
        }
        JsonNode previousPropertiesJson=tryEvaluateFunctionsInProperties(previousTemplate,fieldName,userId);
        JsonNode nextPropertiesJson=tryEvaluateFunctionsInProperties(nextTemplate,fieldName,userId);
        if (!equalsJson(previousPropertiesJson,nextPropertiesJson)) {
          requiresUpdate=true;
          break;
        }
      }
    }
    for (    ResourceInfo resourceInfo : nextTemplate.getResourceInfoMap().values()) {
      if (resourceInfo.getAllowedByCondition() == Boolean.TRUE && resourceInfo.getType().equals("String_Node_Str")) {
        requiresUpdate=true;
        break;
      }
    }
    if (!requiresUpdate) {
      throw new ValidationErrorException(NO_UPDATES_ARE_TO_BE_PERFORMED);
    }
    final StackEntity nextStackEntity=StackEntityManager.checkValidUpdateStatusAndUpdateStack(stackId,accountId,nextTemplate,nextTemplateText,request,previousStackVersion);
    String outerStackArn=StackResourceEntityManager.findOuterStackArnIfExists(stackId,accountId);
    for (    ResourceInfo resourceInfo : nextTemplate.getResourceInfoMap().values()) {
      StackResourceEntity stackResourceEntity=new StackResourceEntity();
      stackResourceEntity=StackResourceEntityManager.updateResourceInfo(stackResourceEntity,resourceInfo);
      stackResourceEntity.setDescription("String_Node_Str");
      stackResourceEntity.setResourceStatus(Status.NOT_STARTED);
      stackResourceEntity.setStackId(stackId);
      stackResourceEntity.setStackName(stackName);
      stackResourceEntity.setRecordDeleted(Boolean.FALSE);
      stackResourceEntity.setResourceVersion(nextStackEntity.getStackVersion());
      StackResourceEntityManager.addStackResource(stackResourceEntity);
    }
    String previousResourceDependencyManagerJson=StackEntityHelper.resourceDependencyManagerToJson(previousTemplate.getResourceDependencyManager());
    StackUpdateInfoEntityManager.createUpdateInfo(stackId,accountId,previousResourceDependencyManagerJson,nextStackEntity.getResourceDependencyManagerJson(),nextStackEntity.getStackVersion(),stackName,accountAlias);
    StackWorkflowTags stackWorkflowTags=new StackWorkflowTags(stackId,stackName,accountId,accountAlias);
    WorkflowClientFactory updateStackWorkflowClientFactory=new WorkflowClientFactory(WorkflowClientManager.getSimpleWorkflowClient(),CloudFormationProperties.SWF_DOMAIN,CloudFormationProperties.SWF_TASKLIST);
    WorkflowDescriptionTemplate updateStackWorkflowDescriptionTemplate=new UpdateStackWorkflowDescriptionTemplate();
    InterfaceBasedWorkflowClient<UpdateStackWorkflow> updateStackWorkflowClient=updateStackWorkflowClientFactory.getNewWorkflowClient(UpdateStackWorkflow.class,updateStackWorkflowDescriptionTemplate,stackWorkflowTags);
    UpdateStackWorkflow updateStackWorkflow=new UpdateStackWorkflowClient(updateStackWorkflowClient);
    updateStackWorkflow.updateStack(nextStackEntity.getStackId(),nextStackEntity.getAccountId(),nextStackEntity.getResourceDependencyManagerJson(),userId,nextStackEntity.getStackVersion());
    StackWorkflowEntityManager.addOrUpdateStackWorkflowEntity(stackId,StackWorkflowEntity.WorkflowType.UPDATE_STACK_WORKFLOW,CloudFormationProperties.SWF_DOMAIN,updateStackWorkflowClient.getWorkflowExecution().getWorkflowId(),updateStackWorkflowClient.getWorkflowExecution().getRunId());
    WorkflowClientFactory monitorUpdateStackWorkflowClientFactory=new WorkflowClientFactory(WorkflowClientManager.getSimpleWorkflowClient(),CloudFormationProperties.SWF_DOMAIN,CloudFormationProperties.SWF_TASKLIST);
    WorkflowDescriptionTemplate monitorUpdateStackWorkflowDescriptionTemplate=new MonitorUpdateStackWorkflowDescriptionTemplate();
    InterfaceBasedWorkflowClient<MonitorUpdateStackWorkflow> monitorUpdateStackWorkflowClient=monitorUpdateStackWorkflowClientFactory.getNewWorkflowClient(MonitorUpdateStackWorkflow.class,monitorUpdateStackWorkflowDescriptionTemplate,stackWorkflowTags);
    MonitorUpdateStackWorkflow monitorUpdateStackWorkflow=new MonitorUpdateStackWorkflowClient(monitorUpdateStackWorkflowClient);
    monitorUpdateStackWorkflow.monitorUpdateStack(nextStackEntity.getStackId(),nextStackEntity.getAccountId(),userId,nextStackEntity.getStackVersion(),outerStackArn);
    StackWorkflowEntityManager.addOrUpdateStackWorkflowEntity(stackId,StackWorkflowEntity.WorkflowType.MONITOR_UPDATE_STACK_WORKFLOW,CloudFormationProperties.SWF_DOMAIN,monitorUpdateStackWorkflowClient.getWorkflowExecution().getWorkflowId(),monitorUpdateStackWorkflowClient.getWorkflowExecution().getRunId());
    UpdateStackResult updateStackResult=new UpdateStackResult();
    updateStackResult.setStackId(stackId);
    reply.setUpdateStackResult(updateStackResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}

Fixed version (ground truth):
public UpdateStackResponseType updateStack(UpdateStackType request) throws CloudFormationException {
  UpdateStackResponseType reply=request.getReply();
  try {
    final Context ctx=Contexts.lookup();
    final User user=ctx.getUser();
    final String userId=user.getUserId();
    final String accountId=user.getAccountNumber();
    final String accountAlias=ctx.getAccountAlias();
    String stackName=request.getStackName();
    if (stackName == null) {
      throw new ValidationErrorException("String_Node_Str");
    }
    List<Parameter> nextParameters=null;
    if (request.getParameters() != null && request.getParameters().getMember() != null) {
      nextParameters=request.getParameters().getMember();
    }
    final ArrayList<String> nextCapabilities=Lists.newArrayList();
    if (request.getCapabilities() != null && request.getCapabilities().getMember() != null) {
      nextCapabilities.addAll(request.getCapabilities().getMember());
    }
    final String nextStackPolicyBody=request.getStackPolicyBody();
    final String nextStackPolicyUrl=request.getStackPolicyURL();
    final String nextStackPolicyText=validateAndGetStackPolicy(user,nextStackPolicyBody,nextStackPolicyUrl);
    final String tempStackPolicyBody=request.getStackPolicyDuringUpdateBody();
    final String tempStackPolicyUrl=request.getStackPolicyDuringUpdateURL();
    final String tempStackPolicyText=validateAndGetStackPolicyDuringUpdate(user,tempStackPolicyBody,tempStackPolicyUrl);
    final String nextTemplateBody=request.getTemplateBody();
    if (nextTemplateBody != null) {
      if (nextTemplateBody.getBytes().length > Limits.REQUEST_TEMPLATE_BODY_MAX_LENGTH_BYTES) {
        throw new ValidationErrorException("String_Node_Str" + Limits.REQUEST_TEMPLATE_BODY_MAX_LENGTH_BYTES + "String_Node_Str");
      }
    }
    final String nextTemplateUrl=request.getTemplateURL();
    final boolean usePreviousTemplate=(request.getUsePreviousTemplate() == null) ? false : request.getUsePreviousTemplate().booleanValue();
    if (usePreviousTemplate && (nextTemplateBody != null || nextTemplateUrl != null)) {
      throw new ValidationErrorException("String_Node_Str");
    }
    if (nextTemplateBody != null && nextTemplateUrl != null)     throw new ValidationErrorException("String_Node_Str");
    if (!usePreviousTemplate && (nextTemplateBody == null && nextTemplateUrl == null)) {
      throw new ValidationErrorException("String_Node_Str");
    }
    checkStackPermission(ctx,stackName,accountId);
    final StackEntity previousStackEntity=StackEntityManager.getNonDeletedStackByNameOrId(stackName,accountId);
    if (previousStackEntity == null) {
      throw new ValidationErrorException("String_Node_Str" + stackName + "String_Node_Str");
    }
    final String stackId=previousStackEntity.getStackId();
    stackName=previousStackEntity.getStackName();
    if (previousStackEntity.getStackStatus() != Status.CREATE_COMPLETE && previousStackEntity.getStackStatus() != Status.UPDATE_COMPLETE && previousStackEntity.getStackStatus() != Status.UPDATE_ROLLBACK_COMPLETE) {
      throw new ValidationErrorException("String_Node_Str" + stackId + "String_Node_Str"+ previousStackEntity.getStackStatus().toString()+ "String_Node_Str");
    }
    int previousStackVersion=previousStackEntity.getStackVersion();
    if (request.getTags() != null && request.getTags().getMember() != null) {
      for (      Tag tag : request.getTags().getMember()) {
        if (Strings.isNullOrEmpty(tag.getKey()) || Strings.isNullOrEmpty(tag.getValue())) {
          throw new ValidationErrorException("String_Node_Str");
        }
 else         if (tag.getKey().startsWith("String_Node_Str")) {
          throw new ValidationErrorException("String_Node_Str");
        }
 else         if (tag.getKey().startsWith("String_Node_Str")) {
          throw new ValidationErrorException("String_Node_Str");
        }
      }
    }
    final PseudoParameterValues nextPseudoParameterValues=new PseudoParameterValues();
    nextPseudoParameterValues.setAccountId(accountId);
    nextPseudoParameterValues.setStackName(stackName);
    nextPseudoParameterValues.setStackId(stackId);
    ArrayList<String> nextNotificationArns=null;
    if (request.getNotificationARNs() != null && request.getNotificationARNs().getMember() != null) {
      nextNotificationArns=Lists.newArrayList();
      for (      String notificationArn : request.getNotificationARNs().getMember()) {
        nextNotificationArns.add(notificationArn);
      }
      nextPseudoParameterValues.setNotificationArns(nextNotificationArns);
    }
    nextPseudoParameterValues.setRegion(getRegion());
    final String nextTemplateText=(usePreviousTemplate ? previousStackEntity.getTemplateBody() : (nextTemplateBody != null) ? nextTemplateBody : extractTemplateTextFromURL(nextTemplateUrl,user));
    final List<Parameter> previousParameters=convertToParameters(StackEntityHelper.jsonToParameters(previousStackEntity.getParametersJson()));
    validateAndUpdateParameters(previousParameters,nextParameters);
    final String previousTemplateText=previousStackEntity.getTemplateBody();
    List<String> previousCapabilities=StackEntityHelper.jsonToCapabilities(previousStackEntity.getCapabilitiesJson());
    PseudoParameterValues previousPseudoParameterValues=getPseudoParameterValues(previousStackEntity);
    final Template previousTemplate=new TemplateParser().parse(previousTemplateText,previousParameters,previousCapabilities,previousPseudoParameterValues,userId);
    final Template nextTemplate=new TemplateParser().parse(nextTemplateText,nextParameters,nextCapabilities,nextPseudoParameterValues,userId);
    List<String> changedTypeResources=Lists.newArrayList();
    for (    String resourceName : previousTemplate.getResourceInfoMap().keySet()) {
      if (Boolean.TRUE.equals(previousTemplate.getResourceInfoMap().get(resourceName).getAllowedByCondition()) && nextTemplate.getResourceInfoMap().containsKey(resourceName) && Boolean.TRUE.equals(nextTemplate.getResourceInfoMap().get(resourceName).getAllowedByCondition())&& !previousTemplate.getResourceInfoMap().get(resourceName).getType().equals(nextTemplate.getResourceInfoMap().get(resourceName).getType())) {
        changedTypeResources.add(resourceName);
      }
    }
    if (!changedTypeResources.isEmpty()) {
      throw new ValidationErrorException("String_Node_Str" + changedTypeResources);
    }
    boolean requiresUpdate=false;
    Multiset<String> previousNotificationArnsMS=HashMultiset.create();
    List<String> previousNotificationArns=StackEntityHelper.jsonToNotificationARNs(previousStackEntity.getNotificationARNsJson());
    if (previousNotificationArns != null) {
      previousNotificationArnsMS.addAll(previousNotificationArns);
    }
    Multiset<String> nextNotificationArnsMS=HashMultiset.create();
    if (nextPseudoParameterValues.getNotificationArns() != null) {
      nextNotificationArnsMS.addAll(nextPseudoParameterValues.getNotificationArns());
    }
    if (!previousNotificationArnsMS.equals(nextNotificationArnsMS)) {
      requiresUpdate=true;
    }
 else     if (stackPolicyIsDifferent(previousStackEntity.getStackPolicy(),nextStackPolicyText)) {
      requiresUpdate=true;
    }
 else     if (!previousTemplate.getResourceInfoMap().keySet().equals(nextTemplate.getResourceInfoMap().keySet())) {
      requiresUpdate=true;
    }
 else     if (tagsHaveChanged(request,previousStackEntity)) {
      requiresUpdate=true;
    }
 else {
      for (      String fieldName : previousTemplate.getResourceInfoMap().keySet()) {
        JsonNode previousMetadataJson=tryEvaluateFunctionsInMetadata(previousTemplate,fieldName,userId);
        JsonNode nextMetadataJson=tryEvaluateFunctionsInMetadata(nextTemplate,fieldName,userId);
        if (!equalsJson(previousMetadataJson,nextMetadataJson)) {
          requiresUpdate=true;
          break;
        }
        JsonNode previousPropertiesJson=tryEvaluateFunctionsInProperties(previousTemplate,fieldName,userId);
        JsonNode nextPropertiesJson=tryEvaluateFunctionsInProperties(nextTemplate,fieldName,userId);
        if (!equalsJson(previousPropertiesJson,nextPropertiesJson)) {
          requiresUpdate=true;
          break;
        }
      }
    }
    for (    ResourceInfo resourceInfo : nextTemplate.getResourceInfoMap().values()) {
      if (Boolean.TRUE.equals(resourceInfo.getAllowedByCondition()) && resourceInfo.getType().equals("String_Node_Str")) {
        requiresUpdate=true;
        break;
      }
    }
    if (!requiresUpdate) {
      throw new ValidationErrorException(NO_UPDATES_ARE_TO_BE_PERFORMED);
    }
    final StackEntity nextStackEntity=StackEntityManager.checkValidUpdateStatusAndUpdateStack(stackId,accountId,nextTemplate,nextTemplateText,request,previousStackVersion);
    String outerStackArn=StackResourceEntityManager.findOuterStackArnIfExists(stackId,accountId);
    for (    ResourceInfo resourceInfo : nextTemplate.getResourceInfoMap().values()) {
      StackResourceEntity stackResourceEntity=new StackResourceEntity();
      stackResourceEntity=StackResourceEntityManager.updateResourceInfo(stackResourceEntity,resourceInfo);
      stackResourceEntity.setDescription("String_Node_Str");
      stackResourceEntity.setResourceStatus(Status.NOT_STARTED);
      stackResourceEntity.setStackId(stackId);
      stackResourceEntity.setStackName(stackName);
      stackResourceEntity.setRecordDeleted(Boolean.FALSE);
      stackResourceEntity.setResourceVersion(nextStackEntity.getStackVersion());
      StackResourceEntityManager.addStackResource(stackResourceEntity);
    }
    String previousResourceDependencyManagerJson=StackEntityHelper.resourceDependencyManagerToJson(previousTemplate.getResourceDependencyManager());
    StackUpdateInfoEntityManager.createUpdateInfo(stackId,accountId,previousResourceDependencyManagerJson,nextStackEntity.getResourceDependencyManagerJson(),nextStackEntity.getStackVersion(),stackName,accountAlias);
    StackWorkflowTags stackWorkflowTags=new StackWorkflowTags(stackId,stackName,accountId,accountAlias);
    WorkflowClientFactory updateStackWorkflowClientFactory=new WorkflowClientFactory(WorkflowClientManager.getSimpleWorkflowClient(),CloudFormationProperties.SWF_DOMAIN,CloudFormationProperties.SWF_TASKLIST);
    WorkflowDescriptionTemplate updateStackWorkflowDescriptionTemplate=new UpdateStackWorkflowDescriptionTemplate();
    InterfaceBasedWorkflowClient<UpdateStackWorkflow> updateStackWorkflowClient=updateStackWorkflowClientFactory.getNewWorkflowClient(UpdateStackWorkflow.class,updateStackWorkflowDescriptionTemplate,stackWorkflowTags);
    UpdateStackWorkflow updateStackWorkflow=new UpdateStackWorkflowClient(updateStackWorkflowClient);
    updateStackWorkflow.updateStack(nextStackEntity.getStackId(),nextStackEntity.getAccountId(),nextStackEntity.getResourceDependencyManagerJson(),userId,nextStackEntity.getStackVersion());
    StackWorkflowEntityManager.addOrUpdateStackWorkflowEntity(stackId,StackWorkflowEntity.WorkflowType.UPDATE_STACK_WORKFLOW,CloudFormationProperties.SWF_DOMAIN,updateStackWorkflowClient.getWorkflowExecution().getWorkflowId(),updateStackWorkflowClient.getWorkflowExecution().getRunId());
    WorkflowClientFactory monitorUpdateStackWorkflowClientFactory=new WorkflowClientFactory(WorkflowClientManager.getSimpleWorkflowClient(),CloudFormationProperties.SWF_DOMAIN,CloudFormationProperties.SWF_TASKLIST);
    WorkflowDescriptionTemplate monitorUpdateStackWorkflowDescriptionTemplate=new MonitorUpdateStackWorkflowDescriptionTemplate();
    InterfaceBasedWorkflowClient<MonitorUpdateStackWorkflow> monitorUpdateStackWorkflowClient=monitorUpdateStackWorkflowClientFactory.getNewWorkflowClient(MonitorUpdateStackWorkflow.class,monitorUpdateStackWorkflowDescriptionTemplate,stackWorkflowTags);
    MonitorUpdateStackWorkflow monitorUpdateStackWorkflow=new MonitorUpdateStackWorkflowClient(monitorUpdateStackWorkflowClient);
    monitorUpdateStackWorkflow.monitorUpdateStack(nextStackEntity.getStackId(),nextStackEntity.getAccountId(),userId,nextStackEntity.getStackVersion(),outerStackArn);
    StackWorkflowEntityManager.addOrUpdateStackWorkflowEntity(stackId,StackWorkflowEntity.WorkflowType.MONITOR_UPDATE_STACK_WORKFLOW,CloudFormationProperties.SWF_DOMAIN,monitorUpdateStackWorkflowClient.getWorkflowExecution().getWorkflowId(),monitorUpdateStackWorkflowClient.getWorkflowExecution().getRunId());
    UpdateStackResult updateStackResult=new UpdateStackResult();
    updateStackResult.setStackId(stackId);
    reply.setUpdateStackResult(updateStackResult);
  }
 catch (  Exception ex) {
    handleException(ex);
  }
  return reply;
}