/** * Returns a unique project name that does not exist in the given workspace, for the given clone * name. */ private String getUniqueProjectName(WebWorkspace workspace, String cloneName) { int i = 1; String uniqueName = cloneName; while (workspace.getProjectByName(uniqueName) != null) { // add an incrementing counter suffix until we arrive at a unique name uniqueName = cloneName + '-' + ++i; } return uniqueName; }