blob: 1b24fdc19351efd7016c54e1654bf16599cc07e0 [file] [log] [blame]
Christian van Spaandonk569a4c52008-08-02 09:56:01 +00001/*
Richard S. Hallbbd3feb2009-07-24 17:06:37 +00002 * Copyright (c) OSGi Alliance (2004, 2008). All Rights Reserved.
Christian van Spaandonk569a4c52008-08-02 09:56:01 +00003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package info.dmtree;
17
18/**
19 * Event class storing the details of a change in the tree.
20 * <code>DmtEvent</code> is used by <code>DmtAdmin</code> to notify registered
21 * {@link DmtEventListener EventListeners} about important changes. Events are
22 * generated after every successful DMT change, and also when sessions are
23 * opened or closed. If a {@link DmtSession} is opened in atomic mode, DMT
24 * events are only sent when the session is committed, when the changes are
25 * actually performed.
26 * <p>
27 * An event is generated for each group of nodes added, deleted, replaced,
Richard S. Hallbbd3feb2009-07-24 17:06:37 +000028 * renamed or copied, in this order. Events are also generated when sessions are
29 * opened and closed.
Christian van Spaandonk569a4c52008-08-02 09:56:01 +000030 * <p>
31 * The <code>type</code> of the event describes the change that triggered the
32 * event delivery. Each event carries the unique identifier of the session in
33 * which the described change happened. The events describing changes in the DMT
34 * carry the list of affected nodes. In case of {@link #COPIED} or
35 * {@link #RENAMED} events, the event carries the list of new nodes as well.
36 * <p>
37 * When a <code>DmtEvent</code> is delivered to a listener, the event contains
38 * only those node URIs that the listener has access to. This access control
39 * decision is based on the principal specified when the listener was
40 * registered:
41 * <ul>
Richard S. Hallbbd3feb2009-07-24 17:06:37 +000042 * <li>If the listener was registered specifying an explicit principal, using
Christian van Spaandonk569a4c52008-08-02 09:56:01 +000043 * the {@link DmtAdmin#addEventListener(String, int, String, DmtEventListener)}
44 * method, then the target node ACLs should be checked for providing GET access
45 * to the specified principal;
Richard S. Hallbbd3feb2009-07-24 17:06:37 +000046 * <li>When the listener was registered without an explicit principal then the
47 * listener needs GET {@link info.dmtree.security.DmtPermission} for the
48 * corresponding node.
Christian van Spaandonk569a4c52008-08-02 09:56:01 +000049 * </ul>
Richard S. Hallbbd3feb2009-07-24 17:06:37 +000050 *
51 * @version $Revision: 5673 $
Christian van Spaandonk569a4c52008-08-02 09:56:01 +000052 */
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}