Program: 188923
Project: 188923
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Experiment newObj=null;
  JaxbObject<Experiment> jo=new JaxbObject<Experiment>();
  try {
    String text=entity.getText();
    newObj=(Experiment)XmlTools.unMarshal(jo,new Experiment(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex);
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e);
  }
  try {
    ExperimentService service=BeanFactory.getExperimentServiceBean();
    Experiment exp=(Experiment)testIfNull(service.findByID(newObj.getExperimentId()));
    exp.givesPermission(registration);
    String title=newObj.getTitle();
    String name=newObj.getName();
    String desc=newObj.getDescription();
    String alias=newObj.getAlias();
    String accession=newObj.getAccession();
    String status=newObj.getStatus();
    String centerName=newObj.getCenterName();
    String sequencerSpace=newObj.getSequenceSpace();
    String baseCaller=newObj.getBaseCaller();
    String qualityScorer=newObj.getQualityScorer();
    Integer qualityNumberLevels=newObj.getQualityNumberOfLevels();
    Integer qualityMultiplier=newObj.getQualityMultiplier();
    Long expectedNumberSpots=newObj.getExpectedNumberSpots();
    Long expectedNumberReads=newObj.getExpectedNumberReads();
    Study study=newObj.getStudy();
    Registration owner=newObj.getOwner();
    Set<ExperimentAttribute> expAttributes=newObj.getExperimentAttributes();
    if (title != null) {
      exp.setTitle(title);
    }
    if (name != null) {
      exp.setName(name);
    }
    if (desc != null) {
      exp.setDescription(desc);
    }
    if (alias != null) {
      exp.setAlias(alias);
    }
    if (accession != null) {
      exp.setAccession(accession);
    }
    if (status != null) {
      exp.setStatus(status);
    }
    if (centerName != null) {
      exp.setCenterName(centerName);
    }
    if (sequencerSpace != null) {
      exp.setSequenceSpace(sequencerSpace);
    }
    if (baseCaller != null) {
      exp.setBaseCaller(baseCaller);
    }
    if (qualityScorer != null) {
      exp.setQualityScorer(qualityScorer);
    }
    if (qualityNumberLevels != null) {
      exp.setQualityNumberOfLevels(qualityNumberLevels);
    }
    if (qualityMultiplier != null) {
      exp.setQualityMultiplier(qualityMultiplier);
    }
    if (expectedNumberSpots != null) {
      exp.setExpectedNumberSpots(expectedNumberSpots);
    }
    if (expectedNumberReads != null) {
      exp.setExpectedNumberReads(expectedNumberReads);
    }
    if (study != null) {
      StudyService ss=BeanFactory.getStudyServiceBean();
      Study newStudy=ss.findByID(study.getStudyId());
      if (newStudy != null && newStudy.givesPermission(registration)) {
        exp.setStudy(newStudy);
      }
 else       if (newStudy == null) {
        Log.info("String_Node_Str" + study);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        exp.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (exp.getOwner() == null) {
      exp.setOwner(registration);
    }
    if (null != expAttributes) {
      exp.getExperimentAttributes().clear();
      for (      ExperimentAttribute ea : expAttributes) {
        ea.setExperiment(exp);
        exp.getExperimentAttributes().add(ea);
      }
    }
    service.update(registration,exp);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Experiment detachedLane=copier.hibernate2dto(Experiment.class,exp);
    Document line=XmlTools.marshalToDocument(jo,detachedLane);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedLane.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 @Put public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  Experiment newObj=null;
  JaxbObject<Experiment> jo=new JaxbObject<Experiment>();
  try {
    String text=entity.getText();
    newObj=(Experiment)XmlTools.unMarshal(jo,new Experiment(),text);
  }
 catch (  SAXException ex) {
    ex.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,ex);
  }
catch (  IOException e) {
    e.printStackTrace();
    throw new ResourceException(Status.CLIENT_ERROR_BAD_REQUEST,e);
  }
  try {
    ExperimentService service=BeanFactory.getExperimentServiceBean();
    Experiment exp=(Experiment)testIfNull(service.findByID(newObj.getExperimentId()));
    exp.givesPermission(registration);
    String title=newObj.getTitle();
    String name=newObj.getName();
    String desc=newObj.getDescription();
    String alias=newObj.getAlias();
    String accession=newObj.getAccession();
    String status=newObj.getStatus();
    String centerName=newObj.getCenterName();
    String sequencerSpace=newObj.getSequenceSpace();
    String baseCaller=newObj.getBaseCaller();
    String qualityScorer=newObj.getQualityScorer();
    Integer qualityNumberLevels=newObj.getQualityNumberOfLevels();
    Integer qualityMultiplier=newObj.getQualityMultiplier();
    Long expectedNumberSpots=newObj.getExpectedNumberSpots();
    Long expectedNumberReads=newObj.getExpectedNumberReads();
    Study study=newObj.getStudy();
    Registration owner=newObj.getOwner();
    Set<ExperimentAttribute> expAttributes=newObj.getExperimentAttributes();
    if (title != null) {
      exp.setTitle(title);
    }
    if (name != null) {
      exp.setName(name);
    }
    if (desc != null) {
      exp.setDescription(desc);
    }
    if (alias != null) {
      exp.setAlias(alias);
    }
    if (accession != null) {
      exp.setAccession(accession);
    }
    if (status != null) {
      exp.setStatus(status);
    }
    if (centerName != null) {
      exp.setCenterName(centerName);
    }
    if (sequencerSpace != null) {
      exp.setSequenceSpace(sequencerSpace);
    }
    if (baseCaller != null) {
      exp.setBaseCaller(baseCaller);
    }
    if (qualityScorer != null) {
      exp.setQualityScorer(qualityScorer);
    }
    if (qualityNumberLevels != null) {
      exp.setQualityNumberOfLevels(qualityNumberLevels);
    }
    if (qualityMultiplier != null) {
      exp.setQualityMultiplier(qualityMultiplier);
    }
    if (expectedNumberSpots != null) {
      exp.setExpectedNumberSpots(expectedNumberSpots);
    }
    if (expectedNumberReads != null) {
      exp.setExpectedNumberReads(expectedNumberReads);
    }
    if (study != null) {
      StudyService ss=BeanFactory.getStudyServiceBean();
      Study newStudy=ss.findByID(study.getStudyId());
      if (newStudy != null && newStudy.givesPermission(registration)) {
        exp.setStudy(newStudy);
      }
 else       if (newStudy == null) {
        Log.info("String_Node_Str" + study);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        exp.setOwner(newReg);
      }
 else {
        Log.info("String_Node_Str" + owner);
      }
    }
 else     if (exp.getOwner() == null) {
      exp.setOwner(registration);
    }
    if (null != expAttributes) {
      for (      ExperimentAttribute ea : expAttributes) {
        ea.setExperiment(exp);
        exp.getExperimentAttributes().add(ea);
      }
    }
    service.update(registration,exp);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    Experiment detachedLane=copier.hibernate2dto(Experiment.class,exp);
    Document line=XmlTools.marshalToDocument(jo,detachedLane);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedLane.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;
}