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-94f89814c4dfmaster
parent
b970fb1864
commit
d2681805b0
|
|
@ -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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,25 +18,23 @@
|
||||||
*/
|
*/
|
||||||
package com.arsdigita.forum;
|
package com.arsdigita.forum;
|
||||||
|
|
||||||
import com.arsdigita.loader.PackageLoader;
|
|
||||||
|
|
||||||
|
import com.arsdigita.forum.portlet.MyForumsPortlet;
|
||||||
|
import com.arsdigita.forum.portlet.RecentPostingsPortlet;
|
||||||
|
import com.arsdigita.kernel.EmailAddress;
|
||||||
import com.arsdigita.kernel.Kernel;
|
import com.arsdigita.kernel.Kernel;
|
||||||
import com.arsdigita.kernel.KernelExcursion;
|
import com.arsdigita.kernel.KernelExcursion;
|
||||||
import com.arsdigita.kernel.Party;
|
// unused?
|
||||||
|
import com.arsdigita.kernel.Party;
|
||||||
import com.arsdigita.kernel.User;
|
import com.arsdigita.kernel.User;
|
||||||
import com.arsdigita.kernel.EmailAddress;
|
import com.arsdigita.kernel.UserCollection;
|
||||||
import com.arsdigita.kernel.UserCollection;
|
|
||||||
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
|
||||||
|
import com.arsdigita.loader.PackageLoader;
|
||||||
import com.arsdigita.persistence.SessionManager;
|
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.portal.PortletType;
|
||||||
import com.arsdigita.forum.portlet.MyForumsPortlet;
|
import com.arsdigita.portal.apportlet.AppPortletType;
|
||||||
import com.arsdigita.forum.portlet.RecentPostingsPortlet;
|
import com.arsdigita.runtime.ScriptContext;
|
||||||
|
import com.arsdigita.web.ApplicationType;
|
||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
@ -45,13 +43,9 @@ import org.apache.log4j.Logger;
|
||||||
* Loader.
|
* Loader.
|
||||||
*
|
*
|
||||||
* @author Justin Ross <jross@redhat.com>
|
* @author Justin Ross <jross@redhat.com>
|
||||||
* @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);
|
||||||
|
|
||||||
|
|
@ -63,9 +57,9 @@ public class Loader extends PackageLoader {
|
||||||
setupForumAppType();
|
setupForumAppType();
|
||||||
//setupInboxAppType();
|
//setupInboxAppType();
|
||||||
setupRecentPostingsPortletType();
|
setupRecentPostingsPortletType();
|
||||||
setupMyForumsPortletType();
|
setupMyForumsPortletType();
|
||||||
setupDigestUser();
|
setupDigestUser();
|
||||||
SessionManager.getSession().flushAll();
|
SessionManager.getSession().flushAll();
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
|
|
@ -101,54 +95,54 @@ public class Loader extends PackageLoader {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PortletType setupMyForumsPortletType() {
|
public static PortletType setupMyForumsPortletType() {
|
||||||
|
|
||||||
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");
|
||||||
users.close();
|
// Fixes a NPE in Loader of ccm-forum if screen_names are being used
|
||||||
}
|
user.setScreenName("Forum");
|
||||||
|
users.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setupPrivileges() {
|
public static void setupPrivileges() {
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(
|
||||||
Forum.FORUM_MODERATION_PRIVILEGE);
|
Forum.FORUM_MODERATION_PRIVILEGE);
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(
|
||||||
Forum.CREATE_THREAD_PRIVILEGE);
|
Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.addChildPrivilege(Forum.FORUM_MODERATION_PRIVILEGE, Forum.CREATE_THREAD_PRIVILEGE);
|
PrivilegeDescriptor.addChildPrivilege(Forum.FORUM_MODERATION_PRIVILEGE, Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.addChildPrivilege(Forum.CREATE_THREAD_PRIVILEGE, Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
PrivilegeDescriptor.addChildPrivilege(Forum.CREATE_THREAD_PRIVILEGE, Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.addChildPrivilege(Forum.RESPOND_TO_THREAD_PRIVILEGE, PrivilegeDescriptor.READ.getName());
|
PrivilegeDescriptor.addChildPrivilege(Forum.RESPOND_TO_THREAD_PRIVILEGE, PrivilegeDescriptor.READ.getName());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue