KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > webman > form > eventhandler > CTDeleteHandler


1 package de.webman.form.eventhandler;
2
3 import com.teamkonzept.web.*;
4 import com.teamkonzept.webman.*;
5 import com.teamkonzept.webman.db.TKWebmanDBManager;
6 import com.teamkonzept.webman.mainint.*;
7 import com.teamkonzept.webman.mainint.db.*;
8 import com.teamkonzept.webman.mainint.db.queries.*;
9 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
24     extends DefaultEventHandler
25     implements ParameterTypes,
26                FrameConstants,
27                DatabaseDefaults
28 {
29
30     /**
31      * The singleton instance.
32      */

33     private static final CTDeleteHandler INSTANCE = new CTDeleteHandler();
34
35     /**
36      * Avoids outside instantiation.
37      */

38     private CTDeleteHandler ()
39     {
40         // NOP
41
}
42
43     /**
44      * Returns the singleton instance.
45      *
46      * @return the singleton instance.
47      */

48     public static CTDeleteHandler getInstance ()
49     {
50         return INSTANCE;
51     }
52
53     /**
54      * Handles the specified event.
55      *
56      * @param event the event to be handled.
57      * @throws TKException if any error occurred during event handling.
58      */

59     public void handleEvent (TKEvent event)
60         throws TKException
61     {
62         try
63         {
64             // Check event.
65
WebManEvent.checkEvent(event.getRemoteUser(), event.getName(), ContextConstants.CONTENT_TREE);
66
67             // Get form.
68
Form form = new Form(Integer.valueOf(event.getParameter(PARAMETER, "FORM_ID")));
69
70             if (form.hasDependencies())
71             {
72                 // Complain.
73
throw new TKUserException("Form", OBJECT_IN_USE, USER_SEVERITY, true, null);
74             }
75
76             // Delete form.
77
TKFormDBInterface.Del(new TKFormDBData(form.getIdentifierAsInt()));
78
79             // Forward event.
80
CTFramesHandler.getInstance().handleEvent(event);
81         }
82         catch (Throwable JavaDoc e)
83         {
84             // TO DO : Analyze Exception !
85
throw WebmanExceptionHandler.getException(e);
86         }
87     }
88
89     /**
90      * Checks wether this handler is capable to handle the specified event.
91      *
92      * @param event the event to be handled.
93      * @return <CODE>true</CODE> if this handler is capable to handle the
94      * specified event, otherwise <CODE>false</CODE>.
95      */

96     public boolean isHandler (TKEvent event)
97     {
98         return event.getName().equalsIgnoreCase("CT_DELETE");
99     }
100
101 }
102
Popular Tags