Verschiedenes an Formatierungen.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1308 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2011-11-30 13:31:24 +00:00
parent 4eff66ae5f
commit 2aff85e105
7 changed files with 102 additions and 58 deletions

View File

@ -56,6 +56,7 @@ public class Group extends Party {
public static final String BASE_DATA_OBJECT_TYPE =
"com.arsdigita.kernel.Group";
@Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
@ -165,7 +166,7 @@ public class Group extends Party {
* Currently, this is the same as getMemberUsers(). However, in
* the future we may allow other types of parties to be members
* of groups (specifically, we may allow groups to be members of groups).
* <P>
*
* NOTE: Any prior calls to addMember() or removeMember() will not
* affect the resulting collection unless save() has been called after
* adding or removing the member(s).
@ -178,7 +179,7 @@ public class Group extends Party {
/**
* Returns a collection of users that are direct members of this group.
* <P>
*
* NOTE: Any prior calls to addMember() or removeMember() will not
* affect the resulting collection unless save() has been called after
* adding or removing the member(s).

View File

@ -84,6 +84,13 @@ public class ApplicationType extends ResourceType {
super(dataObjectType);
}
/**
* Convenient class constructs an ApplicationType object which does not
* create a container group.
* @param objectType
* @param title
* @param applicationObjectType
*/
protected ApplicationType(final String objectType,
final String title,
final String applicationObjectType) {
@ -118,6 +125,7 @@ public class ApplicationType extends ResourceType {
setApplicationObjectType(applicationObjectType);
setDefaults();
if (createContainerGroup) {
createGroup();
}
@ -705,12 +713,19 @@ public class ApplicationType extends ResourceType {
setAssociation("containerGroup", group);
}
/**
* Create a group in user administration for this application type. This
* group is used as a container (hence the name in pdl/table col) for
* subgroup for application instances of this type.
* It is named using the application types title followed by the constant
* "groups". No localisation yet!
*/
public void createGroup () {
Assert.isEqual(getGroup(), null, "Group has already been created for " +
"Application Type " + getTitle());
Group group = new Group();
group.setName(getTitle() + " Groups");
setAssociation("containerGroup", group);
Assert.isEqual(getGroup(), null, "Group has already been created for " +
"Application Type " + getTitle());
Group group = new Group();
group.setName(getTitle() + " Groups");
setAssociation("containerGroup", group);
}

View File

@ -171,11 +171,13 @@ public class Forum extends Application {
}
/**
* Convenient class for creation of a standard forum. Property "Moderated"
* is set to false.
*
* @param urlName of the forum to be created
* @param title of forum to be created
* @param parent object of forum to be created
* @return
* @return Forum instance
*/
public static Forum create(String urlName, String title,
Application parent) {
@ -198,10 +200,12 @@ public class Forum extends Application {
Application parent, boolean moderated) {
s_log.debug("creating forum " + title);
/* Create an aplication instance including a container group in the
* user administration (5. parameter true) named according to the
* forum title. */
Forum forum = (Forum) Application.createApplication(
BASE_DATA_OBJECT_TYPE,
urlName,
title, parent, true);
BASE_DATA_OBJECT_TYPE, urlName,
title, parent, true);
forum.setModerated(moderated);
forum.setPublic(true);

View File

@ -76,10 +76,10 @@ public class Loader extends PackageLoader {
* @return
*/
private static ApplicationType setupForumAppType() {
ApplicationType type =
ApplicationType.createApplicationType(Forum.PACKAGE_TYPE,
"Discussion Forum Application",
Forum.BASE_DATA_OBJECT_TYPE);
ApplicationType type = ApplicationType
.createApplicationType(Forum.PACKAGE_TYPE,
"Discussion Forum Application",
Forum.BASE_DATA_OBJECT_TYPE);
type.setDescription("An electronic bulletin board system.");
return type;
}

View File

@ -98,7 +98,7 @@ public class Initializer extends CompoundInitializer {
}
});
e.getFactory().registerInstantiator(
e.getFactory().registerInstantiator(
WorkspacePage.BASE_DATA_OBJECT_TYPE,
new ACSObjectInstantiator() {
@Override

View File

@ -18,13 +18,10 @@
package com.arsdigita.portalworkspace;
// import com.arsdigita.domain.DomainObject;
// import com.arsdigita.kernel.ACSObjectInstantiator;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.kernel.ResourceType;
import com.arsdigita.loader.PackageLoader;
// import com.arsdigita.persistence.DataObject;
import com.arsdigita.portalworkspace.portlet.ApplicationDirectoryPortlet;
import com.arsdigita.portalworkspace.portlet.ContentDirectoryPortlet;
import com.arsdigita.portalworkspace.portlet.FreeformHTMLPortlet;
@ -41,7 +38,6 @@ import com.arsdigita.util.parameter.BooleanParameter;
import com.arsdigita.util.parameter.Parameter;
import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.web.Application;
// import com.arsdigita.web.ApplicationSetup;
import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger;
@ -74,10 +70,12 @@ public class Loader extends PackageLoader {
private StringParameter m_title = new StringParameter(
"com.arsdigita.portalworkspace.default_title",
Parameter.REQUIRED,
"Portal Homepage");
"Portal Homepage");
/** Actually a kind of misnomer. In the creation process it is used to
* indicate whether a Containergroup should be created.
/**
* If true the group created for the instance of portal workspace will
* contain the public user as a member.
* NOTE: Current implementation actually doesn't check for access permission!
*/
private BooleanParameter m_isPublic = new BooleanParameter(
"com.arsdigita.portalworkspace.default_is_public",
@ -122,9 +120,13 @@ public class Loader extends PackageLoader {
}
/**
* Prepares creation of application type by checking proper formatting of
* applications url and determining whether a parent is specified as part
* of the url.
*
* @param url
* @param isPublic
* @param url Sting containing the full url (including parents url in any
* @param isPublic if true the group created for this instance will include
* the public user as a member
* @param title
*/
private void createApplication(String url, Boolean isPublic, String title) {
@ -138,13 +140,16 @@ public class Loader extends PackageLoader {
s_log.debug("process url " + url);
Assert.isTrue(url.startsWith("/"), "url starts not with /");
Assert.isTrue(url.endsWith("/"), "url ends not with /");
Assert.isTrue(!url.equals("/"), "url is not /");
Assert.isTrue(!url.equals("/"), "url is just /");
int last = url.lastIndexOf("/" // last = 0 is leading slash
,url.length() - 2);// trailing slash excluded
s_log.debug("last slash at " + last); // last > 0 : multipe elements
int last = url.lastIndexOf("/", url.length() - 2);
s_log.debug("last slash at " + last);
Application parent = null;
String name = null;
if (last > 0) {
if (last > 0) { // url has more than 1 part = has a parent
String base = url.substring(0, last + 1);
s_log.debug("Finding parent at " + base);
parent = Application.retrieveApplicationForPath(base);
@ -154,9 +159,7 @@ public class Loader extends PackageLoader {
}
s_log.debug("node name is " + name);
// set up the portal default node (instance)
// Workspace workspace = Workspace.createWorkspace(name, title,
// parent, Boolean.TRUE.equals(isPublic));
// set up the portal workspace default node (instance)
Workspace workspace = Workspace.createWorkspace(type, name, title,
null, parent, Boolean.TRUE.equals(isPublic));
@ -175,16 +178,21 @@ public class Loader extends PackageLoader {
* to lower case.
* "Portal Workspace" will become "portal-workspace".
*
* @return
* @return created ApplicationType
*/
private ApplicationType setupWorkspaceType() {
s_log.debug("Creating an application type for portal workspace. " +
"Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
ApplicationType type = new ApplicationType( "Portal Workspace",
Workspace.BASE_DATA_OBJECT_TYPE );
/* Create legacy-free application type */
ApplicationType type = new ApplicationType(
"Portal Workspace",
Workspace.BASE_DATA_OBJECT_TYPE );
type.setDescription("Portal based collaborative workspaces");
/* Create an application type specific group in user administration *
* which serves as a container for subgroups, each subgroup coupled *
* to an application (instances) of this type. */
type.createGroup();
return type;

View File

@ -215,33 +215,38 @@ public class Workspace extends Application {
}
/**
* Does the real work to create a workspace as a legacy free application
* in the storage (db)
* Does the real work to create a workspace instance as a
* legacy free application in the storage (db)
*
* NOTE: Parameter isPublic may be a misnomer, the actual usage of it in the
* process of application creation uses it as createGroupContainer
*
* @param url
* @param title
* @param layout
* @param parent
* @param isPublic whether to create a workspace group
* @param url of the application (last part, its "name")
* @param title the application to be created
* @param layout layout to use for this instance
* @param parent, url of the parent part if any, null otherwise
* @param isPublic whether the group that will be created for this instance
* should be created with the public user as a member
* @return
*/
public static Workspace createWorkspace(ApplicationType type,
String url, String title,
String url,
String title,
PageLayout layout,
Application parent,
boolean isPublic) {
if (s_log.isDebugEnabled()) {
s_log.debug("Creating group workspace, isPublic:" + isPublic
+ " on " + url + " with parent "
+ (parent == null ? "none" : parent.getOID().toString()));
s_log.debug("Creating portal workspace on " + url
+ " with parent "
+ (parent == null ? "none" : parent.getOID().toString())
+ "and public access is: " + isPublic);
}
if (layout==null) layout = PageLayout.getDefaultLayout();
/* A container group is always created fo a portal workspace instance. */
// MODIFIED
/* A container group is NOT created fo a portal workspace instance here. */
Workspace workspace = (Workspace) Application.createApplication(
type, url, title, parent, isPublic );
type, url, title, parent, true );
workspace.setupGroups(title, isPublic);
workspace.setDefaultLayout(layout);
return workspace;
@ -315,13 +320,17 @@ public class Workspace extends Application {
@Override
public void beforeSave() {
// If no permissions are configured, then setup empty groups
if (get(PARTY) == null) {
if (s_log.isDebugEnabled()) {
s_log.debug("No party is set, creating shared workspace "
+ getOID());
}
setupGroups(getTitle(), false);
}
// DOES NOT WORK AS DESIGNED!
// Is always invoked BEFORE any group setup can take place therefore always
// dreating an empty (and doubled) group.
// (pb 2011-11)
// if (get(PARTY) == null) {
// if (s_log.isDebugEnabled()) {
// s_log.debug("No party is set, creating shared workspace "
// + getOID());
// }
// setupGroups(getTitle(), false);
// }
// Setup the default layout.
if (isNew() && getDefaultLayout() == null) {
setDefaultLayout(PageLayout.getDefaultLayout());
@ -384,6 +393,7 @@ public class Workspace extends Application {
* @param isPublic
*/
private void setupGroups(String title, boolean isPublic) {
Group members = new Group();
members.setName(title);
members.save();
@ -394,7 +404,7 @@ public class Workspace extends Application {
// own groups so doesn't need a hierarchy and (b) hierarchy would
// mean for a given workspace, role would be on the same level
// as member groups of sub workspaces - messy & confusing
getApplicationType().getGroup().addSubgroup(members);
// getApplicationType().getGroup().addSubgroup(members);
Role admins = members.createRole("Administrators");
admins.save();
@ -414,6 +424,12 @@ public class Workspace extends Application {
members.save();
}
// getApplicationType().getGroup().addSubgroup(members);
Group container = getGroup(); // Application.getGroup(): get group
// associated with this application
container.addSubgroup(members);
container.save();
setParty(members);
}