*/
@SuppressWarnings ("CollectionWithoutInitialCapacity")
public FinancialsUserActivityWebApplicationBean () {
- // Try to get EJB instance
- try {
- // Get initial context
- Context context = new InitialContext();
-
- // Try to lookup
- this.userActivityBean = (UserActivityLogSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote"); //NOI18N
- } catch (final NamingException e) {
- // Throw again
- throw new FaceletException(e);
- }
-
// Init cache
this.usersActivity = new LinkedHashMap<>();
}
- /**
- * Adds user activity entry with given type
- * <p>
- * @param user User instance
- * @param activityType Activity type
- */
- private void addUserActivity (final User user, final String activityType) {
- // Better re-validate
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
- } else if (null == activityType) {
- // Throw NPE again
- throw new NullPointerException("activityType is null"); //NOI18N
- } else if (activityType.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("activityType is empty"); //NOI18N
- }
-
- // Create new activity object
- LogableUserActivity userActivity = new UserActivityLog(activityType, user, new GregorianCalendar(), this.determinePrincipalName());
-
- // Call bean to add it
- this.userActivityBean.addUserActivityLog(userActivity);
-
- // Add to cache, too
- this.addUserActivityToCache(userActivity);
- }
-
- /**
- * Adds user activity log with type and message
- * <p>
- * @param user User instance
- * @param activityType Activity type
- * @param message Activity message
- */
- private void addUserActivity (final User user, final String activityType, final String message) {
- // Better re-validate
- if (null == user) {
- // Throw NPE
- throw new NullPointerException("user is null"); //NOI18N
- } else if (user.getUserId() == null) {
- // Throw again
- throw new NullPointerException("user.userId is null"); //NOI18N
- } else if (user.getUserId() < 1) {
- // Invalid id number
- throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
- } else if (null == activityType) {
- // Throw NPE again
- throw new NullPointerException("activityType is null"); //NOI18N
- } else if (activityType.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("activityType is empty"); //NOI18N
- } else if (null == message) {
- // Throw NPE again
- throw new NullPointerException("message is null"); //NOI18N
- } else if (message.isEmpty()) {
- // Is empty
- throw new IllegalArgumentException("message is empty"); //NOI18N
- }
-
- // Create new activity object
- LogableUserActivity userActivity = new UserActivityLog(message, activityType, user, new GregorianCalendar(), this.determinePrincipalName());
-
- // Call bean to add it
- this.userActivityBean.addUserActivityLog(userActivity);
-
- // Add to cache, too
- this.addUserActivityToCache(userActivity);
- }
-
/**
* Event observer for newly added users by administrator
* <p>
*/
@PostConstruct
public void init () {
+ // Try to get EJB instance
+ try {
+ // Get initial context
+ Context context = new InitialContext();
+
+ // Try to lookup
+ this.userActivityBean = (UserActivityLogSessionBeanRemote) context.lookup("java:global/jfinancials-ejb/userActivity!org.mxchange.jusercore.model.user.activity.UserActivityLogSessionBeanRemote"); //NOI18N
+ } catch (final NamingException e) {
+ // Throw again
+ throw new FaceletException(e);
+ }
+
// Get whole list
List<LogableUserActivity> list = this.userActivityBean.fetchAllUserActivityLog();
}
}
+ /**
+ * Adds user activity entry with given type
+ * <p>
+ * @param user User instance
+ * @param activityType Activity type
+ */
+ private void addUserActivity (final User user, final String activityType) {
+ // Better re-validate
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (null == activityType) {
+ // Throw NPE again
+ throw new NullPointerException("activityType is null"); //NOI18N
+ } else if (activityType.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("activityType is empty"); //NOI18N
+ }
+
+ // Create new activity object
+ LogableUserActivity userActivity = new UserActivityLog(activityType, user, new GregorianCalendar(), this.determinePrincipalName());
+
+ // Call bean to add it
+ this.userActivityBean.addUserActivityLog(userActivity);
+
+ // Add to cache, too
+ this.addUserActivityToCache(userActivity);
+ }
+
+ /**
+ * Adds user activity log with type and message
+ * <p>
+ * @param user User instance
+ * @param activityType Activity type
+ * @param message Activity message
+ */
+ private void addUserActivity (final User user, final String activityType, final String message) {
+ // Better re-validate
+ if (null == user) {
+ // Throw NPE
+ throw new NullPointerException("user is null"); //NOI18N
+ } else if (user.getUserId() == null) {
+ // Throw again
+ throw new NullPointerException("user.userId is null"); //NOI18N
+ } else if (user.getUserId() < 1) {
+ // Invalid id number
+ throw new IllegalArgumentException(MessageFormat.format("user.userId={0} is not valid", user.getUserId())); //NOI18N
+ } else if (null == activityType) {
+ // Throw NPE again
+ throw new NullPointerException("activityType is null"); //NOI18N
+ } else if (activityType.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("activityType is empty"); //NOI18N
+ } else if (null == message) {
+ // Throw NPE again
+ throw new NullPointerException("message is null"); //NOI18N
+ } else if (message.isEmpty()) {
+ // Is empty
+ throw new IllegalArgumentException("message is empty"); //NOI18N
+ }
+
+ // Create new activity object
+ LogableUserActivity userActivity = new UserActivityLog(message, activityType, user, new GregorianCalendar(), this.determinePrincipalName());
+
+ // Call bean to add it
+ this.userActivityBean.addUserActivityLog(userActivity);
+
+ // Add to cache, too
+ this.addUserActivityToCache(userActivity);
+ }
+
/**
* Adds given user activity instance to "cache" (local map)
* <p>