Program: 62177
Project: 62177
Buggy source:
/** 
 * Create a new version for an application. The new application version can be created from an exiting application version of not. When created from an existing application version all topology versions from the original version will be created in the new application version.
 * @param applicationId The id of the application for which to create the version.
 * @param version The new version.
 * @param description The description.
 * @param originalId The version (application version or topology) from witch to create the new application version.
 * @param originalIsAppVersion True if the originalId is the id of an application version id, false if it is the id of a topology id.
 */
public ApplicationVersion createApplicationVersion(String applicationId,String version,String description,String originalId,boolean originalIsAppVersion){
  if (isVersionNameExist(applicationId,version)) {
    throw new AlreadyExistException("String_Node_Str" + version + "String_Node_Str"+ applicationId+ "String_Node_Str");
  }
  ApplicationVersion appVersion=new ApplicationVersion();
  appVersion.setDelegateId(applicationId);
  appVersion.setVersion(version);
  appVersion.setNestedVersion(VersionUtil.parseVersion(version));
  appVersion.setReleased(!VersionUtil.isSnapshot(version));
  appVersion.setDescription(description);
  appVersion.setTopologyVersions(Maps.newHashMap());
  if (originalIsAppVersion && originalId != null) {
    ApplicationVersion originalAppVersion=getOrFail(originalId);
    if (!applicationId.equals(originalAppVersion.getApplicationId())) {
      throw new AuthorizationServiceException("String_Node_Str");
    }
    importTopologiesFromPreviousVersion(appVersion,originalAppVersion);
  }
 else {
    Topology topology;
    if (originalId == null) {
      topology=new Topology();
    }
 else {
      try {
        topology=getTemplateTopology(originalId);
      }
 catch (      NotFoundException|AccessDeniedException e) {
        topology=new Topology();
      }
    }
    ApplicationTopologyVersion applicationTopologyVersion=createTopologyVersion(applicationId,version,null,"String_Node_Str",topology);
    appVersion.getTopologyVersions().put(version,applicationTopologyVersion);
  }
  alienDAO.save(appVersion);
  return appVersion;
}

Fixed version (ground truth):
/** 
 * Create a new version for an application. The new application version can be created from an exiting application version of not. When created from an existing application version all topology versions from the original version will be created in the new application version.
 * @param applicationId The id of the application for which to create the version.
 * @param version The new version.
 * @param description The description.
 * @param originalId The version (application version or topology) from witch to create the new application version.
 * @param originalIsAppVersion True if the originalId is the id of an application version id, false if it is the id of a topology id.
 */
public ApplicationVersion createApplicationVersion(String applicationId,String version,String description,String originalId,boolean originalIsAppVersion){
  if (isVersionNameExist(applicationId,version)) {
    throw new AlreadyExistException("String_Node_Str" + version + "String_Node_Str"+ applicationId+ "String_Node_Str");
  }
  ApplicationVersion appVersion=new ApplicationVersion();
  appVersion.setDelegateId(applicationId);
  appVersion.setVersion(version);
  appVersion.setNestedVersion(VersionUtil.parseVersion(version));
  appVersion.setReleased(!VersionUtil.isSnapshot(version));
  appVersion.setDescription(description);
  appVersion.setTopologyVersions(Maps.newHashMap());
  if (originalIsAppVersion && originalId != null) {
    ApplicationVersion originalAppVersion=getOrFail(originalId);
    if (!applicationId.equals(originalAppVersion.getApplicationId())) {
      throw new AuthorizationServiceException("String_Node_Str");
    }
    importTopologiesFromPreviousVersion(appVersion,originalAppVersion);
  }
 else {
    Topology topology;
    if (originalId == null) {
      topology=new Topology();
    }
 else {
      topology=getTemplateTopology(originalId);
    }
    ApplicationTopologyVersion applicationTopologyVersion=createTopologyVersion(applicationId,version,null,"String_Node_Str",topology);
    appVersion.getTopologyVersions().put(version,applicationTopologyVersion);
  }
  alienDAO.save(appVersion);
  return appVersion;
}