Verschiedene Formatierungen und Dokumentationsergänzungen.
git-svn-id: https://svn.libreccm.org/ccm/trunk@542 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
5424b1ea64
commit
1804c32331
|
|
@ -115,7 +115,10 @@ public class PrivilegeDescriptor {
|
||||||
priv.set("privilege", name);
|
priv.set("privilege", name);
|
||||||
priv.save();
|
priv.save();
|
||||||
addChildPrivilege(ADMIN_NAME, name);
|
addChildPrivilege(ADMIN_NAME, name);
|
||||||
PrivilegeDescriptor desc = new PrivilegeDescriptor(name);
|
// Constructor PrivilegeDescriptor is deprecated and should be
|
||||||
|
// replace the class method get(name)
|
||||||
|
// PrivilegeDescriptor desc = new PrivilegeDescriptor(name);
|
||||||
|
PrivilegeDescriptor desc = get(name);
|
||||||
put(desc);
|
put(desc);
|
||||||
return desc;
|
return desc;
|
||||||
}
|
}
|
||||||
|
|
@ -145,7 +148,6 @@ public class PrivilegeDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Given a privilege name, returns a privilege descriptor or null
|
* Given a privilege name, returns a privilege descriptor or null
|
||||||
* if the privilege does not exist on the system.
|
* if the privilege does not exist on the system.
|
||||||
*
|
*
|
||||||
|
|
@ -159,19 +161,17 @@ public class PrivilegeDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Returns a collection of privilege descriptors for every privilege in
|
* Returns a collection of privilege descriptors for every privilege in
|
||||||
* the system.
|
* the system.
|
||||||
* @return a collection of privilege descriptors.
|
|
||||||
*
|
|
||||||
* @see #get(String)
|
* @see #get(String)
|
||||||
|
*
|
||||||
|
* @return a collection of privilege descriptors.
|
||||||
*/
|
*/
|
||||||
public static Collection getAll() {
|
public static Collection getAll() {
|
||||||
return s_privs.values();
|
return s_privs.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Deletes the privilege described by this from the system.
|
* Deletes the privilege described by this from the system.
|
||||||
*
|
*
|
||||||
* @exception PersistenceException when there is a persistence
|
* @exception PersistenceException when there is a persistence
|
||||||
|
|
@ -185,9 +185,9 @@ public class PrivilegeDescriptor {
|
||||||
OID oid = new OID("com.arsdigita.kernel.permissions.Privilege",
|
OID oid = new OID("com.arsdigita.kernel.permissions.Privilege",
|
||||||
m_name);
|
m_name);
|
||||||
|
|
||||||
DataObject priv = SessionManager.getSession()
|
DataObject priv = SessionManager.getSession().retrieve(oid);
|
||||||
.retrieve(oid);
|
|
||||||
priv.delete();
|
priv.delete();
|
||||||
|
|
||||||
s_privs.remove(m_name);
|
s_privs.remove(m_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,14 +201,11 @@ public class PrivilegeDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <br>
|
|
||||||
*
|
|
||||||
* Returns the display name for the privilege, or just the
|
* Returns the display name for the privilege, or just the
|
||||||
* privilege name if no display name is defined.
|
* privilege name if no display name is defined.
|
||||||
*
|
*
|
||||||
* @return the display name
|
* @return the display name
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
if (m_displayName != null) {
|
if (m_displayName != null) {
|
||||||
return m_displayName;
|
return m_displayName;
|
||||||
|
|
@ -261,8 +258,8 @@ public class PrivilegeDescriptor {
|
||||||
* Create a new privilege descriptor for use with PermissionDescriptor
|
* Create a new privilege descriptor for use with PermissionDescriptor
|
||||||
* and PermissionService.
|
* and PermissionService.
|
||||||
*
|
*
|
||||||
* @deprecated see #get
|
|
||||||
* @param name The name of the privilege.
|
* @param name The name of the privilege.
|
||||||
|
* @deprecated see #get
|
||||||
**/
|
**/
|
||||||
public PrivilegeDescriptor(String name) {
|
public PrivilegeDescriptor(String name) {
|
||||||
m_name = name;
|
m_name = name;
|
||||||
|
|
@ -281,9 +278,8 @@ public class PrivilegeDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Puts a privilege descriptor into the internal cache that is used by
|
||||||
* Puts a privilege descriptor into the internal cache that is
|
* the get method. The put method supports extendibility by allowing
|
||||||
* used by the get method. The put method supports extendibility by allowing
|
|
||||||
* subclasses to be returned by the get method.
|
* subclasses to be returned by the get method.
|
||||||
*/
|
*/
|
||||||
protected static void put(PrivilegeDescriptor privDesc) {
|
protected static void put(PrivilegeDescriptor privDesc) {
|
||||||
|
|
@ -291,7 +287,6 @@ public class PrivilegeDescriptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* Returns the list of privilege names that imply this privilege.
|
* Returns the list of privilege names that imply this privilege.
|
||||||
* @return a collection of the privilege names that imply this privilege.
|
* @return a collection of the privilege names that imply this privilege.
|
||||||
*/
|
*/
|
||||||
|
|
@ -349,5 +344,4 @@ public class PrivilegeDescriptor {
|
||||||
privs.close();
|
privs.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,13 @@ public class Application extends Resource {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Application instance encapsulating the given data object.
|
||||||
|
* @see com.arsdigita.persistence.Session#retrieve(String)
|
||||||
|
*
|
||||||
|
* @param dataObject The data object to encapsulate in the Forum instance
|
||||||
|
* (new domain object).
|
||||||
|
*/
|
||||||
protected Application(DataObject dataObject) {
|
protected Application(DataObject dataObject) {
|
||||||
super(dataObject);
|
super(dataObject);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,9 @@ import com.arsdigita.web.Application;
|
||||||
/**
|
/**
|
||||||
* Main domain class of a forum application representing a discussion forum.
|
* Main domain class of a forum application representing a discussion forum.
|
||||||
*
|
*
|
||||||
|
* It manages creation of new forum instances and provides getters and setters
|
||||||
|
* for instance specific configuration options.
|
||||||
|
*
|
||||||
* XXX: Forum knows about <i>threads</i> which groups a set of posts to the same
|
* XXX: Forum knows about <i>threads</i> which groups a set of posts to the same
|
||||||
* subject, and <i>topics</i> which group a set of threads about the same general
|
* subject, and <i>topics</i> which group a set of threads about the same general
|
||||||
* theme. Currently Forum uses <i>catgegory</i> as synonym for topic, which may be
|
* theme. Currently Forum uses <i>catgegory</i> as synonym for topic, which may be
|
||||||
|
|
@ -63,7 +66,6 @@ import com.arsdigita.web.Application;
|
||||||
* @version $Revision: 1.7 $
|
* @version $Revision: 1.7 $
|
||||||
* @version $Id: Forum.java 1628 2007-09-17 08:10:40Z chrisg23 $
|
* @version $Id: Forum.java 1628 2007-09-17 08:10:40Z chrisg23 $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Forum extends Application {
|
public class Forum extends Application {
|
||||||
|
|
||||||
/** Private logger instance for debugging purpose */
|
/** Private logger instance for debugging purpose */
|
||||||
|
|
@ -135,21 +137,48 @@ public class Forum extends Application {
|
||||||
private static final String ANONYMOUS_POSTS = "anonymousPostsAllowed";
|
private static final String ANONYMOUS_POSTS = "anonymousPostsAllowed";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Creates a new Forum instance encapsulating the given data object.
|
||||||
|
* @see com.arsdigita.persistence.Session#retrieve(String)
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data The data object to encapsulate in the Forum instance
|
||||||
|
* (new domain object).
|
||||||
*/
|
*/
|
||||||
public Forum(DataObject data) {
|
public Forum(DataObject data) {
|
||||||
super(data);
|
super(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The contained <code>DataObject</code> is retrieved from the
|
||||||
|
* persistent storage mechanism with an OID specified by <i>oid</i>.
|
||||||
|
*
|
||||||
|
* @param oid The <code>OID</code> for the retrieved
|
||||||
|
* <code>DataObject</code>.
|
||||||
|
*
|
||||||
|
* @exception DataObjectNotFoundException Thrown if we cannot
|
||||||
|
* retrieve a data object for the specified OID
|
||||||
|
*/
|
||||||
public Forum(OID oid) throws DataObjectNotFoundException {
|
public Forum(OID oid) throws DataObjectNotFoundException {
|
||||||
super(oid);
|
super(oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a Forum instance (its contained DataObject) based on its
|
||||||
|
* internal id which is used to search for the OID.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* @throws DataObjectNotFoundException
|
||||||
|
*/
|
||||||
public Forum(BigDecimal id) throws DataObjectNotFoundException {
|
public Forum(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
super(new OID(BASE_DATA_OBJECT_TYPE, id));
|
super(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param urlName of the forum to be created
|
||||||
|
* @param title of forum to be created
|
||||||
|
* @param parent object of forum to be created
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public static Forum create(String urlName, String title,
|
public static Forum create(String urlName, String title,
|
||||||
Application parent) {
|
Application parent) {
|
||||||
return create(urlName, title, parent, false);
|
return create(urlName, title, parent, false);
|
||||||
|
|
@ -159,8 +188,8 @@ public class Forum extends Application {
|
||||||
* This method should be used to create a new Forum object everywhere
|
* This method should be used to create a new Forum object everywhere
|
||||||
* except in the constructor of a subclass of Forum.
|
* except in the constructor of a subclass of Forum.
|
||||||
* This will by default create a new Category which will be the root
|
* This will by default create a new Category which will be the root
|
||||||
* category for the Forum in the event that the Forum should be
|
* category for the Forum in the event that the Forum should be categorized.
|
||||||
* categorized.
|
*
|
||||||
* This also sets up instant and daily subscriptions on the Forum.
|
* This also sets up instant and daily subscriptions on the Forum.
|
||||||
* The default for moderation is false.
|
* The default for moderation is false.
|
||||||
*
|
*
|
||||||
|
|
@ -170,8 +199,10 @@ public class Forum extends Application {
|
||||||
public static Forum create(String urlName, String title,
|
public static Forum create(String urlName, String title,
|
||||||
Application parent, boolean moderated) {
|
Application parent, boolean moderated) {
|
||||||
s_log.debug("creating forum " + title);
|
s_log.debug("creating forum " + title);
|
||||||
Forum forum = (Forum) Application.createApplication
|
|
||||||
(BASE_DATA_OBJECT_TYPE, urlName, title, parent, true);
|
Forum forum = (Forum) Application.createApplication(BASE_DATA_OBJECT_TYPE,
|
||||||
|
urlName,
|
||||||
|
title, parent, true);
|
||||||
|
|
||||||
forum.setModerated(moderated);
|
forum.setModerated(moderated);
|
||||||
// default settings ensure legacy forum users do not
|
// default settings ensure legacy forum users do not
|
||||||
|
|
@ -217,10 +248,8 @@ public class Forum extends Application {
|
||||||
/**
|
/**
|
||||||
* @return introduction
|
* @return introduction
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String getIntroduction() {
|
public String getIntroduction() {
|
||||||
return (String) get(INTRODUCTION);
|
return (String) get(INTRODUCTION);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -239,6 +268,7 @@ public class Forum extends Application {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void createGroups() {
|
private void createGroups() {
|
||||||
|
|
||||||
Group administrators = new Group();
|
Group administrators = new Group();
|
||||||
administrators.setName(getTitle() + " Administrators");
|
administrators.setName(getTitle() + " Administrators");
|
||||||
setAssociation(ADMIN_GROUP, administrators);
|
setAssociation(ADMIN_GROUP, administrators);
|
||||||
|
|
@ -259,9 +289,9 @@ public class Forum extends Application {
|
||||||
moderators.setPrimaryEmail(new EmailAddress(email));
|
moderators.setPrimaryEmail(new EmailAddress(email));
|
||||||
|
|
||||||
// chris.gilbert@westsussex.gov.uk create additional groups for privilege
|
// chris.gilbert@westsussex.gov.uk create additional groups for privilege
|
||||||
// assignment - could have assigned privileges directly without having associated
|
// assignment - could have assigned privileges directly without having
|
||||||
// groups, but this reduces rows in the (already enormous) dnm_permissions
|
// associated groups, but this reduces rows in the (already enormous)
|
||||||
// table
|
// dnm_permissions table
|
||||||
Group threadCreators = new Group();
|
Group threadCreators = new Group();
|
||||||
threadCreators.setName(getTitle() + " Thread Creators");
|
threadCreators.setName(getTitle() + " Thread Creators");
|
||||||
setAssociation(THREAD_CREATE_GROUP, threadCreators);
|
setAssociation(THREAD_CREATE_GROUP, threadCreators);
|
||||||
|
|
@ -274,7 +304,8 @@ public class Forum extends Application {
|
||||||
forumReaders.setName(getTitle() + " Readers");
|
forumReaders.setName(getTitle() + " Readers");
|
||||||
setAssociation(READ_GROUP, forumReaders);
|
setAssociation(READ_GROUP, forumReaders);
|
||||||
|
|
||||||
Group container = getGroup();
|
Group container = getGroup(); // Application.getGroup(): get group
|
||||||
|
// associated with this application
|
||||||
|
|
||||||
container.addSubgroup(administrators);
|
container.addSubgroup(administrators);
|
||||||
container.addSubgroup(moderators);
|
container.addSubgroup(moderators);
|
||||||
|
|
@ -286,8 +317,6 @@ public class Forum extends Application {
|
||||||
container.addSubgroup(threadSubscriptions);
|
container.addSubgroup(threadSubscriptions);
|
||||||
container.save();
|
container.save();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -315,28 +344,32 @@ public class Forum extends Application {
|
||||||
super.beforeSave();
|
super.beforeSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void afterSave() {
|
protected void afterSave() {
|
||||||
|
|
||||||
if (m_wasNew) {
|
if (m_wasNew) {
|
||||||
PermissionService.setContext(getRootCategory(), this);
|
PermissionService.setContext(getRootCategory(), this);
|
||||||
createGroups();
|
createGroups();
|
||||||
if (getAdminGroup() != null) {
|
if (getAdminGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission( new PermissionDescriptor(
|
||||||
new PermissionDescriptor(
|
|
||||||
PrivilegeDescriptor.ADMIN,
|
PrivilegeDescriptor.ADMIN,
|
||||||
this,
|
this,
|
||||||
getAdminGroup()));
|
getAdminGroup()));
|
||||||
s_log.debug(
|
s_log.debug("Current user : "
|
||||||
"Current user : "
|
|
||||||
+ Kernel.getContext().getParty().getPrimaryEmail()
|
+ Kernel.getContext().getParty().getPrimaryEmail()
|
||||||
+ " class is "
|
+ " class is "
|
||||||
+ Kernel.getContext().getParty().getClass());
|
+ Kernel.getContext().getParty().getClass());
|
||||||
|
|
||||||
//
|
//
|
||||||
// chris.gilbert@westsussex.gov.uk Original plan was that creator of forum
|
// chris.gilbert@westsussex.gov.uk Original plan was that
|
||||||
// is administrator by default, but party from Kernel at this point in code is
|
// creator of forum is administrator by default,
|
||||||
// acs-system-party - creation must happen in a KernelExcersion somewhere
|
// but party from Kernel at this point in code is
|
||||||
// though I can't immediately see where.
|
// acs-system-party - creation must happen in a KernelExcersion
|
||||||
// as a consequence, code below justs causes a classcast exception,
|
// somewhere though I can't immediately see where.
|
||||||
|
// As a consequence, code below justs causes a classcast exception,
|
||||||
//
|
//
|
||||||
// revisit, but in meantime, only site admin can administer new forum
|
// revisit, but in meantime, only site admin can administer new forum
|
||||||
// until forum admin permissions set in UI
|
// until forum admin permissions set in UI
|
||||||
|
|
@ -346,20 +379,23 @@ public class Forum extends Application {
|
||||||
// if (creator != null) {
|
// if (creator != null) {
|
||||||
// getAdminGroup().addMember(creator);
|
// getAdminGroup().addMember(creator);
|
||||||
// }
|
// }
|
||||||
///
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getModerationGroup() != null ) {
|
if (getModerationGroup() != null ) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(FORUM_MODERATION_PRIVILEGE),
|
PrivilegeDescriptor.get(
|
||||||
|
FORUM_MODERATION_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getModerationGroup()));
|
getModerationGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getThreadCreateGroup() != null) {
|
if (getThreadCreateGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(CREATE_THREAD_PRIVILEGE),
|
PrivilegeDescriptor.get(
|
||||||
|
CREATE_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getThreadCreateGroup()));
|
getThreadCreateGroup()));
|
||||||
// chris.gilbert@westsussex.gov.uk
|
// chris.gilbert@westsussex.gov.uk
|
||||||
|
|
@ -373,7 +409,8 @@ public class Forum extends Application {
|
||||||
if (getThreadResponderGroup() != null) {
|
if (getThreadResponderGroup() != null) {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(
|
new PermissionDescriptor(
|
||||||
PrivilegeDescriptor.get(RESPOND_TO_THREAD_PRIVILEGE),
|
PrivilegeDescriptor.get(
|
||||||
|
RESPOND_TO_THREAD_PRIVILEGE),
|
||||||
this,
|
this,
|
||||||
getThreadResponderGroup()));
|
getThreadResponderGroup()));
|
||||||
}
|
}
|
||||||
|
|
@ -385,6 +422,7 @@ public class Forum extends Application {
|
||||||
this,
|
this,
|
||||||
getReadGroup()));
|
getReadGroup()));
|
||||||
}
|
}
|
||||||
|
|
||||||
KernelExcursion excursion = new KernelExcursion() {
|
KernelExcursion excursion = new KernelExcursion() {
|
||||||
protected void excurse() {
|
protected void excurse() {
|
||||||
setParty(Kernel.getSystemParty());
|
setParty(Kernel.getSystemParty());
|
||||||
|
|
@ -404,7 +442,7 @@ public class Forum extends Application {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
excursion.run();
|
excursion.run();
|
||||||
}
|
} //if mWasNew
|
||||||
|
|
||||||
DataCollection subs = null;
|
DataCollection subs = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -426,10 +464,9 @@ public class Forum extends Application {
|
||||||
// don't want to inherit permissions of portal,
|
// don't want to inherit permissions of portal,
|
||||||
// as public users have 'READ' privilege on this
|
// as public users have 'READ' privilege on this
|
||||||
// and so get shown postings in search results.
|
// and so get shown postings in search results.
|
||||||
//
|
|
||||||
//
|
|
||||||
// super.afterSave();
|
// super.afterSave();
|
||||||
}
|
|
||||||
|
} //Method afterSave()
|
||||||
|
|
||||||
protected String getBaseDataObjectType() {
|
protected String getBaseDataObjectType() {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
|
@ -749,6 +786,7 @@ public class Forum extends Application {
|
||||||
Assert.exists(dObj, DataObject.class);
|
Assert.exists(dObj, DataObject.class);
|
||||||
return (Group) DomainObjectFactory.newInstance(dObj);
|
return (Group) DomainObjectFactory.newInstance(dObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the moderator group. Null if it doesn't exist */
|
/** Returns the moderator group. Null if it doesn't exist */
|
||||||
public Group getModerationGroup() {
|
public Group getModerationGroup() {
|
||||||
DataObject dObj = (DataObject) get( MODERATION_GROUP );
|
DataObject dObj = (DataObject) get( MODERATION_GROUP );
|
||||||
|
|
@ -800,16 +838,10 @@ public class Forum extends Application {
|
||||||
// have the same expiration policy.
|
// have the same expiration policy.
|
||||||
DataAssociationCursor posts = getPosts().cursor();
|
DataAssociationCursor posts = getPosts().cursor();
|
||||||
while (posts.next()) {
|
while (posts.next()) {
|
||||||
Post post =
|
Post post = (Post) DomainObjectFactory.newInstance(posts.getDataObject());
|
||||||
(Post) DomainObjectFactory.newInstance(posts.getDataObject());
|
if (post.getThread().getRootMessage().getID()
|
||||||
if (post
|
|
||||||
.getThread()
|
|
||||||
.getRootMessage()
|
|
||||||
.getID()
|
|
||||||
.equals(post.getID())) {
|
.equals(post.getID())) {
|
||||||
|
s_log.debug("Resetting expiration lifecycle for " + post.getOID());
|
||||||
s_log.debug(
|
|
||||||
"Resetting expiration lifecycle for " + post.getOID());
|
|
||||||
post.setLifecycle(newLife);
|
post.setLifecycle(newLife);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -847,6 +879,7 @@ public class Forum extends Application {
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, group));
|
new PermissionDescriptor(PrivilegeDescriptor.ADMIN, this, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method required for upgrade - normally groups are set during
|
* method required for upgrade - normally groups are set during
|
||||||
* forum creation and so there is no need to invoke a setter
|
* forum creation and so there is no need to invoke a setter
|
||||||
|
|
@ -861,6 +894,7 @@ public class Forum extends Application {
|
||||||
this,
|
this,
|
||||||
group));
|
group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method required for upgrade - normally groups are set during forum
|
* method required for upgrade - normally groups are set during forum
|
||||||
* creation and so there is no need to invoke a setter
|
* creation and so there is no need to invoke a setter
|
||||||
|
|
@ -875,6 +909,7 @@ public class Forum extends Application {
|
||||||
this,
|
this,
|
||||||
group));
|
group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* method required for upgrade - normally groups are set during forum
|
* method required for upgrade - normally groups are set during forum
|
||||||
* creation and so creation and so there is no need to invoke a setter
|
* creation and so creation and so there is no need to invoke a setter
|
||||||
|
|
@ -884,7 +919,8 @@ public class Forum extends Application {
|
||||||
public void setReaderGroup(Group group) {
|
public void setReaderGroup(Group group) {
|
||||||
setAssociation(READ_GROUP, group);
|
setAssociation(READ_GROUP, group);
|
||||||
PermissionService.grantPermission(
|
PermissionService.grantPermission(
|
||||||
new PermissionDescriptor(PrivilegeDescriptor.READ, this, group));
|
new PermissionDescriptor(
|
||||||
|
PrivilegeDescriptor.READ, this, group));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -936,14 +972,20 @@ public class Forum extends Application {
|
||||||
getThreadCreateGroup().setName(title + " Thread Creators");
|
getThreadCreateGroup().setName(title + " Thread Creators");
|
||||||
getThreadResponderGroup().setName(title + " Thread Responders");
|
getThreadResponderGroup().setName(title + " Thread Responders");
|
||||||
getReadGroup().setName(title + " Readers");
|
getReadGroup().setName(title + " Readers");
|
||||||
|
|
||||||
DataCollection subscriptions = getSubscriptions();
|
DataCollection subscriptions = getSubscriptions();
|
||||||
while (subscriptions.next()) {
|
while (subscriptions.next()) {
|
||||||
ForumSubscription subscription = (ForumSubscription)DomainObjectFactory.newInstance(subscriptions.getDataObject());
|
ForumSubscription
|
||||||
|
subscription = (ForumSubscription)DomainObjectFactory.
|
||||||
|
newInstance(subscriptions.getDataObject());
|
||||||
subscription.getGroup().setName(subscription.getGroupName(this));
|
subscription.getGroup().setName(subscription.getGroupName(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
ThreadCollection threads = getThreads();
|
ThreadCollection threads = getThreads();
|
||||||
while (threads.next()) {
|
while (threads.next()) {
|
||||||
ThreadSubscription threadSub = ThreadSubscription.getThreadSubscription(threads.getMessageThread());
|
ThreadSubscription threadSub = ThreadSubscription.
|
||||||
|
getThreadSubscription(
|
||||||
|
threads.getMessageThread());
|
||||||
threadSub.getGroup().setName(threadSub.getSubscriptionGroupName(this));
|
threadSub.getGroup().setName(threadSub.getSubscriptionGroupName(this));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,11 @@ public class ForumPageBuilder implements PageBuilder, Constants {
|
||||||
page.add(forumComp);
|
page.add(forumComp);
|
||||||
BigDecimalParameter topic = new BigDecimalParameter(TOPIC_PARAM);
|
BigDecimalParameter topic = new BigDecimalParameter(TOPIC_PARAM);
|
||||||
page.addGlobalStateParam(topic);
|
page.addGlobalStateParam(topic);
|
||||||
|
// adds primitive READ descriptor, should be FORUM_READ instead in order
|
||||||
|
// to allow forum specific READ access and forums not accessible to
|
||||||
|
// the public, not logged-in user.
|
||||||
|
// PrivilegeDescriptor.get(RESPOND_TO_THREAD_PRIVILEGE)
|
||||||
|
// PrivilegeDescriptor.get(FORUM_READ_PRIVILEGE)
|
||||||
page.addRequestListener(
|
page.addRequestListener(
|
||||||
new ApplicationAuthenticationListener(PrivilegeDescriptor.READ));
|
new ApplicationAuthenticationListener(PrivilegeDescriptor.READ));
|
||||||
page.addRequestListener(new ForumPageRequestListener(topic, forumComp));
|
page.addRequestListener(new ForumPageRequestListener(topic, forumComp));
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class Initializer extends CompoundInitializer {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
e.getFactory().registerInstantiator( // OOPS: inbox commented out in
|
e.getFactory().registerInstantiator( // OOPS: inbox commented out in
|
||||||
"com.arsdigita.forum.Inbox", // Forum loader!
|
"com.arsdigita.forum.Inbox", // Forum loader! see Inbox.pdl
|
||||||
new ACSObjectInstantiator() {
|
new ACSObjectInstantiator() {
|
||||||
public DomainObject doNewInstance(DataObject dataObject) {
|
public DomainObject doNewInstance(DataObject dataObject) {
|
||||||
return new Forum(dataObject);
|
return new Forum(dataObject);
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ public class Loader extends PackageLoader {
|
||||||
|
|
||||||
setupPrivileges();
|
setupPrivileges();
|
||||||
setupForumAppType();
|
setupForumAppType();
|
||||||
//setupInboxAppType();
|
//setupInboxAppType(); //TODO: why it is commented out?
|
||||||
setupRecentPostingsPortletType();
|
setupRecentPostingsPortletType();
|
||||||
setupMyForumsPortletType();
|
setupMyForumsPortletType();
|
||||||
setupDigestUser();
|
setupDigestUser();
|
||||||
|
|
@ -87,7 +87,7 @@ public class Loader extends PackageLoader {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* TODO: What is it for? Execution is currently commented out.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static ApplicationType setupInboxAppType() {
|
private static ApplicationType setupInboxAppType() {
|
||||||
|
|
@ -151,7 +151,6 @@ public class Loader extends PackageLoader {
|
||||||
users.close();
|
users.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -165,7 +164,7 @@ public class Loader extends PackageLoader {
|
||||||
Forum.CREATE_THREAD_PRIVILEGE);
|
Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.createPrivilege(
|
PrivilegeDescriptor.createPrivilege(
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
|
// Establich privilege hierarchie, eg. moderation includes createThread
|
||||||
PrivilegeDescriptor.addChildPrivilege(
|
PrivilegeDescriptor.addChildPrivilege(
|
||||||
Forum.FORUM_MODERATION_PRIVILEGE,
|
Forum.FORUM_MODERATION_PRIVILEGE,
|
||||||
Forum.CREATE_THREAD_PRIVILEGE);
|
Forum.CREATE_THREAD_PRIVILEGE);
|
||||||
|
|
@ -174,7 +173,7 @@ public class Loader extends PackageLoader {
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
Forum.RESPOND_TO_THREAD_PRIVILEGE);
|
||||||
PrivilegeDescriptor.addChildPrivilege(
|
PrivilegeDescriptor.addChildPrivilege(
|
||||||
Forum.RESPOND_TO_THREAD_PRIVILEGE,
|
Forum.RESPOND_TO_THREAD_PRIVILEGE,
|
||||||
PrivilegeDescriptor.READ.getName());
|
PrivilegeDescriptor.READ.getName()); // general read privilege
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -81,9 +81,9 @@ import com.arsdigita.util.Assert;
|
||||||
* <li> Submitter edits already approved message (notify admin)
|
* <li> Submitter edits already approved message (notify admin)
|
||||||
* status changes to 'reapprove'</li>
|
* status changes to 'reapprove'</li>
|
||||||
*
|
*
|
||||||
* <li> -> Admin moderates, change state to 'approve',
|
* <li> -> Admin moderates, change state to 'approve','supressed', or
|
||||||
*'supressed', or 'rejected' depending on whether they want to hide
|
* 'rejected' depending on whether they want to hide the entire
|
||||||
*the entire thread or just the content of the message.</li>
|
* thread or just the content of the message.</li>
|
||||||
*
|
*
|
||||||
* <li> -> APPROVED new version of message goes live</li>
|
* <li> -> APPROVED new version of message goes live</li>
|
||||||
*
|
*
|
||||||
|
|
@ -113,7 +113,6 @@ import com.arsdigita.util.Assert;
|
||||||
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
* @author Kevin Scaldeferri (kevin@arsdigita.com)
|
||||||
* @author Nobuko Asakai (nasakai@redhat.com)
|
* @author Nobuko Asakai (nasakai@redhat.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class Post extends ThreadedMessage {
|
public class Post extends ThreadedMessage {
|
||||||
private static final Logger s_log = Logger.getLogger(Post.class);
|
private static final Logger s_log = Logger.getLogger(Post.class);
|
||||||
|
|
||||||
|
|
@ -155,7 +154,6 @@ public class Post extends ThreadedMessage {
|
||||||
* The base DomainObject is Post which extends ThreadedMessage. In
|
* The base DomainObject is Post which extends ThreadedMessage. In
|
||||||
* other words, all bboard messages are ThreadedMessages.
|
* other words, all bboard messages are ThreadedMessages.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"com.arsdigita.forum.Post";
|
"com.arsdigita.forum.Post";
|
||||||
|
|
||||||
|
|
@ -192,6 +190,10 @@ public class Post extends ThreadedMessage {
|
||||||
return post;
|
return post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
protected String getBaseDataObjectType() {
|
protected String getBaseDataObjectType() {
|
||||||
return BASE_DATA_OBJECT_TYPE;
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
}
|
}
|
||||||
|
|
@ -229,7 +231,6 @@ public class Post extends ThreadedMessage {
|
||||||
* post to the forum. Additionally create a lifecycle if required for a new
|
* post to the forum. Additionally create a lifecycle if required for a new
|
||||||
* root post
|
* root post
|
||||||
*/
|
*/
|
||||||
|
|
||||||
protected void afterSave() {
|
protected void afterSave() {
|
||||||
super.afterSave();
|
super.afterSave();
|
||||||
Forum forum = getForum();
|
Forum forum = getForum();
|
||||||
|
|
@ -238,14 +239,14 @@ public class Post extends ThreadedMessage {
|
||||||
|
|
||||||
s_log.info("Setting context for " + getOID() + " to " + root.getOID());
|
s_log.info("Setting context for " + getOID() + " to " + root.getOID());
|
||||||
PermissionService.setContext(this, root);
|
PermissionService.setContext(this, root);
|
||||||
s_log.info(
|
s_log.info( "Setting context for " + root.getOID() + " to " +
|
||||||
"Setting context for " + root.getOID() + " to " +
|
|
||||||
forum.getOID());
|
forum.getOID());
|
||||||
PermissionService.setContext(root, forum);
|
PermissionService.setContext(root, forum);
|
||||||
// originally this was created in beforeSave, but this was when only noticeboard
|
// originally this was created in beforeSave, but this was when only
|
||||||
// (reply disabled) forums could have a lifecycle. Now that all forums may
|
// noticeboard (reply disabled) forums could have a lifecycle. Now that
|
||||||
// have a lifecycle on root posts, the method needs to be here in order
|
// all forums may have a lifecycle on root posts, the method needs to be
|
||||||
// for persistence to work when users are replying to posts chris.gilbert@westsussex.gov.uk
|
// here in order for persistence to work when users are replying to
|
||||||
|
// posts (chris.gilbert@westsussex.gov.uk)
|
||||||
|
|
||||||
if (m_wasNew) {
|
if (m_wasNew) {
|
||||||
if (getRoot() == null && forum.getExpireAfter() > 0) {
|
if (getRoot() == null && forum.getExpireAfter() > 0) {
|
||||||
|
|
@ -271,7 +272,7 @@ public class Post extends ThreadedMessage {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // Method afterSave()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends out the notifications for any subscriptions to the forum
|
* Sends out the notifications for any subscriptions to the forum
|
||||||
|
|
@ -322,7 +323,8 @@ public class Post extends ThreadedMessage {
|
||||||
subscriptions.getDataObject());
|
subscriptions.getDataObject());
|
||||||
s_log.debug("notification to " + subscription.getOID());
|
s_log.debug("notification to " + subscription.getOID());
|
||||||
|
|
||||||
subscription.sendNotification(Post.this, Forum.getConfig().deleteNotifications());
|
subscription.sendNotification(Post.this, Forum.getConfig()
|
||||||
|
.deleteNotifications());
|
||||||
}
|
}
|
||||||
|
|
||||||
s_log.debug("Sending thread level subsriptions");
|
s_log.debug("Sending thread level subsriptions");
|
||||||
|
|
@ -493,10 +495,10 @@ public class Post extends ThreadedMessage {
|
||||||
* on the forum is not cached.
|
* on the forum is not cached.
|
||||||
*/
|
*/
|
||||||
public boolean canEdit(Party party) {
|
public boolean canEdit(Party party) {
|
||||||
Party author = getFrom();
|
Party author = getFrom(); //determin sender / author of message
|
||||||
// cg added - for anonymous posts, don't allow editing, else everyone could edit everyone else's posts
|
// cg added - for anonymous posts, don't allow editing, else everyone
|
||||||
return (
|
// could edit everyone else's posts
|
||||||
!author.equals(Kernel.getPublicUser())
|
return ( !author.equals(Kernel.getPublicUser())
|
||||||
&& Forum.getConfig().canAuthorEditPosts()
|
&& Forum.getConfig().canAuthorEditPosts()
|
||||||
&& author.equals(party) )
|
&& author.equals(party) )
|
||||||
|| getForum().canEdit(party);
|
|| getForum().canEdit(party);
|
||||||
|
|
|
||||||
|
|
@ -51,16 +51,19 @@ public class ThreadPageBuilder implements PageBuilder, Constants {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Page buildPage() {
|
public Page buildPage() {
|
||||||
|
|
||||||
Page threadPage = PageFactory.buildPage(Constants.FORUM_XML_PREFIX,
|
Page threadPage = PageFactory.buildPage(Constants.FORUM_XML_PREFIX,
|
||||||
"Threads", "forumThreadPage");
|
"Threads", "forumThreadPage");
|
||||||
//Output the title in an easy to find place
|
//Output the title in an easy to find place
|
||||||
threadPage.add(new SimpleComponent(){
|
threadPage.add(new SimpleComponent(){
|
||||||
|
|
||||||
public void generateXML(PageState state, Element parent) {
|
public void generateXML(PageState state, Element parent) {
|
||||||
Element nameElement = parent.newChildElement(
|
Element nameElement = parent.newChildElement(
|
||||||
Constants.FORUM_XML_PREFIX + ":name",
|
Constants.FORUM_XML_PREFIX + ":name",
|
||||||
Constants.FORUM_XML_NS);
|
Constants.FORUM_XML_NS);
|
||||||
nameElement.setText(ForumContext.getContext(state).getForum().
|
nameElement.setText(ForumContext.getContext(state)
|
||||||
getTitle());
|
.getForum().getTitle());
|
||||||
|
|
||||||
Element introductionElement = parent.newChildElement(
|
Element introductionElement = parent.newChildElement(
|
||||||
Constants.FORUM_XML_PREFIX +
|
Constants.FORUM_XML_PREFIX +
|
||||||
":introduction",
|
":introduction",
|
||||||
|
|
@ -72,14 +75,15 @@ public class ThreadPageBuilder implements PageBuilder, Constants {
|
||||||
});
|
});
|
||||||
//
|
//
|
||||||
threadPage.add(new DiscussionThreadSimpleView());
|
threadPage.add(new DiscussionThreadSimpleView());
|
||||||
|
|
||||||
// Register the thread id parameter as a global state parameter.
|
// Register the thread id parameter as a global state parameter.
|
||||||
BigDecimalParameter threadID = new BigDecimalParameter(THREAD_PARAM);
|
BigDecimalParameter threadID = new BigDecimalParameter(THREAD_PARAM);
|
||||||
threadPage.addGlobalStateParam(threadID);
|
threadPage.addGlobalStateParam(threadID);
|
||||||
|
// Basic PrivilegeDescriptor.READ allows general read access to the public
|
||||||
|
// Should be FORUM_READ instead!
|
||||||
threadPage.addRequestListener(
|
threadPage.addRequestListener(
|
||||||
new ApplicationAuthenticationListener(PrivilegeDescriptor.READ));
|
new ApplicationAuthenticationListener(PrivilegeDescriptor.READ));
|
||||||
|
threadPage.addRequestListener(new ThreadPageRequestListener(threadID));
|
||||||
threadPage.addRequestListener
|
|
||||||
(new ThreadPageRequestListener(threadID));
|
|
||||||
return threadPage;
|
return threadPage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,19 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
The forum package provides discussion forums in which users can post and
|
The forum package provides electronic bulletin board where users can post and
|
||||||
reply to messages. Additionally, users may register for notifications of
|
reply to messages. It is highly integrated with ccm systems user and permission
|
||||||
new posts to the system.
|
administration as well as search feature. More than one instance of a forum is
|
||||||
|
supported, each with its own set f configuration. There exists a enhancement
|
||||||
|
package forum-categorized which allows a forum to be integrated into navigation
|
||||||
|
system.
|
||||||
</p>
|
</p>
|
||||||
|
<p>Several features and funcionality may be configured (some system wide, most of
|
||||||
|
them on a per forum base), among others:</p>
|
||||||
|
<ul>
|
||||||
|
<li>Reply functionality may be disabled so it is just a noticeboard.</li>
|
||||||
|
<li>Users may register for notifications of new posts to the system</li>
|
||||||
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
<i>Forum.java</i> is the main domain class.
|
<i>Forum.java</i> is the main domain class.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue