Grid viewer for Portal Workspace

git-svn-id: https://svn.libreccm.org/ccm/trunk@2925 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2014-10-28 15:04:06 +00:00
parent eb56a010ba
commit c559329701
15 changed files with 1054 additions and 622 deletions

View File

@ -5,7 +5,7 @@ insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '2 Column', 'Two columns, equal size', '50%,50%'); values (nextval('acs_object_id_seq'), '2 Column', 'Two columns, equal size', '50%,50%');
insert into pw_workspace_page_layouts (layout_id, title, description, format) insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '3 Column', 'Three columns, equal size', '30%,40%,30%'); values (nextval('acs_object_id_seq'), '3 Column', 'Three columns, equal size', '33.33%,33.33%,33.33%');
insert into pw_workspace_page_layouts (layout_id, title, description, format) insert into pw_workspace_page_layouts (layout_id, title, description, format)
values (nextval('acs_object_id_seq'), '4 Column', 'Four columns, equal size', '25%,25%,25%,25%'); values (nextval('acs_object_id_seq'), '4 Column', 'Four columns, equal size', '25%,25%,25%,25%');

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.Kernel;
@ -40,52 +39,52 @@ import com.arsdigita.web.ApplicationType;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Executes nonrecurring at install time and loads (and configures ) a default * Executes nonrecurring at install time and loads (and configures ) a default workspace instance
* workspace instance (i.e. instance of ccm-portalworkspace) in a default * (i.e. instance of ccm-portalworkspace) in a default configuration.
* configuration.
* *
* Configuration can be modified by configuration parameters before processing, * Configuration can be modified by configuration parameters before processing, otherwise hardcoded
* otherwise hardcoded default values take effect. A set of portlets, part of * default values take effect. A set of portlets, part of the ccm-ldn-portal package, are loaded as
* the ccm-ldn-portal package, are loaded as well, so they are statically available. * well, so they are statically available.
*
* After processing the installation values can not be modified anymore without a fresh installation
* of the whole system.
* *
* After processing the installation values can not be modified anymore without
* a fresh installation of the whole system.
*
* @author Justin Ross <jross@redhat.com> * @author Justin Ross <jross@redhat.com>
* @author Peter Boy <pboy@barkhof.uni-bremen.de> * @author Peter Boy <pboy@barkhof.uni-bremen.de>
* @version $Id: Loader.java 2070 2010-01-28 08:47:41Z pboy $ * @version $Id: Loader.java 2070 2010-01-28 08:47:41Z pboy $
*/ */
public class Loader extends PackageLoader { public class Loader extends PackageLoader {
/** Private Logger instance for debugging purpose. */ /**
* Private Logger instance for debugging purpose.
*/
private static final Logger s_log = Logger.getLogger(Loader.class); private static final Logger s_log = Logger.getLogger(Loader.class);
private StringParameter m_url = new StringParameter( private StringParameter m_url = new StringParameter(
"com.arsdigita.portalworkspace.default_url", "com.arsdigita.portalworkspace.default_url",
Parameter.REQUIRED, Parameter.REQUIRED,
"/portal/"); "/portal/");
private StringParameter m_title = new StringParameter( private StringParameter m_title = new StringParameter(
"com.arsdigita.portalworkspace.default_title", "com.arsdigita.portalworkspace.default_title",
Parameter.REQUIRED, Parameter.REQUIRED,
"Portal Homepage"); "Portal Homepage");
/** /**
* If true the group created for the instance of portal workspace will * If true the group created for the instance of portal workspace will contain the public user
* contain the public user as a member. * as a member. NOTE: Current implementation actually doesn't check for access permission!
* 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",
Parameter.REQUIRED, Boolean.TRUE); Parameter.REQUIRED, Boolean.TRUE);
/** /**
* Standard constructor loads/registers the configuration parameter. * Standard constructor loads/registers the configuration parameter.
*/ */
public Loader() { public Loader() {
register(m_isPublic); register(m_isPublic);
register(m_url); register(m_url);
register(m_title); register(m_title);
} }
/** /**
@ -96,6 +95,7 @@ public class Loader extends PackageLoader {
public void run(final ScriptContext ctx) { public void run(final ScriptContext ctx) {
new KernelExcursion() { new KernelExcursion() {
public void excurse() { public void excurse() {
setEffectiveParty(Kernel.getSystemParty()); setEffectiveParty(Kernel.getSystemParty());
@ -111,17 +111,17 @@ public class Loader extends PackageLoader {
loadRSSFeedPortlet(); loadRSSFeedPortlet();
// loadTimeOfDayPortlet(); // loadTimeOfDayPortlet();
} }
}.run(); }.run();
} }
/** /**
* Prepares creation of application type by checking proper formatting of * Prepares creation of application type by checking proper formatting of applications url and
* applications url and determining whether a parent is specified as part * determining whether a parent is specified as part of the url.
* of the url. *
* * @param url Sting containing the full url (including parents url in any
* @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
* @param isPublic if true the group created for this instance will include * member
* 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) {
@ -137,13 +137,13 @@ public class Loader extends PackageLoader {
Assert.isTrue(url.endsWith("/"), "url ends not with /"); Assert.isTrue(url.endsWith("/"), "url ends not with /");
Assert.isTrue(!url.equals("/"), "url is just /"); Assert.isTrue(!url.equals("/"), "url is just /");
int last = url.lastIndexOf("/" // last = 0 is leading slash int last = url.lastIndexOf("/" // last = 0 is leading slash
,url.length() - 2);// trailing slash excluded , url.length() - 2);// trailing slash excluded
s_log.debug("last slash at " + last); // last > 0 : multipe elements s_log.debug("last slash at " + last); // last > 0 : multipe elements
Application parent = null; Application parent = null;
String name = null; String name = null;
if (last > 0) { // url has more than 1 part = has a parent 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);
@ -156,8 +156,9 @@ public class Loader extends PackageLoader {
// set up the portal workspace default node (instance) // set up the portal workspace default node (instance)
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));
} }
} }
@ -166,12 +167,12 @@ public class Loader extends PackageLoader {
* *
* No localization here because it is an invariant configuration. * No localization here because it is an invariant configuration.
* *
* @return created ApplicationType * @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);
/* Create legacy-free application type /* Create legacy-free application type
* *
@ -181,16 +182,16 @@ public class Loader extends PackageLoader {
* replacing blanks between words and illegal characters with an * replacing blanks between words and illegal characters with an
* hyphen and converted to lower case. * hyphen and converted to lower case.
* "Portal Workspace" will become "portal-workspace". */ * "Portal Workspace" will become "portal-workspace". */
ApplicationType type = new ApplicationType( ApplicationType type = new ApplicationType(
"Portal 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");
/* Create an application type specific group in user administration * /* Create an application type specific group in user administration *
* which serves as a container for subgroups, each subgroup coupled * * which serves as a container for subgroups, each subgroup coupled *
* to an application (instances) of this type. */ * to an application (instances) of this type. */
type.createGroup(); type.createGroup();
return type; return type;
} }
@ -198,57 +199,59 @@ public class Loader extends PackageLoader {
/** /**
* Setup WorkspacePage type. * Setup WorkspacePage type.
* *
* Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in * Creates an entry for class (=type) c.ad.portalworkspace.WorkspacePage in table
* table application_types, but not in apm_package_types. * application_types, but not in apm_package_types.
*
* Uses the legacy free type of application Information (i.e. a title string and the object type
* = fully qualified domain class name) for creation
* *
* Uses the legacy free type of application Information (i.e. a title string
* and the object type = fully qualified domain class name) for creation
* @return * @return
*/ */
private ResourceType setupWorkspacePageType() { private ResourceType setupWorkspacePageType() {
ResourceType type = ResourceType.createResourceType( ResourceType type = ResourceType.createResourceType(
"Portal Workspace Page", "Portal Workspace Page",
WorkspacePage.BASE_DATA_OBJECT_TYPE); WorkspacePage.BASE_DATA_OBJECT_TYPE);
type.setDescription("Pages for the portal workspaces"); type.setDescription("Pages for the portal workspaces");
return type; return type;
} }
/** /**
* *
*/ */
private void loadApplicationDirectoryPortlet() { private void loadApplicationDirectoryPortlet() {
PortletType type = PortletType.createPortletType( PortletType type = PortletType.createPortletType(
"PW Application Directory", PortletType.WIDE_PROFILE, "PW Application Directory", PortletType.WIDE_PROFILE,
ApplicationDirectoryPortlet.BASE_DATA_OBJECT_TYPE); ApplicationDirectoryPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Displays a list of portal workspace applications"); type.setDescription("Displays a list of portal workspace applications");
} }
private void loadContentDirectoryPortlet() { private void loadContentDirectoryPortlet() {
PortletType type = PortletType.createPortletType("PW Content Directory", PortletType type = PortletType.createPortletType("PW Content Directory",
PortletType.WIDE_PROFILE, PortletType.WIDE_PROFILE,
ContentDirectoryPortlet.BASE_DATA_OBJECT_TYPE); ContentDirectoryPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Displays the content directory categories"); type.setDescription("Displays the content directory categories");
} }
private void loadFreeformHTMLPortlet() { private void loadFreeformHTMLPortlet() {
PortletType type = PortletType.createPortletType("Freeform HTML", PortletType type = PortletType.createPortletType("Freeform HTML",
PortletType.WIDE_PROFILE, PortletType.WIDE_PROFILE,
FreeformHTMLPortlet.BASE_DATA_OBJECT_TYPE); FreeformHTMLPortlet.BASE_DATA_OBJECT_TYPE);
type.setDescription("Displays a freeform block of HTML"); type.setDescription("Displays a freeform block of HTML");
} }
private void loadLoginPortlet() { private void loadLoginPortlet() {
PortletType type = PortletType.createPortletType("Site Login", PortletType type = PortletType.createPortletType("Site Login",
PortletType.WIDE_PROFILE, LoginPortlet.BASE_DATA_OBJECT_TYPE); PortletType.WIDE_PROFILE,
type.setDescription("Display a login form or user details"); LoginPortlet.BASE_DATA_OBJECT_TYPE);
} type.setDescription("Display a login form or user details");
}
private void loadRSSFeedPortlet() { private void loadRSSFeedPortlet() {
PortletType type = PortletType.createPortletType("RSS Feed", PortletType type = PortletType.createPortletType("RSS Feed",
PortletType.WIDE_PROFILE, RSSFeedPortlet.BASE_DATA_OBJECT_TYPE); PortletType.WIDE_PROFILE,
type.setDescription("Displays an RSS Feed"); RSSFeedPortlet.BASE_DATA_OBJECT_TYPE);
} type.setDescription("Displays an RSS Feed");
}
/** /**
* *
@ -259,5 +262,4 @@ public class Loader extends PackageLoader {
// 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");
// } // }
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace; package com.arsdigita.portalworkspace;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -32,13 +31,12 @@ import com.arsdigita.util.StringUtils;
import com.arsdigita.util.UncheckedWrapperException; import com.arsdigita.util.UncheckedWrapperException;
/** /**
* *
* *
*/ */
public class PageLayout extends DomainObject { public class PageLayout extends DomainObject {
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.portalworkspace.PageLayout";
"com.arsdigita.portalworkspace.PageLayout";
public static final String ID = "id"; public static final String ID = "id";
public static final String TITLE = "title"; public static final String TITLE = "title";
@ -46,7 +44,8 @@ public class PageLayout extends DomainObject {
public static final String FORMAT = "format"; public static final String FORMAT = "format";
public static final String FORMAT_ONE_COLUMN = "100%"; public static final String FORMAT_ONE_COLUMN = "100%";
public static final String FORMAT_TWO_COLUMNS = "50%,50%"; public static final String FORMAT_TWO_COLUMNS = "50%,50%";
public static final String FORMAT_THREE_COLUMNS = "30%,40%,30%"; //public static final String FORMAT_THREE_COLUMNS = "30%,40%,30%";
public static final String FORMAT_THREE_COLUMNS = "33.33%,33.33%,33.33%";
public static final String FORMAT_FOUR_COLUMNS = "25%,25%,25%,25%"; public static final String FORMAT_FOUR_COLUMNS = "25%,25%,25%,25%";
public PageLayout() { public PageLayout() {
@ -66,8 +65,9 @@ public class PageLayout extends DomainObject {
} }
/** /**
* *
*/ */
@Override
public void initialize() { public void initialize() {
super.initialize(); super.initialize();
@ -98,11 +98,12 @@ public class PageLayout extends DomainObject {
} }
/** /**
* *
* @param title * @param title
* @param description * @param description
* @param format * @param format
* @return *
* @return
*/ */
public static PageLayout create(String title, String description, public static PageLayout create(String title, String description,
String format) { String format) {
@ -117,42 +118,43 @@ public class PageLayout extends DomainObject {
setFormat(format); setFormat(format);
} }
public static DomainCollection retrieveAll() { public static DomainCollection retrieveAll() {
DataCollection layouts = SessionManager.getSession().retrieve( DataCollection layouts = SessionManager.getSession().retrieve(
BASE_DATA_OBJECT_TYPE); BASE_DATA_OBJECT_TYPE);
return new DomainCollection(layouts); return new DomainCollection(layouts);
} }
public BigDecimal getID() { public BigDecimal getID() {
return (BigDecimal) get(ID); return (BigDecimal) get(ID);
} }
public void setTitle(String title) { public void setTitle(String title) {
set(TITLE, title); set(TITLE, title);
} }
public String getTitle() { public String getTitle() {
return (String) get(TITLE); return (String) get(TITLE);
} }
public void setDescription(String description) { public void setDescription(String description) {
set(DESCRIPTION, description); set(DESCRIPTION, description);
} }
public String getDescription() { public String getDescription() {
return (String) get(DESCRIPTION); return (String) get(DESCRIPTION);
} }
public void setFormat(String format) { public void setFormat(String format) {
set(FORMAT, format); set(FORMAT, format);
} }
public String getFormat() { public String getFormat() {
return (String) get(FORMAT); return (String) get(FORMAT);
} }
public int getColumns() {
String[] bits = StringUtils.split(getFormat(), ',');
return bits.length;
}
public int getColumns() {
String[] bits = StringUtils.split(getFormat(), ',');
return bits.length;
}
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.kernel.permissions.PrivilegeDescriptor; import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
@ -34,20 +33,23 @@ import org.apache.log4j.Logger;
public class WorkspaceConfig extends AbstractConfig { public class WorkspaceConfig extends AbstractConfig {
/** Internal logger instance to faciliate debugging. Enable logging output /**
* by editing /WEB-INF/conf/log4j.properties int hte runtime environment * Internal logger instance to faciliate debugging. Enable logging output by editing
* and set com.arsdigita.portalworkspace.WorkspaceConfig=DEBUG by * /WEB-INF/conf/log4j.properties int hte runtime environment and set
* uncommenting or adding it. */ * com.arsdigita.portalworkspace.WorkspaceConfig=DEBUG by uncommenting or adding it.
private static final Logger s_log = Logger.getLogger(WorkspaceConfig.class); */
private static final Logger s_log = Logger.getLogger(WorkspaceConfig.class);
/** Singelton config object. */ /**
* Singelton config object.
*/
private static WorkspaceConfig s_conf; private static WorkspaceConfig s_conf;
/** /**
* Gain a WorkspaceConfig object. * Gain a WorkspaceConfig object.
* *
* Singelton pattern, don't instantiate a config object using the * Singelton pattern, don't instantiate a config object using the constructor directly!
* constructor directly! *
* @return * @return
*/ */
public static synchronized WorkspaceConfig getInstanceOf() { public static synchronized WorkspaceConfig getInstanceOf() {
@ -59,94 +61,100 @@ public class WorkspaceConfig extends AbstractConfig {
return s_conf; return s_conf;
} }
// set of configuration parameters // set of configuration parameters
/** File with rules for configuring information in generated XML */ /**
private final Parameter m_adapters = * File with rules for configuring information in generated XML
new ResourceParameter( */
"com.arsdigita.portalworkspace.traversal_adapters", private final Parameter m_adapters = new ResourceParameter(
Parameter.REQUIRED, "com.arsdigita.portalworkspace.traversal_adapters",
"/WEB-INF/resources/portalworkspace-adapters.xml"); Parameter.REQUIRED,
"/WEB-INF/resources/portalworkspace-adapters.xml");
/** Default column layout for workspace portals */ /**
private final Parameter m_defaultLayout = * Default column layout for workspace portals
new StringParameter( */
"com.arsdigita.portalworkspace.default_layout", private final Parameter m_defaultLayout = new StringParameter(
Parameter.REQUIRED, PageLayout.FORMAT_THREE_COLUMNS); "com.arsdigita.portalworkspace.default_layout",
Parameter.REQUIRED, PageLayout.FORMAT_THREE_COLUMNS);
/** Whether non-admin users should have their own custom workspaces */ /**
private final Parameter m_createUserWorkspaces = * Whether non-admin users should have their own custom workspaces
new BooleanParameter( */
"com.arsdigita.portalworkspace.create_user_workspaces", private final Parameter m_createUserWorkspaces = new BooleanParameter(
Parameter.REQUIRED, Boolean.TRUE); "com.arsdigita.portalworkspace.create_user_workspaces",
Parameter.REQUIRED, Boolean.TRUE);
/** Types not to be included in the drop down list of portlets to add to a page*/ /**
private final Parameter m_excludedPortletTypes = * Types not to be included in the drop down list of portlets to add to a page
new StringArrayParameter( */
"com.arsdigita.portalworkspace.excluded_portlet_types", private final Parameter m_excludedPortletTypes = new StringArrayParameter(
Parameter.OPTIONAL, new String[0]); "com.arsdigita.portalworkspace.excluded_portlet_types",
Parameter.OPTIONAL, new String[0]);
/** Types only available to administrator of homepage, or subsite frontpage*/ /**
private final Parameter m_adminPortletTypes = * Types only available to administrator of homepage, or subsite frontpage
new StringArrayParameter( */
"com.arsdigita.portalworkspace.admin_only_portlet_types", private final Parameter m_adminPortletTypes = new StringArrayParameter(
Parameter.OPTIONAL, new String[0]); "com.arsdigita.portalworkspace.admin_only_portlet_types",
Parameter.OPTIONAL, new String[0]);
/** Whether to use editor specified by waf.bebop.dhtml_editor for editing /**
freeform html portlet*/ * Whether to use editor specified by waf.bebop.dhtml_editor for editing freeform html portlet
private final Parameter m_htmlPortletWysiwygEditor = */
new BooleanParameter( private final Parameter m_htmlPortletWysiwygEditor = new BooleanParameter(
"com.arsdigita.portalworkspace.portlet.freeform_html_editor", "com.arsdigita.portalworkspace.portlet.freeform_html_editor",
Parameter.REQUIRED, Boolean.FALSE); Parameter.REQUIRED, Boolean.FALSE);
/** Which privilege ("read" or "edit") is granted to the workspace party. */ /**
private final Parameter m_workspacePartyPrivilege = * Which privilege ("read" or "edit") is granted to the workspace party.
new StringParameter( */
"com.arsdigita.portalworkspace.workspacePartyPrivilege", private final Parameter m_workspacePartyPrivilege = new StringParameter(
Parameter.OPTIONAL, "read"); "com.arsdigita.portalworkspace.workspacePartyPrivilege",
Parameter.OPTIONAL, "read");
/** Whether READ permissions will be checked when viewing workspaces. /**
By default we don't, which is odd. */ * Whether READ permissions will be checked when viewing workspaces. By default we don't, which
private final Parameter m_checkWorkspaceReadPermissions = * is odd.
new BooleanParameter( */
"com.arsdigita.portalworkspace.checkWorkspaceReadPermissions", private final Parameter m_checkWorkspaceReadPermissions = new BooleanParameter(
Parameter.OPTIONAL, Boolean.FALSE); "com.arsdigita.portalworkspace.checkWorkspaceReadPermissions",
Parameter.OPTIONAL, Boolean.FALSE);
public WorkspaceConfig() { public WorkspaceConfig() {
register(m_adapters); register(m_adapters);
register(m_defaultLayout); register(m_defaultLayout);
register(m_createUserWorkspaces); register(m_createUserWorkspaces);
register(m_excludedPortletTypes); register(m_excludedPortletTypes);
register(m_adminPortletTypes); register(m_adminPortletTypes);
register(m_htmlPortletWysiwygEditor); register(m_htmlPortletWysiwygEditor);
register(m_workspacePartyPrivilege); register(m_workspacePartyPrivilege);
register(m_checkWorkspaceReadPermissions); register(m_checkWorkspaceReadPermissions);
loadInfo(); loadInfo();
} }
InputStream getTraversalAdapters() { InputStream getTraversalAdapters() {
return (InputStream) get(m_adapters); return (InputStream) get(m_adapters);
} }
public String getDefaultLayout() { public String getDefaultLayout() {
return (String) get(m_defaultLayout); return (String) get(m_defaultLayout);
} }
public boolean getCreateUserWorkspaces() { public boolean getCreateUserWorkspaces() {
return ((Boolean) get(m_createUserWorkspaces)).booleanValue(); return ((Boolean) get(m_createUserWorkspaces)).booleanValue();
} }
public List getExcludedPortletTypes() { public List getExcludedPortletTypes() {
String[] excludedTypes = (String[]) get(m_excludedPortletTypes); String[] excludedTypes = (String[]) get(m_excludedPortletTypes);
return Arrays.asList(excludedTypes); return Arrays.asList(excludedTypes);
} }
public List getAdminPortletTypes() { public List getAdminPortletTypes() {
String[] adminTypes = (String[]) get(m_adminPortletTypes); String[] adminTypes = (String[]) get(m_adminPortletTypes);
return Arrays.asList(adminTypes); return Arrays.asList(adminTypes);
} }
public boolean useWysiwygEditor() { public boolean useWysiwygEditor() {
return ((Boolean) get(m_htmlPortletWysiwygEditor)).booleanValue(); return ((Boolean) get(m_htmlPortletWysiwygEditor)).booleanValue();
@ -168,14 +176,15 @@ public class WorkspaceConfig extends AbstractConfig {
} }
} }
public PrivilegeDescriptor getWorkspacePartyPrivilege() { public PrivilegeDescriptor getWorkspacePartyPrivilege() {
if (workspacePartyPrivilegeDescriptor == null) { if (workspacePartyPrivilegeDescriptor == null) {
initWorkspacePartyPrivilegeDescriptor(); initWorkspacePartyPrivilegeDescriptor();
} }
return workspacePartyPrivilegeDescriptor; return workspacePartyPrivilegeDescriptor;
} }
public boolean getCheckWorkspaceReadPermissions() { public boolean getCheckWorkspaceReadPermissions() {
return ((Boolean) get(m_checkWorkspaceReadPermissions)).booleanValue(); return ((Boolean) get(m_checkWorkspaceReadPermissions)).booleanValue();
} }
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace; package com.arsdigita.portalworkspace;
import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObjectFactory;
@ -24,88 +23,88 @@ import com.arsdigita.persistence.DataObject;
import com.arsdigita.persistence.OID; import com.arsdigita.persistence.OID;
import com.arsdigita.portal.Portal; import com.arsdigita.portal.Portal;
/** /**
* *
* *
*/ */
public class WorkspacePage extends Portal { public class WorkspacePage extends Portal {
public static final String SORT_KEY = "sortKey"; public static final String SORT_KEY = "sortKey";
public static final String LAYOUT = "layout"; public static final String LAYOUT = "layout";
public static final String WORKSPACE = "workspace"; public static final String WORKSPACE = "workspace";
public static final String BASE_DATA_OBJECT_TYPE = public static final String BASE_DATA_OBJECT_TYPE
"com.arsdigita.portalworkspace.WorkspacePage"; = "com.arsdigita.portalworkspace.WorkspacePage";
public static final String MODE_EDITOR = "editor"; public static final String MODE_EDITOR = "editor";
public static final String PORTAL_XML_NS = "http://www.uk.arsdigita.com/portal/1.0"; public static final String PORTAL_XML_NS = "http://www.uk.arsdigita.com/portal/1.0";
public static final String PORTLET_XML_NS = "http://www.uk.arsdigita.com/portlet/1.0"; public static final String PORTLET_XML_NS = "http://www.uk.arsdigita.com/portlet/1.0";
public static final String MODE_DISPLAY = "display"; public static final String MODE_DISPLAY = "display";
public WorkspacePage() { public WorkspacePage() {
this(BASE_DATA_OBJECT_TYPE); this(BASE_DATA_OBJECT_TYPE);
} }
public WorkspacePage(String type) { public WorkspacePage(String type) {
super(type); super(type);
} }
public WorkspacePage(DataObject dobj) { public WorkspacePage(DataObject dobj) {
super(dobj); super(dobj);
} }
public WorkspacePage(OID oid) { public WorkspacePage(OID oid) {
super(oid); super(oid);
} }
static WorkspacePage create(String title, static WorkspacePage create(String title,
String description, String description,
PageLayout layout, PageLayout layout,
Workspace workspace, Workspace workspace,
int sortKey) { int sortKey) {
WorkspacePage page = (WorkspacePage) Resource WorkspacePage page = (WorkspacePage) Resource
.createResource(WorkspacePage.BASE_DATA_OBJECT_TYPE, .createResource(WorkspacePage.BASE_DATA_OBJECT_TYPE,
title, title,
null); null);
page.setup(description, layout, workspace, sortKey); page.setup(description, layout, workspace, sortKey);
return page; return page;
} }
protected void setup(String description, protected void setup(String description,
PageLayout layout, PageLayout layout,
Workspace workspace, Workspace workspace,
int sortKey) { int sortKey) {
setDescription(description); setDescription(description);
setLayout(layout); setLayout(layout);
setWorkspace(workspace); setWorkspace(workspace);
setSortKey(sortKey); setSortKey(sortKey);
} }
void setSortKey(int key) { void setSortKey(int key) {
set(SORT_KEY, new Integer(key)); set(SORT_KEY, new Integer(key));
} }
public int getSortKey() { public int getSortKey() {
return ((Integer) get(SORT_KEY)).intValue(); return ((Integer) get(SORT_KEY)).intValue();
} }
void setWorkspace(Workspace workspace) { void setWorkspace(Workspace workspace) {
setAssociation(WORKSPACE, workspace); setAssociation(WORKSPACE, workspace);
} }
public Workspace getWorkspace() { public Workspace getWorkspace() {
return (Workspace) DomainObjectFactory return (Workspace) DomainObjectFactory
.newInstance((DataObject) get(WORKSPACE)); .newInstance((DataObject) get(WORKSPACE));
} }
public void setLayout(PageLayout layout) { public void setLayout(PageLayout layout) {
setAssociation(LAYOUT, layout); setAssociation(LAYOUT, layout);
} }
public PageLayout getLayout() { public PageLayout getLayout() {
return (PageLayout) DomainObjectFactory return (PageLayout) DomainObjectFactory
.newInstance((DataObject) get(LAYOUT)); .newInstance((DataObject) get(LAYOUT));
} }
} }

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings=No settings yet cw.workspace.ui.admin.no_settings=No settings yet
cw.workspace.default_layout=Layout cw.workspace.default_layout=Layout
cw.workspace.ui.categorized.create_workspace.info=Currently there is no Portal Workspace for this category. If you want to create one now, please click the link below.
cw.workspace.ui.categorized.create_workspace.link=Create PortalWorkspace for this category
cw.workspace.ui.categorized.workspace.add_row.link=Add new row

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings=Noch keine Einstellungen cw.workspace.ui.admin.no_settings=Noch keine Einstellungen
cw.workspace.default_layout=Layout cw.workspace.default_layout=Layout
cw.workspace.ui.categorized.create_workspace.info=Es gibt noch keinen Portal Workspace f\u00fcr diese Kategorie. Wenn Sie jetzt einen neuen Workspace f\u00fcr diese Kategorie anlegen m\u00f6chten klicken Sie bitte auf untenstehenden Link.
cw.workspace.ui.categorized.create_workspace.link=PortalWorkspace f\u00fcr diese Kategorie anlegen
cw.workspace.ui.categorized.workspace.add_row.link=Weitere Zeile hinzuf\u00fcgen

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings= cw.workspace.ui.admin.no_settings=
cw.workspace.default_layout= cw.workspace.default_layout=
cw.workspace.ui.categorized.create_workspace.info=
cw.workspace.ui.categorized.create_workspace.link=
cw.workspace.ui.categorized.workspace.add_row.link=

View File

@ -30,3 +30,6 @@ cw.workspace.ui.participant_info=Participant Info
cw.workspace.ui.participant_roles=Participant Roles cw.workspace.ui.participant_roles=Participant Roles
cw.workspace.ui.admin.no_settings= cw.workspace.ui.admin.no_settings=
cw.workspace.default_layout= cw.workspace.default_layout=
cw.workspace.ui.categorized.create_workspace.info=
cw.workspace.ui.categorized.create_workspace.link=
cw.workspace.ui.categorized.workspace.add_row.link=

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.portalworkspace.StatefulPersistentPortal; import com.arsdigita.portalworkspace.StatefulPersistentPortal;
@ -74,12 +73,12 @@ import org.apache.log4j.Logger;
// XXX this class is disgusting // XXX this class is disgusting
/** /**
* PersistentPortals are able to have more than one column, and the constructor * PersistentPortals are able to have more than one column, and the constructor for PersistentPortal
* for PersistentPortal takes in an integer argument for number of columns. * takes in an integer argument for number of columns.
* *
* HomepagePortals defined on the jsp page each construct instances of this * HomepagePortals defined on the jsp page each construct instances of this class, one for the
* class, one for the portal in view mode, one in edit mode. * portal in view mode, one in edit mode.
* *
*/ */
public class PersistentPortal extends SimpleContainer { public class PersistentPortal extends SimpleContainer {
@ -91,7 +90,6 @@ public class PersistentPortal extends SimpleContainer {
public static final String ACTION_MOVE_LEFT = "moveLeft"; public static final String ACTION_MOVE_LEFT = "moveLeft";
public static final String ACTION_MOVE_RIGHT = "moveRight"; public static final String ACTION_MOVE_RIGHT = "moveRight";
public static final String ACTION_DELETE = "delete"; public static final String ACTION_DELETE = "delete";
private WorkspaceSelectionAbstractModel m_workspace; private WorkspaceSelectionAbstractModel m_workspace;
@ -119,9 +117,9 @@ public class PersistentPortal extends SimpleContainer {
// pixels wide... // pixels wide...
public static final int MAX_COLUMNS = 10; public static final int MAX_COLUMNS = 10;
/** /**
* Constructor * Constructor
*
* @param portal * @param portal
* @param mode * @param mode
*/ */
@ -131,7 +129,7 @@ public class PersistentPortal extends SimpleContainer {
} }
/** /**
* *
* @param portal * @param portal
* @param name * @param name
* @param mode * @param mode
@ -139,7 +137,7 @@ public class PersistentPortal extends SimpleContainer {
public PersistentPortal(PortalSelectionModel portal, public PersistentPortal(PortalSelectionModel portal,
String name, String name,
String mode) { String mode) {
setTag("portal:portal"); setTag("portal:portal");
setNamespace(WorkspacePage.PORTAL_XML_NS); setNamespace(WorkspacePage.PORTAL_XML_NS);
@ -150,7 +148,6 @@ public class PersistentPortal extends SimpleContainer {
m_column = new ParameterSingleSelectionModel(new IntegerParameter("column")); m_column = new ParameterSingleSelectionModel(new IntegerParameter("column"));
if (m_mode.equals(WorkspacePage.MODE_EDITOR)) { if (m_mode.equals(WorkspacePage.MODE_EDITOR)) {
for (int i = 0; i < m_adders.length; i++) { for (int i = 0; i < m_adders.length; i++) {
m_adders[i] = new PortletTypeForm("add" + name + i); m_adders[i] = new PortletTypeForm("add" + name + i);
@ -161,11 +158,12 @@ public class PersistentPortal extends SimpleContainer {
} }
m_portlet = new PortletSelectionModel( m_portlet = new PortletSelectionModel(
new BigDecimalParameter("edit") ); new BigDecimalParameter("edit"));
m_portletType = new PortletTypeSelectionModel( m_portletType = new PortletTypeSelectionModel(
new BigDecimalParameter("create") ); new BigDecimalParameter("create"));
m_portal.addChangeListener(new ChangeListener() { m_portal.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_portal.isSelected(state)) { if (m_portal.isSelected(state)) {
@ -177,14 +175,16 @@ public class PersistentPortal extends SimpleContainer {
m_parentResource.set(state, null); m_parentResource.set(state, null);
} }
} }
}); });
m_portlet.addChangeListener(new ChangeListener() { m_portlet.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent event) { public void stateChanged(ChangeEvent event) {
PageState state = event.getPageState(); PageState state = event.getPageState();
if (m_portal.isSelected(state)) { if (m_portal.isSelected(state)) {
com.arsdigita.portal.Portlet portlet = com.arsdigita.portal.Portlet portlet
m_portlet.getSelectedPortlet(state); = m_portlet.getSelectedPortlet(state);
s_log.debug("Setting portlet" + portlet); s_log.debug("Setting portlet" + portlet);
m_currentResource.set(state, portlet); m_currentResource.set(state, portlet);
} else { } else {
@ -192,26 +192,33 @@ public class PersistentPortal extends SimpleContainer {
m_currentResource.set(state, null); m_currentResource.set(state, null);
} }
} }
}); });
m_parentApp = new DomainObjectParameter("parentApp"); m_parentApp = new DomainObjectParameter("parentApp");
m_parentResource = new RequestLocal() { m_parentResource = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return state.getValue(m_parentApp); return state.getValue(m_parentApp);
} }
}; };
m_currentResource = new RequestLocal() { m_currentResource = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return m_portlet.getSelectedPortlet(state); return m_portlet.getSelectedPortlet(state);
} }
}; };
m_currentApp = new RequestLocal() { m_currentApp = new RequestLocal() {
public Object initialValue(PageState state) { public Object initialValue(PageState state) {
return Kernel.getContext().getResource(); return Kernel.getContext().getResource();
} }
}; };
PortletTypeCollection types = PortletType.retrieveAllPortletTypes(); PortletTypeCollection types = PortletType.retrieveAllPortletTypes();
@ -223,22 +230,23 @@ public class PersistentPortal extends SimpleContainer {
PortletType type = types.getPortletType(); PortletType type = types.getPortletType();
s_log.debug("Add type " + type.getResourceObjectType()); s_log.debug("Add type " + type.getResourceObjectType());
final ResourceConfigComponent create = final ResourceConfigComponent create
type.getCreateComponent(m_parentResource); = type.getCreateComponent(m_parentResource);
final ResourceConfigComponent modify = final ResourceConfigComponent modify
type.getModifyComponent(m_currentResource); = type.getModifyComponent(m_currentResource);
ApplicationType appType = type.getProviderApplicationType(); ApplicationType appType = type.getProviderApplicationType();
SimpleContainer createApp = null; SimpleContainer createApp = null;
if (appType != null) { if (appType != null) {
final ResourceConfigComponent appCreate = final ResourceConfigComponent appCreate
appType.getCreateComponent(m_currentApp); = appType.getCreateComponent(m_currentApp);
ApplicationSelector sel = new ApplicationSelector( ApplicationSelector sel = new ApplicationSelector(
appType, appType,
m_parentApp, m_parentApp,
appType.getConfig() == null ? null : appType.getConfig().getViewPrivilege()); appType.getConfig() == null ? null : appType.getConfig().
getViewPrivilege());
appCreate.addCompletionListener(new ActionListener() { appCreate.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
s_log.debug("Do create of portlet"); s_log.debug("Do create of portlet");
@ -251,19 +259,21 @@ public class PersistentPortal extends SimpleContainer {
state.setValue(m_parentApp, resource); state.setValue(m_parentApp, resource);
} }
} }
}); });
sel.addCompletionListener(new ActionListener() { sel.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
if (state.getValue(m_parentApp) == null) { if (state.getValue(m_parentApp) == null) {
s_log.debug("Sel no resource, reset"); s_log.debug("Sel no resource, reset");
m_portletType.clearSelection(e.getPageState()); m_portletType.clearSelection(e.getPageState());
} else { } else {
s_log.debug("Got res " + s_log.debug("Got res " + state.getValue(m_parentApp));
state.getValue(m_parentApp));
} }
} }
}); });
createApp = new SimpleContainer(); createApp = new SimpleContainer();
@ -275,20 +285,20 @@ public class PersistentPortal extends SimpleContainer {
s_log.debug("Modify component is " + modify); s_log.debug("Modify component is " + modify);
create.addCompletionListener(new ActionListener() { create.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
s_log.debug("Do create of portlet"); s_log.debug("Do create of portlet");
Resource resource = create.createResource(state); Resource resource = create.createResource(state);
if (resource != null) { if (resource != null) {
Integer column = (Integer) Integer column = (Integer) m_column.getSelectedKey(state);
m_column.getSelectedKey(state);
Assert.exists(column, Integer.class); Assert.exists(column, Integer.class);
WorkspacePage portal = m_portal WorkspacePage portal = m_portal
.getSelectedPortal(state); .getSelectedPortal(state);
portal.addPortlet((Portlet)resource, portal.addPortlet((Portlet) resource,
column.intValue()); column.intValue());
portal.save(); portal.save();
} }
@ -299,254 +309,268 @@ public class PersistentPortal extends SimpleContainer {
s_log.debug("Stateful portlet added"); s_log.debug("Stateful portlet added");
// check if the maximum number of stateful // check if the maximum number of stateful
// portlets has increased // portlets has increased
PortletType portletType = PortletType portletType
((Portlet) resource).getPortletType(); = ((Portlet) resource).getPortletType();
DataQuery findMaxInstances = DataQuery findMaxInstances
SessionManager.getSession().retrieveQuery( = SessionManager.getSession().retrieveQuery(
"com.arsdigita.london.portal.MaxPortletInstances"); "com.arsdigita.london.portal.MaxPortletInstances");
findMaxInstances.setParameter("portletType", findMaxInstances.setParameter("portletType",
portletType.getID()); portletType.getID());
int maxCount = 0; int maxCount = 0;
while (findMaxInstances.next()) { while (findMaxInstances.next()) {
maxCount = maxCount
((Integer) findMaxInstances = ((Integer) findMaxInstances
.get("maxCount")) .get("maxCount"))
.intValue(); .intValue();
} }
String key = portletType.getResourceObjectType(); String key = portletType.getResourceObjectType();
int previousMax = StatefulPersistentPortal int previousMax = StatefulPersistentPortal
.getCurrentPortletRendererInstances(key); .getCurrentPortletRendererInstances(key);
s_log.debug( portletType + ": previous count = " s_log.debug(portletType + ": previous count = "
+ previousMax + " | new max = " + previousMax + " | new max = "
+ maxCount); + maxCount);
if (maxCount > previousMax) { if (maxCount > previousMax) {
DefinePage.invalidatePage( DefinePage.invalidatePage(
DispatcherHelper DispatcherHelper
.getCurrentResourcePath(state.getRequest())); } .getCurrentResourcePath(state.getRequest()));
}
} }
m_portletType.clearSelection(e.getPageState()); m_portletType.clearSelection(e.getPageState());
state.setValue(m_parentApp, null); state.setValue(m_parentApp, null);
m_parentResource.set(state, null); m_parentResource.set(state, null);
} }
});
modify.addCompletionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
s_log.debug("Do modify of portlet");
PageState state = e.getPageState();
modify.modifyResource(state);
Portlet portlet = m_portlet.getSelectedPortlet(state);
portlet.save();
m_portlet.clearSelection(state);
}
});
m_create.put(type.getResourceObjectType(), create);
m_modify.put(type.getResourceObjectType(), modify);
if (createApp != null) {
m_createApp.put(type.getResourceObjectType(), createApp);
}
add(create);
add(modify);
if (createApp != null) {
add(createApp);
}
}
s_log.debug("Done with add types" + m_create.size()
+ " " + m_modify.size());
Assert.exists(m_parentResource, RequestLocal.class); });
m_portalModelBuilder = new PortalEditModelBuilder( modify.addCompletionListener(new ActionListener() {
portal, m_adders,
m_portletType, m_column, m_portlet,
m_create, m_modify, m_createApp, m_parentResource);
} else {
m_portalModelBuilder = new PortalViewModelBuilder(portal);
}
}
public void register(Page page) { public void actionPerformed(ActionEvent e) {
super.register(page); s_log.debug("Do modify of portlet");
PageState state = e.getPageState();
modify.modifyResource(state);
Portlet portlet = m_portlet.getSelectedPortlet(state);
portlet.save();
m_portlet.clearSelection(state);
}
if (m_portlet != null) { });
page.addComponentStateParam(this, m_portlet.getStateParameter()); m_create.put(type.getResourceObjectType(), create);
} m_modify.put(type.getResourceObjectType(), modify);
if (m_portletType != null) { if (createApp != null) {
m_createApp.put(type.getResourceObjectType(), createApp);
}
add(create);
add(modify);
if (createApp != null) {
add(createApp);
}
}
s_log.debug("Done with add types" + m_create.size()
+ " " + m_modify.size());
Assert.exists(m_parentResource, RequestLocal.class);
m_portalModelBuilder = new PortalEditModelBuilder(portal,
m_adders,
m_portletType,
m_column,
m_portlet,
m_create,
m_modify,
m_createApp,
m_parentResource);
} else {
m_portalModelBuilder = new PortalViewModelBuilder(portal);
}
}
public void register(Page page) {
super.register(page);
if (m_portlet != null) {
page.addComponentStateParam(this, m_portlet.getStateParameter());
}
if (m_portletType != null) {
page.addComponentStateParam(this, m_portletType.getStateParameter()); page.addComponentStateParam(this, m_portletType.getStateParameter());
} }
page.addComponentStateParam(this, m_column.getStateParameter()); page.addComponentStateParam(this, m_column.getStateParameter());
if (m_parentApp != null) { if (m_parentApp != null) {
page.addComponentStateParam(this, m_parentApp); page.addComponentStateParam(this, m_parentApp);
} }
} }
public void generateXML(PageState state, public void generateXML(PageState state,
Element parent) { Element parent) {
Element content = generateParent(parent); Element content = generateParent(parent);
WorkspacePage page = m_portal.getSelectedPortal(state); WorkspacePage page = m_portal.getSelectedPortal(state);
content.addAttribute("layout", page.getLayout().getFormat()); content.addAttribute("layout", page.getLayout().getFormat());
content.addAttribute("style", page.getLayout().getTitle()); content.addAttribute("style", page.getLayout().getTitle());
content.addAttribute("title", page.getTitle()); content.addAttribute("title", page.getTitle());
content.addAttribute("description", page.getDescription()); content.addAttribute("description", page.getDescription());
PortalModel pm = m_portalModelBuilder.buildModel(state); PortalModel pm = m_portalModelBuilder.buildModel(state);
Iterator portlets = pm.getPortletRenderers(); Iterator portlets = pm.getPortletRenderers();
while (portlets.hasNext()) { while (portlets.hasNext()) {
Object entry = portlets.next(); Object entry = portlets.next();
if (entry instanceof Object[]) { if (entry instanceof Object[]) {
PortletRenderer renderer = (PortletRenderer) ((Object[]) entry)[0]; PortletRenderer renderer = (PortletRenderer) ((Object[]) entry)[0];
BigDecimal portlet = (BigDecimal) ((Object[]) entry)[1]; BigDecimal portlet = (BigDecimal) ((Object[]) entry)[1];
// We want the root element created by the portlet // We want the root element created by the portlet
// but the crap generateXML signature doesn't let // but the crap generateXML signature doesn't let
// us get at it :-( And the bebop portlet isn't // us get at it :-( And the bebop portlet isn't
// any more helpful either :-( // any more helpful either :-(
Element hack = new Element("hack"); Element hack = new Element("hack");
renderer.generateXML(state, hack); renderer.generateXML(state, hack);
Iterator elements = hack.getChildren().iterator(); Iterator elements = hack.getChildren().iterator();
while (elements.hasNext()) { while (elements.hasNext()) {
Element child = (Element) elements.next(); Element child = (Element) elements.next();
generateActionXML(state, child, portlet); generateActionXML(state, child, portlet);
content.addContent(child); content.addContent(child);
} }
} else { } else {
PortletRenderer renderer = (PortletRenderer) entry; PortletRenderer renderer = (PortletRenderer) entry;
renderer.generateXML(state, content); renderer.generateXML(state, content);
} }
} }
} }
public void generateActionXML(PageState state, public void generateActionXML(PageState state,
Element parent, Element parent,
BigDecimal portlet) { BigDecimal portlet) {
generateActionXML(state, parent, portlet, ACTION_CUSTOMIZE); generateActionXML(state, parent, portlet, ACTION_CUSTOMIZE);
generateActionXML(state, parent, portlet, ACTION_MOVE_UP); generateActionXML(state, parent, portlet, ACTION_MOVE_UP);
generateActionXML(state, parent, portlet, ACTION_MOVE_DOWN); generateActionXML(state, parent, portlet, ACTION_MOVE_DOWN);
generateActionXML(state, parent, portlet, ACTION_MOVE_LEFT); generateActionXML(state, parent, portlet, ACTION_MOVE_LEFT);
generateActionXML(state, parent, portlet, ACTION_MOVE_RIGHT); generateActionXML(state, parent, portlet, ACTION_MOVE_RIGHT);
generateActionXML(state, parent, portlet, ACTION_DELETE); generateActionXML(state, parent, portlet, ACTION_DELETE);
} }
public void generateActionXML(PageState state, public void generateActionXML(PageState state,
Element parent, Element parent,
BigDecimal portlet, BigDecimal portlet,
String name) { String name) {
Element action = parent.newChildElement("portlet:action", Element action = parent.newChildElement("portlet:action",
WorkspacePage.PORTLET_XML_NS); WorkspacePage.PORTLET_XML_NS);
try { try {
state.setControlEvent(this, state.setControlEvent(this,
name, name,
portlet.toString()); portlet.toString());
action.addAttribute("name", name); action.addAttribute("name", name);
action.addAttribute("url", state.stateAsURL()); action.addAttribute("url", state.stateAsURL());
state.clearControlEvent(); state.clearControlEvent();
} catch (IOException ex) { } catch (IOException ex) {
throw new UncheckedWrapperException("cannot get state url", ex); throw new UncheckedWrapperException("cannot get state url", ex);
} }
} }
public void respond(PageState state) { public void respond(PageState state) {
WorkspacePage portal = m_portal.getSelectedPortal(state); WorkspacePage portal = m_portal.getSelectedPortal(state);
if (m_mode.equals(WorkspacePage.MODE_EDITOR)) { if (m_mode.equals(WorkspacePage.MODE_EDITOR)) {
// check permission on Workspace, not WorkspacePage, // check permission on Workspace, not WorkspacePage,
// as this is where the permissiones/groups are set // as this is where the permissiones/groups are set
Workspace workspace = portal.getWorkspace(); Workspace workspace = portal.getWorkspace();
Party party = Kernel.getContext().getParty(); Party party = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(party, if (!PortalHelper.canCustomize(party,
workspace)) { workspace)) {
throw new AccessDeniedException( throw new AccessDeniedException(
"no permissions to customize workspace"); "no permissions to customize workspace");
} }
String key = state.getControlEventName(); String key = state.getControlEventName();
String value = state.getControlEventValue(); String value = state.getControlEventValue();
Portlet portlet = Portlet.retrievePortlet(new BigDecimal(value)); Portlet portlet = Portlet.retrievePortlet(new BigDecimal(value));
if (ACTION_MOVE_UP.equals(key)) { if (ACTION_MOVE_UP.equals(key)) {
portal.swapPortletWithPrevious(portlet); portal.swapPortletWithPrevious(portlet);
portal.save(); portal.save();
} else if (ACTION_MOVE_DOWN.equals(key)) { } else if (ACTION_MOVE_DOWN.equals(key)) {
portal.swapPortletWithNext(portlet); portal.swapPortletWithNext(portlet);
portal.save(); portal.save();
} else if (ACTION_MOVE_LEFT.equals(key)) { } else if (ACTION_MOVE_LEFT.equals(key)) {
int cell = portlet.getCellNumber(); int cell = portlet.getCellNumber();
cell = cell - 1; cell = cell - 1;
if (cell < 1) { cell = 1; } if (cell < 1) {
cell = 1;
}
portlet.setCellNumber(cell); portlet.setCellNumber(cell);
portlet.save(); portlet.save();
} else if (ACTION_MOVE_RIGHT.equals(key)) { } else if (ACTION_MOVE_RIGHT.equals(key)) {
int cello = portlet.getCellNumber(); int cello = portlet.getCellNumber();
cello = cello + 1; cello = cello + 1;
if (cello > 3) { cello = 3; } if (cello > 3) {
cello = 3;
}
portlet.setCellNumber(cello); portlet.setCellNumber(cello);
portlet.save(); portlet.save();
} else if (ACTION_DELETE.equals(key)) { } else if (ACTION_DELETE.equals(key)) {
if (portlet != null) { if (portlet != null) {
// null if double click on link - in which case do nothing // null if double click on link - in which case do nothing
// note - may not have js double click protection on this as it is // note - may not have js double click protection on this as it is
// a link cg // a link cg
portlet.delete(); portlet.delete();
} else { } else {
s_log.debug("doubleclick detected"); s_log.debug("doubleclick detected");
} }
} else if (ACTION_CUSTOMIZE.equals(key)) {
m_portlet.setSelectedKey(state, new BigDecimal(value));
}
}
state.clearControlEvent();
}
private class PortletAddListener implements FormProcessListener { } else if (ACTION_CUSTOMIZE.equals(key)) {
m_portlet.setSelectedKey(state, new BigDecimal(value));
}
}
state.clearControlEvent();
}
private PortalSelectionModel m_portal; private class PortletAddListener implements FormProcessListener {
private int m_col;
private PortalSelectionModel m_portal;
private int m_col;
public PortletAddListener(PortalSelectionModel portal, public PortletAddListener(PortalSelectionModel portal,
int column) { int column) {
m_portal = portal; m_portal = portal;
m_col = column; m_col = column;
} }
public void process(FormSectionEvent e) public void process(FormSectionEvent e)
throws FormProcessException { throws FormProcessException {
PageState state = e.getPageState(); PageState state = e.getPageState();
PortletTypeForm form = (PortletTypeForm) e.getSource(); PortletTypeForm form = (PortletTypeForm) e.getSource();
WorkspacePage portal = m_portal.getSelectedPortal(state); WorkspacePage portal = m_portal.getSelectedPortal(state);
// check permission on Workspace, not WorkspacePage, // check permission on Workspace, not WorkspacePage,
// as this is where the permissiones/groups are set // as this is where the permissiones/groups are set
Workspace workspace = portal.getWorkspace(); Workspace workspace = portal.getWorkspace();
Party party = Kernel.getContext().getParty(); Party party = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(party, if (!PortalHelper.canCustomize(party,
workspace)) { workspace)) {
throw new AccessDeniedException( throw new AccessDeniedException(
"no permissions to customize workspace" "no permissions to customize workspace"
); );
} }
PortletType type = PortletType.retrievePortletType( PortletType type = PortletType.retrievePortletType(
form.getPortletType(state)); form.getPortletType(state));
if (s_log.isDebugEnabled()) { if (s_log.isDebugEnabled()) {
s_log.debug("Got create event for type " + s_log.debug("Got create event for type " + type.getID() + " column " + m_col);
type.getID() + " column " + m_col); }
} m_portletType.setSelectedKey(state, type.getID());
m_portletType.setSelectedKey(state, type.getID()); m_column.setSelectedKey(state, new Integer(m_col));
m_column.setSelectedKey(state, new Integer(m_col)); }
}
} }
} }

View File

@ -12,7 +12,6 @@
* rights and limitations under the License. * rights and limitations under the License.
* *
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -26,27 +25,30 @@ import com.arsdigita.portal.PortletType;
public class PortletTypeSelectionModel extends AbstractSingleSelectionModel { public class PortletTypeSelectionModel extends AbstractSingleSelectionModel {
private ParameterSingleSelectionModel m_model; private ParameterSingleSelectionModel m_model;
public PortletTypeSelectionModel(BigDecimalParameter p) { public PortletTypeSelectionModel(BigDecimalParameter p) {
m_model = new ParameterSingleSelectionModel(p); m_model = new ParameterSingleSelectionModel(p);
} }
public Object getSelectedKey(PageState state) { @Override
return m_model.getSelectedKey(state); public Object getSelectedKey(PageState state) {
} return m_model.getSelectedKey(state);
}
public void setSelectedKey(PageState state, Object key) { @Override
m_model.setSelectedKey(state, key); public void setSelectedKey(PageState state, Object key) {
} m_model.setSelectedKey(state, key);
}
public ParameterModel getStateParameter() { @Override
return m_model.getStateParameter(); public ParameterModel getStateParameter() {
} return m_model.getStateParameter();
}
public PortletType getSelectedPortletType(PageState state) { public PortletType getSelectedPortletType(PageState state) {
BigDecimal key = (BigDecimal) getSelectedKey(state); BigDecimal key = (BigDecimal) getSelectedKey(state);
return PortletType.retrievePortletType(key); return PortletType.retrievePortletType(key);
} }
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -32,62 +31,80 @@ import com.arsdigita.xml.Element;
import com.arsdigita.xml.XML; import com.arsdigita.xml.XML;
/** /**
* *
* *
*/ */
public class WorkspaceDetails extends SimpleComponent { public class WorkspaceDetails extends SimpleComponent {
private WorkspaceSelectionAbstractModel m_workspace; private WorkspaceSelectionAbstractModel workspaceModel;
public WorkspaceDetails(WorkspaceSelectionAbstractModel workspace) { public WorkspaceDetails(final WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace; super();
} this.workspaceModel = workspace;
}
public void setWorkspaceModel(WorkspaceSelectionAbstractModel workspace) { public void setWorkspaceModel(final WorkspaceSelectionAbstractModel workspace) {
m_workspace = workspace; this.workspaceModel = workspace;
} }
public Workspace getSelectedWorkspace(PageState state) { public Workspace getSelectedWorkspace(final PageState state) {
return m_workspace.getSelectedWorkspace(state); return workspaceModel.getSelectedWorkspace(state);
} }
/**
* Overridden {@link SimpleComponent#isVisible(com.arsdigita.bebop.PageState)} to ensure that
* {@code WorkspaceDetails} is not rendered when there is not Workspace to show.
*
* Previously an none existing Workspace (which can occur when using a PortalWorkspace on a
* category page) caused a NPE.
*
* @param state
* @return
*/
@Override
public boolean isVisible(final PageState state) {
return super.isVisible(state) && workspaceModel.getSelectedWorkspace(state) != null;
}
@Override @Override
public void generateXML(PageState state, Element parent) { public void generateXML(final PageState state, final Element parent) {
Workspace workspace = getSelectedWorkspace(state); final Workspace workspace = getSelectedWorkspace(state);
Element content = new Element("portal:workspaceDetails", final Element content = new Element("portal:workspaceDetails",
WorkspacePage.PORTAL_XML_NS); WorkspacePage.PORTAL_XML_NS);
exportAttributes(content); exportAttributes(content);
generateWorkspaceXML(state, content, workspace); generateWorkspaceXML(state, content, workspace);
generatePermissionXML(state, content, workspace); generatePermissionXML(state, content, workspace);
parent.addContent(content); parent.addContent(content);
} }
protected void generateWorkspaceXML(PageState state, Element content, protected void generateWorkspaceXML(final PageState state,
Workspace workspace) { final Element content,
final Workspace workspace) {
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(content); final DomainObjectXMLRenderer renderer = new DomainObjectXMLRenderer(content);
xr.setWrapRoot(false); renderer.setWrapRoot(false);
xr.setWrapAttributes(true); renderer.setWrapAttributes(true);
xr.setWrapObjects(false); renderer.setWrapObjects(false);
xr.walk(workspace, WorkspaceDetails.class.getName()); renderer.walk(workspace, WorkspaceDetails.class.getName());
} }
protected void generatePermissionXML(PageState state, Element content, protected void generatePermissionXML(final PageState state,
Workspace workspace) { final Element content,
Party party = Kernel.getContext().getParty(); final Workspace workspace) {
final Party party = Kernel.getContext().getParty();
PermissionDescriptor edit = new PermissionDescriptor( final PermissionDescriptor edit = new PermissionDescriptor(
PrivilegeDescriptor.EDIT, workspace, party); PrivilegeDescriptor.EDIT, workspace, party);
PermissionDescriptor admin = new PermissionDescriptor( final PermissionDescriptor admin = new PermissionDescriptor(
PrivilegeDescriptor.ADMIN, workspace, party); PrivilegeDescriptor.ADMIN, workspace, party);
content.addAttribute("canEdit", XML.format(PermissionService.checkPermission(edit)));
content.addAttribute("canAdmin", XML.format(PermissionService.checkPermission(admin)));
}
content.addAttribute("canEdit", XML.format(new Boolean(
PermissionService.checkPermission(edit))));
content.addAttribute("canAdmin", XML.format(new Boolean(
PermissionService.checkPermission(admin))));
}
} }

View File

@ -15,7 +15,6 @@
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
package com.arsdigita.portalworkspace.ui; package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.ActionLink; import com.arsdigita.bebop.ActionLink;
@ -42,11 +41,9 @@ import com.arsdigita.portalworkspace.util.GlobalizationUtil;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
* Entry point into a standard (public or access restricted) portal workspace * Entry point into a standard (public or access restricted) portal workspace page where the page is
* page where the page is constructed in "edit" mode to allow configuration * constructed in "edit" mode to allow configuration and modification by an authorized participant.
* and modification by an authorized participant.
* *
* It is used via a jsp page which is invoked at the applications url. * It is used via a jsp page which is invoked at the applications url.
* *
@ -60,9 +57,8 @@ import org.apache.log4j.Logger;
* </jsp:scriptlet> * </jsp:scriptlet>
* </pre> * </pre>
* *
* Currently there is a jsp for the default url at * Currently there is a jsp for the default url at (web)/templates/ccm-portalworkspace/edit.jsp
* (web)/templates/ccm-portalworkspace/edit.jsp which is mapped via web.xml * which is mapped via web.xml to /ccm/portal/edit.jsp in the default, pre-configured configuration.
* to /ccm/portal/edit.jsp in the default, pre-configured configuration.
*/ */
public class WorkspaceEditor extends AbstractWorkspaceComponent { public class WorkspaceEditor extends AbstractWorkspaceComponent {
@ -74,7 +70,6 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
private ActionLink m_editBasicPropertiesLink; private ActionLink m_editBasicPropertiesLink;
/** /**
* Default Constructor constructs a new, empty WorkspaceEditor object. * Default Constructor constructs a new, empty WorkspaceEditor object.
*/ */
@ -83,9 +78,9 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
} }
/** /**
* Constructs a WorkspaceViewer for a specific workspace object * Constructs a WorkspaceViewer for a specific workspace object and sets the xml tags
* and sets the xml tags accordingly. * accordingly.
* *
* @param workspace * @param workspace
*/ */
public WorkspaceEditor(WorkspaceSelectionAbstractModel workspace) { public WorkspaceEditor(WorkspaceSelectionAbstractModel workspace) {
@ -96,28 +91,28 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
m_add = new ActionLink("add pane"); m_add = new ActionLink("add pane");
m_add.setClassAttr("actionLink"); m_add.setClassAttr("actionLink");
m_add.addActionListener(new ActionListener() { m_add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
PageState state = e.getPageState(); PageState state = e.getPageState();
Workspace workspace = getSelectedWorkspace(state); Workspace workspace = getSelectedWorkspace(state);
Party party = Kernel.getContext().getParty(); Party party = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(party, workspace)) { if (!PortalHelper.canCustomize(party, workspace)) {
throw new AccessDeniedException( throw new AccessDeniedException(
"no permissions to customize workspace"); "no permissions to customize workspace");
} }
WorkspacePage page = workspace.addPage("New page", WorkspacePage page = workspace.addPage("New page",
"New portal page"); "New portal page");
} }
}); });
add(m_add); add(m_add);
// now add the basic properties controls // now add the basic properties controls
m_editBasicPropertiesLink = new ActionLink((String) GlobalizationUtil m_editBasicPropertiesLink = new ActionLink((String) GlobalizationUtil
.globalize("portal.ui.admin.edit_basic_properties").localize()); .globalize("portal.ui.admin.edit_basic_properties").localize());
m_editBasicPropertiesLink m_editBasicPropertiesLink
.addActionListener(new BasicPropertiesLinkListener()); .addActionListener(new BasicPropertiesLinkListener());
m_editBasicPropertiesLink.setClassAttr("actionLink"); m_editBasicPropertiesLink.setClassAttr("actionLink");
add(m_editBasicPropertiesLink); add(m_editBasicPropertiesLink);
m_basisPropertiesForm = new BasicPropertiesForm(); m_basisPropertiesForm = new BasicPropertiesForm();
@ -125,7 +120,7 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
} }
/** /**
* *
* @param portal * @param portal
* @return * @return
*/ */
@ -133,17 +128,15 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
return new PortalListEditor(portal); return new PortalListEditor(portal);
} }
@Override @Override
public void register(Page page) { public void register(Page page) {
super.register(page); super.register(page);
// Modigyable themes removed, cf. above // Modigyable themes removed, cf. above
// page.setVisibleDefault(m_selectForm, !m_workspaceThemes.isEmpty()); // page.setVisibleDefault(m_selectForm, !m_workspaceThemes.isEmpty());
// page.setVisibleDefault(m_createForm, false); // page.setVisibleDefault(m_createForm, false);
page.setVisibleDefault(m_basisPropertiesForm, false); page.setVisibleDefault(m_basisPropertiesForm, false);
} }
/** /**
* *
* @param portal * @param portal
@ -154,84 +147,86 @@ public class WorkspaceEditor extends AbstractWorkspaceComponent {
} }
/** /**
* *
*/ */
private class BasicPropertiesLinkListener implements ActionListener { private class BasicPropertiesLinkListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
PageState ps = e.getPageState();
m_editBasicPropertiesLink.setVisible(ps, false);
m_basisPropertiesForm.setVisible(ps, true);
}
}
public class BasicPropertiesForm extends Form implements public void actionPerformed(ActionEvent e) {
FormProcessListener, FormInitListener { PageState ps = e.getPageState();
private Label title; m_editBasicPropertiesLink.setVisible(ps, false);
m_basisPropertiesForm.setVisible(ps, true);
}
}
private TextField m_title; public class BasicPropertiesForm extends Form implements
FormProcessListener, FormInitListener {
private Label description; private Label title;
private Submit savebutton; private TextField m_title;
private Submit cancelbutton; private Label description;
private TextArea m_description; private Submit savebutton;
public BasicPropertiesForm() { private Submit cancelbutton;
super("basicpropertiesform");
setClassAttr("basicprops");
title = new Label(GlobalizationUtil private TextArea m_description;
.globalize("portal.ui.admin.workspace_title"));
m_title = new TextField("title"); public BasicPropertiesForm() {
m_title.setSize(40); super("basicpropertiesform");
m_title.getParameterModel().addParameterListener( setClassAttr("basicprops");
new NotEmptyValidationListener());
m_description = new TextArea("description"); title = new Label(GlobalizationUtil
m_description.setRows(10); .globalize("portal.ui.admin.workspace_title"));
m_description.setCols(40);
description = new Label(GlobalizationUtil m_title = new TextField("title");
.globalize("portal.ui.admin.workspace_description")); m_title.setSize(40);
m_title.getParameterModel().addParameterListener(
new NotEmptyValidationListener());
savebutton = new Submit("save", "Save"); m_description = new TextArea("description");
cancelbutton = new Submit("cancel", "Cancel"); m_description.setRows(10);
m_description.setCols(40);
add(title); description = new Label(GlobalizationUtil
add(m_title); .globalize("portal.ui.admin.workspace_description"));
add(description);
add(m_description);
add(cancelbutton);
add(savebutton);
addProcessListener(this);
addInitListener(this);
}
public void process(FormSectionEvent e) { savebutton = new Submit("save", "Save");
s_log.debug("processing the basic properties form"); cancelbutton = new Submit("cancel", "Cancel");
PageState ps = e.getPageState();
if (savebutton.isSelected(ps)) {
Workspace workspace = getSelectedWorkspace(ps); add(title);
workspace.setTitle((String) m_title.getValue(ps)); add(m_title);
workspace.setDescription((String) m_description.getValue(ps)); add(description);
workspace.save(); add(m_description);
} add(cancelbutton);
m_editBasicPropertiesLink.setVisible(ps, true); add(savebutton);
this.setVisible(ps, false); addProcessListener(this);
} addInitListener(this);
}
public void init(FormSectionEvent e) throws FormProcessException { public void process(FormSectionEvent e) {
// s_log.debug("initialising the basic properties form"); s_log.debug("processing the basic properties form");
PageState ps = e.getPageState(); PageState ps = e.getPageState();
Workspace workspace = getSelectedWorkspace(ps); if (savebutton.isSelected(ps)) {
m_title.setValue(ps, workspace.getTitle());
m_description.setValue(ps, workspace.getDescription()); Workspace workspace = getSelectedWorkspace(ps);
// s_log.debug("setting visibility to false"); workspace.setTitle((String) m_title.getValue(ps));
// this.setVisible(ps, false); workspace.setDescription((String) m_description.getValue(ps));
} workspace.save();
} }
m_editBasicPropertiesLink.setVisible(ps, true);
this.setVisible(ps, false);
}
public void init(FormSectionEvent e) throws FormProcessException {
// s_log.debug("initialising the basic properties form");
PageState ps = e.getPageState();
Workspace workspace = getSelectedWorkspace(ps);
m_title.setValue(ps, workspace.getTitle());
m_description.setValue(ps, workspace.getDescription());
// s_log.debug("setting visibility to false");
// this.setVisible(ps, false);
}
}
} }

