1 package com.sri.emo.wizard.wizardgateway; 2 3 import com.jcorporate.expresso.core.controller.*; 4 import com.jcorporate.expresso.core.db.DBException; 5 import com.sri.common.controller.StateHandler; 6 import com.sri.emo.dbobj.WizDefinition; 7 import com.sri.emo.wizard.WizDefinitionRepository; 8 9 /*** 10 * @author Michael Rimov 11 * @version 1.0 12 */ 13 public class DoDeleteWizard extends WizardGatewayHandler implements StateHandler { 14 15 16 /*** 17 * Name of the State for which this handler deals with. 18 */ 19 public static final String STATE_NAME = "doDeleteWizard"; 20 21 22 /*** 23 * Friendly description of this handler. 24 */ 25 public static final String STATE_DESCRIPTION = "Delete A Wizard"; 26 27 /*** 28 * Constructs this particular state handler. 29 * 30 * @param handlerOwner Controller the controller that is the parent of this 31 * state handler. 32 * @param myRepository WizDefinitionRepository the repository to use 33 * for data access methods. 34 */ 35 public DoDeleteWizard(final Controller handlerOwner, final WizDefinitionRepository myRepository) { 36 super(handlerOwner, myRepository); 37 } 38 39 /*** 40 * Called to handle the request. 41 * 42 * @param request ControllerRequest The Function's ControllerRequest 43 * object. 44 * @param response ControllerResponse The Function's ControllerResponse 45 * object. 46 * @throws DBException upon underlying database exception error. 47 * @throws ControllerException upon underlying ControllerException error. 48 */ 49 public void handleRequest(final ExpressoRequest request, final ExpressoResponse response) throws DBException, 50 ControllerException { 51 try { 52 WizDefinition wizdef = getWizDef(request); 53 wizdef.delete(true); 54 Transition next = new Transition("next", "next", WizardGatewayController.class, ListWizards.STATE_NAME); 55 next.redirectTransition(request, response); 56 } catch (DBException ex) { 57 throw new ControllerException("Database error deleting wizard.", ex); 58 } 59 60 } 61 }