/** Shows the page for inserting or updating a recipe or deletes a recipe. */
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
GoogleBaseService service = (GoogleBaseService) request.getAttribute(
AuthenticationFilter.SERVICE_ATTRIBUTE);
String id = request.getParameter(RecipeUtil.ID_PARAMETER);
try {
if (isDelete()) {
recipeDelete(service, id);
listOwnRecipes(response);
} else {
// The recipe that will be used on the edit page
// for inserting or updating.
Recipe recipe = null;
if (isAdd()) {
recipe = new Recipe();
} else if (isUpdate()) {
URL entryUrl = urlFactory.getItemsEntryURL(id);
GoogleBaseEntry entry = service.getEntry(entryUrl);
recipe = new Recipe(entry);
}
if (recipe != null) {
// Ready to add or update
editRecipe(request, response, recipe, null);