Program: 188930
Project: 188930
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Workflow newWorkflow=null;
  JaxbObject<Workflow> jo=new JaxbObject<Workflow>();
  try {
    String text=entity.getText();
    newWorkflow=(Workflow)XmlTools.unMarshal(jo,new Workflow(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex.getMessage());
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e.getMessage());
  }
  try {
    WorkflowService fs=BeanFactory.getWorkflowServiceBean();
    Workflow workflow=(Workflow)testIfNull(fs.findByID(newWorkflow.getWorkflowId()));
    workflow.givesPermission(registration);
    String name=newWorkflow.getName();
    String desc=newWorkflow.getDescription();
    String baseIniFile=newWorkflow.getBaseIniFile();
    String command=newWorkflow.getCommand();
    String cwd=newWorkflow.getCwd();
    String host=newWorkflow.getHost();
    String inputAlgorithm=newWorkflow.getInputAlgorithm();
    String permanentBundleLocation=newWorkflow.getPermanentBundleLocation();
    String seqwareVersion=newWorkflow.getSeqwareVersion();
    String template=newWorkflow.getTemplate();
    String username=newWorkflow.getUsername();
    String version=newWorkflow.getVersion();
    Registration owner=newWorkflow.getOwner();
    workflow.setName(name);
    workflow.setDescription(desc);
    workflow.setBaseIniFile(baseIniFile);
    workflow.setCommand(command);
    workflow.setCwd(cwd);
    workflow.setHost(host);
    workflow.setInputAlgorithm(inputAlgorithm);
    workflow.setPermanentBundleLocation(permanentBundleLocation);
    workflow.setSeqwareVersion(seqwareVersion);
    workflow.setTemplate(template);
    workflow.setUsername(username);
    workflow.setVersion(version);
    workflow.setUpdateTimestamp(new Date());
    workflow.setWorkflowClass(newWorkflow.getWorkflowClass());
    workflow.setWorkflowType(newWorkflow.getWorkflowType());
    workflow.setWorkflowEngine(newWorkflow.getWorkflowEngine());
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        workflow.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (workflow.getOwner() == null) {
      workflow.setOwner(registration);
    }
    if (newWorkflow.getWorkflowAttributes() != null) {
      workflow.getWorkflowAttributes().clear();
      for (      WorkflowAttribute wfa : newWorkflow.getWorkflowAttributes()) {
        wfa.setWorkflow(workflow);
        workflow.getWorkflowAttributes().add(wfa);
      }
    }
    fs.update(registration,workflow);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Workflow detachedWorkflow=copier.hibernate2dto(Workflow.class,workflow);
    Document line=XmlTools.marshalToDocument(jo,detachedWorkflow);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedWorkflow.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e.getMessage());
  }
  return representation;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Workflow newWorkflow=null;
  JaxbObject<Workflow> jo=new JaxbObject<Workflow>();
  try {
    String text=entity.getText();
    newWorkflow=(Workflow)XmlTools.unMarshal(jo,new Workflow(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex.getMessage());
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e.getMessage());
  }
  try {
    WorkflowService fs=BeanFactory.getWorkflowServiceBean();
    Workflow workflow=(Workflow)testIfNull(fs.findByID(newWorkflow.getWorkflowId()));
    workflow.givesPermission(registration);
    String name=newWorkflow.getName();
    String desc=newWorkflow.getDescription();
    String baseIniFile=newWorkflow.getBaseIniFile();
    String command=newWorkflow.getCommand();
    String cwd=newWorkflow.getCwd();
    String host=newWorkflow.getHost();
    String inputAlgorithm=newWorkflow.getInputAlgorithm();
    String permanentBundleLocation=newWorkflow.getPermanentBundleLocation();
    String seqwareVersion=newWorkflow.getSeqwareVersion();
    String template=newWorkflow.getTemplate();
    String username=newWorkflow.getUsername();
    String version=newWorkflow.getVersion();
    Registration owner=newWorkflow.getOwner();
    workflow.setName(name);
    workflow.setDescription(desc);
    workflow.setBaseIniFile(baseIniFile);
    workflow.setCommand(command);
    workflow.setCwd(cwd);
    workflow.setHost(host);
    workflow.setInputAlgorithm(inputAlgorithm);
    workflow.setPermanentBundleLocation(permanentBundleLocation);
    workflow.setSeqwareVersion(seqwareVersion);
    workflow.setTemplate(template);
    workflow.setUsername(username);
    workflow.setVersion(version);
    workflow.setUpdateTimestamp(new Date());
    workflow.setWorkflowClass(newWorkflow.getWorkflowClass());
    workflow.setWorkflowType(newWorkflow.getWorkflowType());
    workflow.setWorkflowEngine(newWorkflow.getWorkflowEngine());
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        workflow.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (workflow.getOwner() == null) {
      workflow.setOwner(registration);
    }
    if (newWorkflow.getWorkflowAttributes() != null) {
      for (      WorkflowAttribute wfa : newWorkflow.getWorkflowAttributes()) {
        wfa.setWorkflow(workflow);
        workflow.getWorkflowAttributes().add(wfa);
      }
    }
    fs.update(registration,workflow);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Workflow detachedWorkflow=copier.hibernate2dto(Workflow.class,workflow);
    Document line=XmlTools.marshalToDocument(jo,detachedWorkflow);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedWorkflow.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e.getMessage());
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e.getMessage());
  }
  return representation;
}