@Nonnull
@Override
public CreateProjectValidationResult validateCreateProjectBasedOnExistingProject(
final ApplicationUser user,
@Nonnull final Long existingProjectId,
@Nonnull ProjectCreationData input
)
{
final JiraServiceContext serviceContext = getServiceContext(user, ErrorCollections.empty());
final I18nHelper i18nBean = getI18nBean(user);
if (!globalPermissionManager.hasPermission(GlobalPermissionKey.ADMINISTER, user))
{
serviceContext.getErrorCollection().addErrorMessage(i18nBean.getText("admin.projects.service.error.no.admin.permission"), Reason.FORBIDDEN);
return new CreateProjectValidationResult(serviceContext.getErrorCollection());
}
final GetProjectResult projectById = getProjectByIdForAction(user, existingProjectId, ProjectAction.EDIT_PROJECT_CONFIG);
if (!projectById.isValid())
{
return new CreateProjectValidationResult(projectById.getErrorCollection());
}
final ProjectCreationData creationData = new ProjectCreationData.Builder().fromExistingProject(projectById.get(), input).build();
isValidAllProjectData(serviceContext, creationData);
return new CreateProjectValidationResult(serviceContext.getErrorCollection(), user, creationData, Optional.of(existingProjectId));
}