Package org.nemesis.forum

Examples of org.nemesis.forum.Forum


    ActionErrors errors = new ActionErrors();

    try {

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      request.setAttribute("id", request.getParameter("id"));
      //check permission
      checkPermission(request, OperationConstants.EDIT_FORUM_FILTER, forum);
     
      MessageFilter filter= forum.getForumMessageFilters()[Integer.parseInt(request.getParameter("edit"))];
      Enumeration props = filter.getFilterPropertyNames();
      while( props.hasMoreElements() ) {
        String propName = (String)props.nextElement();
        String propValue = request.getParameter(propName);
        if( propValue != null ) {
View Full Code Here


    ActionErrors errors = new ActionErrors();
    boolean isRootmessage=false;
    try {

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      request.setAttribute("id", request.getParameter("id"));
      //check permission
      checkPermission(request, OperationConstants.DELETE_MESSAGE, forum);
     
      ForumThread t=forum.getThread( Integer.parseInt(request.getParameter("threadID")));
      Message m=t.getMessage( Integer.parseInt(request.getParameter("messageID")));
     
      if(t.getRootMessage().getID()==(m.getID()))isRootmessage=true;
     
      t.deleteMessage(m);
View Full Code Here

        User user = manager.getUser(getAuthToken(request).getUserID());
        try {
         
          ForumBean fb=(ForumBean)PropertyUtils.getProperty(form, "forumBean");
          ForumFactory ff =ForumFactory.getInstance(getAuthToken(request));
          Forum f =ff.createForum(fb.getName(),fb.getDescription());
         
          //ForumPermissions permissions = forumFactory.getPermissions(getAuthToken(request));
          //boolean isSystemAdmin = permissions.get(ForumPermissions.SYSTEM_ADMIN);
          //boolean isUserAdmin   = permissions.get(ForumPermissions.FORUM_ADMIN);
         
          //f.addUserPermission(user,Constants.FORUM_ADMIN);
          f.addUserPermission(user,Constants.READ);
          f.addUserPermission(user,Constants.MODERATOR);
          f.addUserPermission(user,Constants.CREATE_THREAD);
          f.addUserPermission(user,Constants.CREATE_MESSAGE);
          f.addUserPermission(user,Constants.FORUM_ADMIN);
          //if(SecurityTools.isSystemAdmin(getAuthToken(request)))
          //f.addUserPermission(user,Constants.SYSTEM_ADMIN);
         
          f.setModerationType(fb.getModerationType());
         
          //properties
          String temp=null;
          for(Iterator it=fb.getProperties().keySet().iterator();it.hasNext();){
            temp=(String)it.next();
            f.setProperty(temp,(String)fb.getProperties().get(temp));
          }
         
         
        }
        catch( AlreadyExistsException aee ) {
View Full Code Here

            + " in DbForumMessage.getForumThread()."
            + " You may wish to delete the message from your database.");
        return null;
      }

      Forum forum = null;
      ForumThread thread = null;
      try {
        forum = factory.getForum(forumID);
        //Now, get the thread
        thread = forum.getThread(threadID);
      } catch (Exception e) {
        log.error("",e);
        return null;
      }
      this.thread = thread;
View Full Code Here

        // ::TODO::search, not very nice
        String query = request.getParameter("query");
        forumIterator =forumFactory.forumsModeration();
        List tempListe = new ArrayList();
        Forum forumTemp = null;
        int c = 0;
        while (forumIterator.hasNext()) {
          forumTemp = (Forum) forumIterator.next();
          if (forumTemp.getName().toLowerCase().indexOf(query.toLowerCase()) > -1
            || forumTemp.getDescription().toLowerCase().indexOf(query.toLowerCase()) > -1
            ) {
            //match
            if(c >= start && c<(start+maxPageItems)){
              tempListe.add(forumTemp);
            }
            c++;
           
          }
        }
        forumIterator = tempListe.iterator();
        request.setAttribute("nbItems", new Integer(c));
        request.setAttribute("query", query);
      } else {
        forumIterator = forumFactory.forumsModeration();
        List tempListe = new ArrayList();
        Forum forumTemp = null;
        int c = 0;
        while (forumIterator.hasNext()) {
          forumTemp = (Forum) forumIterator.next();
          //match
          if(c >= start && c<(start+maxPageItems)){
            tempListe.add(forumTemp);
          }
          c++;
        }
        forumIterator = tempListe.iterator();
        request.setAttribute("nbItems"new Integer(c));
      }
      //populate
      String temp = null;
      ForumBean ub = null;
      Forum forum = null;
      while (forumIterator.hasNext()) {
        forum = (Forum) forumIterator.next();
        ub = new ForumBean();
        ub.setId(forum.getID());
        ub.setName(forum.getName());
        ub.setDescription(forum.getDescription());
        ub.setMessages(forum.getMessageCount());
        ub.setThreads(forum.getThreadCount());
        ub.setModerationType(forum.getModerationType());
       
        ub.setAdmin(SecurityTools.isSystemAdmin(getAuthToken(request)) || SecurityTools.isForumAdmin(getAuthToken(request),forum));
       
        //not necessary
        /*for(Enumeration enum =user.propertyNames(); enum.hasMoreElements();){
View Full Code Here

   
   
    try {

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      request.setAttribute("id", request.getParameter("id"));
      //check permission
      checkPermission(request, OperationConstants.DELETE_USER_PERMISSION, forum);
     
      ProfileManager manager = forumFactory.getProfileManager();
      User user = manager.getUser( Integer.parseInt(request.getParameter("actor")));
       
 
      int perm=Integer.parseInt(request.getParameter("type"));
      if(perm==Constants.FORUM_ADMIN && ! SecurityTools.isSystemAdmin(getAuthToken(request))){
         throw new UnauthorizedException();
      }
      forum.removeUserPermission(user, perm);
     
    } catch (NotFoundException e) {
      errors.add("general", new ActionError("forumPermission.forumNotFound"));
    } catch (UnauthorizedException ue) {
      errors.add("general", new ActionError("forumPermission.Unauthorized"));
View Full Code Here

   
   
    try {

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      request.setAttribute("id", request.getParameter("id"));
      //check permission
      checkPermission(request, OperationConstants.DELETE_GROUP_PERMISSION, forum);
     
      ProfileManager manager = forumFactory.getProfileManager();
      Group group = manager.getGroup( Integer.parseInt(request.getParameter("actor")));
       
      int perm=Integer.parseInt(request.getParameter("type"));
      if(perm==Constants.FORUM_ADMIN && ! SecurityTools.isSystemAdmin(getAuthToken(request))){
         throw new UnauthorizedException();
      }
      forum.removeGroupPermission(group, perm);
     
    } catch (NotFoundException e) {
      errors.add("general", new ActionError("forumPermission.forumNotFound"));
    } catch (UnauthorizedException ue) {
      errors.add("general", new ActionError("forumPermission.Unauthorized"));
View Full Code Here

     
     
      List v = new Vector();

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      //check permission
      checkPermission(request, OperationConstants.LIST_FORUM_CONTENT, forum);

      ForumBean fb = new ForumBean();
      fb.setId(forum.getID());
      fb.setName(forum.getName());
      fb.setNotApprovedMessages(forum.getMessageCount(false));
      fb.setNotApprovedThreads(forum.getThreadCount(false));
      fb.setThreads(forum.getThreadCount());
      fb.setMessages(forum.getMessageCount());

      request.setAttribute("fb", fb);
     
      request.setAttribute("nbItems",new Integer(forum.getThreadCount()));
     
     
      List tbs = new ArrayList();
      Iterator threadIterator = forum.threads(start,maxPageItems); //start,range

      ThreadBean tb = null;

      while (threadIterator.hasNext()) {
        ForumThread currentThread = (ForumThread) threadIterator.next();
        tb = new ThreadBean();
        tb.setId(currentThread.getID());
        tb.setForumID(forum.getID());
        tb.setCreationDate(currentThread.getCreationDate());
        tb.setModifiedDate(currentThread.getModifiedDate());
        tb.setApproved(currentThread.isApproved());
        tb.setNotApprovedMessages(currentThread.getMessageCount(false));
        tb.setReplies(currentThread.getMessageCount() - 1);
View Full Code Here

    try {
      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      ProfileManager manager = forumFactory.getProfileManager();
     
     
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));

      //check permission
      checkPermission(request, OperationConstants.LIST_FORUM_PERMISSION, forum);
     
     
      ForumPermissionsBean fb = new ForumPermissionsBean();
      fb.setId(forum.getID());
      fb.setName(forum.getName());
      fb.setDescription(forum.getDescription());

      int[] ids;
      UserBean ub = null;
      GroupBean gb = null;
      User user = null;
      Group group = null;

      ids = forum.usersWithPermission(Constants.READ);
      for (int i = 0; i < ids.length; i++) {
        ub = new UserBean();
        user = manager.getUser(ids[i]);
        ub.setId(user.getID());
        if( user.getID() == -1 )ub.setUserName(messages.getMessage(getLocale(request),"user.anonymous"));
        else if( user.getID() == 0 )ub.setUserName(messages.getMessage(getLocale(request),"user.registered"));
        else
        ub.setUserName(user.getUsername());
        fb.addUsersWithReadPerm(ub);
      }

      ids = forum.usersWithPermission(Constants.CREATE_THREAD);
      for (int i = 0; i < ids.length; i++) {
        ub = new UserBean();
        user = manager.getUser(ids[i]);
        ub.setId(user.getID());
        if( user.getID() == -1 )ub.setUserName(messages.getMessage(getLocale(request),"user.anonymous"));
        else if( user.getID() == 0 )ub.setUserName(messages.getMessage(getLocale(request),"user.registered"));
        else
        ub.setUserName(user.getUsername());
        fb.addUsersWithThreadPerm(ub);
      }

      ids = forum.usersWithPermission(Constants.CREATE_MESSAGE);
      for (int i = 0; i < ids.length; i++) {
        ub = new UserBean();
        user = manager.getUser(ids[i]);
        ub.setId(user.getID());
        if( user.getID() == -1 )ub.setUserName(messages.getMessage(getLocale(request),"user.anonymous"));
        else if( user.getID() == 0 )ub.setUserName(messages.getMessage(getLocale(request),"user.registered"));
        else
        ub.setUserName(user.getUsername());
        fb.addUsersWithMessagePerm(ub);
      }
      ids = forum.usersWithPermission(Constants.MODERATOR);
      for (int i = 0; i < ids.length; i++) {
        ub = new UserBean();
        user = manager.getUser(ids[i]);
        ub.setId(user.getID());
        if( user.getID() == -1 )ub.setUserName(messages.getMessage(getLocale(request),"user.anonymous"));
        else if( user.getID() == 0 )ub.setUserName(messages.getMessage(getLocale(request),"user.registered"));
        else
        ub.setUserName(user.getUsername());
        fb.addUsersWithModeratorPerm(ub);
      }
      ids = forum.usersWithPermission(Constants.FORUM_ADMIN);
        for (int i = 0; i < ids.length; i++) {
          ub = new UserBean();
          user = manager.getUser(ids[i]);
          ub.setId(user.getID());
          if( user.getID() == -1 )ub.setUserName(messages.getMessage(getLocale(request),"user.anonymous"));
          else if( user.getID() == 0 )ub.setUserName(messages.getMessage(getLocale(request),"user.registered"));
          else
          ub.setUserName(user.getUsername());
          fb.addUsersWithAdminPerm(ub);
      }
     
     
     
     
     
      ids = forum.groupsWithPermission(Constants.READ);
      for (int i = 0; i < ids.length; i++) {
        gb = new GroupBean();
        group = manager.getGroup(ids[i]);
        gb.setId(group.getID());
        gb.setName(group.getName());
        fb.addGroupsWithReadPerm(gb);
      }

      ids = forum.groupsWithPermission(Constants.CREATE_THREAD);
      for (int i = 0; i < ids.length; i++) {
        gb = new GroupBean();
        group = manager.getGroup(ids[i]);
        gb.setId(group.getID());
        gb.setName(group.getName());
        fb.addGroupsWithThreadPerm(gb);
      }

      ids = forum.groupsWithPermission(Constants.CREATE_MESSAGE);
      for (int i = 0; i < ids.length; i++) {
        gb = new GroupBean();
        group = manager.getGroup(ids[i]);
        gb.setId(group.getID());
        gb.setName(group.getName());
        fb.addGroupsWithMessagePerm(gb);
      }
      ids = forum.groupsWithPermission(Constants.MODERATOR);
      for (int i = 0; i < ids.length; i++) {
        gb = new GroupBean();
        group = manager.getGroup(ids[i]);
        gb.setId(group.getID());
        gb.setName(group.getName());
        fb.addGroupsWithModeratorPerm(gb);
      }
      ids = forum.groupsWithPermission(Constants.FORUM_ADMIN);
        for (int i = 0; i < ids.length; i++) {
          gb = new GroupBean();
          group = manager.getGroup(ids[i]);
          gb.setId(group.getID());
          gb.setName(group.getName());
View Full Code Here

   
   
    try {

      ForumFactory forumFactory = ForumFactory.getInstance(getAuthToken(request));
      Forum forum = forumFactory.getForum(Integer.parseInt(request.getParameter("id")));
      request.setAttribute("id", request.getParameter("id"));
      //check permission
      checkPermission(request, OperationConstants.DELETE_FORUM_FILTER, forum);

      forum.removeForumMessageFilter(Integer.parseInt(request.getParameter("filter")));
     
    } catch (UnauthorizedException ue) {
      errors.add("general", new ActionError("delForumFilter.Unauthorized"));
    } catch (Exception e) {
      String eid = this.getClass().getName() + "_" + System.currentTimeMillis();
View Full Code Here

TOP

Related Classes of org.nemesis.forum.Forum

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.