private void onStartConversation(GwtConversation conversation) { User user = conversation.getSession().getUser(); if (user == null) throw new PermissionDeniedException("Login required."); conversation.clearRemoteEntities(); conversation.getNextData().applicationInfo = webApplication.getApplicationInfo(); conversation.sendToClient(webApplication.getSystemConfig()); conversation.getNextData().setUserId(user.getId()); conversation.sendUserScopeDataToClient(user); }
@Override public void onResetPassword(GwtConversation conversation, String userId) { if (!conversation.getSession().getUser().isAdmin()) throw new PermissionDeniedException(); User user = userDao.getById(userId); if (webApplication.getSystemConfig().isSmtpServerSet() && user.isEmailSet()) { user.triggerPasswordReset(); } else { user.setPassword(webApplication.getSystemConfig().getDefaultUserPassword()); } }
private void postProjectEvent(GwtConversation conversation, String message, AEntity subject) { assertProjectSelected(conversation); Project project = conversation.getProject(); webApplication.postProjectEvent(project, message, subject); try { sendProjectEventEmails( message, subject, project, conversation.getSession().getUser().getEmail()); } catch (Throwable ex) { log.error("Sending project event notification emails failed.", ex); } }
@Override public void onTestLdap(GwtConversation conversation) { SystemConfig config = webApplication.getSystemConfig(); try { Ldap.authenticateUserGetEmail( config.getLdapUrl(), config.getLdapUser(), config.getLdapPassword(), config.getLdapBaseDn(), config.getLdapUserFilterRegex(), "dummyUser", "dummyPassword"); } catch (AuthenticationFailedException ex) { } }
@Override public void onDeleteEntity(GwtConversation conversation, String entityId) { AEntity entity = getDaoService().getEntityById(entityId); User user = conversation.getSession().getUser(); if (!Auth.isDeletable(entity, user)) throw new PermissionDeniedException(); if (entity instanceof File) { File file = (File) entity; file.deleteFile(); } if (entity instanceof Task) { // update sprint day snapshot before delete conversation .getProject() .getCurrentSprint() .getDaySnapshot(Date.today()) .updateWithCurrentSprint(); } ADao dao = getDaoService().getDao(entity); dao.deleteEntity(entity); if (entity instanceof Task) onTaskDeleted(conversation, (Task) entity); Project project = conversation.getProject(); if (project != null) { for (GwtConversation c : webApplication.getConversationsByProject(project, conversation)) { c.getNextData().addDeletedEntity(entityId); } } if (user != null && project != null) { ProjectUserConfig config = project.getUserConfig(user); config.touch(); sendToClients(conversation, config); } }
private void onSystemConfigChanged( GwtConversation conversation, SystemConfig config, Map properties) { if (properties.containsKey("url")) { webApplication.getConfig().setUrl(config.getUrl()); } }
@Override public void onLogout(GwtConversation conversation) { WebSession session = conversation.getSession(); webApplication.destroyWebSession(session, getThreadLocalRequest().getSession()); }
@Override public void onUpdateSystemMessage(GwtConversation conversation, SystemMessage systemMessage) { User user = conversation.getSession().getUser(); if (user == null || user.isAdmin() == false) throw new PermissionDeniedException(); webApplication.updateSystemMessage(systemMessage); }
private void sendToClients(GwtConversation conversation, AEntity entity) { webApplication.sendToConversationsByProject(conversation, entity); }
private String createProjectEventEmailText(Project project, String message, AEntity subject) { StringBuilder sb = new StringBuilder(); sb.append(message).append("\n"); sb.append(webApplication.createUrl(project, subject)).append("\n"); return sb.toString(); }