/** * Simple call to {@link CallContext#current()} to retrieve the current calling account. * This method facilitates unit testing, it avoids mocking static methods. */ protected Account getCurrentAccount() { return CallContext.current().getCallingAccount(); }
private Long getSnapshotUserId() { Long userId = CallContext.current().getCallingUserId(); if (userId == null) { return User.UID_SYSTEM; } return userId; }
public static void setActionEventInfo(String eventType, String description) { CallContext context = CallContext.current(); if (context != null) { context.setEventType(eventType); context.setEventDescription(description); } }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
@Override public Object onEnterContext(boolean reentry) { if (!reentry && CallContext.current() == null) { CallContext.registerSystemCallContextOnceOnly(); } return null; }
public static void unregisterAll() { while (unregister() != null) { // NOOP } }
public static void setActionEventInfo(String eventType, String description) { LogContext context = LogContext.current(); if (context != null) { context.setEventType(eventType); context.setEventDescription(description); } }
@Override public void onLeaveContext(Object unused, boolean reentry) { if (!reentry) { CallContext.unregisterAll(); } }
@Override public Object onEnterContext(boolean reentry) { if (!reentry && LogContext.current() == null) { LogContext.registerSystemLogContextOnceOnly(); } return null; }
@Override public void onLeaveContext(Object unused, boolean reentry) { if (!reentry) { LogContext.unregister(); } }
/** * This method should only be called if you can propagate the context id * from another LogContext. * * @param callingUser calling user * @param callingAccount calling account * @param contextId context id propagated from another call context * @return LogContext */ public static LogContext register(User callingUser, Account callingAccount, String contextId) { return register(callingUser, callingAccount, null, null, contextId); }
@Override final public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
/** * Returns the calling account using the method {@link CallContext#getCallingAccount()}. * We are introducing this method to avoid using 'PowerMockRunner' in unit tests. Then, we can mock the calls to this method, which facilitates the development of test cases. */ protected Account getCurrentCallingAccount() { return CallContext.current().getCallingAccount(); }
public long getAutoscaleUserId() { if (autoscaleUserId != null) { return autoscaleUserId; } else { return CallContext.current().getCallingUserId(); } }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
/** * @return */ protected Account getCaller() { final Account caller = CallContext.current().getCallingAccount(); return caller; }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }
@Override public long getEntityOwnerId() { return CallContext.current().getCallingAccountId(); }