blob: dac4f1d27649736c71654586c07c4b58cdc14deb [file] [log] [blame]
Christian van Spaandonk63814412008-08-02 09:56:01 +00001/*
2 * $Header: /cvshome/build/info.dmtree/src/info/dmtree/DmtEvent.java,v 1.8 2006/07/04 12:12:16 tszeredi Exp $
3 *
4 * Copyright (c) OSGi Alliance (2004, 2006). All Rights Reserved.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18package info.dmtree;
19
20/**
21 * Event class storing the details of a change in the tree.
22 * <code>DmtEvent</code> is used by <code>DmtAdmin</code> to notify registered
23 * {@link DmtEventListener EventListeners} about important changes. Events are
24 * generated after every successful DMT change, and also when sessions are
25 * opened or closed. If a {@link DmtSession} is opened in atomic mode, DMT
26 * events are only sent when the session is committed, when the changes are
27 * actually performed.
28 * <p>
29 * An event is generated for each group of nodes added, deleted, replaced,
30 * renamed or copied, in this order. Events are also generated when sessions
31 * are opened and closed.
32 * <p>
33 * The <code>type</code> of the event describes the change that triggered the
34 * event delivery. Each event carries the unique identifier of the session in
35 * which the described change happened. The events describing changes in the DMT
36 * carry the list of affected nodes. In case of {@link #COPIED} or
37 * {@link #RENAMED} events, the event carries the list of new nodes as well.
38 * <p>
39 * When a <code>DmtEvent</code> is delivered to a listener, the event contains
40 * only those node URIs that the listener has access to. This access control
41 * decision is based on the principal specified when the listener was
42 * registered:
43 * <ul>
44 * <li> If the listener was registered specifying an explicit principal, using
45 * the {@link DmtAdmin#addEventListener(String, int, String, DmtEventListener)}
46 * method, then the target node ACLs should be checked for providing GET access
47 * to the specified principal;
48 * <li> When the listener was registered without an explicit principal then the
49 * listener needs GET {@link info.dmtree.security.DmtPermission} for
50 * the corresponding node.
51 * </ul>
52 */
53public interface DmtEvent {
54
55 /**
56 * Event type indicating nodes that were added.
57 */
58 int ADDED = 0x01;
59
60 /**
61 * Event type indicating nodes that were copied.
62 */
63 int COPIED = 0x02;
64
65 /**
66 * Event type indicating nodes that were deleted.
67 */
68 int DELETED = 0x04;
69
70 /**
71 * Event type indicating nodes that were renamed.
72 */
73 int RENAMED = 0x08;
74
75 /**
76 * Event type indicating nodes that were replaced.
77 */
78 int REPLACED = 0x10;
79
80 /**
81 * Event type indicating that a new session was opened.
82 */
83 int SESSION_OPENED = 0x20;
84
85 /**
86 * Event type indicating that a session was closed. This type of event is
87 * sent when the session is closed by the client or becomes inactive for any
88 * other reason (session timeout, fatal errors in business methods, etc.).
89 */
90 int SESSION_CLOSED = 0x40;
91
92 /**
93 * This method returns the type of this event.
94 *
95 * @return the type of this event.
96 */
97 int getType();
98
99 /**
100 * This method returns the identifier of the session in which this event
101 * took place. The ID is guaranteed to be unique on a machine.
102 *
103 * @return the unique indetifier of the session that triggered the event
104 */
105 int getSessionId();
106
107 /**
108 * This method can be used to query the subject nodes of this event. The
109 * method returns <code>null</code> for {@link #SESSION_OPENED} and
110 * {@link #SESSION_CLOSED}.
111 * <p>
112 * The method returns only those affected nodes that the caller has the GET
113 * permission for (or in case of {@link #COPIED} or {@link #RENAMED} events,
114 * where the caller has GET permissions for either the source or the
115 * destination nodes). Therefore, it is possible that the method returns an
116 * empty array. All returned URIs are absolute.
117 *
118 * @return the array of affected nodes
119 * @see #getNewNodes
120 */
121 String[] getNodes();
122
123 /**
124 * This method can be used to query the new nodes, when the type of the
125 * event is {@link #COPIED} or {@link #RENAMED}. For all other event types
126 * this method returns <code>null</code>.
127 * <p>
128 * The array returned by this method runs parallel to the array returned by
129 * {@link #getNodes}, the elements in the two arrays contain the source and
130 * destination URIs for the renamed or copied nodes in the same order. All
131 * returned URIs are absolute.
132 * <p>
133 * This method returns only those nodes where the caller has the GET
134 * permission for the source or destination node of the operation.
135 * Therefore, it is possible that the method returns an empty array.
136 *
137 * @return the array of newly created nodes
138 */
139 String[] getNewNodes();
140}