KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > event > AuditModuleEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.event;
25
26 import com.sun.enterprise.admin.event.AdminEvent;
27
28 //i18n import
29
import com.sun.enterprise.util.i18n.StringManager;
30
31 /**
32  * Audit Module Event - emitted by DAS after comletion of
33  * create/delete/update operation on security-service.audit-module element
34  * Contains name of module and action type.
35  */

36 public class AuditModuleEvent extends AdminEvent {
37
38     /**
39      * Constant denoting action code
40      */

41     public static final int ACTION_CREATE = 1;
42     public static final int ACTION_DELETE = 2;
43     public static final int ACTION_UPDATE = 3;
44
45     /**
46      * Event type
47      */

48     static final String JavaDoc eventType = AuditModuleEvent.class.getName();
49
50     /**
51      * Attributes
52      */

53     private int actionType;
54     private String JavaDoc moduleName;
55
56     // i18n StringManager
57
private static StringManager localStrings = StringManager.getManager( AuditModuleEvent.class );
58
59     /**
60      * Create a new AuditModuleEvent.
61      * @param type event type, a string representation for the event
62      * @param instance name of the instance to which the event applies
63      * @param module name of the Audit Module on which event happened.
64      * @param action type of action - one of AuditModuleEvent.ACTION_CREATE,
65      * AuditModuleEvent.ACTION_DELETE, AuditModuleEvent.ACTION_UPDATE
66      * @throws IllegalArgumentException if specified action is not valid
67      */

68     public AuditModuleEvent(String JavaDoc instance, String JavaDoc module, int action) {
69         this(eventType, instance, module, action);
70     }
71
72     /**
73      * Create a new AuditModuleEvent.
74      * @param type event type, a string representation for the event
75      * @param instance name of the instance to which the event applies
76      * @param module name of the Audit Module on which event happened.
77      * @param action type of action - one of AuditModuleEvent.ACTION_CREATE,
78      * AuditModuleEvent.ACTION_DELETE, AuditModuleEvent.ACTION_UPDATE
79      * @throws IllegalArgumentException if specified action is not valid
80      */

81     public AuditModuleEvent(String JavaDoc type, String JavaDoc instance, String JavaDoc module, int action) {
82         super(type, instance);
83         moduleName = module;
84         setAction(action);
85     }
86
87     /**
88      * Get name of the Audit Module on which event happened
89      */

90     public String JavaDoc getModuleName() {
91         return moduleName;
92     }
93
94     /**
95      * Get action type for this event.
96      */

97     public int getActionType() {
98         return actionType;
99     }
100
101     /**
102      * Set action to specified value. If action is not one of allowed,
103      * then IllegalArgumentException is thrown.
104      * @throws IllegalArgumentException if action is invalid
105      */

106     private void setAction(int action) {
107         boolean valid = false;
108         if (action==ACTION_CREATE ||
109             action==ACTION_DELETE ||
110             action==ACTION_UPDATE )
111             valid = true;
112         if (!valid) {
113             String JavaDoc msg = localStrings.getString( "admin.event.invalid_action", ""+action );
114             throw new IllegalArgumentException JavaDoc( msg );
115         }
116         this.actionType = action;
117     }
118
119 }
120
Popular Tags