in command.line/java/com/jetbrains/teamcity/Server.java [143:188]
public long createChangeList(@NotNull final File patchFile, @NotNull final String comment, @NotNull final IProgressMonitor monitor) throws ECommunicationException {
HttpConnection connection = null;
try {
monitor.beginTask("Sending patch to TeamCity Server");
connection = getHttpConnection();
final PostMethod postMethod = new PostMethod(createUploadPatchUrl());
final BufferedInputStream content = new BufferedInputStream(new FileInputStream(patchFile));
try {
addAuthorizationHeader(postMethod);
postMethod.setRequestHeader("Connection", "close");
postMethod.setRequestHeader("Accept", "text/plain");
postMethod.addRequestHeader("User-Agent", mySession.getUserAgent());
postMethod.setRequestEntity(new InputStreamRequestEntity(content, patchFile.length()));
postMethod.setQueryString(new NameValuePair[] { new NameValuePair("userId", String.valueOf(getCurrentUser())),
new NameValuePair("description", comment),
new NameValuePair("date", String.valueOf(System.currentTimeMillis())),
new NameValuePair("commitType", String.valueOf(PreTestedCommitType.NONE.getId())), });
postMethod.execute(new HttpState(), connection);
} finally {
content.close();
}
if (postMethod.getStatusCode() >= 400) {
throw new ECommunicationException("Error creating change list on server with /" + UPLOAD_URL + ": " + postMethod.getResponseBodyAsString() +
"; take a look at TeamCity/logs/teamcity-server.log file for details. HTTP Status code: " + postMethod.getStatusCode());
}
// post requests to queue
final String response = postMethod.getResponseBodyAsString();
monitor.status(new ProgressStatus(IProgressStatus.INFO, String.format("sent %d bytes", patchFile.length())));
monitor.done();
return Long.parseLong(response);
} catch (IOException e) {
throw new ECommunicationException(e);
} finally {
if (connection != null) {
connection.close();
}
}
}