Event logs added

This commit is contained in:
Mauro Mugnaini 2020-06-25 12:34:21 +02:00
parent 0e76d41afd
commit 92306088e6
6 changed files with 49 additions and 12 deletions

View File

@ -22,7 +22,11 @@ public class PostLoginAction extends Action {
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
eventPublisher.publish(ActionEvent.newLoginEvent(request, response));
ActionEvent actionEvent = ActionEvent.newLoginEvent(request, response);
if (log.isDebugEnabled()) {
log.debug("ActionEvent is: " + actionEvent);
}
eventPublisher.publish(actionEvent);
}
}

View File

@ -22,7 +22,11 @@ public class PreLogoutAction extends Action {
@Override
public void run(HttpServletRequest request, HttpServletResponse response) throws ActionException {
eventPublisher.publish(ActionEvent.newLogoutEvent(request, response));
ActionEvent actionEvent = ActionEvent.newLogoutEvent(request, response);
if (log.isDebugEnabled()) {
log.debug("ActionEvent is: " + actionEvent);
}
eventPublisher.publish(actionEvent);
}
}

View File

@ -19,10 +19,11 @@ public class StartupAction extends SimpleAction {
@Override
public void run(String[] ids) throws ActionException {
SimpleActionEvent event = SimpleActionEvent.newStartupEvent(ids);
if (log.isInfoEnabled()) {
log.info("Sending startup event");
log.info("Sending startup event: " + event);
}
eventPublisher.publish(SimpleActionEvent.newStartupEvent(ids));
eventPublisher.publish(event);
}
}

View File

@ -8,7 +8,12 @@ public class GroupEventPublisher extends AbstractEventPublisherBaseModelListener
@Override
public void onAfterCreate(Group group) throws ModelListenerException {
if (group.isSite()) {
publish(GroupEvent.newCreatedEvent(group));
log.info("Created a site Group");
GroupEvent groupEvent = GroupEvent.newCreatedEvent(group);
if (log.isDebugEnabled()) {
log.debug("Group event is: " + groupEvent);
}
publish(groupEvent);
} else {
log.info("Created a non-site Group");
}
@ -17,7 +22,12 @@ public class GroupEventPublisher extends AbstractEventPublisherBaseModelListener
@Override
public void onBeforeRemove(Group group) throws ModelListenerException {
if (group.isSite()) {
publish(GroupEvent.newDeletedEvent(group));
log.info("Deleted a site Group");
GroupEvent groupEvent = GroupEvent.newDeletedEvent(group);
if (log.isDebugEnabled()) {
log.debug("Group event is: " + groupEvent);
}
publish(groupEvent);
} else {
log.info("Deleted a non-site Group");
}

View File

@ -7,12 +7,22 @@ public class UserEventPublisher extends AbstractEventPublisherBaseModelListener<
@Override
public void onAfterCreate(User user) throws ModelListenerException {
publish(UserEvent.newCreatedEvent(user));
log.info("New user created");
UserEvent userEvent = UserEvent.newCreatedEvent(user);
if (log.isDebugEnabled()) {
log.debug("User event is: " + userEvent);
}
publish(userEvent);
}
@Override
public void onBeforeRemove(User user) throws ModelListenerException {
publish(UserEvent.newDeletedEvent(user));
log.info("User removed");
UserEvent userEvent = UserEvent.newDeletedEvent(user);
if (log.isDebugEnabled()) {
log.debug("User event is: " + userEvent);
}
publish(userEvent);
}
/* Uninteresting model events */

View File

@ -13,10 +13,17 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
try {
Group group = userGroupRole.getGroup();
if (group.isSite()) {
publish(UserGroupRoleEvent.newCreatedEvent(userGroupRole, userGroupRole.getUser(), group,
userGroupRole.getRole()));
log.info("Created a site user's group role");
UserGroupRoleEvent event = UserGroupRoleEvent.newCreatedEvent(userGroupRole, userGroupRole.getUser(),
group,
userGroupRole.getRole());
if (log.isDebugEnabled()) {
log.debug("Event is: " + event);
}
publish(event);
} else {
log.info("Created a non-site group's role");
log.info("Created a non-site user's group role");
}
} catch (PortalException | SystemException e) {
log.error("Cannot get related model objects", e);
@ -29,10 +36,11 @@ public class UserGroupRoleEventPublisher extends AbstractEventPublisherBaseModel
try {
Group group = userGroupRole.getGroup();
if (group.isSite()) {
log.info("Deleted a site user's group role");
publish(UserGroupRoleEvent.newDeletedEvent(userGroupRole, userGroupRole.getUser(), group,
userGroupRole.getRole()));
} else {
log.info("Deleted a non-site group's role");
log.info("Deleted a non-site user's group role");
}
} catch (PortalException | SystemException e) {
log.error("Cannot get related model objects", e);