Integrate patch 1911: Forum, fix NPE in loader if screen_names are being used

git-svn-id: https://svn.libreccm.org/ccm/trunk@237 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2009-08-28 13:30:45 +00:00
parent b970fb1864
commit d2681805b0
2 changed files with 54 additions and 59 deletions

View File

@ -40,13 +40,14 @@ import org.apache.log4j.Logger;
* A set of configuration parameters for forums. * A set of configuration parameters for forums.
* *
* @author Justin Ross <jross@redhat.com> * @author Justin Ross <jross@redhat.com>
* @author Chris Gilbert Westsussex Council / Westsussex Learning Grid
* @version $Id: ForumConfig.java 1628 2007-09-17 08:10:40Z chrisg23 $ * @version $Id: ForumConfig.java 1628 2007-09-17 08:10:40Z chrisg23 $
*/ */
public class ForumConfig extends AbstractConfig { public class ForumConfig extends AbstractConfig {
public final static String versionId = // public final static String versionId =
"$Id: ForumConfig.java 1628 2007-09-17 08:10:40Z chrisg23 $" + // "$Id: ForumConfig.java 1628 2007-09-17 08:10:40Z chrisg23 $" +
"$Author: chrisg23 $" + // "$Author: chrisg23 $" +
"$DateTime: 2004/08/17 23:26:27 $"; // "$DateTime: 2004/08/17 23:26:27 $";
private static final Logger s_log = Logger.getLogger(ForumConfig.class); private static final Logger s_log = Logger.getLogger(ForumConfig.class);

View File

@ -18,25 +18,23 @@
*/ */
package com.arsdigita.forum; package com.arsdigita.forum;
import com.arsdigita.loader.PackageLoader;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.User;
import com.arsdigita.kernel.EmailAddress;
import com.arsdigita.kernel.UserCollection;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.runtime.ScriptContext;
import com.arsdigita.web.ApplicationType;
import com.arsdigita.portal.apportlet.AppPortletType;
import com.arsdigita.portal.PortletType;
import com.arsdigita.forum.portlet.MyForumsPortlet; import com.arsdigita.forum.portlet.MyForumsPortlet;
import com.arsdigita.forum.portlet.RecentPostingsPortlet; import com.arsdigita.forum.portlet.RecentPostingsPortlet;
import com.arsdigita.kernel.EmailAddress;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
// unused?
import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.User;
import com.arsdigita.kernel.UserCollection;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
import com.arsdigita.loader.PackageLoader;
import com.arsdigita.persistence.SessionManager;
import com.arsdigita.portal.PortletType;
import com.arsdigita.portal.apportlet.AppPortletType;
import com.arsdigita.runtime.ScriptContext;
import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -48,10 +46,6 @@ import org.apache.log4j.Logger;
* @version $Id: Loader.java 1628 2007-09-17 08:10:40Z chrisg23 $ * @version $Id: Loader.java 1628 2007-09-17 08:10:40Z chrisg23 $
*/ */
public class Loader extends PackageLoader { public class Loader extends PackageLoader {
public final static String versionId =
"$Id: Loader.java 1628 2007-09-17 08:10:40Z chrisg23 $" +
"$Author: chrisg23 $" +
"$DateTime: 2004/08/17 23:26:27 $";
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);
@ -65,7 +59,7 @@ public class Loader extends PackageLoader {
setupRecentPostingsPortletType(); setupRecentPostingsPortletType();
setupMyForumsPortletType(); setupMyForumsPortletType();
setupDigestUser(); setupDigestUser();
SessionManager.getSession().flushAll(); SessionManager.getSession().flushAll();
} }
}.run(); }.run();
} }
@ -105,31 +99,31 @@ public class Loader extends PackageLoader {
PortletType type = PortletType PortletType type = PortletType
.createPortletType("My Forums", .createPortletType("My Forums",
PortletType.WIDE_PROFILE, PortletType.WIDE_PROFILE,
MyForumsPortlet.BASE_DATA_OBJECT_TYPE); MyForumsPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Lists forums that user has access to, with last posting date"); type.setDescription("Lists forums that user has access to, with last posting date");
return type; return type;
} }
private static void setupDigestUser() { private static void setupDigestUser() {
s_log.debug("Setting up the digest user"); s_log.debug("Setting up the digest user");
// Email address corresponding to the digest sender, as // Email address corresponding to the digest sender, as
// specified in the configuration file. // specified in the configuration file.
String email = Forum.getConfig().getDigestUserEmail(); String email = Forum.getConfig().getDigestUserEmail();
UserCollection users = User.retrieveAll(); UserCollection users = User.retrieveAll();
users.addEqualsFilter("primaryEmail", email); users.addEqualsFilter("primaryEmail", email);
if (users.next()) { if (users.next()) {
s_log.debug("user exists"); s_log.debug("user exists");
} else { } else {
s_log.debug("Creating a user with the email " + email); s_log.debug("Creating a user with the email " + email);
User user = new User(); User user = new User();
user.setPrimaryEmail(new EmailAddress(email)); user.setPrimaryEmail(new EmailAddress(email));
user.getPersonName().setGivenName("Forum"); user.getPersonName().setGivenName("Forum");
user.getPersonName().setFamilyName("Digest Sender"); user.getPersonName().setFamilyName("Digest Sender");
// Fixes a NPE in Loader of ccm-forum if screen_names are being used
user.setScreenName("Forum");
users.close(); users.close();
} }