@Override public Object put(Object key, Object value) { Map<String, Object> eventParams = new HashMap<String, Object>(); Object answer; String keyString = (String) key; synchronized (keyString.intern()) { if (properties.containsKey(keyString)) { String originalValue = properties.get(keyString); answer = properties.put(keyString, (String) value); updateProperty(keyString, (String) value); // Configure event. eventParams.put("type", "propertyModified"); eventParams.put("propertyKey", key); eventParams.put("originalValue", originalValue); } else { answer = properties.put(keyString, (String) value); insertProperty(keyString, (String) value); // Configure event. eventParams.put("type", "propertyAdded"); eventParams.put("propertyKey", key); } } // Fire event. UserEventDispatcher.dispatchEvent( User.this, UserEventDispatcher.EventType.user_modified, eventParams); return answer; }
public void setEmail(String email) { if (UserManager.getUserProvider().isReadOnly()) { throw new UnsupportedOperationException("User provider is read-only."); } if (email != null && email.matches("\\s*")) { email = null; } if (UserManager.getUserProvider().isEmailRequired() && !StringUtils.isValidEmailAddress(email)) { throw new IllegalArgumentException("User provider requires email address."); } try { String originalEmail = this.email; UserManager.getUserProvider().setEmail(username, email); this.email = email; // Fire event. Map<String, Object> params = new HashMap<String, Object>(); params.put("type", "emailModified"); params.put("originalValue", originalEmail); UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, params); } catch (UserNotFoundException unfe) { Log.error(unfe.getMessage(), unfe); } }
public void setName(String name) { if (UserManager.getUserProvider().isReadOnly()) { throw new UnsupportedOperationException("User provider is read-only."); } if (name != null && name.matches("\\s*")) { name = null; } if (name == null && UserManager.getUserProvider().isNameRequired()) { throw new IllegalArgumentException("User provider requires name."); } try { String originalName = this.name; UserManager.getUserProvider().setName(username, name); this.name = name; // Fire event. Map<String, Object> params = new HashMap<String, Object>(); params.put("type", "nameModified"); params.put("originalValue", originalName); UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, params); } catch (UserNotFoundException unfe) { Log.error(unfe.getMessage(), unfe); } }
@Override public void stop() { super.stop(); // Clean up the pool of sax readers xmlReaders.clear(); // Remove this module as a user event listener UserEventDispatcher.removeListener(this); }
@Override public void start() throws IllegalStateException { super.start(); // Initialize the pool of sax readers for (int i = 0; i < POOL_SIZE; i++) { SAXReader xmlReader = new SAXReader(); xmlReader.setEncoding("UTF-8"); xmlReaders.add(xmlReader); } // Add this module as a user event listener so we can delete // all offline messages when a user is deleted UserEventDispatcher.addListener(this); }
/** * Sets a new password for this user. * * @param password the new password for the user. * @throws UnsupportedOperationException exception */ public void setPassword(String password) throws UnsupportedOperationException { if (UserManager.getUserProvider().isReadOnly()) { throw new UnsupportedOperationException("User provider is read-only."); } try { AuthFactory.getAuthProvider().setPassword(username, password); // Fire event. Map<String, Object> params = new HashMap<String, Object>(); params.put("type", "passwordModified"); UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, params); } catch (UserNotFoundException unfe) { Log.error(unfe.getMessage(), unfe); } }
public void setModificationDate(Date modificationDate) { if (UserManager.getUserProvider().isReadOnly()) { throw new UnsupportedOperationException("User provider is read-only."); } try { Date originalModificationDate = this.modificationDate; UserManager.getUserProvider().setCreationDate(username, modificationDate); this.modificationDate = modificationDate; // Fire event. Map<String, Object> params = new HashMap<String, Object>(); params.put("type", "nameModified"); params.put("originalValue", originalModificationDate); UserEventDispatcher.dispatchEvent(this, UserEventDispatcher.EventType.user_modified, params); } catch (UserNotFoundException unfe) { Log.error(unfe.getMessage(), unfe); } }