[jboss-svn-commits] JBL Code SVN: r9109 - in labs/jbossforums/branches/forums26: forums/src/main/org/jboss/portlet/forums and 6 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Mon Jan 29 20:27:56 EST 2007
Author: unibrew
Date: 2007-01-29 20:27:56 -0500 (Mon, 29 Jan 2007)
New Revision: 9109
Modified:
labs/jbossforums/branches/forums26/authz-jaae-plugin/src/main/org/jboss/forums/security/JBossPortalUtil.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/Context.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/NewTopicAction.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/ReplyAction.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java
labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/jboss-portlet-api-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-api-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-common-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-core-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-format-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-identity-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-jems-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-portlet-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-server-lib.jar
labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portlet-api-lib.jar
Log:
[JBFORUMS-162] Migrating Forums to JBoss Portal 2.6Alpha1. I managed to solve all compile time problems but still there are problems with few views.
Modified: labs/jbossforums/branches/forums26/authz-jaae-plugin/src/main/org/jboss/forums/security/JBossPortalUtil.java
===================================================================
--- labs/jbossforums/branches/forums26/authz-jaae-plugin/src/main/org/jboss/forums/security/JBossPortalUtil.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/authz-jaae-plugin/src/main/org/jboss/forums/security/JBossPortalUtil.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -20,6 +20,7 @@
*/
import org.jboss.portal.identity.RoleModule;
import org.jboss.portal.identity.UserModule;
+import org.jboss.portal.identity.MembershipModule;
/**
@@ -31,6 +32,7 @@
{
private static final String ROLE_MODULE_JNDI_NAME = "java:portal/RoleModule";
private static final String USER_MODULE_JNDI_NAME = "java:portal/UserModule";
+ private static final String MEMBERSHIP_MODULE_JNDI_NAME = "java:portal/MembershipModule";
@@ -51,11 +53,30 @@
return roleModule;
}
+
+
/**
*
* @return
* @throws Exception
*/
+ public static MembershipModule getMembershipModule() throws Exception
+ {
+ MembershipModule membershipModule = null;
+
+ //get the role module from the portal
+ InitialContext ctx = new InitialContext();
+ membershipModule = (MembershipModule)new InitialContext().lookup(JBossPortalUtil.MEMBERSHIP_MODULE_JNDI_NAME);
+
+
+ return membershipModule;
+ }
+
+ /**
+ *
+ * @return
+ * @throws Exception
+ */
public static UserModule getUserModule() throws Exception
{
UserModule userModule = null;
@@ -84,7 +105,7 @@
//grab the roles for this user
String username = user.getIdentity().getUserName();
org.jboss.portal.identity.User portalUser = userModule.findUserByUserName(username);
- Set roles = getRoleModule().getRoles(portalUser);
+ Set roles = getMembershipModule().getRoles(portalUser);
if(!Util.isEmpty(roles))
{
for(Iterator itr=roles.iterator();itr.hasNext();)
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/Context.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/Context.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/Context.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -12,7 +12,7 @@
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
-import org.jboss.portal.portlet.Parameters;
+import org.jboss.portlet.util.Parameters;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.forums.action.*;
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsModule.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -13,6 +13,7 @@
import java.util.Collection;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.jems.hibernate.HibernateProvider;
import org.jboss.portlet.forums.command.result.Result;
@@ -603,5 +604,11 @@
*
*/
public void processNotifications (Integer postId, int watchType , String postUrl , String replyUrl );
+
+ /**
+ *
+ * @return
+ */
+ public UserProfileModule getUserProfileModule();
}
\ No newline at end of file
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ForumsPortlet.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -17,7 +17,11 @@
import org.jboss.portal.format.template.DelegateContext;
import org.jboss.portal.common.util.ProxyInfo;
import org.jboss.portal.identity.ProfileMap;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.info.ProfileInfo;
+import org.jboss.portal.identity.info.PropertyInfo;
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.core.servlet.jsp.PortalJsp;
import org.jboss.portal.format.render.bbcodehtml.ToHTMLConfig;
@@ -109,6 +113,7 @@
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @author <a href="mailto:boleslaw.dawidowicz at jboss.com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
* @version $Revision: 3301 $
*/
public class ForumsPortlet
@@ -156,6 +161,8 @@
private CLLoader loader;
private ForumsModule forumsModule;
+
+ private UserProfileModule upm;
/**
* Initialization method of the portlet
@@ -170,6 +177,7 @@
{
forumsModule = (ForumsModule)new InitialContext().lookup("java:portal/ForumsModule");
getPortletContext().setAttribute("forumsModule", forumsModule);
+ upm=forumsModule.getUserProfileModule();
}
catch (NamingException e)
{
@@ -1210,16 +1218,17 @@
try
{
PortletPreferences pp = request.getPreferences();
- ProfileMap upm = request.getUser().getProfile();
+ Map upm = this.upm.getProperties(request.getUser());
if (!pp.isReadOnly("notifyreply"))
{
pp.setValue("notifyreply", request.getParameter("notifyreply"));
}
/*if (!pp.isReadOnly("attachsig"))
pp.setValue("attachsig", request.getParameter("attachsig"));*/
- if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
+ if (this.upm.getProfileInfo().getPropertyInfo(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).
+ getAccessMode().compareTo(PropertyInfo.ACCESS_MODE_READ_ONLY)!=0)
{
- upm.put(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY, request.getParameter("attachsig"));
+ this.upm.setProperty(request.getUser(),ForumsConstants.USER_SIGNATURE_ADD_PROPERTY, request.getParameter("attachsig"));
}
//TODO: BBCode disable should be implemented
/*if (!pp.isReadOnly("allowbbcode"))
@@ -1265,9 +1274,10 @@
{
pp.setValue("signature", request.getParameter("signature"));
}*/
- if (!upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
+ if (this.upm.getProfileInfo().getPropertyInfo(ForumsConstants.USER_SIGNATURE_PROPERTY).
+ getAccessMode().compareTo(PropertyInfo.ACCESS_MODE_READ_ONLY)!=0)
{
- upm.put(ForumsConstants.USER_SIGNATURE_PROPERTY, request.getParameter("signature"));
+ this.upm.setProperty(request.getUser(),ForumsConstants.USER_SIGNATURE_PROPERTY, request.getParameter("signature"));
}
String summarymode = request.getParameter("summarymode");
@@ -1910,9 +1920,15 @@
if (ctx.p_preview)
{
- ProfileMap upm = request.getUser().getProfile();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+ User userReq = request.getUser();
+ String sign = null;
+ String addsign = null;
+ try {
+ sign = this.upm.getProperty(userReq,ForumsConstants.USER_SIGNATURE_PROPERTY).toString();
+ addsign = this.upm.getProperty(userReq,ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).toString();
+ } catch (IdentityException e) {
+ e.printStackTrace();
+ }
String preview_message = "";
if ((addsign != null) && (sign != null) && addsign.equals("1"))
{
@@ -3387,7 +3403,13 @@
User user = req.getUser();
//boolean loggedIn = isUserLoggedIn(user);
boolean loggedIn = req.getRemoteUser() != null;
- Date lastVisit = loggedIn ? user.getLastVisitDate() : null;
+ Date lastVisit = null;
+ try {
+ lastVisit = loggedIn ? getSDF(req).parse(upm.getProperty(user,User.INFO_USER_LAST_LOGIN_DATE).toString()) : null;
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
String categoryTitle = category.getTitle();
String forumName = forum.getName();
@@ -3778,7 +3800,6 @@
}
PortletPreferences pp = req.getPreferences();
- ProfileMap upm = req.getUser().getProfile();
if (pp.getValue("notifyreply", "0").equals("1"))
{
root.put("NOTIFY_REPLY_YES", "CHECKED");
@@ -3795,7 +3816,8 @@
{
root.put("ALWAYS_ADD_SIGNATURE_NO", "CHECKED");
}*/
- String attachsig = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+ try {
+ String attachsig = this.upm.getProperty(req.getUser(),ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).toString();
if ((attachsig != null) && attachsig.equals("1"))
{
root.put("ALWAYS_ADD_SIGNATURE_YES", "CHECKED");
@@ -3878,10 +3900,9 @@
root.put("POSTS_PER_TOPIC_N30", "CHECKED");
break;
}
-
root.put("DATE_FORMAT", pp.getValue("dateformat", ForumsConstants.DEFAULT_DATE_PATTERN));
//root.put("SIGNATURE", pp.getValue("signature", ""));
- String sig = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
+ String sig = this.upm.getProperty(req.getUser(),ForumsConstants.USER_SIGNATURE_PROPERTY).toString();
root.put("SIGNATURE", (sig != null) ? sig : "");
if (pp.isReadOnly("notifyreply"))
@@ -3890,7 +3911,8 @@
}
/*if (pp.isReadOnly("attachsig"))
root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");*/
- if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY))
+ if (this.upm.getProfileInfo().getPropertyInfo(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).
+ getAccessMode().compareTo(PropertyInfo.ACCESS_MODE_READ_ONLY)==0)
{
root.put("ALWAYS_ADD_SIGNATURE_DISABLED", "DISABLED");
}
@@ -3918,11 +3940,14 @@
}
/*if (pp.isReadOnly("signature"))
root.put("SIGNATURE_DISABLED", "DISABLED");*/
- if (upm.isReadOnly(ForumsConstants.USER_SIGNATURE_PROPERTY))
+ if (this.upm.getProfileInfo().getPropertyInfo(ForumsConstants.USER_SIGNATURE_PROPERTY)
+ .getAccessMode().compareTo(PropertyInfo.ACCESS_MODE_READ_ONLY)==0)
{
root.put("SIGNATURE_DISABLED", "DISABLED");
}
-
+ } catch (IdentityException e) {
+ e.printStackTrace();
+ }
int summarymode = Integer.parseInt(pp.getValue("summarymode", "0"));
switch (summarymode)
{
@@ -3977,37 +4002,47 @@
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
return root;
}
+
+ String fakeEmail = null;
+ String homepage = null;
+ String icqAddr = null;
+ String aimAddr = null;
+ String yimAddr = null;
+
+ try {
+ PortletURL viewMainPageURL = resp.createRenderURL();
+ viewMainPageURL.setParameter("op", OP_MAIN);
+ root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
+ root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
+ root.put("USERNAME", upm.getProperty(user,User.INFO_USER_NAME_GIVEN).toString());
+
+ //root.put("EMAIL_IMG", user.getFakeEmail());
+ //String homepage = (String)(user.getProfile().get(CoreConstants.INFO_USER_HOMEPAGE));
+ //root.put("WWW", "<a href=\"" + homepage + "\">"+ homepage + "</a>");
+ root.put("LOCATION", (String)(upm.getProperty(user,User.INFO_USER_LOCATION)));
+ root.put("OCCUPATION", (String)(upm.getProperty(user,User.INFO_USER_OCCUPATION)));
+ root.put("INTERESTS", (String)(upm.getProperty(user,User.INFO_USER_INTERESTS)));
+
+ //root.put("ICQ_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_ICQ)));
+ //root.put("AIM_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_AIM)));
+ //root.put("YIM_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_YIM)));
+ root.put("MSN_IMG", (String)(upm.getProperty(user,User.INFO_USER_IM_MSNM)));
+ root.put("SKYPE_IMG", (String)(upm.getProperty(user,User.INFO_USER_IM_SKYPE)));
+
+ root.put("JOINED", "" + upm.getProperty(user,User.INFO_USER_REGISTRATION_DATE).toString());
+ root.put("POSTS", "" + poster.getPostCount());
+
+
+ fakeEmail = upm.getProperty(user,User.INFO_USER_EMAIL_FAKE).toString();
+ homepage = (String)(upm.getProperty(user,User.INFO_USER_HOMEPAGE));
+ icqAddr = (String)(upm.getProperty(user,User.INFO_USER_IM_ICQ));
+ aimAddr = (String)(upm.getProperty(user,User.INFO_USER_IM_AIM));
+ yimAddr = (String)(upm.getProperty(user,User.INFO_USER_IM_YIM));
+ } catch (IdentityException e) {
+ e.printStackTrace();
+ return root;
+ }
- PortletURL viewMainPageURL = resp.createRenderURL();
- viewMainPageURL.setParameter("op", OP_MAIN);
- root.put("U_VIEW_MAIN_PAGE", viewMainPageURL.toString());
- root.put("MAIN_PAGE_NAME", req.getPortalContext().getProperty("org.jboss.portal.property.name"));
- root.put("USERNAME", user.getGivenName());
-
- //root.put("EMAIL_IMG", user.getFakeEmail());
- //String homepage = (String)(user.getProfile().get(CoreConstants.INFO_USER_HOMEPAGE));
- //root.put("WWW", "<a href=\"" + homepage + "\">"+ homepage + "</a>");
- root.put("LOCATION", (String)(user.getProfile().get(User.INFO_USER_LOCATION)));
- root.put("OCCUPATION", (String)(user.getProfile().get(User.INFO_USER_OCCUPATION)));
- root.put("INTERESTS", (String)(user.getProfile().get(User.INFO_USER_INTERESTS)));
-
- //root.put("ICQ_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_ICQ)));
- //root.put("AIM_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_AIM)));
- //root.put("YIM_IMG", (String)(user.getProfile().get(CoreConstants.INFO_USER_IM_YIM)));
- root.put("MSN_IMG", (String)(user.getProfile().get(User.INFO_USER_IM_MSNM)));
- root.put("SKYPE_IMG", (String)(user.getProfile().get(User.INFO_USER_IM_SKYPE)));
-
- root.put("JOINED", "" + user.getRegistrationDate());
- root.put("POSTS", "" + poster.getPostCount());
-
-
- String fakeEmail = user.getFakeEmail();
- String homepage = (String)(user.getProfile().get(User.INFO_USER_HOMEPAGE));
- String icqAddr = (String)(user.getProfile().get(User.INFO_USER_IM_ICQ));
- String aimAddr = (String)(user.getProfile().get(User.INFO_USER_IM_AIM));
- String yimAddr = (String)(user.getProfile().get(User.INFO_USER_IM_YIM));
-
-
if (fakeEmail != null && fakeEmail.length() > 0)
{
String emailImgLnk = ForumsTools.createImageLink("mailto:" + fakeEmail, theme.resourceIconEmailURL, "");
@@ -4204,10 +4239,18 @@
if (req.getParameters().getParameterExists("preview"))
{
- ProfileMap upm = req.getUser().getProfile();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
-
+ User userReq = req.getUser();
+ String sign = null;
+ String addsign = null;
+
+ try {
+ sign = this.upm.getProperty(userReq,ForumsConstants.USER_SIGNATURE_PROPERTY).toString();
+ addsign = this.upm.getProperty(userReq,ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
+
DelegateContext preview = root.next("preview");
preview.put("PREVIEW_SUBJECT", req.getParameter("PREVIEW_SUBJECT"));
preview.put("TOPIC_TITLE", req.getParameter("TOPIC_TITLE"));
@@ -4456,9 +4499,16 @@
postRow.put("POST_DATE", getSDF(req).format(post.getCreateDate()));
postRow.put("POST_SUBJECT", post.getMessage().getSubject());
String message = post.getMessage().getText();
- ProfileMap upm = post.getPoster().getUser().getProfile();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+ String sign = null;
+ String addsign = null;
+ try {
+ sign = this.upm.getProperty(req.getUser(),ForumsConstants.USER_SIGNATURE_PROPERTY).toString();
+ addsign = this.upm.getProperty(req.getUser(),ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
+
if ((addsign != null) && (sign != null) && addsign.equals("1"))
{
message += "\n\n" + sign;
@@ -4526,10 +4576,11 @@
//if (isUserLoggedIn(user))
if (req.getRemoteUser() != null)
{
- // Date lastVisit = user.getPreviousLastVisitDate();
- Date lastVisit = user.getLastVisitDate();
- try
- {
+ try
+ {
+ // Date lastVisit = user.getPreviousLastVisitDate();
+ Date lastVisit = getSDF(req).parse(upm.getProperty(user,User.INFO_USER_LAST_LOGIN_DATE).toString());
+
topic = forumsModule.findTopicById(topicId);
Post post = topic.getLastPost();
@@ -4540,6 +4591,10 @@
catch (ModuleException e)
{
// Die.exit(GENERAL_MESSAGE, "${No_new_posts_last_visit}");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
}
}
else
@@ -5396,14 +5451,27 @@
String postDate = sdf.format(post.getCreateDate());
String posterPosts = req.getRemoteUser() != null ? (bundle.getString("Posts")
+ ":" + poster.getUserName()) : "";
- String location = (String)poster.getProfile().get("LOCATION");
+ String location = null;
+ try {
+ location = this.upm.getProperty(poster,User.INFO_USER_LOCATION).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
String posterFrom = (req.getRemoteUser() != null && (location != null)) ? (bundle
.getString("Location")
+ ":" + location) : "";
/*String posterJoined = (poster != null) ? (bundle.getString("Joined")
+ ":" + poster.getRegistrationDate()) : "";*/
+ String registrationDate = null;
+ try {
+ registrationDate = upm.getProperty(poster,User.INFO_USER_REGISTRATION_DATE).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
String posterJoined = req.getRemoteUser() != null ? (bundle.getString("Joined")
- + ":" + sdf.format(poster.getRegistrationDate())) : "";
+ + ":" + sdf.format(registrationDate)) : "";
// String posterAvatar = "";
// $poster_avatar = '';
@@ -5497,13 +5565,26 @@
if ((req.getRemoteUser() != null))
{
//user.getPreferenceStore().
- String fakeEmail = poster.getFakeEmail();
- String homepage = (String)(poster.getProfile().get(User.INFO_USER_HOMEPAGE));
- String icqAddr = (String)(poster.getProfile().get(User.INFO_USER_IM_ICQ));
- String aimAddr = (String)(poster.getProfile().get(User.INFO_USER_IM_AIM));
- String msnmAddr = (String)(poster.getProfile().get(User.INFO_USER_IM_MSNM));
- String yimAddr = (String)(poster.getProfile().get(User.INFO_USER_IM_YIM));
- String skypeAddr = (String)(poster.getProfile().get(User.INFO_USER_IM_SKYPE));
+ String fakeEmail = null;
+ String homepage = null;
+ String icqAddr = null;
+ String aimAddr = null;
+ String msnmAddr = null;
+ String yimAddr = null;
+ String skypeAddr = null;
+
+ try {
+ fakeEmail = this.upm.getProperty(poster,User.INFO_USER_EMAIL_FAKE).toString();
+ homepage = this.upm.getProperty(poster,User.INFO_USER_HOMEPAGE).toString();
+ icqAddr = this.upm.getProperty(poster,User.INFO_USER_IM_ICQ).toString();
+ aimAddr = this.upm.getProperty(poster,User.INFO_USER_IM_AIM).toString();
+ msnmAddr = this.upm.getProperty(poster,User.INFO_USER_IM_MSNM).toString();
+ yimAddr = this.upm.getProperty(poster,User.INFO_USER_IM_YIM).toString();
+ skypeAddr = this.upm.getProperty(poster,User.INFO_USER_IM_SKYPE).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
profileImgLnk = ForumsTools.createImageLink(userProfileURL.toString(), theme.resourceIconProfileURL, "");
if (fakeEmail != null && fakeEmail.length() > 0)
@@ -5652,9 +5733,17 @@
text = new String(message.getText());
}
- ProfileMap upm = post.getPoster().getUser().getProfile();
- String sign = (String)upm.get(ForumsConstants.USER_SIGNATURE_PROPERTY);
- String addsign = (String)upm.get(ForumsConstants.USER_SIGNATURE_ADD_PROPERTY);
+ User posterUser = post.getPoster().getUser();
+
+ String sign = null;
+ String addsign = null;
+ try {
+ sign = this.upm.getProperty(posterUser,ForumsConstants.USER_SIGNATURE_PROPERTY).toString();
+ addsign = this.upm.getProperty(posterUser,ForumsConstants.USER_SIGNATURE_ADD_PROPERTY).toString();
+ } catch (IdentityException e)
+ {
+ e.printStackTrace();
+ }
if ((addsign != null) && (sign != null) && addsign.equals("1"))
{
text += "\n\n" + sign;
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/NewTopicAction.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/NewTopicAction.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/NewTopicAction.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -14,6 +14,9 @@
import java.util.List;
import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.User;
import org.jboss.portlet.forums.impl.MessageImpl;
import org.jboss.portlet.forums.impl.PollImpl;
import org.jboss.portlet.forums.impl.PosterImpl;
@@ -25,6 +28,7 @@
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
* @version $Revision: 916 $
*/
public class NewTopicAction
@@ -125,13 +129,16 @@
forum = module.findForumById(new Integer(forumId));
if (getMode() == INIT)
{
- message.setSignatureEnabled((poster.getUser().getSignature() != null)
- && (poster.getUser().getSignature().trim().length() != 0));
+ UserProfileModule upm = module.getUserProfileModule();
+ message.setSignatureEnabled((upm.getProperty(poster.getUser(),User.INFO_USER_SIGNATURE) != null)
+ && (upm.getProperty(poster.getUser(),User.INFO_USER_SIGNATURE).toString().trim().length() != 0));
}
}
catch (ModuleException e)
{
throw new RuntimeException();
+ } catch (IdentityException e) {
+ throw new RuntimeException();
}
}
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/ReplyAction.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/ReplyAction.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/action/ReplyAction.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -14,6 +14,8 @@
import java.util.List;
import org.jboss.portal.core.modules.ModuleException;
+import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portlet.forums.model.Forum;
import org.jboss.portlet.forums.model.Message;
import org.jboss.portlet.forums.model.Post;
@@ -23,6 +25,7 @@
/**
* @author <a href="mailto:julien at jboss.org">Julien Viet</a>
* @author <a href="mailto:theute at jboss.org">Thomas Heute</a>
+ * @author <a href="mailto:ryszard.kozmik at jboss.com">Ryszard Kozmik</a>
* @version $Revision: 916 $
*/
public class ReplyAction
@@ -171,7 +174,7 @@
message.setSubject("Re: " + message.getSubject());
}
- String signature = getPoster().getUser().getSignature();
+ String signature = module.getUserProfileModule().getProperty(getPoster().getUser(),User.INFO_USER_SIGNATURE).toString();
if ((signature != null) && (signature.trim().length() != 0))
{
message.setSignatureEnabled(true);
@@ -181,6 +184,8 @@
catch (ModuleException e)
{
e.printStackTrace();
+ } catch (IdentityException e) {
+ e.printStackTrace();
}
}
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/impl/ForumsModuleImpl.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -20,6 +20,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import javax.naming.InitialContext;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
@@ -29,6 +30,7 @@
import org.jboss.portal.core.modules.AbstractModule;
import org.jboss.portal.core.modules.ModuleException;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portal.jems.hibernate.HibernateProvider;
import org.jboss.portlet.forums.ForumsConstants;
import org.jboss.portlet.forums.ForumsModule;
@@ -70,6 +72,7 @@
private HibernateProvider hibernate;
private SessionFactory factory;
+ private UserProfileModule userProfileModule;
private NotificationEngine notificationEngine;
@@ -90,7 +93,7 @@
super.startService();
factory = hibernate.getSessionFactory();
-
+ userProfileModule = (UserProfileModule)new InitialContext().lookup("java:portal/UserProfileModule");
notificationEngine = new NotificationEngine(this);
notificationEngine.setFrom(fromAddress);
// Define the chain of interceptors
@@ -1705,6 +1708,10 @@
notificationEngine.schedule(postId, watchType, postUrl , replyUrl );
}
+ public UserProfileModule getUserProfileModule() {
+ return this.userProfileModule;
+ }
+
protected Session getSession () {
return factory.getCurrentSession();
}
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/interceptors/NotificationInterceptor.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -24,6 +24,8 @@
import org.jboss.portal.api.node.PortalNode;
import org.jboss.portal.api.node.PortalNodeURL;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.JBossActionResponse;
import org.jboss.portlet.forums.command.ActionCommand;
@@ -65,6 +67,7 @@
private static final int MODE_REPOST = 2;
private ForumsModule forumsModule;
+ private UserProfileModule upm;
private TemplateLoader mailTemplates;
private String from;
private QueuedExecutor executor;
@@ -81,6 +84,7 @@
mailModule = (MailModule)ctx.lookup(ModuleConstants.MAILMODULE_JNDINAME);
tm = (TransactionManager)ctx.lookup("java:TransactionManager");
executor = new QueuedExecutor(new LinkedQueue());
+ upm = forumsModule.getUserProfileModule();
}
catch (NamingException e)
{
@@ -170,17 +174,25 @@
private String getFrom(Post post)
{
StringBuffer fromBuf = null;
- if ((post.getPoster().getUser().getGivenName() != null)
- && (post.getPoster().getUser().getFamilyName() != null))
+ try {
+ User user = post.getPoster().getUser();
+ if ((upm.getProperty(user,User.INFO_USER_NAME_GIVEN) != null)
+ && (upm.getProperty(user,User.INFO_USER_NAME_FAMILY) != null))
{
- fromBuf = new StringBuffer(post.getPoster().getUser().getGivenName()
- + " " + post.getPoster().getUser().getFamilyName() + " <");
+ fromBuf = new StringBuffer(upm.getProperty(user,User.INFO_USER_NAME_GIVEN)
+ + " " + upm.getProperty(user,User.INFO_USER_NAME_FAMILY) + " <");
}
else
{
fromBuf = new StringBuffer(post.getPoster().getUser().getUserName() + " <");
}
fromBuf.append(from + ">");
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ log.error(e);
+ }
return fromBuf.toString();
}
@@ -271,7 +283,7 @@
subject = forumEmbededArgsSubject;
text = forumEmbededArgsText;
}
- mailModule.send(getFrom(post), watcher.getRealEmail(), subject, text);
+ mailModule.send(getFrom(post), upm.getProperty(watcher,User.INFO_USER_EMAIL_REAL).toString(), subject, text);
}
else
{
@@ -308,7 +320,7 @@
+ bundle.getString("EMAIL_VIEWORIGINAL") + " : " + viewURL.toString() + "#" + post.getId() + "\n\n";
mailModule.send((String)getFrom(post),
- watcher.getRealEmail(),
+ upm.getProperty(watcher,User.INFO_USER_EMAIL_REAL).toString(),
"[" + forum.getName() + "] " + bundle.getString("Topic_reply_notification"),
mailBody);
}
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/ui/ForumsJSFPortlet.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -50,7 +50,7 @@
import javax.portlet.PortletMode;
//jboss portal
-import org.jboss.portal.portlet.Parameters;
+import org.jboss.portal.portlet.PortletParameters;
import org.jboss.portal.portlet.impl.jsr168.PortletRequestImpl;
import org.jboss.portlet.JBossActionRequest;
import org.jboss.portlet.forums.helper.TempFileBinding;
@@ -309,7 +309,7 @@
Class requestClass = PortletRequestImpl.class;
Field field = requestClass.getDeclaredField("parameters");
field.setAccessible(true);
- field.set(request, new Parameters(newParams));
+ field.set(request, new PortletParameters(newParams));
field.setAccessible(false);
if (fc.getViewRoot()==null) {
@@ -541,7 +541,7 @@
Class requestClass = PortletRequestImpl.class;
Field field = requestClass.getDeclaredField("parameters");
field.setAccessible(true);
- field.set(req, new Parameters(newParams));
+ field.set(req, new PortletParameters(newParams));
// TODO: This workaround is not best possible because we are using here JBossActionRequest.
Modified: labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java
===================================================================
--- labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java 2007-01-29 23:48:21 UTC (rev 9108)
+++ labs/jbossforums/branches/forums26/forums/src/main/org/jboss/portlet/forums/util/NotificationEngine.java 2007-01-30 01:27:56 UTC (rev 9109)
@@ -51,7 +51,9 @@
import org.jboss.portal.common.transaction.Transactions;
import org.jboss.portal.format.render.bbcodehtml.ToTextRenderer;
import org.jboss.portal.format.template.TemplateLoader;
+import org.jboss.portal.identity.IdentityException;
import org.jboss.portal.identity.User;
+import org.jboss.portal.identity.UserProfileModule;
import org.jboss.portlet.forums.ForumsConstants;
import org.jboss.portlet.forums.ForumsModule;
import org.jboss.portlet.forums.auth.Authorization;
@@ -81,6 +83,7 @@
public static final int MODE_REPOST = 2;
private ForumsModule forumsModule;
+ private UserProfileModule userProfileModule;
private TemplateLoader mailTemplates;
private String from;
private QueuedExecutor executor;
@@ -95,6 +98,7 @@
InitialContext ctx = new InitialContext();
tm = (TransactionManager)ctx.lookup("java:TransactionManager");
executor = new QueuedExecutor(new LinkedQueue());
+ userProfileModule = forumsModule.getUserProfileModule();
}
catch (NamingException e)
{
@@ -173,19 +177,23 @@
}
private String getFrom(Post post)
- {
- StringBuffer fromBuf = null;
- if ((post.getPoster().getUser().getGivenName() != null)
- && (post.getPoster().getUser().getFamilyName() != null))
- {
- fromBuf = new StringBuffer(post.getPoster().getUser().getGivenName()
- + " " + post.getPoster().getUser().getFamilyName() + " <");
- }
- else
- {
- fromBuf = new StringBuffer(post.getPoster().getUser().getUserName() + " <");
- }
+ {
+ StringBuffer fromBuf = null;
+ try {
+ if ( (userProfileModule.getProperty(post.getPoster().getUser(),User.INFO_USER_NAME_GIVEN) != null)
+ && (userProfileModule.getProperty(post.getPoster().getUser(),User.INFO_USER_NAME_FAMILY) != null))
+ {
+ fromBuf = new StringBuffer(userProfileModule.getProperty(post.getPoster().getUser(),User.INFO_USER_NAME_GIVEN)
+ + " " + userProfileModule.getProperty(post.getPoster().getUser(),User.INFO_USER_NAME_FAMILY) + " <");
+ }
+ else
+ {
+ fromBuf = new StringBuffer(post.getPoster().getUser().getUserName() + " <");
+ }
fromBuf.append(from + ">");
+ } catch (IdentityException e) {
+ log.error(e);
+ }
return fromBuf.toString();
}
@@ -386,7 +394,7 @@
StringBuffer buffer = null;
Address[] to = null;
MimeMessage m = new MimeMessage(session);
- String email = watcher.getRealEmail();
+ String email = userProfileModule.getProperty(watcher,User.INFO_USER_EMAIL_REAL).toString();
if ( email != null ) {
m.setFrom(new InternetAddress(from));
to = new InternetAddress[] { new InternetAddress(
@@ -407,6 +415,8 @@
}
} catch (javax.mail.MessagingException e) {
log.error(e);
+ } catch (IdentityException e2) {
+ log.error(e2);
}
} catch (javax.naming.NamingException e) {
log.error(e);
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/jboss-portlet-api-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-api-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-common-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-core-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-format-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-identity-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-jems-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-portlet-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portal-server-lib.jar
===================================================================
(Binary files differ)
Modified: labs/jbossforums/branches/forums26/thirdparty/jbportal/lib/portlet-api-lib.jar
===================================================================
(Binary files differ)
More information about the jboss-svn-commits
mailing list