in nuget-feed/src/jetbrains/buildServer/nuget/feed/server/controllers/upload/PackageUploadHandler.java [105:175]
private void handleUpload(final MultipartHttpServletRequest request,
final HttpServletResponse response,
final TContext context) throws IOException {
final RunningBuildEx build = getRunningBuild(request.getHeader(NUGET_APIKEY_HEADER));
if (build == null) {
LOG.debug(INVALID_TOKEN_VALUE);
response.sendError(HttpServletResponse.SC_FORBIDDEN, INVALID_TOKEN_VALUE);
return;
}
if (!NuGetIndexUtils.isIndexingEnabledForBuild(build)) {
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Indexing is disabled for build " + LogUtil.describe(build));
return;
}
final MultipartFile file = request.getFile("package");
if (file == null) {
LOG.debug("Push NuGet package request does not contain package file");
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "NuGet package data not found");
return;
}
// Check maximum size of artifacts
final ArtifactsUploadLimit artifactsLimit = build.getArtifactsLimit();
long fileSize = file.getSize();
final Long maxArtifactFileSize = artifactsLimit.getMaxArtifactFileSize();
if (maxArtifactFileSize != null && maxArtifactFileSize >= 0 && fileSize > maxArtifactFileSize) {
final String message = String.format(
"NuGet package size is %s bytes which exceeds maximum build artifact file size of %s bytes.\n" +
"Consider increasing this limit on the Administration -> Global Settings page.",
fileSize, maxArtifactFileSize);
BuildProblemData problem = BuildProblemData.createBuildProblem(
ARTIFACT_PUBLISHING_FAILED + "_maxArtifactFileSize",
ARTIFACT_PUBLISHING_FAILED,
message);
build.addBuildProblem(problem);
LOG.debug(message);
response.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE, "NuGet package is too large");
return;
}
final Long totalSizeLimit = artifactsLimit.getArtifactsTotalSizeLimit();
if (totalSizeLimit != null && totalSizeLimit >= 0 && fileSize > totalSizeLimit) {
final String message = String.format(
"NuGet package size is %s bytes which exceeds elapsed size of build configuration artifacts of %s bytes.\n" +
"Consider increasing this limit in the project or build configuration parameters.",
fileSize, totalSizeLimit);
BuildProblemData problem = BuildProblemData.createBuildProblem(
ARTIFACT_PUBLISHING_FAILED + "_totalSizeLimit",
ARTIFACT_PUBLISHING_FAILED,
message);
build.addBuildProblem(problem);
LOG.debug(message);
response.sendError(HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE, "NuGet package is too large");
return;
}
try {
processPackage(request, response, build, file, context);
} catch (PackageLoadException e) {
LOG.debug("Invalid NuGet package: " + e.getMessage(), e);
response.sendError(HttpServletResponse.SC_BAD_REQUEST, INVALID_PACKAGE_CONTENTS);
} catch (PackageExistsException e) {
LOG.debug(e);
response.sendError(HttpServletResponse.SC_CONFLICT, e.getMessage());
} catch (Throwable e) {
LOG.warnAndDebugDetails("Failed to process NuGet package: " + e.getMessage(), e);
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to process NuGet package");
}
}