01: package de.webman.form.eventhandler;
02:
03: import com.teamkonzept.web.*;
04: import com.teamkonzept.webman.*;
05: import com.teamkonzept.webman.db.TKWebmanDBManager;
06: import com.teamkonzept.webman.mainint.*;
07: import com.teamkonzept.webman.mainint.db.*;
08: import com.teamkonzept.webman.mainint.db.queries.*;
09: import com.teamkonzept.webman.mainint.events.*;
10: import com.teamkonzept.lib.*;
11: import com.teamkonzept.field.*;
12: import com.teamkonzept.field.db.*;
13: import com.teamkonzept.db.*;
14: import com.teamkonzept.publishing.markups.*;
15: import de.webman.form.Form;
16:
17: /**
18: * Deletes an existing form.
19: *
20: * @author $Author: uli $
21: * @version $Revision: 1.4 $
22: */
23: public class CTDeleteHandler extends DefaultEventHandler implements
24: ParameterTypes, FrameConstants, DatabaseDefaults {
25:
26: /**
27: * The singleton instance.
28: */
29: private static final CTDeleteHandler INSTANCE = new CTDeleteHandler();
30:
31: /**
32: * Avoids outside instantiation.
33: */
34: private CTDeleteHandler() {
35: // NOP
36: }
37:
38: /**
39: * Returns the singleton instance.
40: *
41: * @return the singleton instance.
42: */
43: public static CTDeleteHandler getInstance() {
44: return INSTANCE;
45: }
46:
47: /**
48: * Handles the specified event.
49: *
50: * @param event the event to be handled.
51: * @throws TKException if any error occurred during event handling.
52: */
53: public void handleEvent(TKEvent event) throws TKException {
54: try {
55: // Check event.
56: WebManEvent.checkEvent(event.getRemoteUser(), event
57: .getName(), ContextConstants.CONTENT_TREE);
58:
59: // Get form.
60: Form form = new Form(Integer.valueOf(event.getParameter(
61: PARAMETER, "FORM_ID")));
62:
63: if (form.hasDependencies()) {
64: // Complain.
65: throw new TKUserException("Form", OBJECT_IN_USE,
66: USER_SEVERITY, true, null);
67: }
68:
69: // Delete form.
70: TKFormDBInterface.Del(new TKFormDBData(form
71: .getIdentifierAsInt()));
72:
73: // Forward event.
74: CTFramesHandler.getInstance().handleEvent(event);
75: } catch (Throwable e) {
76: // TO DO : Analyze Exception !
77: throw WebmanExceptionHandler.getException(e);
78: }
79: }
80:
81: /**
82: * Checks wether this handler is capable to handle the specified event.
83: *
84: * @param event the event to be handled.
85: * @return <CODE>true</CODE> if this handler is capable to handle the
86: * specified event, otherwise <CODE>false</CODE>.
87: */
88: public boolean isHandler(TKEvent event) {
89: return event.getName().equalsIgnoreCase("CT_DELETE");
90: }
91:
92: }
|