improve modification events to pass the item before it was modified to the subscriber

This commit is contained in:
Sebastian Sdorra
2016-06-25 21:48:53 +02:00
parent 1eb5a6c9ad
commit 8e3c3e4b63
13 changed files with 317 additions and 28 deletions

View File

@@ -222,13 +222,14 @@ public class DefaultGroupManager extends AbstractGroupManager
String name = group.getName();
if (groupDAO.contains(name))
Group notModified = groupDAO.get(name);
if (notModified != null)
{
removeDuplicateMembers(group);
fireEvent(new GroupModificationEvent(group, notModified, HandlerEvent.BEFORE_MODIFY));
group.setLastModified(System.currentTimeMillis());
fireEvent(group, HandlerEvent.BEFORE_MODIFY);
groupDAO.modify(group);
fireEvent(group, HandlerEvent.MODIFY);
fireEvent(new GroupModificationEvent(group, notModified, HandlerEvent.MODIFY));
}
else
{

View File

@@ -373,7 +373,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
if (notModifiedRepository != null)
{
assertIsOwner(notModifiedRepository);
fireEvent(repository, HandlerEvent.BEFORE_MODIFY);
fireEvent(new RepositoryModificationEvent(repository, notModifiedRepository, HandlerEvent.BEFORE_MODIFY));
repository.setLastModified(System.currentTimeMillis());
getHandler(repository).modify(repository);
repositoryDAO.modify(repository);
@@ -384,7 +384,7 @@ public class DefaultRepositoryManager extends AbstractRepositoryManager
"repository ".concat(repository.getName()).concat(" not found"));
}
fireEvent(repository, HandlerEvent.MODIFY);
fireEvent(new RepositoryModificationEvent(repository, notModifiedRepository, HandlerEvent.MODIFY));
}
/**

View File

@@ -280,14 +280,15 @@ public class DefaultUserManager extends AbstractUserManager
}
String name = user.getName();
if (userDAO.contains(name))
User notModified = userDAO.get(name);
if (notModified != null)
{
AssertUtil.assertIsValid(user);
fireEvent(new UserModificationEvent(user, notModified, HandlerEvent.BEFORE_MODIFY));
user.setLastModified(System.currentTimeMillis());
fireEvent(user, HandlerEvent.BEFORE_MODIFY);
userDAO.modify(user);
fireEvent(user, HandlerEvent.MODIFY);
fireEvent(new UserModificationEvent(user, notModified, HandlerEvent.MODIFY));
}
else
{