return;
}
if (path.equals("/")) {
// Create a new worksheet and redirect to it
final Worksheet worksheet = new Worksheet();
obj.save().entity(worksheet).now();
resp.sendRedirect("/" + worksheet.id + (skipUACheck ? "?skipuacheck=1" : ""));
} else {
final String worksheetId = path.substring(1);
if (worksheetId.length() == 8) {
// This is readonly, duplicate it and redirect to
// a new id
final Worksheet worksheet = new Worksheet();
final Worksheet template = obj.load().type(Worksheet.class).filter("readOnlyId", worksheetId).first().get();
if (template == null) {
resp.sendError(404);
return;
}
worksheet.parentId = worksheet.id;
worksheet.qaPairs = template.qaPairs;
obj.save().entity(worksheet);
resp.sendRedirect("/" + worksheet.id);
} else {
final Worksheet worksheet;
try {
worksheet = obj.load().type(Worksheet.class).id(worksheetId).get();
} catch (final NotFoundException e) {
resp.sendError(404, "Worksheet not found");
return;