in buildChainExport-server/src/main/java/org/jetbrains/teamcity/buildChainExport/controllers/ExportChainController.java [42:73]
protected ModelAndView doHandle(@NotNull HttpServletRequest request, @NotNull HttpServletResponse response) throws Exception {
String fileFormat = StringUtil.emptyIfNull(request.getParameter("format"));
GraphFormat format = myFormats.get(fileFormat.toLowerCase());
if (format == null) {
return simpleView("Supported formats: " + myFormats.keySet());
}
String result;
String promoId = request.getParameter("promotionId");
if (promoId != null) {
BuildPromotion promotion = myBuildPromotionManager.findPromotionById(Long.parseLong(promoId));
if (promotion == null) return simpleView("Build promotion does not exist: " + promoId);
result = format.export(new PromotionNode(promotion));
} else {
String buildTypeId = request.getParameter("buildTypeId");
if (buildTypeId == null) {
return simpleView("Neither 'promotionId' nor 'buildTypeId' parameters are specified");
}
final SBuildType buildType = myProjectManager.findBuildTypeByExternalId(buildTypeId);
if (buildType == null) {
return simpleView("Build configuration with id '" + buildTypeId + "' is not found");
}
result = format.export(new BuildTypeNode(buildType));
}
response.setContentType("text/plain");
PrintWriter writer = response.getWriter();
writer.print(result);
writer.close();
return null;
}