Program: 13035
Project: 13035
Buggy source:
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#persistDerivedArtifacts(org.s_ramp.xmlns._2010.s_ramp.BaseArtifactType,java.util.Collection)
 */
@Override public void persistDerivedArtifacts(BaseArtifactType sourceArtifact,Collection<DerivedArtifactType> artifacts) throws RepositoryException {
  Session session=null;
  try {
    session=JCRRepository.getSession();
    JcrTools tools=new JcrTools();
    ArtifactType sourceArtifactType=ArtifactType.valueOf(sourceArtifact);
    String sourceArtifactPath=MapToJCRPath.getArtifactPath(sourceArtifact.getUuid(),sourceArtifactType);
    if (!session.nodeExists(sourceArtifactPath)) {
      throw new RepositoryException("String_Node_Str" + sourceArtifact.getUuid());
    }
    Node sourceArtifactNode=session.getNode(sourceArtifactPath);
    JCRReferenceFactoryImpl referenceFactory=new JCRReferenceFactoryImpl(session);
    for (    DerivedArtifactType derivedArtifact : artifacts) {
      if (derivedArtifact.getUuid() == null) {
        derivedArtifact.setUuid(UUID.randomUUID().toString());
      }
      ArtifactType derivedArtifactType=ArtifactType.valueOf(derivedArtifact);
      String jcrNodeName=derivedArtifactType.getArtifactType().getApiType().value();
      jcrNodeName=JCRConstants.SRAMP_ + StringUtils.uncapitalize(jcrNodeName);
      Node derivedArtifactNode=tools.findOrCreateChild(sourceArtifactNode,derivedArtifact.getName(),jcrNodeName);
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_UUID,derivedArtifact.getUuid());
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_MODEL,derivedArtifactType.getArtifactType().getModel());
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_TYPE,derivedArtifactType.getArtifactType().getType());
      ArtifactToJCRNodeVisitor visitor=new ArtifactToJCRNodeVisitor(derivedArtifactNode,referenceFactory);
      ArtifactVisitorHelper.visitArtifact(visitor,derivedArtifact);
      if (visitor.hasError())       throw visitor.getError();
      log.debug("String_Node_Str",derivedArtifact.getName(),derivedArtifact.getUuid());
    }
    session.save();
    if (log.isDebugEnabled()) {
      printArtifactGraph(sourceArtifact.getUuid(),sourceArtifactType);
    }
  }
 catch (  RepositoryException e) {
    throw e;
  }
catch (  Throwable t) {
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}

Fixed version (ground truth):
/** 
 * @see org.overlord.sramp.repository.PersistenceManager#persistDerivedArtifacts(org.s_ramp.xmlns._2010.s_ramp.BaseArtifactType,java.util.Collection)
 */
@Override public void persistDerivedArtifacts(BaseArtifactType sourceArtifact,Collection<DerivedArtifactType> artifacts) throws RepositoryException {
  Session session=null;
  try {
    session=JCRRepository.getSession();
    ArtifactType sourceArtifactType=ArtifactType.valueOf(sourceArtifact);
    String sourceArtifactPath=MapToJCRPath.getArtifactPath(sourceArtifact.getUuid(),sourceArtifactType);
    if (!session.nodeExists(sourceArtifactPath)) {
      throw new RepositoryException("String_Node_Str" + sourceArtifact.getUuid());
    }
    Node sourceArtifactNode=session.getNode(sourceArtifactPath);
    JCRReferenceFactoryImpl referenceFactory=new JCRReferenceFactoryImpl(session);
    for (    DerivedArtifactType derivedArtifact : artifacts) {
      if (derivedArtifact.getUuid() == null) {
        derivedArtifact.setUuid(UUID.randomUUID().toString());
      }
      ArtifactType derivedArtifactType=ArtifactType.valueOf(derivedArtifact);
      String jcrNodeType=derivedArtifactType.getArtifactType().getApiType().value();
      jcrNodeType=JCRConstants.SRAMP_ + StringUtils.uncapitalize(jcrNodeType);
      String nodeName=derivedArtifact.getUuid();
      Node derivedArtifactNode=sourceArtifactNode.addNode(nodeName,jcrNodeType);
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_UUID,derivedArtifact.getUuid());
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_MODEL,derivedArtifactType.getArtifactType().getModel());
      derivedArtifactNode.setProperty(JCRConstants.SRAMP_ARTIFACT_TYPE,derivedArtifactType.getArtifactType().getType());
      ArtifactToJCRNodeVisitor visitor=new ArtifactToJCRNodeVisitor(derivedArtifactNode,referenceFactory);
      ArtifactVisitorHelper.visitArtifact(visitor,derivedArtifact);
      if (visitor.hasError())       throw visitor.getError();
      log.debug("String_Node_Str",derivedArtifact.getName(),derivedArtifact.getUuid());
    }
    session.save();
    if (log.isDebugEnabled()) {
      printArtifactGraph(sourceArtifact.getUuid(),sourceArtifactType);
    }
  }
 catch (  RepositoryException e) {
    throw e;
  }
catch (  Throwable t) {
    throw new RepositoryException(t);
  }
 finally {
    JCRRepository.logoutQuietly(session);
  }
}