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

View File

@ -84,6 +84,13 @@ public class ApplicationType extends ResourceType {
super(dataObjectType); 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, protected ApplicationType(final String objectType,
final String title, final String title,
final String applicationObjectType) { final String applicationObjectType) {
@ -118,6 +125,7 @@ public class ApplicationType extends ResourceType {
setApplicationObjectType(applicationObjectType); setApplicationObjectType(applicationObjectType);
setDefaults(); setDefaults();
if (createContainerGroup) { if (createContainerGroup) {
createGroup(); createGroup();
} }
@ -705,6 +713,13 @@ public class ApplicationType extends ResourceType {
setAssociation("containerGroup", group); 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 () { public void createGroup () {
Assert.isEqual(getGroup(), null, "Group has already been created for " + Assert.isEqual(getGroup(), null, "Group has already been created for " +
"Application Type " + getTitle()); "Application Type " + getTitle());

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 urlName of the forum to be created
* @param title of forum to be created * @param title of forum to be created
* @param parent object 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, public static Forum create(String urlName, String title,
Application parent) { Application parent) {
@ -198,9 +200,11 @@ public class Forum extends Application {
Application parent, boolean moderated) { Application parent, boolean moderated) {
s_log.debug("creating forum " + title); 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( Forum forum = (Forum) Application.createApplication(
BASE_DATA_OBJECT_TYPE, BASE_DATA_OBJECT_TYPE, urlName,
urlName,
title, parent, true); title, parent, true);
forum.setModerated(moderated); forum.setModerated(moderated);

View File

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

View File

@ -18,13 +18,10 @@
package com.arsdigita.portalworkspace; package com.arsdigita.portalworkspace;
// import com.arsdigita.domain.DomainObject;
// import com.arsdigita.kernel.ACSObjectInstantiator;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.KernelExcursion; import com.arsdigita.kernel.KernelExcursion;
import com.arsdigita.kernel.ResourceType; import com.arsdigita.kernel.ResourceType;
import com.arsdigita.loader.PackageLoader; import com.arsdigita.loader.PackageLoader;
// import com.arsdigita.persistence.DataObject;
import com.arsdigita.portalworkspace.portlet.ApplicationDirectoryPortlet; import com.arsdigita.portalworkspace.portlet.ApplicationDirectoryPortlet;
import com.arsdigita.portalworkspace.portlet.ContentDirectoryPortlet; import com.arsdigita.portalworkspace.portlet.ContentDirectoryPortlet;
import com.arsdigita.portalworkspace.portlet.FreeformHTMLPortlet; 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.Parameter;
import com.arsdigita.util.parameter.StringParameter; import com.arsdigita.util.parameter.StringParameter;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
// import com.arsdigita.web.ApplicationSetup;
import com.arsdigita.web.ApplicationType; import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -76,8 +72,10 @@ public class Loader extends PackageLoader {
Parameter.REQUIRED, 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( private BooleanParameter m_isPublic = new BooleanParameter(
"com.arsdigita.portalworkspace.default_is_public", "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 url Sting containing the full url (including parents url in any
* @param isPublic * @param isPublic if true the group created for this instance will include
* the public user as a member
* @param title * @param title
*/ */
private void createApplication(String url, Boolean isPublic, String 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); s_log.debug("process url " + url);
Assert.isTrue(url.startsWith("/"), "url starts not with /"); Assert.isTrue(url.startsWith("/"), "url starts not with /");
Assert.isTrue(url.endsWith("/"), "url ends 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; Application parent = null;
String name = 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); String base = url.substring(0, last + 1);
s_log.debug("Finding parent at " + base); s_log.debug("Finding parent at " + base);
parent = Application.retrieveApplicationForPath(base); parent = Application.retrieveApplicationForPath(base);
@ -154,9 +159,7 @@ public class Loader extends PackageLoader {
} }
s_log.debug("node name is " + name); s_log.debug("node name is " + name);
// set up the portal default node (instance) // set up the portal workspace default node (instance)
// Workspace workspace = Workspace.createWorkspace(name, title,
// parent, Boolean.TRUE.equals(isPublic));
Workspace workspace = Workspace.createWorkspace(type, name, title, Workspace workspace = Workspace.createWorkspace(type, name, title,
null, parent, Boolean.TRUE.equals(isPublic)); null, parent, Boolean.TRUE.equals(isPublic));
@ -175,16 +178,21 @@ public class Loader extends PackageLoader {
* to lower case. * to lower case.
* "Portal Workspace" will become "portal-workspace". * "Portal Workspace" will become "portal-workspace".
* *
* @return * @return created ApplicationType
*/ */
private ApplicationType setupWorkspaceType() { private ApplicationType setupWorkspaceType() {
s_log.debug("Creating an application type for portal workspace. " + s_log.debug("Creating an application type for portal workspace. " +
"Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE); "Base Data Object Type: " + Workspace.BASE_DATA_OBJECT_TYPE);
ApplicationType type = new ApplicationType( "Portal Workspace", /* Create legacy-free application type */
ApplicationType type = new ApplicationType(
"Portal Workspace",
Workspace.BASE_DATA_OBJECT_TYPE ); Workspace.BASE_DATA_OBJECT_TYPE );
type.setDescription("Portal based collaborative workspaces"); 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(); type.createGroup();
return type; 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 * Does the real work to create a workspace instance as a
* in the storage (db) * 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 url of the application (last part, its "name")
* @param title * @param title the application to be created
* @param layout * @param layout layout to use for this instance
* @param parent * @param parent, url of the parent part if any, null otherwise
* @param isPublic whether to create a workspace group * @param isPublic whether the group that will be created for this instance
* should be created with the public user as a member
* @return * @return
*/ */
public static Workspace createWorkspace(ApplicationType type, public static Workspace createWorkspace(ApplicationType type,
String url, String title, String url,
String title,
PageLayout layout, PageLayout layout,
Application parent, Application parent,
boolean isPublic) { boolean isPublic) {
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Creating group workspace, isPublic:" + isPublic s_log.debug("Creating portal workspace on " + url
+ " on " + url + " with parent " + " with parent "
+ (parent == null ? "none" : parent.getOID().toString())); + (parent == null ? "none" : parent.getOID().toString())
+ "and public access is: " + isPublic);
} }
if (layout==null) layout = PageLayout.getDefaultLayout(); 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( Workspace workspace = (Workspace) Application.createApplication(
type, url, title, parent, isPublic ); type, url, title, parent, true );
workspace.setupGroups(title, isPublic); workspace.setupGroups(title, isPublic);
workspace.setDefaultLayout(layout); workspace.setDefaultLayout(layout);
return workspace; return workspace;
@ -315,13 +320,17 @@ public class Workspace extends Application {
@Override @Override
public void beforeSave() { public void beforeSave() {
// If no permissions are configured, then setup empty groups // If no permissions are configured, then setup empty groups
if (get(PARTY) == null) { // DOES NOT WORK AS DESIGNED!
if (s_log.isDebugEnabled()) { // Is always invoked BEFORE any group setup can take place therefore always
s_log.debug("No party is set, creating shared workspace " // dreating an empty (and doubled) group.
+ getOID()); // (pb 2011-11)
} // if (get(PARTY) == null) {
setupGroups(getTitle(), false); // if (s_log.isDebugEnabled()) {
} // s_log.debug("No party is set, creating shared workspace "
// + getOID());
// }
// setupGroups(getTitle(), false);
// }
// Setup the default layout. // Setup the default layout.
if (isNew() && getDefaultLayout() == null) { if (isNew() && getDefaultLayout() == null) {
setDefaultLayout(PageLayout.getDefaultLayout()); setDefaultLayout(PageLayout.getDefaultLayout());
@ -384,6 +393,7 @@ public class Workspace extends Application {
* @param isPublic * @param isPublic
*/ */
private void setupGroups(String title, boolean isPublic) { private void setupGroups(String title, boolean isPublic) {
Group members = new Group(); Group members = new Group();
members.setName(title); members.setName(title);
members.save(); members.save();
@ -394,7 +404,7 @@ public class Workspace extends Application {
// own groups so doesn't need a hierarchy and (b) hierarchy would // own groups so doesn't need a hierarchy and (b) hierarchy would
// mean for a given workspace, role would be on the same level // mean for a given workspace, role would be on the same level
// as member groups of sub workspaces - messy & confusing // as member groups of sub workspaces - messy & confusing
getApplicationType().getGroup().addSubgroup(members); // getApplicationType().getGroup().addSubgroup(members);
Role admins = members.createRole("Administrators"); Role admins = members.createRole("Administrators");
admins.save(); admins.save();
@ -414,6 +424,12 @@ public class Workspace extends Application {
members.save(); members.save();
} }
// getApplicationType().getGroup().addSubgroup(members);
Group container = getGroup(); // Application.getGroup(): get group
// associated with this application
container.addSubgroup(members);
container.save();
setParty(members); setParty(members);
} }