Example #1
0
 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);
 }
Example #2
0
 @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());
   }
 }
Example #3
0
  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);
    }
  }
Example #4
0
 @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) {
   }
 }
Example #5
0
  @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);
    }
  }
Example #6
0
 private void onSystemConfigChanged(
     GwtConversation conversation, SystemConfig config, Map properties) {
   if (properties.containsKey("url")) {
     webApplication.getConfig().setUrl(config.getUrl());
   }
 }
Example #7
0
 @Override
 public void onLogout(GwtConversation conversation) {
   WebSession session = conversation.getSession();
   webApplication.destroyWebSession(session, getThreadLocalRequest().getSession());
 }
Example #8
0
 @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);
 }
Example #9
0
 private void sendToClients(GwtConversation conversation, AEntity entity) {
   webApplication.sendToConversationsByProject(conversation, entity);
 }
Example #10
0
 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();
 }