Fixed handler end of postback key.

This commit is contained in:
Winston Li 2014-12-04 21:30:25 +00:00
parent c3ef49b17c
commit 1561111a0b
2 changed files with 8 additions and 5 deletions

View file

@ -18,15 +18,17 @@ public class SnapshotPushPostbackContents implements JSONSource {
private final WriteLatexDataSource writeLatexDataSource;
private final String projectName;
private final String postbackKey;
private final SnapshotPostExceptionBuilder snapshotPostExceptionBuilder;
private int versionID;
private SnapshotPostException exception;
public SnapshotPushPostbackContents(WriteLatexDataSource writeLatexDataSource, String projectName, String contents) {
this.projectName = projectName;
public SnapshotPushPostbackContents(WriteLatexDataSource writeLatexDataSource, String projectName, String postbackKey, String contents) {
this.writeLatexDataSource = writeLatexDataSource;
this.projectName = projectName;
this.postbackKey = postbackKey;
snapshotPostExceptionBuilder = new SnapshotPostExceptionBuilder();
fromJSON(new Gson().fromJson(contents, JsonElement.class));
}
@ -41,9 +43,9 @@ public class SnapshotPushPostbackContents implements JSONSource {
public void processPostback() throws UnexpectedPostbackException {
if (exception == null) {
writeLatexDataSource.postbackReceivedSuccessfully(projectName, versionID);
writeLatexDataSource.postbackReceivedSuccessfully(projectName, postbackKey, versionID);
} else {
writeLatexDataSource.postbackReceivedWithException(projectName, exception);
writeLatexDataSource.postbackReceivedWithException(projectName, postbackKey, exception);
}
}

View file

@ -28,7 +28,8 @@ public class SnapshotPushPostbackHandler extends AbstractHandler {
String contents = getContentsOfReader(request.getReader());
String projectName = request.getRequestURI().split("/")[1];
System.out.println("Postback received for project: " + projectName);
SnapshotPushPostbackContents postbackContents = new SnapshotPushPostbackContents(writeLatexDataSource, projectName, contents);
String postbackKey = "postback";
SnapshotPushPostbackContents postbackContents = new SnapshotPushPostbackContents(writeLatexDataSource, projectName, postbackKey, contents);
try {
postbackContents.processPostback();
} catch (UnexpectedPostbackException e) {