View File

@ -0,0 +1,368 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.arsdigita.portalworkspace.ui;
import com.arsdigita.bebop.ActionLink;
import com.arsdigita.bebop.Form;
import com.arsdigita.bebop.FormProcessException;
import com.arsdigita.bebop.Label;
import com.arsdigita.bebop.Page;
import com.arsdigita.bebop.PageState;
import com.arsdigita.bebop.ParameterSingleSelectionModel;
import com.arsdigita.bebop.SimpleContainer;
import com.arsdigita.bebop.event.ActionEvent;
import com.arsdigita.bebop.event.ActionListener;
import com.arsdigita.bebop.event.FormInitListener;
import com.arsdigita.bebop.event.FormSectionEvent;
import com.arsdigita.bebop.event.PrintEvent;
import com.arsdigita.bebop.event.PrintListener;
import com.arsdigita.bebop.form.TextField;
import com.arsdigita.bebop.parameters.StringParameter;
import com.arsdigita.bebop.portal.PortletRenderer;
import com.arsdigita.categorization.Category;
import com.arsdigita.dispatcher.AccessDeniedException;
import com.arsdigita.kernel.Group;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.Party;
import com.arsdigita.kernel.PartyCollection;
import com.arsdigita.navigation.Navigation;
import com.arsdigita.navigation.NavigationModel;
import com.arsdigita.portal.Portlet;
import com.arsdigita.portal.PortletCollection;
import com.arsdigita.portalworkspace.Workspace;
import com.arsdigita.portalworkspace.WorkspacePage;
import com.arsdigita.portalworkspace.WorkspacePageCollection;
import com.arsdigita.portalworkspace.util.GlobalizationUtil;
import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.URL;
import com.arsdigita.xml.Element;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author jensp
*/
public class WorkspaceGridViewer extends SimpleContainer {
private WorkspaceSelectionAbstractModel workspaceModel;
private ParameterSingleSelectionModel rowAction;
private ParameterSingleSelectionModel rowModel;
private WorkspaceDetails workspaceDetails;
private WorkspaceCreator workspaceCreator;
private WorkspaceEditor workspaceEditor;
private WorkspaceGridRowEditor workspaceGridRowEditor;
public WorkspaceGridViewer() {
this(null);
}
public WorkspaceGridViewer(final WorkspaceSelectionAbstractModel workspaceModel) {
super("portal:gridWorkspace", WorkspacePage.PORTAL_XML_NS);
this.workspaceModel = workspaceModel;
rowAction = new ParameterSingleSelectionModel(new StringParameter("rowAction"));
rowModel = new ParameterSingleSelectionModel(new StringParameter("selectedRow"));
workspaceDetails = new WorkspaceDetails(workspaceModel);
workspaceEditor = new WorkspaceEditor();
workspaceGridRowEditor = new WorkspaceGridRowEditor();
workspaceCreator = new WorkspaceCreator();
add(workspaceCreator);
add(workspaceDetails);
add(workspaceEditor);
final SimpleContainer gridRowEditorContainer = new SimpleContainer(
"portal:workspaceGridRowEditor", WorkspacePage.PORTAL_XML_NS) {
@Override
public boolean isVisible(final PageState state) {
return super.isVisible(state) && "edit".equals(rowAction.getSelectedKey(state));
}
};
add(gridRowEditorContainer);
gridRowEditorContainer.add(workspaceGridRowEditor);
}
public WorkspaceSelectionAbstractModel getWorkspaceModel() {
return workspaceModel;
}
public void setWorkspaceModel(final WorkspaceSelectionAbstractModel workspaceModel) {
this.workspaceModel = workspaceModel;
workspaceDetails.setWorkspaceModel(workspaceModel);
}
@Override
public void register(final Page page) {
super.register(page);
page.addComponentStateParam(this, rowAction.getStateParameter());
page.addComponentStateParam(this, rowModel.getStateParameter());
}
@Override
public void generateXML(final PageState state, final Element parent) {
if (isVisible(state)) {
final Element content = generateParent(parent);
if (workspaceModel.getSelectedWorkspace(state) == null) {
workspaceDetails.setVisible(state, false);
workspaceCreator.setVisible(state, true);
} else {
workspaceDetails.setVisible(state, true);
workspaceCreator.setVisible(state, false);
}
if (rowModel.isSelected(state)) {
content.addAttribute("selectedRow", (String) rowModel.getSelectedKey(state));
}
generateChildrenXML(state, content);
if (workspaceModel.getSelectedWorkspace(state) != null) {
final WorkspacePageCollection pages = workspaceModel.getSelectedWorkspace(state).
getPages();
final Element pagesElem = content.newChildElement("portal:rows",
WorkspacePage.PORTAL_XML_NS);
while (pages.next()) {
generateRowXML(pagesElem, state, pages.getPage());
}
}
}
}
private void generateRowXML(final Element pagesElem,
final PageState state,
final WorkspacePage row) {
final Element rowElem = pagesElem.newChildElement("portal:row",
WorkspacePage.PORTAL_XML_NS);
rowElem.addAttribute("id", row.getID().toString());
rowElem.addAttribute("layout", row.getLayout().getFormat());
rowElem.addAttribute("style", row.getLayout().getTitle());
rowElem.addAttribute("title", row.getTitle());
rowElem.addAttribute("description", row.getDescription());
final HttpServletRequest request = state.getRequest();
final String pathInfo = request.getPathInfo();
final ParameterMap parameterMap = new ParameterMap(request);
parameterMap.setParameter(rowAction.getStateParameter().getName(), "edit");
parameterMap.setParameter(rowModel.getStateParameter().getName(), row.getID().toString());
rowElem.addAttribute("editLink", URL.here(request, pathInfo, parameterMap).toString());
final PortletCollection portlets = row.getPortlets();
final Element portletsElem = rowElem.newChildElement("portal:portlets",
WorkspacePage.PORTAL_XML_NS);
while (portlets.next()) {
generatePortletXML(portletsElem, state, portlets.getPortlet());
}
}
private void generatePortletXML(final Element portletsElem,
final PageState state,
final Portlet portlet) {
final PortletRenderer renderer = portlet.getPortletRenderer();
renderer.generateXML(state, portletsElem);
}
private class WorkspaceCreator extends SimpleContainer {
public WorkspaceCreator() {
super("portal:workspaceCreator", WorkspacePage.PORTAL_XML_NS);
final Label info = new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.create_workspace.info"));
add(info);
final ActionLink link = new ActionLink(new Label(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.create_workspace.link")));
link.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
if (!canCreate()) {
throw new AccessDeniedException(
"Current party is not authorized to create a new portal workspace");
}
final NavigationModel navModel = Navigation.getConfig().getDefaultModel();
final Category category = navModel.getCategory();
final String workspaceUrl = String.format("workspace-%s-%s",
category.getID().toString(),
category.getURL());
final String workspaceTitle = String.format("Workspace-%s-%s",
category.getID().toString(),
category.getName());
final String workspaceDesc = String.format(
"Portal Workspace for category %s (ID: %s).",
category.getID().toString(),
category.getName());
final Workspace workspace = Workspace.createWorkspace(workspaceUrl,
workspaceTitle,
null,
true);
workspace.setDescription(workspaceDesc);
workspace.save();
category.addChild(workspace);
}
});
add(link);
}
@Override
public boolean isVisible(final PageState state) {
// final boolean visible = super.isVisible(state);
//
// return visible && canCreate();
return workspaceModel.getSelectedWorkspace(state) == null && canCreate();
}
public boolean canCreate() {
final PartyCollection parties = Party.retrieveAllParties();
parties.filter("Site-wide Administrators");
parties.next();
final Group admins = (Group) parties.getParty();
parties.close();
final Party currentParty = Kernel.getContext().getParty();
return currentParty != null && admins.hasMember(currentParty);
}
}
private class WorkspaceEditor extends SimpleContainer {
public WorkspaceEditor() {
super("portal:workspaceGridEditor", WorkspacePage.PORTAL_XML_NS);
final ActionLink addRowLink = new ActionLink(GlobalizationUtil.globalize(
"cw.workspace.ui.categorized.workspace.add_row.link"));
addRowLink.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent event) {
final PageState state = event.getPageState();
final Workspace workspace = workspaceModel.getSelectedWorkspace(state);
final Party currentParty = Kernel.getContext().getParty();
if (!PortalHelper.canCustomize(currentParty, workspace)) {
throw new AccessDeniedException(
"Current party has now permission to edit this workspace");
}
final WorkspacePageCollection pages = workspace.getPages();
final long size = pages.size();
pages.close();
workspace.addPage(String.format("workspace-grid-row-%d", size + 1), "");
}
});
add(addRowLink);
}
@Override
public boolean isVisible(final PageState state) {
return workspaceModel.getSelectedWorkspace(state) != null && canEdit(state);
}
public boolean canEdit(final PageState state) {
return PortalHelper.canCustomize(Kernel.getContext().getParty(),
workspaceModel.getSelectedWorkspace(state));
}
}
// private class GridRowSelectionModel extends AbstractSingleSelectionModel {
//
// private final RequestLocal selected;
//
// public GridRowSelectionModel() {
// selected = new RequestLocal();
// }
//
// @Override
// public Object getSelectedKey(final PageState state) {
// return selected.get(state);
// }
//
// @Override
// public void setSelectedKey(final PageState state, final Object key) {
// selected.set(state, key);
// }
//
// @Override
// public ParameterModel getStateParameter() {
// throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
// }
//
// }
private class WorkspaceGridRowEditor extends Form {
private final TextField key;
public WorkspaceGridRowEditor() {
super("WordspaceGridRowEditor", new SimpleContainer());
final Label label = new Label();
label.addPrintListener(new PrintListener() {
@Override
public void prepare(final PrintEvent event) {
final Label target = (Label) event.getTarget();
target.setLabel(rowModel.getStateParameter().getName());
}
});
add(label);
key = new TextField("key");
add(key);
addInitListener(new FormInitListener() {
@Override
public void init(final FormSectionEvent event) throws FormProcessException {
key.setValue(event.getPageState(),
rowModel.getSelectedKey(event.getPageState()));
}
});
}
@Override
public void generateXML(final PageState state, final Element parent) {
super.generateXML(state, parent);
if (rowModel.isSelected(state)) {
parent.addAttribute("selectedRow",
(String) rowModel.getSelectedKey(state));
}
}
}
}

View File

@ -66,6 +66,7 @@ public class WorkspaceViewer extends AbstractWorkspaceComponent {
* @param portal * @param portal
* @return * @return
*/ */
@Override
protected PortalList createPortalList(PortalSelectionModel portal) { protected PortalList createPortalList(PortalSelectionModel portal) {
return new PortalListViewer(portal); return new PortalListViewer(portal);
} }
@ -75,6 +76,7 @@ public class WorkspaceViewer extends AbstractWorkspaceComponent {
* @param portal * @param portal
* @return * @return
*/ */
@Override
protected PersistentPortal createPortalDisplay(PortalSelectionModel portal) { protected PersistentPortal createPortalDisplay(PortalSelectionModel portal) {
return new PersistentPortal(portal, WorkspacePage.MODE_DISPLAY); return new PersistentPortal(portal, WorkspacePage.MODE_DISPLAY);
} }