mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
clear cache only on a post event
This commit is contained in:
@@ -44,33 +44,75 @@ public enum HandlerEvent
|
||||
/**
|
||||
* After a new object is stored by a handler.
|
||||
*/
|
||||
CREATE,
|
||||
CREATE(true),
|
||||
|
||||
/**
|
||||
* After a object is modified by a handler.
|
||||
*/
|
||||
MODIFY,
|
||||
MODIFY(true),
|
||||
|
||||
/**
|
||||
* After a object is removed by a handler.
|
||||
*/
|
||||
DELETE,
|
||||
DELETE(true),
|
||||
|
||||
/**
|
||||
* Before a new object is stored by a handler.
|
||||
* @since 1.16
|
||||
*/
|
||||
BEFORE_CREATE,
|
||||
BEFORE_CREATE(false),
|
||||
|
||||
/**
|
||||
* Before a object is modified by a handler.
|
||||
* @since 1.16
|
||||
*/
|
||||
BEFORE_MODIFY,
|
||||
BEFORE_MODIFY(false),
|
||||
|
||||
/**
|
||||
* Before a object is removed by a handler.
|
||||
* @since 1.16
|
||||
*/
|
||||
BEFORE_DELETE
|
||||
BEFORE_DELETE(false);
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
*
|
||||
* @param post
|
||||
*/
|
||||
private HandlerEvent(boolean post)
|
||||
{
|
||||
this.post = post;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if the event is fired after the action is occurred.
|
||||
*
|
||||
*
|
||||
* @return true if the event is fired after the action is occurred
|
||||
* @since 1.21
|
||||
*/
|
||||
public boolean isPost()
|
||||
{
|
||||
return post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the event is fired before the action is occurred.
|
||||
*
|
||||
*
|
||||
* @return true if the event is fired before the action is occurred
|
||||
* @since 1.21
|
||||
*/
|
||||
public boolean isPre()
|
||||
{
|
||||
return !post;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
private boolean post;
|
||||
}
|
||||
|
||||
@@ -158,6 +158,9 @@ public class ScmRealm extends AuthorizingRealm
|
||||
@Override
|
||||
public void onEvent(Repository repository, HandlerEvent event)
|
||||
{
|
||||
if (event.isPost())
|
||||
{
|
||||
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("clear cache, because repository {} has changed",
|
||||
@@ -166,6 +169,7 @@ public class ScmRealm extends AuthorizingRealm
|
||||
|
||||
cache.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
@@ -176,6 +180,8 @@ public class ScmRealm extends AuthorizingRealm
|
||||
*/
|
||||
@Override
|
||||
public void onEvent(User user, HandlerEvent event)
|
||||
{
|
||||
if (event.isPost())
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
@@ -186,6 +192,7 @@ public class ScmRealm extends AuthorizingRealm
|
||||
|
||||
cache.remove(user.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
|
||||
Reference in New Issue
Block a user