Program: 188924
Project: 188924
Buggy source:
/** 
 * {@inheritDoc} 
 */
@Override public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  IUS newIUS=null;
  JaxbObject<IUS> jo=new JaxbObject<IUS>();
  try {
    String text=entity.getText();
    newIUS=(IUS)XmlTools.unMarshal(jo,new IUS(),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 {
    IUSService fs=BeanFactory.getIUSServiceBean();
    IUS ius=(IUS)testIfNull(fs.findByID(newIUS.getIusId()));
    ius.givesPermission(registration);
    String name=newIUS.getName();
    String desc=newIUS.getDescription();
    String tags=newIUS.getTag();
    Boolean skip=newIUS.getSkip();
    Sample sample=newIUS.getSample();
    Registration owner=newIUS.getOwner();
    Set<IUSAttribute> newAttributes=newIUS.getIusAttributes();
    ius.setName(name);
    ius.setDescription(desc);
    ius.setSkip(skip);
    ius.setTag(tags);
    if (sample != null) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Sample newSample=ss.findByID(sample.getSampleId());
      if (newSample != null && newSample.givesPermission(registration)) {
        ius.setSample(newSample);
      }
 else       if (newSample == null) {
        Log.info("String_Node_Str" + sample);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        ius.setOwner(newReg);
      }
 else {
        Log.info(newReg.getClass().getName() + "String_Node_Str" + owner.getEmailAddress());
      }
    }
 else     if (ius.getOwner() == null) {
      ius.setOwner(registration);
    }
    if (newAttributes != null) {
      ius.getIusAttributes().clear();
      for (      IUSAttribute ia : newAttributes) {
        ia.setIus(ius);
        ius.getIusAttributes().add(ia);
      }
    }
    fs.update(registration,ius);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    IUS detachedIUS=copier.hibernate2dto(IUS.class,ius);
    Document line=XmlTools.marshalToDocument(jo,detachedIUS);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedIUS.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e);
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e);
  }
  return representation;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc} 
 */
@Override public Representation put(Representation entity){
  authenticate();
  Representation representation=null;
  IUS newIUS=null;
  JaxbObject<IUS> jo=new JaxbObject<IUS>();
  try {
    String text=entity.getText();
    newIUS=(IUS)XmlTools.unMarshal(jo,new IUS(),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 {
    IUSService fs=BeanFactory.getIUSServiceBean();
    IUS ius=(IUS)testIfNull(fs.findByID(newIUS.getIusId()));
    ius.givesPermission(registration);
    String name=newIUS.getName();
    String desc=newIUS.getDescription();
    String tags=newIUS.getTag();
    Boolean skip=newIUS.getSkip();
    Sample sample=newIUS.getSample();
    Registration owner=newIUS.getOwner();
    Set<IUSAttribute> newAttributes=newIUS.getIusAttributes();
    ius.setName(name);
    ius.setDescription(desc);
    ius.setSkip(skip);
    ius.setTag(tags);
    if (sample != null) {
      SampleService ss=BeanFactory.getSampleServiceBean();
      Sample newSample=ss.findByID(sample.getSampleId());
      if (newSample != null && newSample.givesPermission(registration)) {
        ius.setSample(newSample);
      }
 else       if (newSample == null) {
        Log.info("String_Node_Str" + sample);
      }
    }
    if (owner != null) {
      RegistrationService rs=BeanFactory.getRegistrationServiceBean();
      Registration newReg=rs.findByEmailAddress(owner.getEmailAddress());
      if (newReg != null) {
        ius.setOwner(newReg);
      }
 else {
        Log.info(newReg.getClass().getName() + "String_Node_Str" + owner.getEmailAddress());
      }
    }
 else     if (ius.getOwner() == null) {
      ius.setOwner(registration);
    }
    if (newAttributes != null) {
      for (      IUSAttribute ia : newAttributes) {
        ia.setIus(ius);
        ius.getIusAttributes().add(ia);
      }
    }
    fs.update(registration,ius);
    Hibernate3DtoCopier copier=new Hibernate3DtoCopier();
    IUS detachedIUS=copier.hibernate2dto(IUS.class,ius);
    Document line=XmlTools.marshalToDocument(jo,detachedIUS);
    representation=XmlTools.getRepresentation(line);
    getResponse().setEntity(representation);
    getResponse().setLocationRef(getRequest().getRootRef() + "String_Node_Str" + detachedIUS.getSwAccession());
    getResponse().setStatus(Status.SUCCESS_CREATED);
  }
 catch (  SecurityException e) {
    getResponse().setStatus(Status.CLIENT_ERROR_FORBIDDEN,e);
  }
catch (  Exception e) {
    e.printStackTrace();
    getResponse().setStatus(Status.SERVER_ERROR_INTERNAL,e);
  }
  return representation;
}