001: /*
002: * Copyright 2006 Day Management AG, Switzerland. All rights reserved.
003: */
004: package javax.jcr.observation;
005:
006: import javax.jcr.RepositoryException;
007: import java.util.Map;
008:
009: /**
010: * An event fired by the observation mechanism.
011: * <p>
012: * An event may be a <i>method event</i> or a <i>state-change event</i>.
013: * If this is a method event then {@link #getType} will return the constant <code>Event.METHOD_EVENT</code>.
014: * If this is a state-change event then {@link #getType} will return one of the other
015: * <code>int<code> constants defined in this interface.
016: * <p>
017: * For each state-change event constant, the values returned by the methods {@link #getPath},
018: * {@link #getIdentifier} are explained.
019: * <p>
020: * For method events further information about the particular method
021: * which caused the event can be acquired through {@link #getMethod} and {@link #getMethodInfo}.
022: * <p>
023: * The value returned by {@link #getUserID} is always the same as
024: * that returned by {@link javax.jcr.Session#getUserID} of the session that
025: * caused the event.
026: */
027: public interface Event {
028:
029: /**
030: * Generated on persist when a node is added.
031: * <ul>
032: * <li>{@link #getPath} returns the absolute path of the node that was added.</li>
033: * <li>{@link #getIdentifier} returns the identifier of the node that was added.</li>
034: * <li>{@link #getMethod} and {@link #getMethodInfo} both return <code>null</code>.</li>
035: * </ul>
036: */
037: public static final int NODE_ADDED = 0x1;
038:
039: /**
040: * Generated on persist when a node is removed.
041: * <ul>
042: * <li>{@link #getPath} returns the absolute path of the node that was removed.</li>
043: * <li>{@link #getIdentifier} returns the identifier of the node that was removed.</li>
044: * <li>{@link #getMethod} and {@link #getMethodInfo} both return <code>null</code>.</li>
045: * </ul>
046: */
047: public static final int NODE_REMOVED = 0x2;
048:
049: /**
050: * Generated on persist when a property is added.
051: * <ul>
052: * <li>{@link #getPath} returns the absolute path of the property that was added.</li>
053: * <li>{@link #getIdentifier} returns the idenifier of the parent node of the property that was added.
054: * <li>{@link #getMethod} and {@link #getMethodInfo} both return <code>null</code>.</li>
055: * </ul>
056: */
057: public static final int PROPERTY_ADDED = 0x4;
058:
059: /**
060: * Generated on persist when a property is removed.
061: * <ul>
062: * <li>{@link #getPath} returns the absolute path of the property that was removed.</li>
063: * <li>{@link #getIdentifier} returns the idenifier of the parent node of the property that was removed.
064: * <li>{@link #getMethod} and {@link #getMethodInfo} both return <code>null</code>.</li>
065: * </ul>
066: */
067: public static final int PROPERTY_REMOVED = 0x8;
068:
069: /**
070: * Generated on persist when a property is changed.
071: * <ul>
072: * <li>{@link #getPath} returns the absolute path of the property that was changed.</li>
073: * <li>{@link #getIdentifier} returns the idenifier of the parent node of the property that was changed.
074: * <li>{@link #getMethod} and {@link #getMethodInfo} both return <code>null</code>.</li>
075: * </ul>
076: */
077: public static final int PROPERTY_CHANGED = 0x10;
078:
079: /**
080: * Indicates that this event is a method event.
081: * <ul>
082: * <li>{@link #getPath} returns <code>null</code>.</li>
083: * <li>{@link #getIdentifier} returns <code>null</code>.</li>
084: * <li>{@link #getMethod} returns the string constant representing the method that caused this event.</li>
085: * <li>{@link #getMethodInfo} returns a <code>Map</code> holding the parameters of the method that
086: * caused this event.</li>
087: * </ul>
088: */
089: public static final int METHOD_EVENT = 0x20;
090:
091: /**
092: * Returns the type of this event: a constant defined by this interface.
093: * One of:
094: * <ul>
095: * <li><code>NODE_ADDED</code></li>
096: * <li><code>NODE_REMOVED</code></li>
097: * <li><code>PROPERTY_ADDED</code></li>
098: * <li><code>PROPERTY_REMOVED</code></li>
099: * <li><code>PROPERTY_CHANGED</code></li>
100: * <li><code>METHOD_EVENT</code></li>
101: * </ul>
102: *
103: * @return the type of this event.
104: */
105: public int getType();
106:
107: /**
108: * Returns the absolute path associated with this event. The meaning of the
109: * associated path depends upon the type of the event.
110: *
111: * @return the absolute path associated with this event.
112: * @throws RepositoryException if an error occurs.
113: */
114: public String getPath() throws RepositoryException;
115:
116: /**
117: * Returns the user ID connected with this event. This is the string returned
118: * by {@link javax.jcr.Session#getUserID} of the session that caused the event.
119: *
120: * @return a <code>String</code>.
121: * @throws RepositoryException if an error occurs.
122: */
123: public String getUserID() throws RepositoryException;
124:
125: /**
126: * Returns the identifier associated with this event or <code>null</code>
127: * if this event has no associated identifier. The meaning of the associated
128: * identifier depends upon the type of the event.
129: *
130: * @return the identifier associated with this event or <code>null</code>
131: * if this event has no associated identifier.
132: * @throws RepositoryException if an error occurs.
133: * @since JCR 2.0
134: */
135: public String getIdentifier() throws RepositoryException;
136:
137: /**
138: * If this is a method event, returns the string constant identify the
139: * method that caused this event.
140: * @return String
141: * @throws RepositoryException
142: */
143: public String getMethod() throws RepositoryException;
144:
145: /**
146: * If this is a method event, returns a <code>Map</code> holding the parameters passed to the method
147: * that caused this event. The parameters are held in the <code>Map</code> as name/value pairs where
148: * the name is the string used in this Javadoc to identify the parameter, and the value is the
149: * parameter passed. If the parameter is a primitive type then it is converted to its corresponding
150: * Java reference type (that is, an <code>Object</code>).
151: * @return Map
152: * @throws RepositoryException
153: */
154: public Map getMethodInfo() throws RepositoryException;
155:
156: /**
157: * Returns the user data set in {@link ObservationManager#setUserData}
158: * @return String
159: * @throws RepositoryException
160: */
161: public String getUserData() throws RepositoryException;
162:
163: public static final String ADD_NODE = "javax.jcr.observation.Event.ADD_NODE";
164:
165: public static final String SET_PROPERTY = "javax.jcr.observation.Event.SET_PROPERTY";
166:
167: public static final String ORDER_BEFORE = "javax.jcr.observation.Event.ORDER_BEFORE";
168:
169: public static final String CHANGE_MIXINS = "javax.jcr.observation.Event.CHANGE_MIXINS";
170:
171: public static final String SET_PRIMARY_TYPE = "javax.jcr.observation.Event.SET_PRIMARY_TYPE";
172:
173: public static final String REMOVE = "javax.jcr.observation.Event.REMOVE";
174:
175: public static final String SESSION_MOVE = "javax.jcr.observation.Event.SESSION_MOVE";
176:
177: public static final String SESSION_IMPORT = "javax.jcr.observation.Event.SESSION_IMPORT";
178:
179: public static final String STORE_AS_NODE = "javax.jcr.observation.Event.STORE_AS_NODE";
180:
181: public static final String COPY = "javax.jcr.observation.Event.COPY";
182:
183: public static final String COPY_EXTERNAL = "javax.jcr.observation.Event.COPY_EXTERNAL";
184:
185: public static final String WORKSPACE_MOVE = "javax.jcr.observation.Event.WORKSPACE_MOVE";
186:
187: public static final String UPDATE = "javax.jcr.observation.Event.UPDATE";
188:
189: public static final String CHECKIN = "javax.jcr.observation.Event.CHECKIN";
190:
191: public static final String CHECKOUT = "javax.jcr.observation.Event.CHECKOUT";
192:
193: public static final String MERGE = "javax.jcr.observation.Event.MERGE";
194:
195: public static final String DONE_MERGE = "javax.jcr.observation.Event.DONE_MERGE";
196:
197: public static final String CANCEL_MERGE = "javax.jcr.observation.Event.CANCEL_MERGE";
198:
199: public static final String ADD_VERSION_LABEL = "javax.jcr.observation.Event.ADD_VERSION_LABEL";
200:
201: public static final String REMOVE_VERSION_LABEL = "javax.jcr.observation.Event.REMOVE_VERSION_LABEL";
202:
203: public static final String LOCK = "javax.jcr.observation.Event.LOCK";
204:
205: public static final String UNLOCK = "javax.jcr.observation.Event.UNLOCK";
206:
207: public static final String WORKSPACE_IMPORT = "javax.jcr.observation.Event.WORKSPACE_IMPORT";
208:
209: public static final String CREATE_ACTIVITY = "javax.jcr.observation.Event.CREATE_ACTIVITY";
210:
211: public static final String MERGE_ACTIVITY = "javax.jcr.observation.Event.MERGE_ACTIVITY";
212:
213: public static final String CREATE_CONFIGURATION = "javax.jcr.observation.Event.CREATE_CONFIGURATION";
214:
215: public static final String SET_HOLD = "javax.jcr.observation.Event.SET_HOLD";
216:
217: public static final String REMOVE_HOLD = "javax.jcr.observation.Event.REMOVE_HOLD";
218:
219: public static final String SET_RETENTION_POLICY = "javax.jcr.observation.Event.SET_RETENTION_POLICY";
220:
221: public static final String REMOVE_RETENTION_POLICY = "javax.jcr.observation.Event.REMOVE_RETENTION_POLICY";
222:
223: public static final String REMOVE_VERSION = "javax.jcr.observation.Event.REMOVE_VERSION";
224:
225: public static final String REGISTER_NODE_TYPE = "javax.jcr.observation.Event.REGISTER_NODE_TYPE";
226:
227: public static final String UNREGISTER_NODE_TYPE = "javax.jcr.observation.Event.UNREGISTER_NODE_TYPE";
228:
229: public static final String SET_POLICY = "javax.jcr.observation.Event.SET_POLICY";
230:
231: public static final String DELETE_POLICY = "javax.jcr.observation.Event.DELETE_POLICY";
232:
233: public static final String SET_PRIVILEGES = "javax.jcr.observation.Event.SET_PRIVILEGES";
234:
235: public static final String DELETE_PRIVILEGES = "javax.jcr.observation.Event.DELETE_PRIVILEGES";
236:
237: public static final String PERSIST = "javax.jcr.observation.Event.PERSIST";
238: }
|