Kleine Bereinigungen bei ccm-ldn-portal

git-svn-id: https://svn.libreccm.org/ccm/trunk@329 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2010-01-16 13:15:37 +00:00
parent aaf77021a0
commit b341967c31
3 changed files with 125 additions and 113 deletions

View File

@ -72,12 +72,12 @@ public class Initializer extends CompoundInitializer {
* *
*/ */
public Initializer() { public Initializer() {
final String url = RuntimeConfig.getConfig().getJDBCURL(); final String url = RuntimeConfig.getConfig().getJDBCURL();
final int database = DbHelper.getDatabaseFromURL(url); final int database = DbHelper.getDatabaseFromURL(url);
add(new PDLInitializer(new ManifestSource("ccm-ldn-portal.pdl.mf", add(new PDLInitializer(new ManifestSource("ccm-ldn-portal.pdl.mf",
new NameFilter(DbHelper.getDatabaseSuffix(database), new NameFilter(DbHelper.getDatabaseSuffix(database),
"pdl")))); "pdl"))));
} }
/** /**

View File

@ -58,8 +58,8 @@ import com.arsdigita.web.ApplicationType;
public class Loader extends PackageLoader { public class Loader extends PackageLoader {
// versionID no longer used as a system variable. version information is // versionID no longer used as a system variable. version information is
// kept as part of java doc. // kept as part of java doc.
// public final static String versionId = "$Id: Loader.java 1718 2008-07-16 14:08:38Z terry $" // public final static String versionId = "$Id: Loader.java 1718 2008-07-16 14:08:38Z terry $"
// + "$Author: terry $" + "$DateTime: 2004/03/02 06:33:42 $"; // + "$Author: terry $" + "$DateTime: 2004/03/02 06:33:42 $";
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);
@ -75,41 +75,44 @@ public class Loader extends PackageLoader {
"com.arsdigita.london.portal.default_is_public", "com.arsdigita.london.portal.default_is_public",
Parameter.REQUIRED, Boolean.TRUE); Parameter.REQUIRED, Boolean.TRUE);
/** /**
* Standard constructor. * Standard constructor.
*/ */
public Loader() { public Loader() {
register(m_isPublic); register(m_isPublic);
register(m_url); register(m_url);
register(m_title); register(m_title);
} }
/** /**
* Run script invoked by the loader script. * Run script invoked by the loader script.
* *
* @param ctx * @param ctx
*/ */
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
new KernelExcursion() {
public void excurse() {
setEffectiveParty(Kernel.getSystemParty());
createApplication((String) get(m_url),
(Boolean) get(m_isPublic), (String) get(m_title));
setupWorkspacePageType(); new KernelExcursion() {
loadTimeOfDayPortlet(); public void excurse() {
loadContentDirectoryPortlet(); setEffectiveParty(Kernel.getSystemParty());
loadRSSFeedPortlet();
loadFreeformHTMLPortlet(); createApplication((String) get(m_url),
loadLoginPortlet(); (Boolean) get(m_isPublic),
loadApplicationDirectoryPortlet(); (String) get(m_title));
loadWorkspaceDirectoryPortlet(); setupWorkspacePageType();
loadTimeOfDayPortlet();
loadContentDirectoryPortlet();
loadRSSFeedPortlet();
loadFreeformHTMLPortlet();
loadLoginPortlet();
loadApplicationDirectoryPortlet();
loadWorkspaceDirectoryPortlet();
NavigationDirectoryPortlet.loadPortletType(); NavigationDirectoryPortlet.loadPortletType();
} }
}.run(); }.run();
} }
/** /**
* *
* @param url * @param url
* @param isPublic * @param isPublic
@ -117,38 +120,38 @@ public class Loader extends PackageLoader {
*/ */
private void createApplication(String url, Boolean isPublic, String title) { private void createApplication(String url, Boolean isPublic, String title) {
ApplicationType type = setupWorkspaceType(); ApplicationType type = setupWorkspaceType();
if (url != null) { if (url != null) {
// check weather the url parameter is properly formatted // check weather the url parameter is properly formatted
s_log.debug("process url " + url); s_log.debug("process url " + url);
Assert.isTrue(url.startsWith("/"), "url starts with /"); Assert.isTrue(url.startsWith("/"), "url starts with /");
Assert.isTrue(url.endsWith("/"), "url ends with /"); Assert.isTrue(url.endsWith("/"), "url ends with /");
Assert.isTrue(!url.equals("/"), "url is not /"); Assert.isTrue(!url.equals("/"), "url is not /");
int last = url.lastIndexOf("/", url.length() - 2); int last = url.lastIndexOf("/", url.length() - 2);
s_log.debug("last slash at " + last); 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) {
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);
name = url.substring(last + 1, url.length() - 1); name = url.substring(last + 1, url.length() - 1);
} else { } else {
name = url.substring(1, url.length() - 1); name = url.substring(1, url.length() - 1);
} }
s_log.debug("node name is " + name); s_log.debug("node name is " + name);
// set up the portal node // set up the portal node
Workspace workspace = Workspace.createWorkspace(name, title, Workspace workspace = Workspace.createWorkspace(name, title,
parent, Boolean.TRUE.equals(isPublic)); parent, Boolean.TRUE.equals(isPublic));
} }
} }
/** /**
* Creates a workspace application type as a legacy-compatible application * Creates a workspace application type as a legacy-compatible application
* type. * type.
* *
@ -159,27 +162,35 @@ public class Loader extends PackageLoader {
private ApplicationType setupWorkspaceType() { private ApplicationType setupWorkspaceType() {
// The first string is a key parameter used to create a // The first string is a key parameter used to create a
// legacy package type to back the new application type. // legacy package type to back the new application type.
ApplicationType type = ApplicationType.createApplicationType( ApplicationType type = ApplicationType.createApplicationType(
"workspace", "Portal Workspace", "workspace", "Portal Workspace",
Workspace.BASE_DATA_OBJECT_TYPE); Workspace.BASE_DATA_OBJECT_TYPE);
type.setDescription("Portal based collaborative workspaces"); type.setDescription("Portal based collaborative workspaces");
type.createGroup(); type.createGroup();
return type; return type;
} }
private ResourceType setupWorkspacePageType() { /**
ResourceType type = ResourceType.createResourceType( *
"Portal Workspace Page", WorkspacePage.BASE_DATA_OBJECT_TYPE); * @return
type.setDescription("Pages for the portal workspaces"); */
return type; private ResourceType setupWorkspacePageType() {
} ResourceType type = ResourceType.createResourceType(
"Portal Workspace Page",
WorkspacePage.BASE_DATA_OBJECT_TYPE);
type.setDescription("Pages for the portal workspaces");
return type;
}
private void loadTimeOfDayPortlet() { /**
*
*/
private void loadTimeOfDayPortlet() {
PortletType type = PortletType.createPortletType("Time of Day", PortletType type = PortletType.createPortletType("Time of Day",
PortletType.WIDE_PROFILE, PortletType.WIDE_PROFILE,
TimeOfDayPortlet.BASE_DATA_OBJECT_TYPE); TimeOfDayPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Displays the current date and time"); type.setDescription("Displays the current date and time");
} }
private void loadContentDirectoryPortlet() { private void loadContentDirectoryPortlet() {
PortletType type = PortletType.createPortletType("Content Directory", PortletType type = PortletType.createPortletType("Content Directory",

View File

@ -162,19 +162,20 @@ public class Workspace extends Application {
* @return * @return
*/ */
public static Workspace createWorkspace(String url, String title, public static Workspace createWorkspace(String url, String title,
PageLayout layout, Application parent, boolean isPublic) { PageLayout layout, Application parent,
if (s_log.isDebugEnabled()) { boolean isPublic) {
s_log.debug("Creating group workspace, isPublic:" + isPublic if (s_log.isDebugEnabled()) {
+ " on " + url + " with parent " s_log.debug("Creating group workspace, isPublic:" + isPublic
+ (parent == null ? "none" : parent.getOID().toString())); + " on " + url + " with parent "
} + (parent == null ? "none" : parent.getOID().toString()));
}
Workspace workspace = (Workspace) Application.createApplication( Workspace workspace = (Workspace) Application.createApplication(
BASE_DATA_OBJECT_TYPE, url, title, parent); BASE_DATA_OBJECT_TYPE, url, title, parent);
workspace.setupGroups(title, isPublic); workspace.setupGroups(title, isPublic);
workspace.setDefaultLayout(layout); workspace.setDefaultLayout(layout);
return workspace; return workspace;
} }
/** /**
* Does the real work to create a workspace in the storage (db) * Does the real work to create a workspace in the storage (db)
@ -199,44 +200,44 @@ public class Workspace extends Application {
workspace.setParty(owner); workspace.setParty(owner);
workspace.setDefaultLayout(layout); workspace.setDefaultLayout(layout);
return workspace; return workspace;
} }
/** /**
* *
* retrieve the workspace that is created during loading of the * retrieve the workspace that is created during loading of the
* ccm-ldn-portal application and is set as the defaultworkspace for the * ccm-ldn-portal application and is set as the defaultworkspace for the
* site. * site.
* *
* Returns null if there are no workspaces (though presumably if that is the * Returns null if there are no workspaces (though presumably if that is the
* case, ccm-ldn-portal hasn't been loaded and so I don't know how you are * case, ccm-ldn-portal hasn't been loaded and so I don't know how you are
* invoking this method!) * invoking this method!)
* *
* @return * @return
*/ */
public static Workspace getDefaultHomepageWorkspace() { public static Workspace getDefaultHomepageWorkspace() {
if (null == defaultHomepageWorkspace) {
// default homepage workspace is created during
// com.arsdigita.london.portal.Loader
// it's attributes are all load variables that are lost as soon as
// the application
// is loaded. So, finding the default homepage workspace is a bit
// tricky - can't filter on name
// or anything else that is site specific - best bet is to assume
// that it is the first workspace created (a reasonable assumption
// at the moment because
// it is created straight after the Workspace application type is
// created.
WorkspaceCollection workspaces = Workspace.retrieveAll();
workspaces.addOrder(Application.TIMESTAMP);
if (workspaces.next()) {
defaultHomepageWorkspace = workspaces.getWorkspace();
}
workspaces.close();
} if (null == defaultHomepageWorkspace) {
return defaultHomepageWorkspace; // default homepage workspace is created during
// com.arsdigita.london.portal.Loader
// it's attributes are all load variables that are lost as soon as
// the application
// is loaded. So, finding the default homepage workspace is a bit
// tricky - can't filter on name
// or anything else that is site specific - best bet is to assume
// that it is the first workspace created (a reasonable assumption
// at the moment because
// it is created straight after the Workspace application type is
// created.
WorkspaceCollection workspaces = Workspace.retrieveAll();
workspaces.addOrder(Application.TIMESTAMP);
if (workspaces.next()) {
defaultHomepageWorkspace = workspaces.getWorkspace();
}
workspaces.close();
}
return defaultHomepageWorkspace;
} }
public void beforeSave() { public void beforeSave() {
// If no permissions are configured, then setup empty groups // If no permissions are configured, then setup empty groups