Add Event Handler¶
Allegra has an extensive event handling system. This makes it possible to extend the system without having to recompile it. Custom event handlers must implement the Allegra event listener interface. This automatically registers them with the Allegra event server when the application is launched and ensures they get notified when events occur.
For example, Allegra fires an event at each server start and server stop. These events can be captured by a custom event handler to log server and service availability.
As a second example, Allegra can fire an event each time users log in or log out. A custom event handler could catch these events and write a log to record user activity.
As a third and last example, Allegra can trigger an event when an item is modified or created. A custom event listener could augment the mailing and notification system and send customized mails based on the exact event type.
/*
* This file is part of the Allegra application, a
* tool for project and change management.
*
* Copyright (C) 2022 Steinbeis GmbH & Co. KG
*
* Use and distribution of this software is governed by the
* Allegra license conditions.
*
*/
package com.aurel.track.util.event;
import java.util.List;
/**
* This interface describes observers that can attach to an
* AdminEventPublisher. They will get notified of events of
* administrative actions, like registering of new users etc.
* @author Joerg Friedrich <joerg.friedrich@trackplus.com>
*/
public interface IEventSubscriber {
//user events
public static final int EVENT_USER_BASE = 1000;
//user add by admin
// public static final int EVENT_PRE_USER_REGISTERED = EVENT_USER_BASE + 1;
public static final int EVENT_POST_USER_REGISTERED = EVENT_USER_BASE + 2;
public static final int EVENT_POST_USER_LOGGED_IN = EVENT_USER_BASE + 3;
public static final int EVENT_PRE_USER_LOGGED_OUT = EVENT_USER_BASE + 4;
// public static final int EVENT_POST_USER_LOGGED_OUT = EVENT_USER_BASE + 5;
// public static final int EVENT_PRE_USER_DELETED = EVENT_USER_BASE + 6;
// public static final int EVENT_PRE_USER_DEACTIVATED = EVENT_USER_BASE + 7;
// public static final int EVENT_PRE_USER_ACTIVATED = EVENT_USER_BASE + 8;
public static final int EVENT_POST_USER_FORGOTPASSWORD = EVENT_USER_BASE + 9;
public static final int EVENT_POST_USER_REMINDER = EVENT_USER_BASE + 10;
public static final int EVENT_POST_USER_SELF_REGISTERED = EVENT_USER_BASE + 11;
public static final int EVENT_POST_USER_CREATED_BY_EMAIL= EVENT_USER_BASE + 12;
// public static final int EVENT_POST_USER_RECURRENCE_REMINDER = EVENT_USER_BASE + 13;
//reminder on individual items
public static final int EVENT_USER_ITEM_REMINDER = EVENT_USER_BASE + 14;
/**
* This event is fired after a user profile has been saved.
* Parameters:
* events: List<Integer>
* params: Object converted into Map<String, Object>
* key value pairs: @EventParamKey.PERSON_BEAN value type: @TPersonBean
* @EventParamKey.CONTEXT value type: Integer Possible values are: @ProfileMainTO.CONTEXT
* @EventParamKey.PLAIN_PWD value type: String Possible value is a plain password or null
*/
public static final int EVENT_POST_USER_PROFILE_SAVE = EVENT_USER_BASE + 15;
public static final int EVENT_POST_RESET_PASSWORD = EVENT_USER_BASE + 16;
/**
* These three events send the same parameters
* events: List<Integer>
*
* params: Object converted into Map<String, Object>
* key value pairs: @EventParamKey.GROUP_BEAN value type: @TPersonBean
* @EventParamKey.MEMBERS value type: List<Integer> a list of
* persons which are members of the group
*
*
*
*/
public static final int EVENT_POST_GROUP_SAVE = EVENT_USER_BASE + 17;
public static final int EVENT_POST_GROUP_MEMBER_ASSIGN = EVENT_USER_BASE + 18;
public static final int EVENT_POST_GROUP_MEMBER_UNASSIGN = EVENT_USER_BASE + 19;
public static final int EVENT_POST_USER_DELETE = EVENT_USER_BASE + 20;
public static final int EVENT_POST_GROUP_DELETE = EVENT_USER_BASE + 21;
public static final int EVENT_SEND_TWO_FACT_AUTH_CODE = EVENT_USER_BASE + 22;
//system events
public static final int EVENT_SYSTEM_BASE = 2000;
public static final int EVENT_POST_SYSTEM_STARTED = EVENT_SYSTEM_BASE + 1;
public static final int EVENT_PRE_SYSTEM_STOPPED = EVENT_SYSTEM_BASE + 2;
// public static final int EVENT_PRE_SYSTEM_LOCKED = EVENT_SYSTEM_BASE + 3;
// public static final int EVENT_PRE_SYSTEM_UNLOCKED = EVENT_SYSTEM_BASE + 4;
// public static final int EVENT_POST_SYSTEM_UNLOCKED = EVENT_SYSTEM_BASE + 5;
//project events
public static final int EVENT_PROJECT_BASE = 3000;
// public static final int EVENT_PRE_PROJECT_ADDED = EVENT_PROJECT_BASE + 1;
// public static final int EVENT_POST_PROJECT_ADDED = EVENT_PROJECT_BASE + 2;
// public static final int EVENT_PRE_PROJECT_REMOVED = EVENT_PROJECT_BASE + 3;
// public static final int EVENT_POST_PROJECT_REMOVED = EVENT_PROJECT_BASE + 4;
// public static final int EVENT_PRE_PROJECT_STATE_CHANGED = EVENT_PROJECT_BASE + 5;
// public static final int EVENT_POST_PROJECT_STATE_CHANGED = EVENT_PROJECT_BASE + 6;
// public static final int EVENT_PRE_PROJECT_CHANGED = EVENT_PROJECT_BASE + 7;
// public static final int EVENT_POST_PROJECT_CHANGED = EVENT_PROJECT_BASE + 8;
//release events
public static final int EVENT_PRE_RELEASE_ADDED = EVENT_PROJECT_BASE + 9;
// public static final int EVENT_POST_RELEASE_ADDED = EVENT_PROJECT_BASE + 10;
// public static final int EVENT_PRE_RELEASE_STATE_CHANGED = EVENT_PROJECT_BASE + 11;
// public static final int EVENT_POST_RELEASE_STATE_CHANGED = EVENT_PROJECT_BASE + 12;
// public static final int EVENT_PRE_RELEASE_CHANGED = EVENT_PROJECT_BASE + 13;
// public static final int EVENT_POST_RELEASE_CHANGED = EVENT_PROJECT_BASE + 14;
/**
* EventHandler is called like
* update(List<Integer> events, Object eventContextObject) {
* AfterItemSaveEventParam afterItemSaveEventParam =
* (AfterItemSaveEventParam)eventContextObject;
* ....
*/
public static final int EVENT_ISSUE_BASE = 4000;
// public static final int EVENT_PRE_ISSUE_CREATE = EVENT_ISSUE_BASE + 1;
public static final int EVENT_POST_ISSUE_CREATE = EVENT_ISSUE_BASE + 2;
// public static final int EVENT_PRE_ISSUE_UPDATE = EVENT_ISSUE_BASE + 3;
public static final int EVENT_POST_ISSUE_UPDATE = EVENT_ISSUE_BASE + 4;
// public static final int EVENT_PRE_ISSUE_MOVE = EVENT_ISSUE_BASE + 5;
public static final int EVENT_POST_ISSUE_MOVE = EVENT_ISSUE_BASE + 6;
// public static final int EVENT_PRE_ISSUE_COPY = EVENT_ISSUE_BASE + 7;
public static final int EVENT_POST_ISSUE_COPY = EVENT_ISSUE_BASE + 8;
// public static final int EVENT_PRE_ISSUE_CLOSE = EVENT_ISSUE_BASE + 9;
public static final int EVENT_POST_ISSUE_CLOSE = EVENT_ISSUE_BASE + 10;
// public static final int EVENT_PRE_ISSUE_REOPEN = EVENT_ISSUE_BASE + 11;
public static final int EVENT_POST_ISSUE_REOPEN = EVENT_ISSUE_BASE + 12;
// public static final int EVENT_PRE_ISSUE_CREATECHILD = EVENT_ISSUE_BASE + 13;
// public static final int EVENT_POST_ISSUE_CREATECHILD = EVENT_ISSUE_BASE + 14;
// public static final int EVENT_PRE_ISSUE_CHANGESTATUS = EVENT_ISSUE_BASE + 15;
public static final int EVENT_POST_ISSUE_CHANGESTATUS = EVENT_ISSUE_BASE + 16;
// public static final int EVENT_PRE_ISSUE_ADD_COMMENT = EVENT_ISSUE_BASE + 17;
public static final int EVENT_POST_ISSUE_ADD_COMMENT = EVENT_ISSUE_BASE + 18;
// public static final int EVENT_PRE_ISSUE_ASSIGNRESPONSIBLE = EVENT_ISSUE_BASE + 19;
public static final int EVENT_POST_ISSUE_ASSIGNRESPONSIBLE = EVENT_ISSUE_BASE + 20;
// public static final int EVENT_PRE_ISSUE_ASSIGNMANAGER = EVENT_ISSUE_BASE + 21;
public static final int EVENT_POST_ISSUE_ASSIGNMANAGER = EVENT_ISSUE_BASE + 22;
// public static final int EVENT_PRE_ISSUE_CHANGEDATE = EVENT_ISSUE_BASE + 23;
public static final int EVENT_POST_ISSUE_CHANGEDATE = EVENT_ISSUE_BASE + 24;
// public static final int EVENT_PRE_ISSUE_DELETE = EVENT_ISSUE_BASE + 25;
// public static final int EVENT_POST_ISSUE_DELETE = EVENT_ISSUE_BASE + 26;
//comment
public static final int EVENT_PRE_ISSUE_EDIT_COMMENT = EVENT_ISSUE_BASE + 27;
public static final int EVENT_POST_ISSUE_EDIT_COMMENT = EVENT_ISSUE_BASE + 28;
// public static final int EVENT_PRE_ISSUE_DELETE_COMMENT = EVENT_ISSUE_BASE + 29;
public static final int EVENT_POST_ISSUE_DELETE_COMMENT = EVENT_ISSUE_BASE + 30;
//attachment
// public static final int EVENT_PRE_ISSUE_ADDATTACHMENT = EVENT_ISSUE_BASE + 31;
public static final int EVENT_POST_ISSUE_ADDATTACHMENT = EVENT_ISSUE_BASE + 32;
// public static final int EVENT_PRE_ISSUE_REMOVEATTACHMENT = EVENT_ISSUE_BASE + 33;
public static final int EVENT_POST_ISSUE_REMOVEATTACHMENT = EVENT_ISSUE_BASE + 34;
// public static final int EVENT_PRE_ISSUE_OPENATTACHMENT = EVENT_ISSUE_BASE + 35;
public static final int EVENT_POST_ISSUE_OPENATTACHMENT = EVENT_ISSUE_BASE + 36;
// public static final int EVENT_PRE_ISSUE_MODIFYATTACHMENT = EVENT_ISSUE_BASE + 37;
public static final int EVENT_POST_ISSUE_MODIFYATTACHMENT = EVENT_ISSUE_BASE + 38;
//watcher
//public static final int EVENT_POST_ISSUE_UPDATEWATCHER = EVENT_ISSUE_BASE + 40;
//budget/plan/expense
// public static final int EVENT_PRE_ISSUE_UPDATEPLANNEDVALUE = EVENT_ISSUE_BASE + 41;
public static final int EVENT_POST_ISSUE_UPDATEPLANNEDVALUE = EVENT_ISSUE_BASE + 42;
// public static final int EVENT_PRE_ISSUE_UPDATEREMAININGPLAN = EVENT_ISSUE_BASE + 43;
public static final int EVENT_POST_ISSUE_UPDATEREMAININGPLAN= EVENT_ISSUE_BASE + 44;
// public static final int EVENT_PRE_ISSUE_ADDEXPENSE = EVENT_ISSUE_BASE + 45;
public static final int EVENT_POST_ISSUE_ADDEXPENSE = EVENT_ISSUE_BASE + 46;
// public static final int EVENT_PRE_ISSUE_UPDATEEXPENSE = EVENT_ISSUE_BASE + 47;
public static final int EVENT_POST_ISSUE_UPDATEEXPENSE = EVENT_ISSUE_BASE + 48;
// public static final int EVENT_PRE_ISSUE_DELETEEXPENSE = EVENT_ISSUE_BASE + 49;
public static final int EVENT_POST_ISSUE_DELETEEXPENSE = EVENT_ISSUE_BASE + 50;
// public static final int EVENT_PRE_ISSUE_UPDATEBUDGET = EVENT_ISSUE_BASE + 51;
public static final int EVENT_POST_ISSUE_UPDATEBUDGET = EVENT_ISSUE_BASE + 52;
//watcher
// public static final int EVENT_PRE_ISSUE_ADD_INFORMED = EVENT_ISSUE_BASE + 60;
public static final int EVENT_POST_ISSUE_ADD_INFORMED = EVENT_ISSUE_BASE + 61;
// public static final int EVENT_PRE_ISSUE_ADD_CONSULTED = EVENT_ISSUE_BASE + 62;
public static final int EVENT_POST_ISSUE_ADD_CONSULTED = EVENT_ISSUE_BASE + 63;
// public static final int EVENT_PRE_ISSUE_DELETE_INFORMED = EVENT_ISSUE_BASE + 64;
public static final int EVENT_POST_ISSUE_DELETE_INFORMED = EVENT_ISSUE_BASE + 65;
// public static final int EVENT_PRE_ISSUE_DELETE_CONSULTED = EVENT_ISSUE_BASE + 66;
public static final int EVENT_POST_ISSUE_DELETE_CONSULTED = EVENT_ISSUE_BASE + 67;
//workflow related events
// public static final int EVENT_PRE_EXLICIT_STATUS_CHANGE_IN_ISSUE= EVENT_ISSUE_BASE + 70;
public static final int EVENT_POST_EXLICIT_STATUS_CHANGE_IN_ISSUE= EVENT_ISSUE_BASE + 71;
//e-mail sent from item
//before sending the e-mail from item
// public static final int EVENT_PRE_EMAIL_SENT_FROM_ISSUE = EVENT_ISSUE_BASE + 80;
//after sending the e-mail form item
public static final int EVENT_POST_EMAIL_SENT_FROM_ISSUE = EVENT_ISSUE_BASE + 81;
//by loading the send item e-mail form from item
public static final int EVENT_SEND_EMAIL_FROM_ITEM = EVENT_ISSUE_BASE + 82;
//internal comment
// public static final int EVENT_PRE_ISSUE_ADD_INTERNAL_COMMENT = EVENT_ISSUE_BASE + 90;
public static final int EVENT_POST_ISSUE_ADD_INTERNAL_COMMENT = EVENT_ISSUE_BASE + 91;
// public static final int EVENT_PRE_ISSUE_EDIT_INTERNAL_COMMENT = EVENT_ISSUE_BASE + 92;
public static final int EVENT_POST_ISSUE_EDIT_INTERNAL_COMMENT = EVENT_ISSUE_BASE + 93;
// public static final int EVENT_PRE_ISSUE_DELETE_INTERNAL_COMMENT = EVENT_ISSUE_BASE + 94;
public static final int EVENT_POST_ISSUE_DELETE_INTERNAL_COMMENT= EVENT_ISSUE_BASE + 95;
//email submission
public static final int EVENT_EMAIL_SUBMISSION_BASE = 5000;
// public static final int EVENT_PRE_ISSUE_CREATE_BY_EMAIL = EVENT_EMAIL_SUBMISSION_BASE + 1;
public static final int EVENT_POST_ISSUE_CREATE_BY_EMAIL = EVENT_EMAIL_SUBMISSION_BASE + 2;
// public static final int EVENT_PRE_ISSUE_UPDATE_BY_EMAIL = EVENT_EMAIL_SUBMISSION_BASE + 3;
public static final int EVENT_POST_ISSUE_UPDATE_BY_EMAIL = EVENT_EMAIL_SUBMISSION_BASE + 4;
public static final int EVENT_POST_ISSUE_CREATE_BY_EMAIL_REJECTED = EVENT_EMAIL_SUBMISSION_BASE + 5;
//field changed on the client side
// public static final int FIELD_CHANGED = 6000;
public static final int EVENT_CALENDAR_CHANGE = 7000;
// public static final int EVENT_NOTIFICATION_SAVED = 8000;
// This is all that is known for right now. If additional
// are required they have to be implemented in the server
// code, not just in the observer classes!
/**
* React on the event(s)
* @param events
* @param eventContextObject
*/
public boolean update(List<Integer> events, Object eventContextObject);
/**
* Gets the list of interested events for this subscriber
* @return
*/
public List<Integer> getInterestedEvents();
}
/*
* This file is part of the Allegra application, a
* tool for project and change management.
*
* Copyright (C) 2007 Trackplus
*
* Use and distribution of this software is governed by the
* Track+ license conditions.
*
* $Id: AfterItemSaveEventParam.java 6217 2014-05-19 14:45:54Z tamas $
*
* Author: <Tamas Ruff>
*
*/
package com.aurel.track.util.event.parameters;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import com.aurel.track.beans.TFieldConfigBean;
import com.aurel.track.beans.TPersonBean;
import com.aurel.track.beans.TWorkItemBean;
import com.aurel.track.fieldType.runtime.base.HistoryContextBean;
public class AfterItemSaveEventParam implements EventParam {
protected TWorkItemBean workItem;
protected TWorkItemBean workItemOld;
protected Set<Integer> interestingFields;
/**
* Whether the item is created now from an e-mail
*/
protected boolean createFromEmail;
protected Map<Integer, TFieldConfigBean> fieldConfigs;
//the locale of the user triggering the event
protected Locale locale;
/**
* The person who executed the item operation
**/
protected TPersonBean personBean;
/**
* Addresses which not receive e-mail notifications if e-mail from item is sent directly to them
*/
private Set<String> excludedEMailAddresses;
private Map<Integer, HistoryContextBean> fieldIDToHistoryCtx;
/**
* @return the specifiedFields
*/
public Set<Integer> getInterestingFields() {
return interestingFields;
}
/**
* @param specifiedFields the specifiedFields to set
*/
public void setInterestingFields(Set<Integer> specifiedFields) {
this.interestingFields = specifiedFields;
}
/**
* @return the workItemNew
*/
public TWorkItemBean getWorkItem() {
return workItem;
}
/**
* @param workItem the workItemNew to set
*/
public void setWorkItem(TWorkItemBean workItem) {
this.workItem = workItem;
}
/**
* @return the workItemOld
*/
public TWorkItemBean getWorkItemOld() {
return workItemOld;
}
/**
* @param workItemOld the workItemOld to set
*/
public void setWorkItemOld(TWorkItemBean workItemOld) {
this.workItemOld = workItemOld;
}
/**
* @return the fieldConfigs
*/
public Map<Integer, TFieldConfigBean> getFieldConfigs() {
return fieldConfigs;
}
/**
* @param fieldConfigs the fieldConfigs to set
*/
public void setFieldConfigs(Map<Integer, TFieldConfigBean> fieldConfigs) {
this.fieldConfigs = fieldConfigs;
}
public Locale getLocale() {
return locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
public TPersonBean getPersonBean() {
return personBean;
}
public void setPersonBean(TPersonBean personBean) {
this.personBean = personBean;
}
public boolean isCreateFromEmail() {
return createFromEmail;
}
public void setCreateFromEmail(boolean createFromEmail) {
this.createFromEmail = createFromEmail;
}
public Map<Integer, HistoryContextBean> getFieldIDToHistoryCtx() {
return fieldIDToHistoryCtx;
}
public void setFieldIDToHistoryCtx(Map<Integer, HistoryContextBean> fieldIDToHistoryCtx) {
this.fieldIDToHistoryCtx = fieldIDToHistoryCtx;
}
public Set<String> getExcludedEMailAddresses() {
return excludedEMailAddresses;
}
public void setExcludedEMailAddresses(Set<String> excludedEMailAddresses) {
this.excludedEMailAddresses = excludedEMailAddresses;
}
}