Package org.dspace.event
Class Event
java.lang.Object
org.dspace.event.Event
- All Implemented Interfaces:
Serializable
An Event object represents a single action that changed one object in the
DSpace data model. An "atomic" action at the application or business-logic
API level may spawn many of these events.
This class includes tools to help set and use the contents of the event. Note that it describes DSpace data object types in two ways: by the type identifiers in the Constants class, and also by an Event-specific bitmask (used by its internal filters). All public API calls use the Constants version of the data model types.
Note that the type of the event itself is actually descriptive of the action it performs: ADD, MODIFY, etc. The most significant elements of the event are:
- (Action) Type
- Subject -- DSpace object to which the action applies, e.g. the Collection to which an ADD adds a member.
- Object -- optional, when present it is the other object effected by an action, e.g. the Item ADDed to a Collection by an ADD.
- detail -- a textual summary of what changed. Content and its significance varies by the combination of action and subject type.
- - timestamp -- exact millisecond timestamp at which event was logged.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intstatic final intEvent (Action) typesstatic final intprotected static final intstatic final intprotected static final String[]protected static final intstatic final intprotected static final intprotected static final intstatic final intstatic final intprotected static final intXXX NOTE: with ALL_OBJECTS_MASK *AND* objTypeToMask hash *static final intprotected static final intstatic final intIndex of filter parts in their array: -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intcoreTypeToMask(int core) booleanCompare two events.intintintGet the text name of event (action) type.Get the DSpace object which is the "object" of an event.intgetSubject(Context context) Syntactic sugar to get the DSpace object which is the "subject" of an event.intlonginthashCode()protected intlog2(int n) protected intmaskTypeToCore(int mask) static intInterpret named event type.static intTranslate a textual DSpace Object type name into an event subject-type mask.booleanTest whether this event would pass through a list of filters.voidKeeps track of which consumers have consumed the event.voidsetCurrentUser(int uid) voidsetDispatcher(int id) Set the identifier of the dispatcher that first processed this event.voidsetExtraLogInfo(String info) voidsetTransactionID(String tid) Sets value of transactionID element of the event.toString()
-
Field Details
-
CREATE
public static final int CREATEEvent (Action) types- See Also:
-
MODIFY
public static final int MODIFY- See Also:
-
MODIFY_METADATA
public static final int MODIFY_METADATA- See Also:
-
ADD
public static final int ADD- See Also:
-
REMOVE
public static final int REMOVE- See Also:
-
DELETE
public static final int DELETE- See Also:
-
INSTALL
public static final int INSTALL- See Also:
-
SUBJECT_MASK
public static final int SUBJECT_MASKIndex of filter parts in their array:- See Also:
-
EVENT_MASK
public static final int EVENT_MASK- See Also:
-
eventTypeText
-
NONE
protected static final int NONEXXX NOTE: with ALL_OBJECTS_MASK *AND* objTypeToMask hash *- See Also:
-
BITSTREAM
protected static final int BITSTREAM- See Also:
-
BUNDLE
protected static final int BUNDLE- See Also:
-
ITEM
protected static final int ITEM- See Also:
-
COLLECTION
protected static final int COLLECTION- See Also:
-
COMMUNITY
protected static final int COMMUNITY- See Also:
-
SITE
protected static final int SITE- See Also:
-
GROUP
protected static final int GROUP- See Also:
-
EPERSON
protected static final int EPERSON- See Also:
-
LDN_MESSAGE
protected static final int LDN_MESSAGE- See Also:
-
ALL_OBJECTS_MASK
protected static final int ALL_OBJECTS_MASK- See Also:
-
objTypeToMask
-
objMaskToType
-
-
Constructor Details
-
Event
Constructor. You should consider to useEvent(int, int, UUID, java.lang.String).- Parameters:
eventType- action type, e.g. Event.ADD.subjectType- DSpace Object Type of subject e.g. Constants.ITEM.subjectID- database ID of subject instance.detail- detail information that depends on context.
-
Event
public Event(int eventType, int subjectType, UUID subjectID, String detail, ArrayList<String> identifiers) Constructor.- Parameters:
eventType- action type, e.g. Event.ADD.subjectType- DSpace Object Type of subject e.g. Constants.ITEM.subjectID- database ID of subject instance.detail- detail information that depends on context.identifiers- array containing all identifiers of the dso or an empty array
-
Event
public Event(int eventType, int subjectType, UUID subjectID, int objectType, UUID objectID, String detail) Constructor. You should consider to useEvent(int, int, UUID, int, UUID, java.lang.String)instead.- Parameters:
eventType- action type, e.g. Event.ADD.subjectType- DSpace Object Type of subject e.g. Constants.ITEM.subjectID- database ID of subject instance.objectType- DSpace Object Type of object e.g. Constants.BUNDLE.objectID- database ID of object instance.detail- detail information that depends on context.
-
Event
public Event(int eventType, int subjectType, UUID subjectID, int objectType, UUID objectID, String detail, ArrayList<String> identifiers) Constructor.- Parameters:
eventType- action type, e.g. Event.ADD.subjectType- DSpace Object Type of subject e.g. Constants.ITEM.subjectID- database ID of subject instance.objectType- DSpace Object Type of object e.g. Constants.BUNDLE.objectID- database ID of object instance.detail- detail information that depends on context.identifiers- array containing all identifiers of the dso or an empty array
-
-
Method Details
-
equals
Compare two events. Ignore any difference in the timestamps. Also ignore transactionID since that is not always set initially. -
hashCode
public int hashCode() -
setDispatcher
public void setDispatcher(int id) Set the identifier of the dispatcher that first processed this event.- Parameters:
id- the unique (hash code) value characteristic of the dispatcher.
-
coreTypeToMask
protected int coreTypeToMask(int core) -
maskTypeToCore
protected int maskTypeToCore(int mask) -
getObject
Get the DSpace object which is the "object" of an event.- Parameters:
context- The relevant DSpace Context.- Returns:
- DSpaceObject or null if none can be found or no object was set.
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getSubject
Syntactic sugar to get the DSpace object which is the "subject" of an event.- Parameters:
context- The relevant DSpace Context.- Returns:
- DSpaceObject or null if none can be found.
- Throws:
SQLException- An exception that provides information on a database access error or other errors.
-
getSubjectID
- Returns:
- database ID of subject of this event.
-
getObjectID
- Returns:
- database ID of object of this event, or -1 if none was set.
-
getSubjectType
public int getSubjectType()- Returns:
- type number (e.g. Constants.ITEM) of subject of this event.
-
getObjectType
public int getObjectType()- Returns:
- type number (e.g. Constants.ITEM) of object of this event, or -1 if none was set.
-
getSubjectTypeAsString
- Returns:
- type of subject of this event as a String, e.g. for logging.
-
getObjectTypeAsString
- Returns:
- type of object of this event as a String, e.g. for logging.
-
parseObjectType
Translate a textual DSpace Object type name into an event subject-type mask. NOTE: This returns a BIT-MASK, not a numeric type value; the mask is only used within the event system.- Parameters:
s- text name of object type.- Returns:
- numeric value of object type or 0 for error.
-
getEventType
public int getEventType()- Returns:
- event-type (i.e. action) this event, one of the masks like Event.ADD defined above.
-
getEventTypeAsString
Get the text name of event (action) type.- Returns:
- event-type (i.e. action) this event as a String, e.g. for logging.
-
parseEventType
Interpret named event type.- Parameters:
s- name of event type.- Returns:
- numeric value of event type or 0 for error.
-
getTimeStamp
public long getTimeStamp()- Returns:
- timestamp at which event occurred, as a count of milliseconds since the epoch (standard Java format).
-
getDispatcher
public int getDispatcher()- Returns:
- hashcode identifier of name of Dispatcher which first dispatched this event. (Needed by asynch dispatch code.)
-
getDetail
- Returns:
- value of detail element of the event.
-
getIdentifiers
- Returns:
- array of identifiers of this event's subject.
-
getTransactionID
- Returns:
- value of transactionID element of the event.
-
setTransactionID
Sets value of transactionID element of the event.- Parameters:
tid- new value of transactionID.
-
setCurrentUser
public void setCurrentUser(int uid) -
getCurrentUser
public int getCurrentUser() -
setExtraLogInfo
-
getExtraLogInfo
-
pass
Test whether this event would pass through a list of filters.- Parameters:
filters- list of filter masks; each one is an Array of two ints.- Returns:
- true if this event would be passed through the given filter list.
-
log2
protected int log2(int n) -
setBitSet
Keeps track of which consumers have consumed the event. Should be called by a dispatcher when calling consume(Context ctx, String name, Event event) on an event.- Parameters:
consumerName- name of consumer which has consumed the event
-
getBitSet
- Returns:
- the set of consumers which have consumed this Event.
-
toString
-