in nuget-feed/src/jetbrains/buildServer/nuget/feed/server/tab/PackagesSettingsController.java [293:340]
public void process(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response, @Nullable Element xmlResponse) {
final ActionErrors errors = new ActionErrors();
final SProject project = getProject(request);
try {
if (project == null) {
errors.addError("projectNotFound", "Project was not found");
return;
}
if (project.isReadOnly()) {
errors.addError("cannotEditProject", "Project is read-only");
return;
}
final String type = request.getParameter("type");
if (StringUtil.isEmpty(type)) {
errors.addError(RepositoryConstants.REPOSITORY_TYPE_KEY, "Repository type not found");
return;
}
RepositoryType repositoryType = myRepositoryRegistry.findType(type);
if (repositoryType == null) {
errors.addError(RepositoryConstants.REPOSITORY_TYPE_KEY, "Repository type not found");
return;
}
final String name = request.getParameter("name");
if (StringUtil.isEmpty(name)) {
errors.addError(RepositoryConstants.REPOSITORY_NAME_KEY, repositoryType.getName() + "name is not found");
return;
}
final Repository repository = repositoryType.createRepository(project, CollectionsUtil.asMap(
RepositoryConstants.REPOSITORY_TYPE_KEY, type,
RepositoryConstants.REPOSITORY_NAME_KEY, name
));
try {
myRepositoryManager.addRepository(project, repository);
} catch (Exception e) {
LOG.infoAndDebugDetails(String.format("Failed to add %s %s in project %s", repositoryType.getName(), name, project.getExternalId()), e);
errors.addError(RepositoryConstants.REPOSITORY_NAME_KEY, e.getMessage());
}
} finally {
if (xmlResponse != null) {
writeErrors(xmlResponse, errors);
}
}
}