01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.event;
19:
20: import java.io.Serializable;
21:
22: final public class PrincipalGroupEvent extends ContelligentEvent {
23:
24: public final static EventType CREATE = new EventType(
25: PRINCIPALGROUP_CREATE_EVENT, "PrincipalGroup created");
26:
27: public final static EventType CHANGE = new EventType(
28: PRINCIPALGROUP_CHANGE_EVENT, "PrincipalGroup changed");
29:
30: public final static EventType REMOVE = new EventType(
31: PRINCIPALGROUP_REMOVE_EVENT, "PrincipalGroup removed");
32:
33: private final EventType eventType;
34:
35: private final String groupId;
36:
37: private final boolean isUserGroup;
38:
39: public PrincipalGroupEvent(EventType eventType, String groupId,
40: boolean isUserGroup) {
41: super (eventType.id, null, null);
42: this .eventType = eventType;
43: this .groupId = groupId;
44: this .isUserGroup = isUserGroup;
45: }
46:
47: public int getType() {
48: return eventType.id;
49: }
50:
51: public String getGroupId() {
52: return groupId;
53: }
54:
55: public boolean isUserGroup() {
56: return isUserGroup;
57: }
58:
59: public String toString() {
60: StringBuffer rs = new StringBuffer("[PrincipalGroupEvent(");
61: rs.append(eventType).append(") ").append(
62: isUserGroup ? "usergroup" : "rolegroup").append(" '")
63: .append(groupId).append("']");
64: if (getInfo() != null) {
65: rs.append(getInfo());
66: }
67: return rs.toString();
68: }
69:
70: protected void additionalXML(StringBuffer buf) {
71: if (isUserGroup)
72: buf.append("<usergroup>").append(groupId).append(
73: "</usergroup>\n");
74: else
75: buf.append("<rolegroup>").append(groupId).append(
76: "</rolegroup>\n");
77: }
78:
79: static final public class EventType implements Serializable {
80: final public int id;
81:
82: final public String idString;
83:
84: private EventType(int id, String idString) {
85: this .id = id;
86: this .idString = idString;
87: }
88:
89: public String toString() {
90: return idString;
91: }
92: }
93:
94: }
|