[jboss-svn-commits] JBL Code SVN: r35295 - in labs/jbossforums/trunk/forums/src: main/org/jboss/portlet/forums/impl and 4 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Sep 25 05:27:08 EDT 2010


Author: sviluppatorefico
Date: 2010-09-25 05:27:07 -0400 (Sat, 25 Sep 2010)
New Revision: 35295

Modified:
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/feeds/FeedsServlet.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/Search.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewJumpbox.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsEditAllForums.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsMain.java
   labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewSummary.java
   labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml
Log:
fixed the RSS feeds bug.

Now the user preferences can be read by the web applications.

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/feeds/FeedsServlet.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/feeds/FeedsServlet.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/feeds/FeedsServlet.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -34,15 +34,20 @@
 import javax.servlet.http.HttpServlet;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.transaction.TransactionManager;
 
 import org.apache.commons.lang.StringEscapeUtils;
 import org.apache.log4j.Logger;
+import org.hibernate.TransactionException;
+import org.jboss.portal.common.transaction.TransactionManagerProvider;
+import org.jboss.portal.common.transaction.Transactions;
 import org.jboss.portal.core.modules.ModuleException;
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.impl.PostImpl;
 import org.jboss.portlet.forums.model.Category;
 import org.jboss.portlet.forums.model.Forum;
 import org.jboss.portlet.forums.model.Topic;
+import org.jboss.portlet.forums.ui.BaseController;
 import org.jboss.portlet.forums.ui.Constants;
 import org.jboss.portlet.forums.ui.PortalUtil;
 
@@ -71,6 +76,8 @@
 
 	@EJB(name = "jboss-forums/ForumsModuleImpl/local")
 	private ForumsModule forumsModule;
+	
+	private TransactionManager tm = null;
 
 	private static final Logger log = Logger.getLogger(FeedsServlet.class);
 
@@ -135,8 +142,20 @@
 						FeedConstants.WRONG_FEED_REQ);
 				return;
 			}
+			javax.transaction.Transaction oldTx = null;
+			if (forumsModule == null) {
+                try {
+                    tm = TransactionManagerProvider.JBOSS_PROVIDER
+                            .getTransactionManager();
+                } catch (Exception e) {
+                    System.out
+                            .println("Obtaining TransactionManagerProvider Problem....");
+                }
+			}
 
 			try {
+				if (tm != null)
+				    oldTx = Transactions.applyBefore(Transactions.TYPE_REQUIRED, tm);
 				if (what.equals(FeedConstants.CATEGORY)) {
 					createCategoryFeed(feed, id, url, urlType);
 				} else if (what.equals(FeedConstants.FORUM)) {
@@ -155,7 +174,15 @@
 						HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e
 								.getMessage());
 				return;
-			}
+			} finally {
+                try {
+                    if (tm != null) Transactions.applyAfter(Transactions.TYPE_REQUIRED, tm,
+                            oldTx);
+
+                } catch (TransactionException e) {
+                    // log.error("", e);
+                }
+            }
 			response.setContentType("text/xml");
 
 			Writer writer = response.getWriter();
@@ -179,7 +206,7 @@
 
 		List entries = new ArrayList();
 
