/** * Get a project name to be used when importing. Use the prefix, copy_of_...+ i to avoid * conflicts */ private String copyProjectName(String aProjectName) { String projectName = "copy_of_" + aProjectName; int i = 1; while (true) { if (projectService.existsProject(projectName)) { projectName = "copy_of_" + aProjectName + "(" + i + ")"; i++; } else { return projectName; } } } }
/** * Get a project name to be used when importing. Use the prefix, copy_of_...+ i to avoid * conflicts */ private String copyProjectName(String aProjectName) { String projectName = "copy_of_" + aProjectName; int i = 1; while (true) { if (projectService.existsProject(projectName)) { projectName = "copy_of_" + aProjectName + "(" + i + ")"; i++; } else { return projectName; } } } }
@Override public void validate(IValidatable<String> aValidatable) { String newName = aValidatable.getValue(); String oldName = aValidatable.getModel().getObject(); if (!StringUtils.equals(newName, oldName) && isNotBlank(newName) && projectService.existsProject(newName)) { aValidatable.error(new ValidationError( "Another project with the same name exists. Please try a different name")); } } }
@Override public void validate(IValidatable<String> aValidatable) { String newName = aValidatable.getValue(); String oldName = aValidatable.getModel().getObject(); if (!StringUtils.equals(newName, oldName) && isNotBlank(newName) && projectService.existsProject(newName)) { aValidatable.error(new ValidationError( "Another project with the same name exists. Please try a different name")); } } }
if (projectService.existsProject(projectName)) { projectName = copyProjectName(projectName);
if (projectService.existsProject(projectName)) { projectName = copyProjectName(projectName);
if (projectRepository.existsProject(aName)) { return ResponseEntity .status(HttpStatus.CONFLICT)
if (projectRepository.existsProject(aName)) { return ResponseEntity .status(HttpStatus.CONFLICT)
if (projectService.existsProject(aName)) { throw new ObjectExistsException("A project with name [" + aName + "] already exists");
if (projectService.existsProject(aName)) { throw new ObjectExistsException("A project with name [" + aName + "] already exists");