Пример #1
0
  public void testDisabledUser() throws Exception {
    User u =
        CommonsUtils.getService(OrganizationService.class)
            .getUserHandler()
            .createUserInstance("binh");
    u.setEmail("email@test");
    u.setFirstName("first");
    u.setLastName("last");
    u.setPassword("pwdADDSomeSaltToBeCompliantWithSomeIS00");
    CommonsUtils.getService(OrganizationService.class).getUserHandler().createUser(u, true);

    userSettingService.save(createUserSetting("binh", null, null, null));
    UserSetting userSetting = userSettingService.get("binh");
    assertTrue(userSetting.isChannelActive(MailChannel.ID));
    assertTrue(userSetting.isEnabled());

    // disable user "root"
    CommonsUtils.getService(OrganizationService.class)
        .getUserHandler()
        .setEnabled("binh", false, true);
    userSetting = userSettingService.get("binh");
    assertTrue(userSetting.isChannelActive(MailChannel.ID));
    assertFalse(userSetting.isEnabled());

    // enable user "root" but not change the active channel status
    CommonsUtils.getService(OrganizationService.class)
        .getUserHandler()
        .setEnabled("binh", true, true);
    userSetting = userSettingService.get("binh");
    assertTrue(userSetting.isChannelActive(MailChannel.ID));
    assertTrue(userSetting.isEnabled());

    CommonsUtils.getService(OrganizationService.class).getUserHandler().removeUser("binh", false);
    assertNull(
        CommonsUtils.getService(OrganizationService.class).getUserHandler().findUserByName("binh"));
  }
Пример #2
0
  @Override
  public void process(NotificationContext ctx, String... userIds) {
    NotificationInfo notification = ctx.getNotificationInfo();
    String pluginId = notification.getKey().getId();
    UserSettingService userService =
        (UserSettingService)
            ExoContainerContext.getCurrentContainer()
                .getComponentInstanceOfType(UserSettingService.class);

    for (String userId : userIds) {
      UserSetting userSetting = userService.get(userId);
      // check channel active for user
      if (!userSetting.isChannelActive(getChannel().getId())) {
        continue;
      }

      if (userSetting.isActive(getChannel().getId(), pluginId)) {
        process(ctx.setNotificationInfo(notification.clone(true).setTo(userId)), userId);
      }
    }
  }