2010-02-04 07:12:22 +01:00
|
|
|
package com.metaweb.gridworks.commands.edit;
|
2010-01-27 02:48:42 +01:00
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
|
|
|
import javax.servlet.ServletException;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
2010-02-04 07:12:22 +01:00
|
|
|
import com.metaweb.gridworks.commands.Command;
|
2010-02-03 03:29:47 +01:00
|
|
|
import com.metaweb.gridworks.history.HistoryProcess;
|
|
|
|
import com.metaweb.gridworks.model.Project;
|
2010-01-27 02:48:42 +01:00
|
|
|
|
|
|
|
public class UndoRedoCommand extends Command {
|
2010-03-03 05:19:58 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void doPost(HttpServletRequest request, HttpServletResponse response)
|
|
|
|
throws ServletException, IOException {
|
|
|
|
|
|
|
|
Project project = getProject(request);
|
|
|
|
|
2010-03-23 01:26:28 +01:00
|
|
|
long lastDoneID = -1;
|
|
|
|
String lastDoneIDString = request.getParameter("lastDoneID");
|
|
|
|
if (lastDoneIDString != null) {
|
|
|
|
lastDoneID = Long.parseLong(lastDoneIDString);
|
|
|
|
} else {
|
|
|
|
String undoIDString = request.getParameter("undoID");
|
|
|
|
if (undoIDString != null) {
|
|
|
|
long undoID = Long.parseLong(undoIDString);
|
|
|
|
|
|
|
|
lastDoneID = project.history.getPrecedingEntryID(undoID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
boolean done = lastDoneID == -1 ||
|
|
|
|
project.processManager.queueProcess(
|
|
|
|
new HistoryProcess(project, lastDoneID));
|
2010-01-27 02:48:42 +01:00
|
|
|
|
2010-03-03 05:19:58 +01:00
|
|
|
respond(response, "{ \"code\" : " + (done ? "\"ok\"" : "\"pending\"") + " }");
|
|
|
|
}
|
2010-01-27 02:48:42 +01:00
|
|
|
}
|