コード例 #1
0
  protected Locale getCurrentLocale() {
    IWContext iwc = CoreUtil.getIWContext();
    Locale locale = iwc == null ? null : iwc.getCurrentLocale();

    if (locale == null) {
      locale = IWMainApplication.getDefaultIWMainApplication().getDefaultLocale();
    }

    return locale == null ? Locale.ENGLISH : locale;
  }
  protected List<User> getUsersHavingHandlerRole() {
    String roleKey = getHandlerRoleKey();
    if (StringUtil.isEmpty(roleKey)) {
      return null;
    }

    IWApplicationContext iwac = IWMainApplication.getDefaultIWApplicationContext();
    AccessController accessControler =
        IWMainApplication.getDefaultIWMainApplication().getAccessController();
    Collection<Group> groupsWithRole = accessControler.getAllGroupsForRoleKey(roleKey, iwac);
    if (ListUtil.isEmpty(groupsWithRole)) {
      return null;
    }

    UserBusiness userBusiness = getUserBusiness();
    if (userBusiness == null) {
      return null;
    }

    List<User> users = new ArrayList<User>();
    for (Group group : groupsWithRole) {
      if (group instanceof User) {
        User user = (User) group;
        if (!users.contains(user)) {
          users.add(user);
        }
      } else {
        Collection<User> usersInGroup = null;
        try {
          usersInGroup = userBusiness.getUsersInGroup(group);
        } catch (Exception e) {
          LOGGER.log(Level.WARNING, "Error getting users in group: " + group, e);
        }
        if (!ListUtil.isEmpty(usersInGroup)) {
          for (User user : usersInGroup) {
            if (!users.contains(user)) {
              users.add(user);
            }
          }
        }
      }
    }

    return users;
  }
  public String getUriToAttachment(String commentId, ICFile attachment, User user) {
    URIUtil uri = new URIUtil(IWMainApplication.getDefaultIWMainApplication().getMediaServletURI());

    uri.setParameter(
        MediaWritable.PRM_WRITABLE_CLASS,
        IWMainApplication.getEncryptedClassName(CommentAttachmentDownloader.class));
    uri.setParameter(ArticleCommentAttachmentStatisticsViewer.COMMENT_ID_PARAMETER, commentId);
    uri.setParameter(
        ArticleCommentAttachmentStatisticsViewer.COMMENT_ATTACHMENT_ID_PARAMETER,
        attachment.getPrimaryKey().toString());

    if (user != null) {
      uri.setParameter(LoginBusinessBean.PARAM_LOGIN_BY_UNIQUE_ID, user.getUniqueId());
      uri.setParameter(LoginBusinessBean.LoginStateParameter, LoginBusinessBean.LOGIN_EVENT_LOGIN);
    }

    return uri.getUri();
  }
コード例 #4
0
 protected IWMainApplication getApplication() {
   return IWMainApplication.getDefaultIWMainApplication();
 }