-		List posts = forumsModule.findPostsDesc(FeedConstants.POST_LIMIT);
+		List posts = getForumsModule().findPostsDesc(FeedConstants.POST_LIMIT);
 
 		for (int i = 0; i < posts.size(); i++) {
 			entries.add(getEntry((PostImpl) posts.get(i), url, urlType));
@@ -191,7 +218,7 @@
 	private void createForumFeed(SyndFeed feed, Integer id, String url,
 			String urlType) throws ModuleException {
 
-		Forum forum = forumsModule.findForumById(id);
+		Forum forum = getForumsModule().findForumById(id);
 
 		feed.setTitle("JBoss Forums Forum Feed: " + forum.getName());
 		feed.setLink(forumLink(id.toString(), url, urlType));
@@ -200,7 +227,7 @@
 
 		List entries = new ArrayList();
 
-		List posts = forumsModule.findPostsFromForumDesc(forum,
+		List posts = getForumsModule().findPostsFromForumDesc(forum,
 				FeedConstants.POST_LIMIT);
 
 		for (int i = 0; i < posts.size(); i++) {
@@ -214,7 +241,7 @@
 	private void createTopicFeed(SyndFeed feed, Integer id, String url,
 			String urlType) throws ModuleException {
 
-		Topic topic = forumsModule.findTopicById(id);
+		Topic topic = getForumsModule().findTopicById(id);
 
 		feed.setTitle("JBoss Forums Topic Feed: " + topic.getSubject());
 		feed.setLink(topicLink(id.toString(), url, urlType));
@@ -248,7 +275,7 @@
 	private void createCategoryFeed(SyndFeed feed, Integer id, String url,
 			String urlType) throws ModuleException {
 
-		Category category = forumsModule.findCategoryById(id);
+		Category category = getForumsModule().findCategoryById(id);
 
 		feed.setTitle("JBoss Forums Category Feed: " + category.getTitle());
 		feed.setLink(categoryLink(id.toString(), url, urlType));
@@ -257,7 +284,7 @@
 
 		List entries = new ArrayList();
 
-		List posts = forumsModule.findPostsFromCategoryDesc(category,
+		List posts = getForumsModule().findPostsFromCategoryDesc(category,
 				FeedConstants.POST_LIMIT);
 
 		for (int i = 0; i < posts.size(); i++) {
@@ -326,7 +353,7 @@
 						+ URLEncoder.encode(PortalUtil.getIdForName(viewUrl),
 								"UTF-8") + "&";
 			} catch (UnsupportedEncodingException e) {
-				e.printStackTrace();
+				log.error(e);
 			}
 		} else {
 			url += viewUrl + "?";
@@ -334,5 +361,16 @@
 
 		return url;
 	}
+	
+	private ForumsModule getForumsModule() {
+		if (forumsModule == null) {
+			try {
+			   forumsModule = BaseController.getForumsModule();
+			} catch (Exception ex) {
+				log.error(ex);
+			}
+		}
+		return forumsModule;
+	}
 
 }

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -1396,7 +1396,7 @@
 			Query query = session
 					.createNamedQuery("findPostsFromForum" + order);
 
-			query.setParameter("forumId", forum.getId().toString());
+			query.setParameter("forumId", forum.getId());
 
 			query.setFirstResult(0);
 

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/ForumUtil.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -159,35 +159,6 @@
         }
     }
     
-    /* Luca Stancapiano start - This method is taken from getPreference
-       method of PortalUtil. The only difference is that this method has
-       to be used also for anonymous users because a preference can to be imported also
-       for a portlet when you are not logged. For example foruminstanceid custom preference
-       must to be seen by an anonymous user to get the right forum instance, otherwise
-       an anonymous user has permission to see an only forum instance
-    */
-    /**
-     * 
-     * @param preferenceKey
-     * @return
-     */
-    public static String getPreference(String preferenceKey)
-    {
-        String preference = null;
-
-        Object o = FacesContext.getCurrentInstance().getExternalContext()
-                .getRequest();
-        if (o instanceof PortletRequest)
-        {
-            PortletRequest request = (PortletRequest) o;
-            PortletPreferences pp = request.getPreferences();
-            preference = pp.getValue(preferenceKey, "");
-        }
-
-        return preference;
-    }
-    // Luca Stancapiano end
-    
     public static boolean isFeedsConfigured()
     {
         ExternalContext ctx = FacesContext.getCurrentInstance().getExternalContext();

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -46,6 +46,7 @@
 import javax.portlet.RenderRequest;
 import javax.portlet.RenderResponse;
 import javax.servlet.http.HttpServletRequest;
+import javax.transaction.NotSupportedException;
 import javax.transaction.SystemException;
 import javax.transaction.UserTransaction;
 
@@ -703,6 +704,10 @@
                     .lookup(ModuleConstants.USERMODULE_JNDINAME);
                user = userModule.findUserByUserName(userName);
                ut.commit();
+		    } catch (NotSupportedException e) {
+	           UserModule userModule = (UserModule) new InitialContext()
+                   .lookup(ModuleConstants.USERMODULE_JNDINAME);
+               user = userModule.findUserByUserName(userName);
 		    } catch (Exception e) {
 			   log.error("Cannot load the user", e);
 			   try {

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -52,6 +52,8 @@
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
 	
     private static final int up = -15;
     private static final int down = 15;
@@ -83,6 +85,22 @@
     private boolean addCategoryMode;
     private boolean addForumMode;
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
+    /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
     //-----ui data-------------------------------------------------------------------------------------------------------------------------
     /**
      * @return Returns the categoryName.
@@ -308,7 +326,7 @@
         	// Luca Stancapiano start
             //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);
@@ -604,7 +622,7 @@
 	         // Luca Stancapiano start
 	         //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);
@@ -649,7 +667,7 @@
 	        // Luca Stancapiano start
 	        //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/Search.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/Search.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/action/Search.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -34,17 +34,34 @@
 import org.jboss.portlet.forums.impl.ForumImpl;
 import org.jboss.portlet.forums.search.SearchCriteria;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
 
 public class Search extends ActionController {
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
 
     private static final long serialVersionUID = 1L;
     
     private SearchCriteria searchCriteria = new SearchCriteria();
+    
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
+    /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
 
     public SearchCriteria getSearchCriteria()
     {
@@ -85,7 +102,7 @@
 	        // Luca Stancapiano start
 	        //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);
@@ -117,7 +134,7 @@
 	        // Luca Stancapiano start
 	        //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewAdminPanel.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -29,8 +29,8 @@
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.ui.BaseController;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 /**
  * @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
@@ -41,6 +41,9 @@
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+	
+    //user preference controller
+    private PreferenceController userPreferences = null;  
 
     private List categories = null;
     private List forums = null;
@@ -53,7 +56,23 @@
         super();                         
     }
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
     /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
+    /**
      * 
      *
      */
@@ -71,7 +90,7 @@
             	// Luca Stancapiano start
             	//get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -104,7 +123,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -43,6 +43,7 @@
 import org.jboss.portlet.forums.ui.JSFUtil;
 import org.jboss.portlet.forums.ui.PortalUtil;
 import org.jboss.portlet.forums.ui.ThemeHelper;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 //jsf imports
 
@@ -56,6 +57,8 @@
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
     
     //business data being generated in this bean by executing ui actions
     //this is data is created such that it can be consumed by the view components
@@ -67,6 +70,22 @@
     private Map forumLastPosts = null;
     private boolean categorySelected = false;
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
+    /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
     //----------------bean configuration supplied by the forums-config.xml---------------------------------------------------------------------------------------------
     
     
@@ -219,7 +238,7 @@
          // Luca Stancapiano start
          //get the forumInstanceId where this forum should be added
 	     int forumInstanceId = -1;
-	     String cou = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	     String cou = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	     if(cou!=null && cou.trim().length()>0)
 	     {
 	        forumInstanceId = Integer.parseInt(cou);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewJumpbox.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewJumpbox.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewJumpbox.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -29,8 +29,8 @@
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.ui.BaseController;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 /**
  * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
@@ -40,6 +40,8 @@
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
 
     private List categories;
 
@@ -50,6 +52,22 @@
         super();
     }
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
+    /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
     public List getCategories() 
     {
         if (categories!=null) {
@@ -64,7 +82,7 @@
             	// Luca Stancapiano start
             	//get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -31,15 +31,17 @@
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.model.Watch;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
 import org.jboss.portlet.forums.ui.PortalUtil;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 public class ViewMyForumsAllSubscribed extends ViewMyForumsBase
 {
 	
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
     
     private int topicId;
     private Watch watch;
@@ -67,7 +69,23 @@
         }
     }
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
     /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
+    /**
      * 
      */
     public Watch getWatch()
@@ -111,7 +129,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -139,7 +157,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsEditAllForums.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsEditAllForums.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsEditAllForums.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -35,15 +35,17 @@
 import org.jboss.portlet.forums.impl.PostImpl;
 import org.jboss.portlet.forums.model.Watch;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
 import org.jboss.portlet.forums.ui.PortalUtil;
 import org.jboss.portlet.forums.ui.ThemeHelper;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 public class ViewMyForumsEditAllForums
 {
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
-    private ForumsModule forumsModule;  
+    private ForumsModule forumsModule; 
+    //user preference controller
+    private PreferenceController userPreferences = null; 
 
     // Map<ForumId,LastPost>
     private Map forumsLastPosts;
@@ -55,7 +57,23 @@
     private Watch watch;
     private int forumId;
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
     /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
+    
+    /**
      * 
      */
     public Map getForumImageDescriptions()
@@ -106,7 +124,7 @@
             {
             	//get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -159,7 +177,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -255,7 +273,7 @@
         	// Luca Stancapiano start
             //get the forumInstanceId where this forum should be added
 	        int forumInstanceId = -1;
-	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
 	        if(cour!=null && cour.trim().length()>0)
 	        {
 	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsMain.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsMain.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsMain.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -29,22 +29,22 @@
 import java.util.Map;
 
 import javax.ejb.EJB;
-import javax.naming.InitialContext;
 
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.impl.ForumImpl;
 import org.jboss.portlet.forums.impl.PostImpl;
-import org.jboss.portlet.forums.ui.BaseController;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
 import org.jboss.portlet.forums.ui.PortalUtil;
 import org.jboss.portlet.forums.ui.ThemeHelper;
+import org.jboss.portlet.forums.ui.action.PreferenceController;
 
 public class ViewMyForumsMain extends ViewMyForumsBase
 {
 	@EJB(name="jboss-forums/ForumsModuleImpl/local")
     private ForumsModule forumsModule;  
+    //user preference controller
+    private PreferenceController userPreferences = null;
     
     // Map<ForumId,LastPost>
     private Map forumsLastPosts;
@@ -54,7 +54,23 @@
     private Map forumImageDescriptions;
     private Map forumImages;
     
+    //------------user preferences-------------------------------------------------------------------------------------------------------------  
+    /**
+     * @return Returns the userPreferences.
+     */
+    public PreferenceController getUserPreferences() 
+    {
+        return userPreferences;
+    }
+    /**
+     * @param userPreferences The userPreferences to set.
+     */
+    public void setUserPreferences(PreferenceController userPreferences) 
+    {
+        this.userPreferences = userPreferences;    
+    }    
     
+    
     /**
      * 
      */
@@ -71,7 +87,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -108,7 +124,7 @@
             	// Luca Stancapiano start
                 //get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);
@@ -168,7 +184,7 @@
             	// Luca Stancapiano start
             	//get the forumInstanceId where this forum should be added
     	        int forumInstanceId = -1;
-    	        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+    	        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
     	        if(cour!=null && cour.trim().length()>0)
     	        {
     	        	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewSummary.java
===================================================================
--- labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewSummary.java	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/main/org/jboss/portlet/forums/ui/view/ViewSummary.java	2010-09-25 09:27:07 UTC (rev 35295)
@@ -32,7 +32,6 @@
 import org.jboss.portlet.forums.ForumsModule;
 import org.jboss.portlet.forums.ui.BaseController;
 import org.jboss.portlet.forums.ui.Constants;
-import org.jboss.portlet.forums.ui.ForumUtil;
 import org.jboss.portlet.forums.ui.JSFUtil;
 import org.jboss.portlet.forums.ui.action.PreferenceController;
 
@@ -174,7 +173,7 @@
         // Luca Stancapiano start
         //get the forumInstanceId where this forum should be added
         int forumInstanceId = -1;
-        String cour = ForumUtil.getPreference(Constants.FORUM_INSTANCE_ID);
+        String cour = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
         if(cour!=null && cour.trim().length()>0)
         {
         	forumInstanceId = Integer.parseInt(cour);

Modified: labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml
===================================================================
--- labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml	2010-09-25 08:41:51 UTC (rev 35294)
+++ labs/jbossforums/trunk/forums/src/resources/portal-forums-war/WEB-INF/forums-config.xml	2010-09-25 09:27:07 UTC (rev 35295)
@@ -247,7 +247,13 @@
 	<managed-bean>
 	    <managed-bean-name>category</managed-bean-name>
 	    <managed-bean-class>org.jboss.portlet.forums.ui.view.ViewCategory</managed-bean-class>
-	    <managed-bean-scope>request</managed-bean-scope>	    
+	    <managed-bean-scope>request</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    	    
     </managed-bean>
     
     <!-- configuration for ViewForum -->
@@ -421,7 +427,13 @@
 	 <managed-bean>
 	  	<managed-bean-name>jumpbox</managed-bean-name>
 	  	<managed-bean-class>org.jboss.portlet.forums.ui.view.ViewJumpbox</managed-bean-class>
-	  	<managed-bean-scope>request</managed-bean-scope>
+	  	<managed-bean-scope>request</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    
 	 </managed-bean>
 	 
 	 <!-- managedBean for the viewProfile usecase -->
@@ -504,13 +516,25 @@
 	 <managed-bean>
 	  	<managed-bean-name>adminPanel</managed-bean-name>
 	  	<managed-bean-class>org.jboss.portlet.forums.ui.view.ViewAdminPanel</managed-bean-class>
-	  	<managed-bean-scope>request</managed-bean-scope>
+	  	<managed-bean-scope>request</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    
 	 </managed-bean>
 	 <!-- managedBean for the adminController usecase -->
 	 <managed-bean>
 	  	<managed-bean-name>adminController</managed-bean-name>
 	  	<managed-bean-class>org.jboss.portlet.forums.ui.action.AdminController</managed-bean-class>
-	  	<managed-bean-scope>request</managed-bean-scope>
+	  	<managed-bean-scope>request</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    
 	 </managed-bean>
 	<navigation-rule>
         <from-view-id>/views/admin/deleteCategory.xhtml</from-view-id>	
@@ -559,30 +583,10 @@
 	    	<map-entries>
 	    		<key-class>java.lang.String</key-class>
 	    		<map-entry>
-	    			<key>notifyreply</key>
-	    			<value>true</value>
+	    			<key>foruminstanceid</key>
+	    			<value>1</value>
 	    		</map-entry>
 	    		<map-entry>
-	    			<key>allowhtml</key>
-	    			<value>true</value>
-	    		</map-entry>
-	    		<map-entry>
-	    			<key>postorder</key>
-	    			<value>ascending</value>
-	    		</map-entry>
-	    		<map-entry>
-	    			<key>dateformat</key>
-	    			<value>EEE MMM d, yyy</value>
-	    		</map-entry>
-	    		<map-entry>
-	    			<key>alwaysaddsignature</key>
-	    			<value>false</value>
-	    		</map-entry>
-	    		<map-entry>
-	    			<key>signature</key>
-	    			<value>null_value</value>
-	    		</map-entry>
-	    		<map-entry>
 	    			<key>summarymode</key>
 	    			<value>0</value>
 	    		</map-entry>
@@ -606,6 +610,30 @@
 	    			<key>postspertopic</key>
 	    			<value>15</value>
 	    		</map-entry>
+	    		<map-entry>
+	    			<key>notifyreply</key>
+	    			<value>true</value>
+	    		</map-entry>
+	    		<map-entry>
+	    			<key>allowhtml</key>
+	    			<value>true</value>
+	    		</map-entry>
+	    		<map-entry>
+	    			<key>postorder</key>
+	    			<value>ascending</value>
+	    		</map-entry>
+	    		<map-entry>
+	    			<key>dateformat</key>
+	    			<value>EEE MMM d, yyyy HH:mm aaa</value>
+	    		</map-entry>
+	    		<map-entry>
+	    			<key>alwaysaddsignature</key>
+	    			<value>false</value>
+	    		</map-entry>
+	    		<map-entry>
+	    			<key>signature</key>
+	    			<value>null_value</value>
+	    		</map-entry>
 	    	</map-entries>
 	    </managed-property> 
 	 </managed-bean>
@@ -704,7 +732,13 @@
      <managed-bean>
         <managed-bean-name>myForumsEdit</managed-bean-name>
         <managed-bean-class>org.jboss.portlet.forums.ui.view.ViewMyForumsEditAllForums</managed-bean-class>
-        <managed-bean-scope>request</managed-bean-scope>
+        <managed-bean-scope>request</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    
      </managed-bean>
      <navigation-rule>
         <from-view-id>/views/myforums/myforums_editforums.xhtml</from-view-id>    
@@ -717,7 +751,13 @@
      <managed-bean>
         <managed-bean-name>search</managed-bean-name>
         <managed-bean-class>org.jboss.portlet.forums.ui.action.Search</managed-bean-class>
-        <managed-bean-scope>session</managed-bean-scope>
+        <managed-bean-scope>session</managed-bean-scope>	    	    
+	    <!-- user preferences -->
+	    <managed-property>
+            <property-name>userPreferences</property-name>
+            <property-class>org.jboss.portlet.forums.ui.action.PreferenceController</property-class>
+            <value>#{prefController}</value>
+        </managed-property>	    
      </managed-bean>
      <managed-bean>
         <managed-bean-name>viewSearch</managed-bean-name>



More information about the jboss-svn-commits mailing list