Program: 61337
Project: 61337
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);
  }
  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:
      UserMod overwriteMod=userTO.buildUserMod();
    overwriteMod.setId(wie.getSyncopeUserId());
  return update(overwriteMod,syncRoles,syncResources);
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);
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);
  }
  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) {
      UserTO localUserTO=new UserTO();
      localUserTO.setId(wie.getSyncopeUserId());
      doExecuteAction(Constants.ACTION_RESET,localUserTO,null);
    }
  UserMod overwriteMod=userTO.buildUserMod();
overwriteMod.setId(wie.getSyncopeUserId());
return update(overwriteMod,syncRoles,syncResources);
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);
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);
}