Program: 61312
Project: 61312
Buggy source:
@RequestMapping(method=RequestMethod.POST,value="String_Node_Str") public UserTO create(HttpServletResponse response,@RequestBody UserTO userTO,@RequestParam(value="String_Node_Str",required=false) Set<Long> syncRoles,@RequestParam(value="String_Node_Str",required=false) Set<String> syncResources) throws SyncopeClientCompositeErrorException, WorkflowException, PropagationException, NotFoundException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + userTO + "String_Node_Str"+ syncRoles+ "String_Node_Str"+ syncResources);
  }
  userTO.setId(0);
  WorkflowInitException wie=null;
  Long workflowId=null;
  try {
    workflowId=userWorkflow.initialize(Constants.USER_WORKFLOW,0,Collections.singletonMap(Constants.USER_TO,userTO));
  }
 catch (  WorkflowInitException e) {
    log.error("String_Node_Str" + e,e);
    wie=e;
    if (workflowStore != null && e.getWorkflowEntryId() != null) {
      workflowStore.delete(e.getWorkflowEntryId());
    }
  }
  if (wie != null) {
switch (wie.getExceptionOperation()) {
case OVERWRITE:
      Integer resetActionId=findWorkflowAction(wie.getWorkflowEntryId(),Constants.ACTION_RESET);
    if (resetActionId != null) {
      doExecuteAction(Constants.ACTION_RESET,wie.getSyncopeUserId(),null);
    }
  userTO.setId(wie.getSyncopeUserId());
break;
case REJECT:
SyncopeClientCompositeErrorException compositeException=new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException rejectedUserCreate=new SyncopeClientException(SyncopeClientExceptionType.RejectedUserCreate);
rejectedUserCreate.addElement(String.valueOf(wie.getSyncopeUserId()));
compositeException.addException(rejectedUserCreate);
throw compositeException;
}
}
SyncopeUser syncopeUser=userDataBinder.createSyncopeUser(userTO);
syncopeUser.setWorkflowEntryId(workflowId);
syncopeUser.setCreationTime(new Date());
syncopeUser=syncopeUserDAO.save(syncopeUser);
userDataBinder.checkUniqueness(syncopeUser);
Set<String> syncResourceNames=getSyncResourceNames(syncopeUser,syncRoles,syncResources);
if (log.isDebugEnabled() && !syncResourceNames.isEmpty()) {
log.debug("String_Node_Str" + syncResourceNames);
}
Set<String> propagatedResources=propagationManager.create(syncopeUser,syncResourceNames);
if (log.isDebugEnabled()) {
log.debug("String_Node_Str" + propagatedResources);
}
Map<String,Object> inputs=new HashMap<String,Object>();
inputs.put(Constants.SYNCOPE_USER,syncopeUser);
int[] availableWorkflowActions=userWorkflow.getAvailableActions(workflowId,null);
for (int availableWorkflowAction : availableWorkflowActions) {
userWorkflow.doAction(workflowId,availableWorkflowAction,inputs);
}
syncopeUser=syncopeUserDAO.save(syncopeUser);
response.setStatus(HttpServletResponse.SC_CREATED);
return userDataBinder.getUserTO(syncopeUser,userWorkflow);
}

Fixed version (ground truth):
@RequestMapping(method=RequestMethod.POST,value="String_Node_Str") public UserTO create(HttpServletResponse response,@RequestBody UserTO userTO,@RequestParam(value="String_Node_Str",required=false) Set<Long> syncRoles,@RequestParam(value="String_Node_Str",required=false) Set<String> syncResources) throws SyncopeClientCompositeErrorException, WorkflowException, PropagationException, NotFoundException {
  if (log.isDebugEnabled()) {
    log.debug("String_Node_Str" + userTO + "String_Node_Str"+ syncRoles+ "String_Node_Str"+ syncResources);
  }
  userTO.setId(0);
  WorkflowInitException wie=null;
  Long workflowId=null;
  try {
    workflowId=userWorkflow.initialize(Constants.USER_WORKFLOW,0,Collections.singletonMap(Constants.USER_TO,userTO));
  }
 catch (  WorkflowInitException e) {
    log.error("String_Node_Str" + e,e);
    wie=e;
    if (workflowStore != null && e.getWorkflowEntryId() != null) {
      workflowStore.delete(e.getWorkflowEntryId());
    }
    workflowId=wie.getWorkflowId();
  }
  if (wie != null) {
switch (wie.getExceptionOperation()) {
case OVERWRITE:
      Integer resetActionId=findWorkflowAction(wie.getWorkflowId(),Constants.ACTION_RESET);
    if (resetActionId != null) {
      doExecuteAction(Constants.ACTION_RESET,wie.getSyncopeUserId(),null);
    }
  userTO.setId(wie.getSyncopeUserId());
break;
case REJECT:
SyncopeClientCompositeErrorException compositeException=new SyncopeClientCompositeErrorException(HttpStatus.BAD_REQUEST);
SyncopeClientException rejectedUserCreate=new SyncopeClientException(SyncopeClientExceptionType.RejectedUserCreate);
rejectedUserCreate.addElement(String.valueOf(wie.getSyncopeUserId()));
compositeException.addException(rejectedUserCreate);
throw compositeException;
}
}
SyncopeUser syncopeUser=userDataBinder.createSyncopeUser(userTO);
syncopeUser.setWorkflowId(workflowId);
syncopeUser.setCreationTime(new Date());
syncopeUser=syncopeUserDAO.save(syncopeUser);
userDataBinder.checkUniqueness(syncopeUser);
Set<String> syncResourceNames=getSyncResourceNames(syncopeUser,syncRoles,syncResources);
if (log.isDebugEnabled() && !syncResourceNames.isEmpty()) {
log.debug("String_Node_Str" + syncResourceNames);
}
Set<String> propagatedResources=propagationManager.create(syncopeUser,syncResourceNames);
if (log.isDebugEnabled()) {
log.debug("String_Node_Str" + propagatedResources);
}
Map<String,Object> inputs=new HashMap<String,Object>();
inputs.put(Constants.SYNCOPE_USER,syncopeUser);
int[] availableWorkflowActions=userWorkflow.getAvailableActions(workflowId,null);
for (int availableWorkflowAction : availableWorkflowActions) {
userWorkflow.doAction(workflowId,availableWorkflowAction,inputs);
}
syncopeUser=syncopeUserDAO.save(syncopeUser);
response.setStatus(HttpServletResponse.SC_CREATED);
return userDataBinder.getUserTO(syncopeUser,userWorkflow);
}