[jboss-svn-commits] JBL Code SVN: r38338 - in labs/jbossforums/branches/forums130P27: forums/src/main/org/jboss/portlet/forums/impl and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri May 31 15:25:05 EDT 2013
Author: sviluppatorefico
Date: 2013-05-31 15:25:05 -0400 (Fri, 31 May 2013)
New Revision: 38338
Modified:
labs/jbossforums/branches/forums130P27/.classpath
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumImpl.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PollImpl.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/model/Forum.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/search/bridge/UserNameTextBridge.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewProfile.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/ForumModelTestCase.java
labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java
labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/category/viewcategory_body.xhtml
labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
Log:
fixed the insert updte problems for topics and forums
Modified: labs/jbossforums/branches/forums130P27/.classpath
===================================================================
--- labs/jbossforums/branches/forums130P27/.classpath 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/.classpath 2013-05-31 19:25:05 UTC (rev 38338)
@@ -5,7 +5,7 @@
<classpathentry kind="src" path="forums/src/main"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-core-lib.jar"/>
- <classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-jems-lib.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-jems-lib.jar" sourcepath="/jems"/>
<classpathentry kind="lib" path="thirdparty/junit-junit/lib/junit.jar"/>
<classpathentry kind="lib" path="thirdparty/jboss-j2ee/lib/jboss-j2ee.jar"/>
<classpathentry kind="lib" path="thirdparty/jakarta-log4j/lib/log4j.jar"/>
@@ -19,7 +19,7 @@
<classpathentry kind="lib" path="thirdparty/jakarta-fileupload/lib/commons-fileupload.jar"/>
<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-portlet-lib.jar"/>
<classpathentry kind="lib" path="thirdparty/jbportal/lib/jboss-portlet-api-lib.jar"/>
- <classpathentry kind="lib" path="thirdparty/jwebunit-jwebunit/lib/jwebunit.jar"/>
+ <classpathentry kind="lib" path="thirdparty/jwebunit-jwebunit/lib/jwebunit.jar" sourcepath="/Users/flashboss/.m2/repository/jwebunit/jwebunit/1.2/jwebunit-1.2-sources.jar"/>
<classpathentry kind="lib" path="thirdparty/dbunit-dbunit/lib/dbunit.jar"/>
<classpathentry kind="lib" path="thirdparty/jbportal/lib/portal-core-test-lib.jar"/>
<classpathentry kind="lib" path="thirdparty/rome/lib/rome-0.9.jar"/>
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumImpl.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumImpl.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumImpl.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -339,17 +339,6 @@
}
/**
- * DOCUMENT_ME
- *
- * @param value
- * DOCUMENT_ME
- */
- public void addTopic(TopicImpl value) {
- value.setForum(this);
- topics.add(value);
- }
-
- /**
*/
public Collection getForumWatch() {
return watch;
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -88,7 +88,7 @@
private String guestUserName = "guest";
private String fromAddress = "portal at example.com";
-
+
@PostConstruct
public void startService() {
try {
@@ -146,7 +146,7 @@
if (id != null) {
try {
EntityManager session = getSession();
- Forum forum = (Forum) session.getReference(
+ Forum forum = (Forum) session.find(
ForumImpl.class, id);
if (forum == null) {
throw new ModuleException("No forum found for " + id);
@@ -550,9 +550,10 @@
List attachments, int type) throws ModuleException {
try {
EntityManager session = getSession();
-
- session.persist(poster);
- session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required
+
+ if (poster.getId() == null || session.find(PosterImpl.class, poster.getId()) == null)
+ session.persist(poster);
+ session.merge(poster);
// for clustered versions
session.persist(poll);
session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required
@@ -574,7 +575,7 @@
TopicImpl topic = new TopicImpl();
topic.setSubject(message.getSubject());
// topic.setForum(forum);
- forum.addTopic(topic);
+ topic.setForum((ForumImpl)forum);
topic.setPoster((PosterImpl)poster);
// topic.setFirstPost(post);
// topic.setLastPost(post);
@@ -591,9 +592,10 @@
forum.addTopicSize();
forum.addPostSize();
-
+ session.merge(forum);
post.setTopic(topic);
session.persist(post);
+
notificationEngine.scheduleForNotification(post.getId(),
NotificationEngine.MODE_POST);
session.flush(); // Luca Stancapiano - 8 feb 2008 - it is required
@@ -621,7 +623,7 @@
TopicImpl topic = new TopicImpl();
topic.setSubject(subject);
// topic.setForum(forum);
- forum.addTopic(topic);
+ topic.setForum((ForumImpl)forum);
topic.setPoster((PosterImpl)poster);
// topic.setFirstPost(post);
// topic.setLastPost(post);
@@ -889,7 +891,7 @@
if (id != null) {
try {
EntityManager session = getSession();
- Topic topic = (Topic) session.getReference(
+ Topic topic = (Topic) session.find(
TopicImpl.class, id);
if (topic == null) {
throw new ModuleException("No topic found for " + id);
@@ -948,7 +950,7 @@
if (id != null) {
try {
EntityManager session = getSession();
- Post post = (Post) session.getReference(PostImpl.class,
+ Post post = (Post) session.find(PostImpl.class,
id);
if (post == null) {
throw new ModuleException("No post found for " + id);
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PollImpl.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PollImpl.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PollImpl.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -40,6 +40,8 @@
import org.jboss.portlet.forums.model.Poll;
+import static javax.persistence.FetchType.EAGER;
+
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet </a>
* @author <a href="mailto:theute at jboss.org">Thomas Heute </a>
@@ -70,7 +72,7 @@
@Column(name="JBP_TITLE")
private String title;
- @OneToMany(mappedBy="poll")
+ @OneToMany(mappedBy="poll", fetch=EAGER)
private List<PollOptionImpl> options;
@Column(name="JBP_LENGTH")
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/impl/PosterImpl.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portlet.forums.impl;
-import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -33,7 +32,6 @@
import javax.persistence.Table;
import javax.persistence.Transient;
-import org.jboss.portal.core.modules.ModuleConstants;
import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
@@ -103,7 +101,7 @@
{
try
{
- UserModule userModule = (UserModule)new InitialContext().lookup(ModuleConstants.USERMODULE_JNDINAME);
+ UserModule userModule = PortalUtil.getUserModule();
user = userModule.findUserById(userId);
}
catch (NamingException e)
@@ -122,7 +120,10 @@
{
e.printStackTrace();
return null;
- }
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
return user;
}
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/model/Forum.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/model/Forum.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/model/Forum.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -208,15 +208,7 @@
*/
List<TopicImpl> getTopics();
-
/**
- * DOCUMENT_ME
- *
- * @param value DOCUMENT_ME
- */
- void addTopic(TopicImpl value);
-
- /**
* @return DOCUMENT_ME
*/
List<WatchImpl> getWatches();
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/search/bridge/UserNameTextBridge.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/search/bridge/UserNameTextBridge.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/search/bridge/UserNameTextBridge.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -45,7 +45,7 @@
try {
String id = poster.getUserId();
- UserModule userModule = (UserModule)new InitialContext().lookup(ModuleConstants.USERMODULE_JNDINAME);
+ UserModule userModule = PortalUtil.getUserModule();
User user = userModule.findUserById(id);
if (user != null) {
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/PortalUtil.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -34,6 +34,9 @@
import java.util.SortedMap;
import java.util.TreeMap;
+import javax.faces.FactoryFinder;
+import javax.faces.application.Application;
+import javax.faces.application.ApplicationFactory;
import javax.faces.component.UIViewRoot;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
@@ -51,7 +54,6 @@
import javax.transaction.UserTransaction;
import org.apache.log4j.Logger;
-import org.jboss.portal.core.modules.ModuleConstants;
import org.jboss.portal.identity.NoSuchUserException;
import org.jboss.portal.identity.User;
import org.jboss.portal.identity.UserModule;
@@ -418,6 +420,17 @@
}
url += "&" + Constants.p_viewId + "=t&" + Constants.p_postId + "="
+ postId + "#" + postId;
+ } else
+ {
+ url = JSFUtil.getContextPath();
+ ApplicationFactory factory = (ApplicationFactory) FactoryFinder
+ .getFactory(FactoryFinder.APPLICATION_FACTORY);
+ Application application = factory.getApplication();
+ EmptyController binding = (EmptyController) application
+ .getVariableResolver().resolveVariable(
+ FacesContext.getCurrentInstance(), "shared");
+ url += binding.getLinks().get("topic").toString();
+ url += "?" + Constants.p_postId + "=" + postId + "#" + postId;
}
return url;
@@ -812,7 +825,7 @@
ut = (UserTransaction) initialContext
.lookup("/UserTransaction");
ut.begin();
- userModule = (UserModule)new InitialContext().lookup(ModuleConstants.USERMODULE_JNDINAME);
+ userModule = PortalUtil.getUserModule();
user = userModule.findUserByUserName(guestUserName);
ut.commit();
}
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/AdminController.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Iterator;
-import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import org.jboss.portal.core.modules.ModuleException;
@@ -89,6 +88,10 @@
private boolean addCategoryMode;
private boolean addForumMode;
+ public AdminController() {
+ startService();
+ }
+
//------------user preferences-------------------------------------------------------------------------------------------------------------
/**
* @return Returns the userPreferences.
@@ -233,7 +236,6 @@
*
*
*/
- @PostConstruct
public void startService()
{
try
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/ModeratorAction.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -225,7 +225,7 @@
return "success";
}
- forumDest.addTopic((TopicImpl)topic);
+ topic.setForum((ForumImpl)forumDest);
forumDest.setPostCount(forumDest.getPostCount()+topic.getReplies()+1);
forumDest.setTopicCount(forumDest.getTopicCount()+1);
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/NewTopic.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -146,7 +146,8 @@
poll.setOptions(pollOptions);
validatePoll(poll);
}
-
+
+ poster.incrementPostCount();
//actually create the topic in this forum
//use this method when poll and attachments are actually integrated
Post post = getForumsModule(forumsModule).createTopic(
@@ -159,7 +160,6 @@
this.topicType
);
- poster.incrementPostCount();
//setup the navigation state
navState = Constants.SUCCESS;
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/action/TopicWatchController.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -57,6 +57,10 @@
private boolean editMode;
private TopicImpl topic;
+ public TopicWatchController() {
+ startService();
+ }
+
/**
*
*/
@@ -133,7 +137,6 @@
*
*
*/
- @PostConstruct
public void startService() {
try
{
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewCategory.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -29,7 +29,6 @@
import java.util.Iterator;
import java.util.Map;
-import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import org.jboss.portlet.forums.ForumsModule;
@@ -47,280 +46,249 @@
//jsf imports
-
/**
* @author <a href="mailto:sohil.shah at jboss.com">Sohil Shah</a>
* @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
*/
-public class ViewCategory extends BaseController
-{
-
+public class ViewCategory extends BaseController {
+
/**
*
*/
private static final long serialVersionUID = 5349549910762005145L;
- @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
- //like facelets
- private Collection categories = null;
- private Map forums = null;
- private Map forumImages = null;
- private Map forumImageDescriptions = null;
- private Map forumLastPosts = null;
- private boolean categorySelected = false;
-
- //------------user preferences-------------------------------------------------------------------------------------------------------------
- /**
- * @return Returns the userPreferences.
- */
- public PreferenceController getUserPreferences()
+ @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
+ // like facelets
+ private Collection categories = null;
+ private Map forums = null;
+ private Map forumImages = null;
+ private Map forumImageDescriptions = null;
+ 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---------------------------------------------------------------------------------------------
+
+ // ----------------business data being generated for use by the view
+ // components like
+ // facelets---------------------------------------------------------------------------------------
+ /**
+ *
+ * @return
+ */
+ public Collection getCategories() {
+ if (this.categories == null) {
+ this.categories = new ArrayList();
+ }
+ return this.categories;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Map getForums() {
+ if (this.forums == null) {
+ this.forums = new HashMap();
+ }
+ return this.forums;
+ }
+
+ public ForumsModule getModule() throws Exception {
+ return getForumsModule(forumsModule);
+ }
+
+ /**
+ * @return Returns the forumImageDescriptions.
+ */
+ public Map getForumImageDescriptions() {
+ if (this.forumImageDescriptions == null) {
+ this.forumImageDescriptions = new HashMap();
+ }
+ return this.forumImageDescriptions;
+ }
+
+ /**
+ * @return Returns the forumImages.
+ */
+ public Map getForumImages() {
+ if (this.forumImages == null) {
+ this.forumImages = new HashMap();
+ }
+ return forumImages;
+ }
+
+ /**
+ * @return Returns the a Map which contains ForumId:LastPost pairs.
+ */
+ public Map getForumLastPosts() {
+ if (this.forumLastPosts == null) {
+ this.forumLastPosts = new HashMap();
+ }
+ return this.forumLastPosts;
+ }
+
+ /**
+ * @return Returns true if category has been selected.
+ */
+ public boolean isCategorySelected() {
+ return this.categorySelected;
+ }
+
+ public String getRssFeed() {
+ if (categorySelected && categories != null && !categories.isEmpty()) {
+ CategoryImpl category = (CategoryImpl) categories.iterator().next();
+ return PortalUtil.createFeedLink(FeedConstants.RSS, FeedConstants.CATEGORY, category.getId());
+ } else {
+ return PortalUtil.createFeedLink(FeedConstants.RSS, FeedConstants.GLOBAL, null);
+ }
+ }
+
+ public String getAtomFeed() {
+ if (categorySelected && categories != null && !categories.isEmpty()) {
+ CategoryImpl category = (CategoryImpl) categories.iterator().next();
+ return PortalUtil.createFeedLink(FeedConstants.ATOM, FeedConstants.CATEGORY, category.getId());
+ } else {
+ return PortalUtil.createFeedLink(FeedConstants.ATOM, FeedConstants.GLOBAL, null);
+ }
+
+ }
+
+ // ------------user
+ // preferences-------------------------------------------------------------------------------------------------------------
+
+ // -------------------------------------------------------------------------------------------------------------------------------------
+ /**
+ *
+ * @author sshah
+ */
+ public ViewCategory() {
+ super();
+ }
+
+ public boolean isInitialized()
{
- return userPreferences;
+ boolean initialized = false;
+ try
+ {
+ this.execute();
+ initialized = true;
+ }
+ catch(Exception e)
+ {
+ JSFUtil.handleException(e);
+ }
+ return initialized;
}
- /**
- * @param userPreferences The userPreferences to set.
- */
- public void setUserPreferences(PreferenceController userPreferences)
- {
- this.userPreferences = userPreferences;
- }
-
- //----------------bean configuration supplied by the forums-config.xml---------------------------------------------------------------------------------------------
-
-
- //----------------business data being generated for use by the view components like facelets---------------------------------------------------------------------------------------
- /**
- *
- * @return
- */
- public Collection getCategories()
- {
- if(this.categories==null)
- {
- this.categories = new ArrayList();
- }
- return this.categories;
- }
-
- /**
- *
- * @return
- */
- public Map getForums()
- {
- if(this.forums==null)
- {
- this.forums = new HashMap();
- }
- return this.forums;
- }
-
- public ForumsModule getModule () throws Exception {
- return getForumsModule(forumsModule);
- }
-
-
- /**
- * @return Returns the forumImageDescriptions.
- */
- public Map getForumImageDescriptions()
- {
- if(this.forumImageDescriptions==null)
- {
- this.forumImageDescriptions = new HashMap();
- }
- return this.forumImageDescriptions;
- }
- /**
- * @return Returns the forumImages.
- */
- public Map getForumImages()
- {
- if(this.forumImages==null)
- {
- this.forumImages = new HashMap();
- }
- return forumImages;
- }
-
- /**
- * @return Returns the a Map which contains ForumId:LastPost pairs.
- */
- public Map getForumLastPosts()
- {
- if(this.forumLastPosts==null)
- {
- this.forumLastPosts = new HashMap();
- }
- return this.forumLastPosts;
- }
-
- /**
- * @return Returns true if category has been selected.
- */
- public boolean isCategorySelected() {
- return this.categorySelected;
- }
-
- public String getRssFeed()
- {
- if (categorySelected && categories!=null && !categories.isEmpty())
- {
- CategoryImpl category = (CategoryImpl)categories.iterator().next();
- return PortalUtil.createFeedLink(FeedConstants.RSS,
- FeedConstants.CATEGORY, category.getId());
- }
- else
- {
- return PortalUtil.createFeedLink(FeedConstants.RSS,
- FeedConstants.GLOBAL,null);
- }
- }
-
- public String getAtomFeed()
- {
- if (categorySelected && categories!=null && !categories.isEmpty())
- {
- CategoryImpl category = (CategoryImpl)categories.iterator().next();
- return PortalUtil.createFeedLink(FeedConstants.ATOM,
- FeedConstants.CATEGORY, category.getId());
- }
- else
- {
- return PortalUtil.createFeedLink(FeedConstants.ATOM,
- FeedConstants.GLOBAL,null);
- }
-
- }
-
- //------------user preferences-------------------------------------------------------------------------------------------------------------
-
- //-------------------------------------------------------------------------------------------------------------------------------------
- /**
- *
- * @author sshah
- */
- public ViewCategory()
- {
- super();
- }
-
- @PostConstruct
- public void init() {
- try
- {
- this.execute();
- }
- catch(Exception e)
- {
- JSFUtil.handleException(e);
- }
- }
-
- //ui actions supported by this bean----------------------------------------------------------------------------------------------------
- /**
- * this generates the category and its corresponding forums
- */
- private void execute() throws Exception
- {
- //try to extract categoryId
- int categoryId = -1;
- String c = ForumUtil.getParameter(Constants.p_categoryId);
- if(c!=null && c.trim().length()>0)
- {
- categoryId = Integer.parseInt(c);
-
- // Setting flag that category has been selected.
- this.categorySelected=true;
- }
- // Luca Stancapiano start
- //get the forumInstanceId where this forum should be added
- int forumInstanceId = -1;
- String cou = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
- if(cou!=null && cou.trim().length()>0)
- {
- forumInstanceId = Integer.parseInt(cou);
- }
-
- this.forumLastPosts = getForumsModule(forumsModule).findLastPostsOfForums(forumInstanceId);
- // Luca Stancapiano end
-
- //setup category related data to be displayed
- if(categoryId==-1)
- {
- //process a default level category
- // Luca Stancapiano
- Collection cour = getForumsModule(forumsModule).findCategoriesFetchForums(forumInstanceId);
- if(cour!=null)
- {
- Iterator iterator = cour.iterator();
- while (iterator.hasNext())
- {
- CategoryImpl currentCategory = (CategoryImpl)iterator.next();
- this.processCategory(currentCategory);
- }
- }
- }
- else
- {
- //process the specifed category
- CategoryImpl currentCategory = (CategoryImpl)getForumsModule(forumsModule).findCategoryByIdFetchForums(categoryId);
- if(currentCategory!=null)
- {
- this.processCategory(currentCategory);
- }
- }
- }
-
- /**
- *
- * @return
- */
- private void processCategory(CategoryImpl category) throws Exception
- {
- Date userLastLogin = PortalUtil.getUserLastLoginDate();
- if(category!=null)
- {
- this.getCategories().add(category);
-
- //process the forums associated with this category
- Collection forums = category.getForums();
- Iterator forumsIterator = forums.iterator();
- Collection categoryForums = new ArrayList();
- while (forumsIterator.hasNext())
- {
- ForumImpl currentForum = (ForumImpl)forumsIterator.next();
- categoryForums.add(currentForum);
-
- //setup folderLook based on whats specified in the theme
- String folderImage = ThemeHelper.getInstance().getResourceForumURL();
- String folderAlt = "No_new_posts"; //bundle key
- if (this.forumLastPosts!=null && this.forumLastPosts.containsKey(currentForum.getId()))
- {
- PostImpl lastPost = (PostImpl)this.forumLastPosts.get(currentForum.getId());
- Date lastPostDate = lastPost.getCreateDate();
- if (lastPostDate!=null && userLastLogin!=null && lastPostDate.compareTo(userLastLogin)>0)
- {
- folderAlt = "New_posts"; //bundle key
- folderImage = ThemeHelper.getInstance().getResourceForumNewURL();
- }
- }
- if (currentForum.getStatus() == Constants.FORUM_LOCKED)
- {
- folderImage = ThemeHelper.getInstance().getResourceForumLockedURL();
- folderAlt = "Forum_locked"; //bundle key
- }
- this.getForumImages().put(currentForum.getId(),folderImage);
- this.getForumImageDescriptions().put(currentForum.getId(),folderAlt);
- }
- this.getForums().put(category.getId(),categoryForums);
- }
- }
- //-------------------------------------------------------------------------------------------------------------------------------------
+ // ui actions supported by this
+ // bean----------------------------------------------------------------------------------------------------
+ /**
+ * this generates the category and its corresponding forums
+ */
+ private void execute() throws Exception {
+ // try to extract categoryId
+ int categoryId = -1;
+ String c = ForumUtil.getParameter(Constants.p_categoryId);
+ if (c != null && c.trim().length() > 0) {
+ categoryId = Integer.parseInt(c);
+
+ // Setting flag that category has been selected.
+ this.categorySelected = true;
+ }
+
+ // Luca Stancapiano start
+ // get the forumInstanceId where this forum should be added
+ int forumInstanceId = -1;
+ String cou = userPreferences.getPreference(Constants.FORUM_INSTANCE_ID);
+ if (cou != null && cou.trim().length() > 0) {
+ forumInstanceId = Integer.parseInt(cou);
+ }
+
+ this.forumLastPosts = getForumsModule(forumsModule).findLastPostsOfForums(forumInstanceId);
+ // Luca Stancapiano end
+
+ // setup category related data to be displayed
+ if (categoryId == -1) {
+ // process a default level category
+ // Luca Stancapiano
+ Collection cour = getForumsModule(forumsModule).findCategoriesFetchForums(forumInstanceId);
+ if (cour != null) {
+ Iterator iterator = cour.iterator();
+ while (iterator.hasNext()) {
+ CategoryImpl currentCategory = (CategoryImpl) iterator.next();
+ this.processCategory(currentCategory);
+ }
+ }
+ } else {
+ // process the specifed category
+ CategoryImpl currentCategory = (CategoryImpl) getForumsModule(forumsModule).findCategoryByIdFetchForums(categoryId);
+ if (currentCategory != null) {
+ this.processCategory(currentCategory);
+ }
+ }
+ }
+
+ /**
+ *
+ * @return
+ */
+ private void processCategory(CategoryImpl category) throws Exception {
+ Date userLastLogin = PortalUtil.getUserLastLoginDate();
+ if (category != null) {
+ this.getCategories().add(category);
+
+ // process the forums associated with this category
+ Collection forums = category.getForums();
+ Iterator forumsIterator = forums.iterator();
+ Collection categoryForums = new ArrayList();
+ while (forumsIterator.hasNext()) {
+ ForumImpl currentForum = (ForumImpl) forumsIterator.next();
+ categoryForums.add(currentForum);
+
+ // setup folderLook based on whats specified in the theme
+ String folderImage = ThemeHelper.getInstance().getResourceForumURL();
+ String folderAlt = "No_new_posts"; // bundle key
+ if (this.forumLastPosts != null && this.forumLastPosts.containsKey(currentForum.getId())) {
+ PostImpl lastPost = (PostImpl) this.forumLastPosts.get(currentForum.getId());
+ Date lastPostDate = lastPost.getCreateDate();
+ if (lastPostDate != null && userLastLogin != null && lastPostDate.compareTo(userLastLogin) > 0) {
+ folderAlt = "New_posts"; // bundle key
+ folderImage = ThemeHelper.getInstance().getResourceForumNewURL();
+ }
+ }
+ if (currentForum.getStatus() == Constants.FORUM_LOCKED) {
+ folderImage = ThemeHelper.getInstance().getResourceForumLockedURL();
+ folderAlt = "Forum_locked"; // bundle key
+ }
+ this.getForumImages().put(currentForum.getId(), folderImage);
+ this.getForumImageDescriptions().put(currentForum.getId(), folderAlt);
+ }
+ this.getForums().put(category.getId(), categoryForums);
+ }
+ }
+ // -------------------------------------------------------------------------------------------------------------------------------------
}
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewMyForumsAllSubscribed.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -25,7 +25,6 @@
import java.util.Collection;
import java.util.Map;
-import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import org.jboss.portlet.forums.ForumsModule;
@@ -51,7 +50,10 @@
private Watch watch;
private Map topicWatches;
- @PostConstruct
+ public ViewMyForumsAllSubscribed() {
+ init();
+ }
+
public void init()
{
try {
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewProfile.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewProfile.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/forums/ui/view/ViewProfile.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -22,7 +22,6 @@
******************************************************************************/
package org.jboss.portlet.forums.ui.view;
-import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import org.jboss.portlet.forums.ForumsModule;
@@ -60,10 +59,10 @@
{
super();
+ init();
}
- @PostConstruct
public void init() {
try
{
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/CategoryModelTestCase.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -166,8 +166,7 @@
topic1.addPost(post2);
ForumImpl forum1 = new ForumImpl();
-
- forum1.addTopic(topic1);
+ topic1.setForum(forum1);
forum1.setName("Sample Forum");
CategoryImpl category1 = new CategoryImpl();
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/ForumModelTestCase.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/ForumModelTestCase.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/ForumModelTestCase.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -153,8 +153,7 @@
topic1.addPost(post2);
ForumImpl forum1 = new ForumImpl();
-
- forum1.addTopic(topic1);
+ topic1.setForum(forum1);
forum1.setName("Sample Forum");
Modified: labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/main/org/jboss/portlet/test/forums/PostModelTestCase.java 2013-05-31 19:25:05 UTC (rev 38338)
@@ -163,7 +163,7 @@
ForumImpl forum1 = new ForumImpl();
- forum1.addTopic(topic1);
+ topic1.setForum(forum1);
forum1.setName("Sample Forum");
CategoryImpl category1 = new CategoryImpl();
Modified: labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/category/viewcategory_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/category/viewcategory_body.xhtml 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/category/viewcategory_body.xhtml 2013-05-31 19:25:05 UTC (rev 38338)
@@ -41,7 +41,7 @@
<h:commandLink value="#{shared.mainPageName}" action="viewCategory"/>
- <c:if test="#{category.categories ne null and category.categorySelected eq true}" >
+ <c:if test="#{category.initialized and category.categories ne null and category.categorySelected eq true}" >
<ul>
<li>>
<c:forEach items="#{category.categories}" var="catrow">
Modified: labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml
===================================================================
--- labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2013-05-31 19:23:30 UTC (rev 38337)
+++ labs/jbossforums/branches/forums130P27/forums/src/resources/portal-forums-war/views/topics/posting_new_body.xhtml 2013-05-31 19:25:05 UTC (rev 38338)
@@ -290,7 +290,7 @@
</div>
<div class="PostviewStyle">
-<h:form id="post" enctype="multipart/form-data">
+<h:form id="post">
<table border="0" cellpadding="5" cellspacing="0" width="100%" name="table" id="table" >
<!-- keeps the forum where this topic is being created in context, this is a control parameter -->
More information about the jboss-svn-commits
mailing list