diff --git a/ccm-bookmarks/src/com/arsdigita/bookmarks/Initializer.java b/ccm-bookmarks/src/com/arsdigita/bookmarks/Initializer.java index 579596328..8af677db5 100755 --- a/ccm-bookmarks/src/com/arsdigita/bookmarks/Initializer.java +++ b/ccm-bookmarks/src/com/arsdigita/bookmarks/Initializer.java @@ -26,7 +26,6 @@ import com.arsdigita.persistence.SessionManager; import com.arsdigita.web.*; import com.arsdigita.kernel.*; // unused import com.arsdigita.sitenode.*; -import com.arsdigita.bookmarks.*; import com.arsdigita.bookmarks.ui.*; // unused import com.arsdigita.domain.DomainObjectFactory; import com.arsdigita.domain.DomainObject; diff --git a/ccm-core/src/com/arsdigita/ui/admin/AdminServlet.java b/ccm-core/src/com/arsdigita/ui/admin/AdminServlet.java index 31c2bc30a..77ca3e9b3 100644 --- a/ccm-core/src/com/arsdigita/ui/admin/AdminServlet.java +++ b/ccm-core/src/com/arsdigita/ui/admin/AdminServlet.java @@ -48,10 +48,6 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -// We need NonEscapedTableCellRenderer -// Currently part of (thisPackage) Dispatcher.java -// When the class will we deleted we must copy first! - /** * Web Developer Support Application Servlet class, central entry point to * create and process the applications UI. diff --git a/ccm-core/src/com/arsdigita/util/Assert.java b/ccm-core/src/com/arsdigita/util/Assert.java index e2392fefc..f93a8c05d 100755 --- a/ccm-core/src/com/arsdigita/util/Assert.java +++ b/ccm-core/src/com/arsdigita/util/Assert.java @@ -226,8 +226,8 @@ public class Assert { * object * @throws AssertionError if the object is null */ - public static final void exists(final Object object, - final Class clacc) { + public static void exists(final Object object, + final Class clacc) { if (object == null) { final String message = clacc.getName() + " is null"; @@ -245,8 +245,8 @@ public class Assert { * * @throws AssertionError if the object is null */ - public static final void exists(final Object object, - final String label) { + public static void exists(final Object object, + final String label) { if (object == null) { final String message = label != null && label.trim().length() > 0 diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/Loader.java b/ccm-portalserver/src/com/arsdigita/portalserver/Loader.java index c361d163e..4c8d8b284 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/Loader.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/Loader.java @@ -20,7 +20,6 @@ package com.arsdigita.portalserver; -// import com.arsdigita.db.*; import com.arsdigita.domain.*; import com.arsdigita.kernel.ACSObjectInstantiator; import com.arsdigita.kernel.Kernel; @@ -138,7 +137,8 @@ public class Loader extends PackageLoader { private void loadPortalSiteApplicationType() { /* First try: create a new style, legacy compatible application */ -/* ApplicationType type = ApplicationType.createApplicationType( +/* + ApplicationType type = ApplicationType.createApplicationType( "portalsite", "Portal Site", PortalSite.BASE_DATA_OBJECT_TYPE); @@ -146,8 +146,9 @@ public class Loader extends PackageLoader { // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.ui.PortalDispatcher"); -*/ +*/ + // Try: new style legacy free application ApplicationType type = new ApplicationType("Portal Site", // title @@ -229,16 +230,23 @@ public class Loader extends PackageLoader { // in applications mit primary_url=/portal-admin/ // in acs_object mit default_domain_class=c.ad.ps.admin.PSAdmin und // object_type=c.ad.admin.CWAdmin, ebenfalls wg. BASE_DATA_OBJ_TYPE - +/* ApplicationType type = ApplicationType.createApplicationType( "portal-admin", "Portal Server Site Administration", PSAdmin.BASE_DATA_OBJECT_TYPE); - type.setDescription ("Displays common administration tasks."); // Current code requires an apps specific dispatcher class. Has to be // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.admin.ui.Dispatcher"); +*/ + // Try: new style legacy free application + ApplicationType type = new + ApplicationType("Portal Admin", // title + PSAdmin.BASE_DATA_OBJECT_TYPE ); + + type.setDescription ("Displays common administration tasks."); + type.save(); } @@ -251,6 +259,7 @@ public class Loader extends PackageLoader { private void loadPortalCreatorApplicationType() { // formerly private ApplicationType setupPortalCreator() { in ui.admin.Initializer +/* ApplicationType type = ApplicationType.createApplicationType( "portal-create", "Portal Creator", @@ -260,6 +269,16 @@ public class Loader extends PackageLoader { // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.ui.admin.PortalCreateDispatcher"); +*/ + + // Try: new style legacy free application + ApplicationType type = new + ApplicationType("Portal Creator", // title + PortalCreator.BASE_DATA_OBJECT_TYPE ); + + type.setDescription ("Creates portals."); + type.save(); + } @@ -270,16 +289,17 @@ public class Loader extends PackageLoader { private void loadPortalSitemapApplicationType() { // formerly private ApplicationType setupPortalSitemapper() { +/* ApplicationType type = ApplicationType.createApplicationType( "portal-sitemap", "Portal Site Map", PortalSiteMap.BASE_DATA_OBJECT_TYPE); - type.setDescription ("Displays and manages Portals."); // Current code requires an apps specific dispatcher class. Has to be // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.ui.admin.PortalSiteMapDispatcher"); +*/ /* ApplicationSetup setup = new ApplicationSetup(s_log); setup.setApplicationObjectType(PortalSiteMap.BASE_DATA_OBJECT_TYPE); setup.setTitle("Portal Site Map"); @@ -298,7 +318,16 @@ public class Loader extends PackageLoader { setup.run(); */ // return setup.run(); - } + + // Try: new style legacy free application + ApplicationType type = new + ApplicationType("Portal SiteMap", // title + PortalSiteMap.BASE_DATA_OBJECT_TYPE ); + + type.setDescription ("Displays and manages Portals."); + type.save(); + + } /* FORMERLY personal.Initializer */ @@ -311,7 +340,7 @@ public class Loader extends PackageLoader { private void loadPersonalPortalCreatorApplicationType() { // private ApplicationType loadPersonalPortalCreatorApplicationType() { // formerly private ApplicationType setupPersonalPortalCreatorApplication() { - +/* ApplicationType type = ApplicationType.createApplicationType( "personal-portal-creator", "Personal Portal Creator", @@ -321,67 +350,41 @@ public class Loader extends PackageLoader { // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.personal.PersonalPortalCreatorDispatcher"); +*/ - // return type; + // Try: new style legacy free application + ApplicationType type = new + ApplicationType("Personal Portal Creator", // title + PersonalPortalCreator.BASE_DATA_OBJECT_TYPE ); -/* ApplicationSetup setup = new ApplicationSetup(s_log); + type.setDescription ("Displays and manages Portals."); + type.save(); - setup.setApplicationObjectType - (PersonalPortalCreator.BASE_DATA_OBJECT_TYPE); - setup.setKey("personal-portal-creator"); - setup.setTitle("Personal Portal Creator"); - setup.setDescription("Responsible for creating personal portals."); - // db based stylesheets nolonger used - // setup.setStylesheet("/packages/portalserver/xsl/portalserver.xsl"); - setup.setDispatcherClass - ("com.arsdigita.portalserver.personal.PersonalPortalCreatorDispatcher"); - setup.setPortalApplication(false); - setup.setInstantiator(new ACSObjectInstantiator() { - @Override - protected DomainObject doNewInstance(DataObject dataObject) { - return new PersonalPortalCreator(dataObject); - } - }); - - return setup.run(); */ - } + } private void loadPersonalPortalApplicationType() { // private ApplicationType loadPersonalPortalApplicationType() { // formerly private ApplicationType setupPersonalPortalApplication() { - +/* ApplicationType type = ApplicationType.createApplicationType( "personal-portal", "Personal Portal", PersonalPortal.BASE_DATA_OBJECT_TYPE); - type.setDescription ("A portal for an individual."); // Current code requires an apps specific dispatcher class. Has to be // modified to be able to create a legacy free app type. type.setDispatcherClass ("com.arsdigita.portalserver.personal.PersonalPortalDispatcher"); +*/ + // Try: new style legacy free application + ApplicationType type = new + ApplicationType("Personal Portal", // title + PersonalPortal.BASE_DATA_OBJECT_TYPE ); + type.setDescription ("A portal for an individual."); + type.save(); -/* ApplicationSetup setup = new ApplicationSetup(s_log); - - setup.setApplicationObjectType(PersonalPortal.BASE_DATA_OBJECT_TYPE); - setup.setKey("personal-portal"); - setup.setTitle("Personal Portal"); - setup.setDescription("A portal for an individual."); - // setup.setStylesheet("/packages/portalserver/xsl/portalserver.xsl"); - setup.setDispatcherClass - ("com.arsdigita.portalserver.personal.PersonalPortalDispatcher"); - setup.setPortalApplication(false); - setup.setInstantiator(new ACSObjectInstantiator() { - @Override - protected DomainObject doNewInstance(DataObject dataObject) { - return new PersonalPortal(dataObject); - } - }); - - ApplicationType type = setup.run(); - - // XXX This must go after setup.run(). Need more elegant approach. +/* // XXX This must go after setup.run(). Need more elegant approach. // pboy: uses ResourceType.registerResourceTypeConfig() which registers // in a hash map. Therefore: not suitable for a loader, may have to be // moved into initializer! diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/PortalSite.java b/ccm-portalserver/src/com/arsdigita/portalserver/PortalSite.java index dd24a193b..6aae5b7b1 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/PortalSite.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/PortalSite.java @@ -472,16 +472,15 @@ public class PortalSite extends Application { * @return */ public static PortalSiteCollection getRootPortalSites() { + DataQuery query = SessionManager.getSession().retrieveQuery ("com.arsdigita.workspace.rootWorkspaces"); DataCollection collection = new DataQueryDataCollectionAdapter(query, "workspace"); - query.close(); PortalSiteCollection psc = new PortalSiteCollection(collection); - psc.filterForUnarchived(); return psc; diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/PortalServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/PortalSiteServlet.java similarity index 62% rename from ccm-portalserver/src/com/arsdigita/portalserver/PortalServlet.java rename to ccm-portalserver/src/com/arsdigita/portalserver/PortalSiteServlet.java index 637775f82..d57462dd8 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/PortalServlet.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/PortalSiteServlet.java @@ -19,13 +19,12 @@ package com.arsdigita.portalserver; import com.arsdigita.bebop.Page; -import com.arsdigita.persistence.TransactionContext; -import com.arsdigita.persistence.SessionManager; import com.arsdigita.portalserver.ui.PortalHomePage; import com.arsdigita.portalserver.ui.PortalParticipants; import com.arsdigita.portalserver.ui.admin.PortalAdminPage; import com.arsdigita.templating.PresentationManager; import com.arsdigita.templating.Templating; +import com.arsdigita.util.Assert; import com.arsdigita.web.Application; import com.arsdigita.web.BaseApplicationServlet; import com.arsdigita.xml.Document; @@ -39,46 +38,33 @@ import javax.servlet.http.HttpServletResponse; import org.apache.log4j.Logger; -// //////////////////////////////////////////////////////////////////////////// -// -// UNKNOWN whether this is unfinished work in progress or really used in some -// way. -// -// Might be a first shot to replace ui.PortalDispatcher by a new legacy free -// servlet because it uses the same pages (PortalHomePage, PortalParticipants -// but additionally a PortalAdminPage (from package c.ad.ps.ui.admin) -// On the other hand this is the same as m_portalsiteAdminDispatcher of -// PortalDispatcher -// -// //////////////////////////////////////////////////////////////////////////// - - /** - * + * Portal Site Application Servlet class, central entry point to create and + * process the applications UI. + * * @author Justin Ross <jross@redhat.com> - * @version $Id: PortalServlet.java pboy $ + * @author Peter Boy + * @version $Id: PortalSiteServlet.java pboy $ */ -public class PortalServlet extends BaseApplicationServlet { +public class PortalSiteServlet extends BaseApplicationServlet { - private static final Logger s_log = Logger.getLogger - (PortalServlet.class); + private static final Logger s_log = Logger.getLogger(PortalSiteServlet.class); private static final PresentationManager s_presManager = - Templating.getPresentationManager(); + Templating.getPresentationManager(); private static Page s_homePage = new PortalHomePage(); private static Page s_particPage = PortalParticipants.createPage(); - private static Page s_adminPage = null; - - static { - // TransactionContext ctx = SessionManager.getSession().getTransactionContext(); - // ctx.beginTxn(); - - s_adminPage = new PortalAdminPage(); - - // ctx.commitTxn(); - } + private static Page s_adminPage = s_adminPage = new PortalAdminPage(); + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ public void doService(HttpServletRequest sreq, HttpServletResponse sresp, Application app) @@ -86,12 +72,21 @@ public class PortalServlet extends BaseApplicationServlet { s_log.debug("PortalServlet.doService called for request '" + sreq.getRequestURI() + "'"); - String path = sreq.getServletPath(); + String pathInfo = sreq.getPathInfo(); + Assert.exists(pathInfo, "String pathInfo"); + if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { + /* NOTE: ServletAPI specifies, pathInfo may be empty or will + * start with a '/' character. It currently carries a + * trailing '/' if a "virtual" page, i.e. not a real jsp, but + * result of a servlet mapping. But Application requires url + * NOT to end with a trailing '/' for legacy free applications. */ + pathInfo = pathInfo.substring(0, pathInfo.length()-1); + } Document doc = null; - if (path.endsWith("participants")) { + if (pathInfo.endsWith("participants")) { doc = s_particPage.buildDocument(sreq, sresp); - } else if (path.endsWith("admin")) { + } else if (pathInfo.endsWith("admin")) { doc = s_adminPage.buildDocument(sreq, sresp); } else { doc = s_homePage.buildDocument(sreq, sresp); diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/Dispatcher.java b/ccm-portalserver/src/com/arsdigita/portalserver/admin/Dispatcher.java similarity index 91% rename from ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/Dispatcher.java rename to ccm-portalserver/src/com/arsdigita/portalserver/admin/Dispatcher.java index dad70fd01..ec3e449fe 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/Dispatcher.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/admin/Dispatcher.java @@ -16,9 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -package com.arsdigita.portalserver.admin.ui; +package com.arsdigita.portalserver.admin; // import com.arsdigita.bebop.*; +import com.arsdigita.portalserver.admin.PSAdminPage; import com.arsdigita.bebop.Page; import com.arsdigita.bebop.page.BebopMapDispatcher; import java.util.*; @@ -36,7 +37,7 @@ public class Dispatcher extends BebopMapDispatcher { public Dispatcher() { Map m = new HashMap(); - Page index = new AdminPage(); + Page index = new PSAdminPage(); index.lock(); m.put("", index); m.put("index.jsp", index); diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdmin.java b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdmin.java index 3c6473de2..5c4e63b9d 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdmin.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdmin.java @@ -21,6 +21,7 @@ package com.arsdigita.portalserver.admin; // import com.arsdigita.portalserver.*; import com.arsdigita.web.Application; import com.arsdigita.persistence.*; +import com.arsdigita.web.URL; import org.apache.log4j.Logger; /** @@ -36,6 +37,7 @@ import org.apache.log4j.Logger; */ public class PSAdmin extends Application { + /** Logger instance for debugging */ private static final Logger s_log = Logger.getLogger(PSAdmin.class); public static final String BASE_DATA_OBJECT_TYPE = @@ -49,4 +51,44 @@ public class PSAdmin extends Application { public PSAdmin(DataObject dataObject) { super(dataObject); } + + /** + * Returns the path name of the location of the applications servlet/JSP. + * + * Application implementations may overwrite this method to provide an + * application specific location, especially if an application (module) is + * to be installed along with others in one context. + * + * If you install the module into its own context you may use a standard + * location. In most cases though all modules (applications) of an + * webapplication should be installed into one context. + * + * Frequently it is a symbolic name/path, which will be mapped in the web.xml + * to the real location in the file system. Example: + * + * applicationName-files + * com.arsdigita.web.ApplicationFileServlet + * + * template-path + * /templates/ccm-applicationName + * + * + * + * + * applicationName-files + * /ccm-applicationName/files/* + * + * + * NOTE: According to Servlet API the path always starts with a leading '/' + * and includes either the servlet name or a path to the servlet, but does + * not include any extra path information or a query string. Returns an + * empry string ("") is the servlet used was matched using the "/*" pattern. + * + * @return path name to the applications servlet/JSP + */ + @Override + public String getServletPath() { + return URL.SERVLET_DIR + "/psadmin"; + } + } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/AdminPage.java b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminPage.java similarity index 96% rename from ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/AdminPage.java rename to ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminPage.java index 00a7123ff..8897487fe 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/admin/ui/AdminPage.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminPage.java @@ -16,7 +16,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ -package com.arsdigita.portalserver.admin.ui; +package com.arsdigita.portalserver.admin; import com.arsdigita.web.Application; import com.arsdigita.web.ApplicationCollection; @@ -32,14 +32,14 @@ import com.arsdigita.xml.Document; import com.arsdigita.xml.Element; /** - * AdminPage + * PSAdminPage * - * This class is the UI component for Portal-admin. * * @author rhs@mit.edu * @version $Revision: #8 $ $Date: 2004/08/17 $ */ -class AdminPage extends PortalPage { +class PSAdminPage extends PortalPage { public static final String versionId = "$Id: //portalserver/dev/src/com/arsdigita/portalserver/admin/ui/AdminPage.java#8 $" + "$Author: dennis $" + @@ -48,7 +48,7 @@ class AdminPage extends PortalPage { BoxPanel m_bpanel; private static Logger s_log = Logger.getLogger - (AdminPage.class.getName()); + (PSAdminPage.class.getName()); private RequestLocal m_children = new RequestLocal() { public Object initialValue(PageState ps) { @@ -58,7 +58,7 @@ class AdminPage extends PortalPage { } }; - public AdminPage() { + public PSAdminPage() { getHeader().setIdAttr("admin"); } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminServlet.java new file mode 100644 index 000000000..07b0cff97 --- /dev/null +++ b/ccm-portalserver/src/com/arsdigita/portalserver/admin/PSAdminServlet.java @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2012 Peter Boy All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ +package com.arsdigita.portalserver.admin; + +import com.arsdigita.bebop.Page; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; +import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; +import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** + * + * @author pb + */ +public class PSAdminServlet extends BaseApplicationServlet { + + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger(PSAdminServlet.class); + + private static final PresentationManager s_presManager = + Templating.getPresentationManager(); + + /** Page object to hold the PortalSite Admin page */ + private static Page s_psAdminPage; + + + /** + * User extension point, initialize PortalCreator (index) page and add + * authentication check. + * + * @throws ServletException + */ + @Override + public void doInit() throws ServletException { + + s_psAdminPage = new PSAdminPage(); + s_psAdminPage.lock(); + + } + + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ + public void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { + s_log.debug("PortalServlet.doService called for request '" + + sreq.getRequestURI() + "'"); + + String pathInfo = sreq.getPathInfo(); + Assert.exists(pathInfo, "String pathInfo"); + if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { + /* NOTE: ServletAPI specifies, pathInfo may be empty or will + * start with a '/' character. It currently carries a + * trailing '/' if a "virtual" page, i.e. not a real jsp, but + * result of a servlet mapping. But Application requires url + * NOT to end with a trailing '/' for legacy free applications. */ + pathInfo = pathInfo.substring(0, pathInfo.length()-1); + } + + Document doc = null; + doc = s_psAdminPage.buildDocument(sreq, sresp); + s_presManager.servePage(doc, sreq, sresp); + + } + +} diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyItemsApplication.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyItemsApplication.java index 737b434ee..a1489ddab 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyItemsApplication.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyItemsApplication.java @@ -28,9 +28,11 @@ import com.arsdigita.persistence.DataObject; * @version $Revision #1 $DateTime: 2004/08/17 23:19:25 $ */ public class MyItemsApplication extends Application { + public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.workspace.personal.MyItemsApplication"; + @Override protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyPortalsPortlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyPortalsPortlet.java index 77ebd869d..a249208f6 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyPortalsPortlet.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/MyPortalsPortlet.java @@ -36,56 +36,86 @@ import com.arsdigita.kernel.Party; import com.arsdigita.util.Assert; import com.arsdigita.xml.Element; +/** + * + * + */ public class MyPortalsPortlet extends AppPortlet { - public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.workspace.personal.MyWorkspacesPortlet"; + public static final String BASE_DATA_OBJECT_TYPE = + "com.arsdigita.workspace.personal.MyWorkspacesPortlet"; + + /** + * + * @return + */ + @Override protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } + /** + * + * @param dataObject + */ public MyPortalsPortlet(DataObject dataObject) { super(dataObject); } + @Override protected AbstractPortletRenderer doGetPortletRenderer() { return new MyPortalsPortletRenderer(this); } + /** + * + * @param party + * @return + */ protected DataQuery getMyPortalsDataQuery(Party party) { - // Assert.assertTrue + Assert.isTrue (!isNew(), "You must save this portlet before you call " + "getMyPortalsDataQuery(User) on it."); DataQuery query = SessionManager.getSession().retrieveQuery - ("com.arsdigita.workspace.personal.MyWorkspaces"); + ("com.arsdigita.workspace.personal.MyWorkspaces"); - // Assert.assertNotNull(query, "query"); Assert.exists(query, "query"); - query.setParameter("userID", party.getID()); Application parent = getParentApplication(); - - // Assert.assertNotNull(parent, "parent"); Assert.exists(parent, "parent"); - query.setParameter - ("personalWorkspaceID", getParentApplication().getID()); + query.setParameter("personalWorkspaceID", getParentApplication().getID()); return query; + } } +/** + * + * + */ class MyPortalsPortletRenderer extends AbstractPortletRenderer { + private MyPortalsPortlet m_portlet; + /** + * Constructor + * @param portlet + */ public MyPortalsPortletRenderer(MyPortalsPortlet portlet) { m_portlet = portlet; } + /** + * + * @param pageState + * @param parent + */ protected void generateBodyXML(PageState pageState, Element parent) { Party party = Kernel.getContext().getParty(); @@ -107,8 +137,6 @@ class MyPortalsPortletRenderer extends AbstractPortletRenderer { title = (String) query.get("title"); primaryURL = (String) query.get("primaryURL"); - // Assert.assertNotNull(title, "title"); - // Assert.assertNotNull(primaryURL, "primaryURL"); Assert.exists(title, "title"); Assert.exists(primaryURL, "primaryURL"); diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortal.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortal.java index 233a1d249..ae872535a 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortal.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortal.java @@ -25,6 +25,7 @@ import com.arsdigita.persistence.DataCollection; import com.arsdigita.persistence.SessionManager; import com.arsdigita.kernel.User; import com.arsdigita.util.Assert; +import com.arsdigita.web.URL; /** *

Experimental

@@ -37,6 +38,11 @@ public class PersonalPortal extends PortalSite { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.workspace.personal.PersonalWorkspace"; + /** + * + * @return + */ + @Override protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } @@ -46,21 +52,33 @@ public class PersonalPortal extends PortalSite { super(dataObject); } + /** + * + * @param user + * @param parent + * @return + */ public static PersonalPortal createPersonalPortal (User user, Application parent) { - // Assert.assertNotNull(user, "user"); + Assert.exists(user, "user"); PersonalPortal portal = (PersonalPortal) - Application.createApplication - (BASE_DATA_OBJECT_TYPE, user.getID().toString(), - "Personal Portal", parent); - + Application.createApplication + (BASE_DATA_OBJECT_TYPE, + user.getID().toString(), + "Personal Portal", + parent); portal.setOwningUser(user); return portal; } + /** + * + * @param user + * @return + */ public static PersonalPortal createPersonalPortal(User user) { Application parent = Application.retrieveApplicationForPath ("/personal-portal/"); @@ -71,7 +89,11 @@ public class PersonalPortal extends PortalSite { return PersonalPortal.createPersonalPortal(user, parent); } - // Can return null. + /** + * + * @param user + * @return (Can return null.) + */ public static PersonalPortal retrievePersonalPortal(User user) { DataCollection portals = SessionManager.getSession().retrieve (BASE_DATA_OBJECT_TYPE); @@ -90,19 +112,66 @@ public class PersonalPortal extends PortalSite { return portal; } + /** + * + * @param user + */ private void setOwningUser(User user) { - // Assert.assertNotNull(user, "user"); + Assert.exists(user, "user"); - setAssociation("user", user); + } + /** + * + * @return + */ public User getOwningUser() { + DataObject dataObject = (DataObject) get("user"); - - // Assert.assertNotNull(dataObject, "dataObject"); Assert.exists(dataObject, "dataObject"); - return User.retrieve(dataObject); + } + + /** + * Returns the path name of the location of the applications servlet/JSP. + * + * Application implementations may overwrite this method to provide an + * application specific location, especially if an application (module) is + * to be installed along with others in one context. + * + * If you install the module into its own context you may use a standard + * location. In most cases though all modules (applications) of an + * webapplication should be installed into one context. + * + * Frequently it is a symbolic name/path, which will be mapped in the web.xml + * to the real location in the file system. Example: + * + * applicationName-files + * com.arsdigita.web.ApplicationFileServlet + * + * template-path + * /templates/ccm-applicationName + * + * + * + * + * applicationName-files + * /ccm-applicationName/files/* + * + * + * NOTE: According to Servlet API the path always starts with a leading '/' + * and includes either the servlet name or a path to the servlet, but does + * not include any extra path information or a query string. Returns an + * empry string ("") is the servlet used was matched using the "/*" pattern. + * + * @return path name to the applications servlet/JSP + */ + @Override + public String getServletPath() { + return URL.SERVLET_DIR + "/personal-portal"; + } + } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalConfig.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalConfig.java index 89a70f03c..4f40e8a59 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalConfig.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalConfig.java @@ -47,7 +47,7 @@ public class PersonalPortalConfig extends ResourceTypeConfig { } public void configureApplication(Application application) { - // Assert.assertTrue(application instanceof PersonalPortal); + Assert.isTrue(application instanceof PersonalPortal); PersonalPortal portal = (PersonalPortal) application; @@ -61,22 +61,23 @@ public class PersonalPortalConfig extends ResourceTypeConfig { Portlet portlet = null; - portlet = Portlet.createPortlet - (MyPortalsPortlet.BASE_DATA_OBJECT_TYPE, portal); + portlet = Portlet.createPortlet(MyPortalsPortlet.BASE_DATA_OBJECT_TYPE, + portal); tab.addPortlet(portlet, 1); - tab.setPortalSite(portal); tab.save(); portal.addPortalTab(tab); portal.addMember(portal.getOwningUser()); - portal.save(); // Permissions PermissionDescriptor perm = new PermissionDescriptor - (PrivilegeDescriptor.ADMIN, portal, portal.getOwningUser()); + (PrivilegeDescriptor.ADMIN, + portal, + portal.getOwningUser()); PermissionService.grantPermission(perm); + } } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreator.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreator.java index 57cf3bd80..0b25ee680 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreator.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreator.java @@ -20,6 +20,7 @@ package com.arsdigita.portalserver.personal; import com.arsdigita.web.Application; import com.arsdigita.persistence.DataObject; +import com.arsdigita.web.URL; /** *

Experimental

@@ -36,12 +37,62 @@ public class PersonalPortalCreator extends Application { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.workspace.personal.PersonalWorkspaceCreator"; - protected String getBaseDataObjectType() { - return BASE_DATA_OBJECT_TYPE; - } - + /** + * Constructor + * + * @param dataObject + */ // protected PersonalPortalCreator(DataObject dataObject) { public PersonalPortalCreator(DataObject dataObject) { super(dataObject); } + + /** + * + * @return + */ + @Override + protected String getBaseDataObjectType() { + return BASE_DATA_OBJECT_TYPE; + } + + /** + * Returns the path name of the location of the applications servlet/JSP. + * + * Application implementations may overwrite this method to provide an + * application specific location, especially if an application (module) is + * to be installed along with others in one context. + * + * If you install the module into its own context you may use a standard + * location. In most cases though all modules (applications) of an + * webapplication should be installed into one context. + * + * Frequently it is a symbolic name/path, which will be mapped in the web.xml + * to the real location in the file system. Example: + * + * applicationName-files + * com.arsdigita.web.ApplicationFileServlet + * + * template-path + * /templates/ccm-applicationName + * + * + * + * + * applicationName-files + * /ccm-applicationName/files/* + * + * + * NOTE: According to Servlet API the path always starts with a leading '/' + * and includes either the servlet name or a path to the servlet, but does + * not include any extra path information or a query string. Returns an + * empry string ("") is the servlet used was matched using the "/*" pattern. + * + * @return path name to the applications servlet/JSP + */ + @Override + public String getServletPath() { + return URL.SERVLET_DIR + "/personal-portal-creator"; + } + } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorDispatcher.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorDispatcher.java index 8d9480c9e..b6d74a74a 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorDispatcher.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorDispatcher.java @@ -128,11 +128,11 @@ public class PersonalPortalCreatorDispatcher implements Dispatcher { return page; } - public void dispatch - (HttpServletRequest request, HttpServletResponse response, - RequestContext context) - throws IOException, ServletException { - // Assert.assertTrue(context instanceof SiteNodeRequestContext); + public void dispatch(HttpServletRequest request, + HttpServletResponse response, + RequestContext context) + throws IOException, ServletException { + Assert.isTrue(context instanceof SiteNodeRequestContext); // XXX has to be replaced by a way NOT built upon SiteNode* @@ -183,12 +183,14 @@ public class PersonalPortalCreatorDispatcher implements Dispatcher { if (m_introDispatcher == null) { m_introDispatcher = new PageDispatcher(buildIntroPage()); } - - // Assert.assertNotNull(m_introDispatcher, "m_introDispatcher"); Assert.exists(m_introDispatcher, "m_introDispatcher"); - DispatcherHelper.sendRedirect - (request, response, snrc.getOriginalURL()); + // Don't understand: Above we create a new PageDisüpatcher but don't + // call it's dispatch() method. + // What does the sendRedirect here? + DispatcherHelper.sendRedirect(request, + response, + snrc.getOriginalURL()); // The following does not work because I need to be able to // reset the RequestContext before I invoke it. Otherwise, diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorServlet.java new file mode 100644 index 000000000..b2691db9a --- /dev/null +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalCreatorServlet.java @@ -0,0 +1,243 @@ +/* + * Copyright (C) 2012 Peter Boy All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.portalserver.personal; + +import com.arsdigita.bebop.Page; +import com.arsdigita.bebop.PageFactory; +import com.arsdigita.bebop.SimpleContainer; +import com.arsdigita.dispatcher.DispatcherHelper; +import com.arsdigita.dispatcher.RequestContext; +import com.arsdigita.domain.DataObjectNotFoundException; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.kernel.KernelExcursion; +import com.arsdigita.kernel.ResourceTypeConfig; +import com.arsdigita.kernel.User; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; +import com.arsdigita.ui.login.UserAuthenticationListener; +import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; +import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; + +import java.io.IOException; +import java.math.BigDecimal; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** + * + * @author pb + */ +public class PersonalPortalCreatorServlet extends BaseApplicationServlet { + + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger( + PersonalPortalCreatorServlet.class); + + private static final String XSL_HOOK = "portal-sitemap"; + + private static final PresentationManager s_presManager = + Templating.getPresentationManager(); + + private static Page s_introPage ; + + + + /** + * User extension point, do some initializing + * + * @throws ServletException + */ + @Override + public void doInit() throws ServletException { + s_log.debug("PortalSiteMapServlet doInit() initialization executing!"); + + // do nothing for now. + s_introPage = buildIntroPage(); + } + + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ + public void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { + s_log.debug("PortalSiteMApServlet.doService called for request '" + + sreq.getRequestURI() + "'"); + + /* NOTE: + * Resolves currently to SiteNodeRequestContext which will be removed.*/ + RequestContext ctx = DispatcherHelper.getRequestContext(); + /* Problem: what application is treated as parent? We assume it is the + * application of the current request, so we get is as parameter. + * The original dispatcher class uses the current context to determine + * the parent application which should provide the same result. */ + // final Application parent = getApplication(ctx); + final Application parent = app; + + BigDecimal userID = scanUserID(sreq); + + if (userID == null) { + s_log.warn + ("Failed to read a user ID from a personal-portal link."); + } else { + final User user = getUser(userID); + + PersonalPortal portal = PersonalPortal.retrievePersonalPortal(user); + + if (portal == null) { + // This is what we expect to happen so we have to create a new + // PersonalPortal for that user. + KernelExcursion rootExcursion = new KernelExcursion() { + protected void excurse() { + setParty(Kernel.getSystemParty()); + PersonalPortal ps = PersonalPortal + .createPersonalPortal(user, parent); + Assert.exists(ps, "portal"); + + configurePortal(ps); + ps.save(); + } + }; + rootExcursion.run(); + } else { + // There's a problem. We should never get here if the + // portal already exists, since the site node + // dispatcher will go to an existing portal + // directly, skipping this dispatcher. + + s_log.error("PersonalPortalCreator invoked when the portalsite " + + "already exists.", new IllegalStateException()); + } + } + + + /* After crfeation of a new PersonalPortal show intro page. */ + Document doc = null; + doc = s_introPage.buildDocument(sreq, sresp); + s_presManager.servePage(doc, sreq, sresp); + + } + + /** + * + * @return + */ + private Page buildIntroPage() { + + Page page = new Page("", new SimpleContainer()); + page.lock(); + + return page; + + } + + + /** + * Has to be replaced by a way not to use SiteNode / SiteNodeRequestContext + * @param snrc + * @return + */ + private Application getApplication(RequestContext ctx) { + + // SiteNode siteNode = snrc.getSiteNode(); + + // Application parent = Application.retrieveApplicationForSiteNode + // (siteNode); + // Assert.exists(parent, "parent"); + + // return parent; + return null; + } + + /** + * Scan the ServletRequest for the userId part. + * We expect something like "1023/" + + * @param sreq + * @return UserId as BigDecimal + */ + private BigDecimal scanUserID(HttpServletRequest sreq) { + + String url = sreq.getPathInfo(); + + int delimIndex = url.indexOf("/"); + + try { + if (delimIndex == -1) { + return new BigDecimal(url); + } else { + return new BigDecimal(url.substring(0, delimIndex)); + } + } catch (NumberFormatException nfe) { + return null; + } catch (IndexOutOfBoundsException iobe) { + // BigDecimal(String) fails to validate its input. An + // empty string makes it bomb, throwing this exception. + return null; + } + } + + /** + * Retrieve the user object based on userId. + * + * @param userID + * @return User object + */ + private User getUser(BigDecimal userID) { + User user = null; + + try { + user = User.retrieve(userID); + } catch (DataObjectNotFoundException nfe) { + s_log.error + ("Failed to retrieve user " + userID + ".", + new IllegalStateException()); + } + + // Assert.assertNotNull(user, "user"); + Assert.exists(user, "user"); + + return user; + } + + /** + * + * @param portal + */ + private void configurePortal(PersonalPortal portal) { + + ResourceTypeConfig config = portal.getApplicationType().getConfig(); + Assert.exists(config, "config"); + config.configureResource(portal); + + } + +} diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalDispatcher.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalDispatcher.java index bd41faff7..63f81a5cb 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalDispatcher.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalDispatcher.java @@ -74,7 +74,9 @@ public class PersonalPortalDispatcher extends PortalDispatcher { if (remainingURLPart.startsWith(PORTAL_ADMIN_PAGE)) { if (m_portalAdminDispatcher == null) { + PortalAdminPage page = new PortalAdminPage() { + @Override protected void buildContextBar() { DimensionalNavbar navbar = new DimensionalNavbar(); diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java index b952542ae..0a3133e98 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java @@ -42,15 +42,19 @@ import com.arsdigita.bebop.Container; *

Experimental

* * @author Justin Ross - * @version $Id: //portalserver/dev/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java#8 $ + * @version $Id: PersonalPortalHomePage.java#8 $ */ public class PersonalPortalHomePage extends PortalHomePage { - public static final String versionId = - "$Id: //portalserver/dev/src/com/arsdigita/portalserver/personal/PersonalPortalHomePage.java#8 $" + - "$Author: dennis $" + - "$DateTime: 2004/08/17 23:19:25 $"; + + /** + * Constructor + */ + public PersonalPortalHomePage() { + super(); + } private final RequestLocal m_adminPermission = new RequestLocal() { + @Override protected Object initialValue(PageState state) { UniversalPermissionDescriptor descriptor = new UniversalPermissionDescriptor @@ -65,10 +69,7 @@ public class PersonalPortalHomePage extends PortalHomePage { } }; - public PersonalPortalHomePage() { - super(); - } - + @Override protected void buildHeader(Container header) { // Add a link to edit profile. Link profileLink = new Link( new Label(GlobalizationUtil.globalize("cw.workspace.personal.edit_your_profile")), "/register/edit-profile"); @@ -84,6 +85,7 @@ public class PersonalPortalHomePage extends PortalHomePage { // the Portal admin page. Link adminLink = new Link( new Label(GlobalizationUtil.globalize("cw.workspace.personal.site_administration")), "/portal-admin/") { + @Override public boolean isVisible(PageState state) { Boolean bool = (Boolean) m_adminPermission.get(state); return bool.booleanValue(); @@ -96,6 +98,7 @@ public class PersonalPortalHomePage extends PortalHomePage { super.buildHeader(header); } + @Override protected void buildTitle() { class TitlePrintListener implements PrintListener { public void prepare(PrintEvent e) { @@ -128,6 +131,7 @@ public class PersonalPortalHomePage extends PortalHomePage { setTitle(new Label(new TitlePrintListener())); } + @Override protected void buildContextBar() { DimensionalNavbar navbar = new DimensionalNavbar(); diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalServlet.java new file mode 100644 index 000000000..41a76cecb --- /dev/null +++ b/ccm-portalserver/src/com/arsdigita/portalserver/personal/PersonalPortalServlet.java @@ -0,0 +1,111 @@ +/* + * Copyright (C) 2002-2004 Red Hat Inc. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.portalserver.personal; + +import com.arsdigita.bebop.DimensionalNavbar; +import com.arsdigita.bebop.Link; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.Page; +import com.arsdigita.portalserver.ui.PortalParticipants; +import com.arsdigita.portalserver.ui.admin.PortalAdminPage; +import com.arsdigita.portalserver.util.GlobalizationUtil; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; +import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; +import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; + +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + + + +/** + * + * @author pb + * @version $Id: PersonalPortalServlet.java pboy $ + */ +public class PersonalPortalServlet extends BaseApplicationServlet { + + private static final Logger s_log = Logger.getLogger(PersonalPortalServlet.class); + + private static final PresentationManager s_presManager = + Templating.getPresentationManager(); + + private static Page s_homePage = new PersonalPortalHomePage(); + private static Page s_particPage = PortalParticipants.createPage(); + private static Page s_adminPage = s_adminPage = new PortalAdminPage() { + @Override + protected void buildContextBar() { + DimensionalNavbar navbar = new DimensionalNavbar(); + navbar.setClassAttr("portalNavbar"); + navbar.add(new Link(new PersonalPortalLinkPrinter())); + navbar.add(new Label(GlobalizationUtil + .globalize( + "cw.workspace.personal.configure_workspace"))); + getHeader().add(navbar); + } + }; + + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ + public void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { + s_log.debug("PortalServlet.doService called for request '" + + sreq.getRequestURI() + "'"); + + String pathInfo = sreq.getPathInfo(); + Assert.exists(pathInfo, "String pathInfo"); + if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { + /* NOTE: ServletAPI specifies, pathInfo may be empty or will + * start with a '/' character. It currently carries a + * trailing '/' if a "virtual" page, i.e. not a real jsp, but + * result of a servlet mapping. But Application requires url + * NOT to end with a trailing '/' for legacy free applications. */ + pathInfo = pathInfo.substring(0, pathInfo.length()-1); + } + Document doc = null; + + if (pathInfo.endsWith("participants")) { + doc = s_particPage.buildDocument(sreq, sresp); + } else if (pathInfo.endsWith("admin")) { + doc = s_adminPage.buildDocument(sreq, sresp); + } else { + doc = s_homePage.buildDocument(sreq, sresp); + } + + s_presManager.servePage(doc, sreq, sresp); + } + +} diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalDispatcher.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalDispatcher.java index aac31e84b..8b6436f2c 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalDispatcher.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalDispatcher.java @@ -33,6 +33,7 @@ import java.io.IOException; import org.apache.log4j.Logger; /** + * Dispatcher for the PortalSite ApplicationType *

Experimental

* * @author Justin Ross diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalHomePage.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalHomePage.java index e7a6c08f8..80e212bea 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalHomePage.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/PortalHomePage.java @@ -21,7 +21,6 @@ package com.arsdigita.portalserver.ui; import com.arsdigita.portalserver.util.GlobalizationUtil; -import com.arsdigita.web.ApplicationCollection; import com.arsdigita.portalserver.PortalSite; import com.arsdigita.portalserver.LoggedInLinkWrapper; import com.arsdigita.portalserver.PortalPage; @@ -45,7 +44,6 @@ import com.arsdigita.bebop.event.RequestListener; import com.arsdigita.bebop.event.RequestEvent; import com.arsdigita.bebop.event.ChangeListener; import com.arsdigita.bebop.event.ChangeEvent; -import com.arsdigita.bebop.portal.Portal; import com.arsdigita.bebop.portal.PortalModel; import com.arsdigita.bebop.portal.PortalModelBuilder; import com.arsdigita.kernel.permissions.PrivilegeDescriptor; @@ -75,6 +73,7 @@ public class PortalHomePage extends PortalPage { List m_tabs; private RequestLocal m_hasAdmin = new RequestLocal() { + @Override public Object initialValue(PageState ps) { PortalSite psite = PortalSite.getCurrentPortalSite(ps.getRequest()); @@ -146,6 +145,7 @@ public class PortalHomePage extends PortalPage { header.add(adminLink); class SearchComponent extends SimpleContainer { + @Override public void generateXML(PageState state, Element parent) { /*XXXjbp - ************************************************* ****This needs to be modified to use core search*********** @@ -392,10 +392,10 @@ public class PortalHomePage extends PortalPage { private class CookieChangeListener implements ChangeListener { public void stateChanged(ChangeEvent e) { - PageState ps = e.getPageState(); - PortalSite psite = getPortalSite(ps); - // Assert.assertNotNull(psite, "workspace"); + PageState ps = e.getPageState(); + + PortalSite psite = getPortalSite(ps); Assert.exists(psite, "workspace"); HttpServletResponse response = ps.getResponse(); @@ -403,10 +403,8 @@ public class PortalHomePage extends PortalPage { String tabName = (String)m_tabs.getSelectedKey(ps); Cookie cookie = new Cookie(cookieNameString,tabName); cookie.setMaxAge(36000); - cookie.setComment( - "This cookie returns you to the tab you " + - "had open when you last visited this portal." - ); + cookie.setComment("This cookie returns you to the tab you " + + "had open when you last visited this portal."); response.addCookie(cookie); } } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreator.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreator.java index dd4cc3512..61c1b8ef1 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreator.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreator.java @@ -20,6 +20,8 @@ package com.arsdigita.portalserver.ui.admin; import com.arsdigita.web.Application; import com.arsdigita.persistence.*; +import com.arsdigita.web.URL; + import org.apache.log4j.Logger; /** @@ -27,24 +29,72 @@ import org.apache.log4j.Logger; * * @author rhs@mit.edu * @version $Revision: #5 $ $Date: 2004/08/17 $ + * @version $Id: PortalCreator.java#5 $ */ public class PortalCreator extends Application { - public static final String versionId = - "$Id: //portalserver/dev/src/com/arsdigita/portalserver/ui/admin/PortalCreator.java#5 $" + - "$Author: dennis $" + - "$DateTime: 2004/08/17 23:19:25 $"; - private static final Logger s_log = Logger.getLogger - (PortalCreator.class); + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger(PortalCreator.class); public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.workspace.ui.WorkspaceCreator"; + "com.arsdigita.workspace.ui.WorkspaceCreator"; + + /** + * Constructor + * + * @param dataObject + */ + public PortalCreator(DataObject dataObject) { + super(dataObject); + } + + /** + * + * @return + */ + @Override protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } - public PortalCreator(DataObject dataObject) { - super(dataObject); + /** + * Returns the path name of the location of the applications servlet/JSP. + * + * Application implementations may overwrite this method to provide an + * application specific location, especially if an application (module) is + * to be installed along with others in one context. + * + * If you install the module into its own context you may use a standard + * location. In most cases though all modules (applications) of an + * webapplication should be installed into one context. + * + * Frequently it is a symbolic name/path, which will be mapped in the web.xml + * to the real location in the file system. Example: + * + * applicationName-files + * com.arsdigita.web.ApplicationFileServlet + * + * template-path + * /templates/ccm-applicationName + * + * + * + * + * applicationName-files + * /ccm-applicationName/files/* + * + * + * NOTE: According to Servlet API the path always starts with a leading '/' + * and includes either the servlet name or a path to the servlet, but does + * not include any extra path information or a query string. Returns an + * empry string ("") is the servlet used was matched using the "/*" pattern. + * + * @return path name to the applications servlet/JSP + */ + @Override + public String getServletPath() { + return URL.SERVLET_DIR + "/portal-creator"; } + } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreatorServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreatorServlet.java new file mode 100644 index 000000000..001db4d16 --- /dev/null +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalCreatorServlet.java @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2012 Peter Boy All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.portalserver.ui.admin; + +import com.arsdigita.bebop.Page; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; +import com.arsdigita.ui.login.UserAuthenticationListener; +import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; +import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** + * + * @author pb + */ +public class PortalCreatorServlet extends BaseApplicationServlet { + + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger(PortalCreatorServlet.class); + + private static final PresentationManager s_presManager = + Templating.getPresentationManager(); + + private static Page s_prtlCreatePage ; + + + + /** + * User extension point, initialize PortalCreator (index) page and add + * authentication check. + * + * @throws ServletException + */ + @Override + public void doInit() throws ServletException { + + s_prtlCreatePage = new PortalCreatePage(); + s_prtlCreatePage.addRequestListener(new UserAuthenticationListener()); + s_prtlCreatePage.lock(); + + } + + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ + public void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { + s_log.debug("PortalCreatorServlet.doService called for request '" + + sreq.getRequestURI() + "'"); + + String pathInfo = sreq.getPathInfo(); + Assert.exists(pathInfo, "String pathInfo"); + if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { + /* NOTE: ServletAPI specifies, pathInfo may be empty or will + * start with a '/' character. It currently carries a + * trailing '/' if a "virtual" page, i.e. not a real jsp, but + * result of a servlet mapping. But Application requires url + * NOT to end with a trailing '/' for legacy free applications. */ + pathInfo = pathInfo.substring(0, pathInfo.length()-1); + } + + Document doc = null; + doc = s_prtlCreatePage.buildDocument(sreq, sresp); + s_presManager.servePage(doc, sreq, sresp); + + } +} diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMap.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMap.java index a6ef2b8a5..35a53be8e 100644 --- a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMap.java +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMap.java @@ -20,6 +20,8 @@ package com.arsdigita.portalserver.ui.admin; import com.arsdigita.web.Application; import com.arsdigita.persistence.*; + +import com.arsdigita.web.URL; import org.apache.log4j.Logger; /** @@ -29,17 +31,65 @@ import org.apache.log4j.Logger; */ public class PortalSiteMap extends Application { - private static final Logger s_log = Logger.getLogger - (PortalSiteMap.class); + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger(PortalSiteMap.class); public static final String BASE_DATA_OBJECT_TYPE = - "com.arsdigita.workspace.ui.PortalSiteMap"; + "com.arsdigita.workspace.ui.PortalSiteMap"; + /** + * Constgructor + * @param dataObject + */ + public PortalSiteMap(DataObject dataObject) { + super(dataObject); + } + + /** + * + * @return + */ protected String getBaseDataObjectType() { return BASE_DATA_OBJECT_TYPE; } - public PortalSiteMap(DataObject dataObject) { - super(dataObject); + /** + * Returns the path name of the location of the applications servlet/JSP. + * + * Application implementations may overwrite this method to provide an + * application specific location, especially if an application (module) is + * to be installed along with others in one context. + * + * If you install the module into its own context you may use a standard + * location. In most cases though all modules (applications) of an + * webapplication should be installed into one context. + * + * Frequently it is a symbolic name/path, which will be mapped in the web.xml + * to the real location in the file system. Example: + * + * applicationName-files + * com.arsdigita.web.ApplicationFileServlet + * + * template-path + * /templates/ccm-applicationName + * + * + * + * + * applicationName-files + * /ccm-applicationName/files/* + * + * + * NOTE: According to Servlet API the path always starts with a leading '/' + * and includes either the servlet name or a path to the servlet, but does + * not include any extra path information or a query string. Returns an + * empry string ("") is the servlet used was matched using the "/*" pattern. + * + * @return path name to the applications servlet/JSP + */ + @Override + public String getServletPath() { + return URL.SERVLET_DIR + "/portal-sitemap"; } + } diff --git a/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMapServlet.java b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMapServlet.java new file mode 100644 index 000000000..2b32a63cf --- /dev/null +++ b/ccm-portalserver/src/com/arsdigita/portalserver/ui/admin/PortalSiteMapServlet.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2012 Peter Boy All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +package com.arsdigita.portalserver.ui.admin; + +import com.arsdigita.bebop.Page; +import com.arsdigita.bebop.PageFactory; +import com.arsdigita.templating.PresentationManager; +import com.arsdigita.templating.Templating; +import com.arsdigita.ui.login.UserAuthenticationListener; +import com.arsdigita.util.Assert; +import com.arsdigita.web.Application; +import com.arsdigita.web.BaseApplicationServlet; +import com.arsdigita.xml.Document; + +import java.io.IOException; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.log4j.Logger; + +/** + * + * @author pb + */ +public class PortalSiteMapServlet extends BaseApplicationServlet { + + /** Logger instance for debugging */ + private static final Logger s_log = Logger.getLogger(PortalSiteMapServlet.class); + + private static final String XSL_HOOK = "portal-sitemap"; + + private static final PresentationManager s_presManager = + Templating.getPresentationManager(); + + private static Page s_indexPage = buildSiteMapPage(); + + + + /** + * User extension point, do some initializing + * + * @throws ServletException + */ + @Override + public void doInit() throws ServletException { + s_log.debug("PortalSiteMapServlet doInit() initialization executing!"); + + // do nothing for now. + + } + + /** + * + * @param sreq + * @param sresp + * @param app + * @throws ServletException + * @throws IOException + */ + public void doService(HttpServletRequest sreq, + HttpServletResponse sresp, + Application app) + throws ServletException, IOException { + s_log.debug("PortalSiteMApServlet.doService called for request '" + + sreq.getRequestURI() + "'"); + + String pathInfo = sreq.getPathInfo(); + Assert.exists(pathInfo, "String pathInfo"); + if (pathInfo.length() > 1 && pathInfo.endsWith("/")) { + /* NOTE: ServletAPI specifies, pathInfo may be empty or will + * start with a '/' character. It currently carries a + * trailing '/' if a "virtual" page, i.e. not a real jsp, but + * result of a servlet mapping. But Application requires url + * NOT to end with a trailing '/' for legacy free applications. */ + pathInfo = pathInfo.substring(0, pathInfo.length()-1); + } + + Document doc = null; + doc = s_indexPage.buildDocument(sreq, sresp); + s_presManager.servePage(doc, sreq, sresp); + + } + + /** + * + * @return + */ + static Page buildSiteMapPage() { + Page page = PageFactory.buildPage(XSL_HOOK, "Portal Site Map"); + PortalSiteMapPanel sitemapPanel = new PortalSiteMapPanel(page); + page.add(sitemapPanel); + page.addRequestListener(new UserAuthenticationListener()); + + page.lock(); + return page; + } + +} diff --git a/ccm-portalserver/web/WEB-INF/web.ccm-portalserver.xml b/ccm-portalserver/web/WEB-INF/web.ccm-portalserver.xml index 14506135e..b6aba89d4 100644 --- a/ccm-portalserver/web/WEB-INF/web.ccm-portalserver.xml +++ b/ccm-portalserver/web/WEB-INF/web.ccm-portalserver.xml @@ -7,12 +7,63 @@ portalsite - com.arsdigita.portalserver.PortalServlet + com.arsdigita.portalserver.PortalSiteServlet + + portalsite-admin + com.arsdigita.portalserver.admin.PSAdminServlet + + + + portal-creator + com.arsdigita.portalserver.ui.admin.PortalCreatorServlet + + + + portal-sitemap + com.arsdigita.portalserver.ui.admin.PortalSiteMapServlet + + + + portal-personalportal + com.arsdigita.portalserver.personal.PersonalPortalServlet + + + + portal-personalportal + com.arsdigita.portalserver.personal.PersonalPortalCreatorServlet + + + portalsite /templates/servlet/portalsite/* + + portalsite-admin + /templates/servlet/psadmin/* + + + + portal-creator + /templates/servlet/portal-creator/* + + + + portal-sitemap + /templates/servlet/portal-sitemap/* + + + + portal-personalportal + /templates/servlet/personal-portal/* + + + + portal-personalportal + /templates/servlet/personal-portal-creator/* + + \ No newline at end of file diff --git a/ccm-portalserver/web/themes/heirloom/apps/portal-site/xsl/index.xsl b/ccm-portalserver/web/themes/heirloom/apps/portal-site/xsl/index.xsl deleted file mode 100644 index cf2744089..000000000 --- a/ccm-portalserver/web/themes/heirloom/apps/portal-site/xsl/index.xsl +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/portalserver.xsl b/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/portalserver.xsl index 1b188b1f2..8dfa8e1be 100644 --- a/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/portalserver.xsl +++ b/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/portalserver.xsl @@ -1,14 +1,13 @@ - + @@ -17,23 +16,31 @@ + + +--> + + + <xsl:value-of select="bebop:title"/> - + @@ -62,7 +69,8 @@ <xsl:value-of select="bebop:title"/> - + @@ -275,7 +283,8 @@ - + @@ -285,7 +294,8 @@ - + @@ -295,7 +305,8 @@ - + @@ -305,7 +316,8 @@ - + @@ -315,7 +327,8 @@ - + @@ -325,7 +338,8 @@ - + @@ -335,7 +349,8 @@ - + @@ -345,7 +360,8 @@ - + @@ -355,7 +371,8 @@ - + @@ -365,7 +382,8 @@ - + @@ -391,7 +409,8 @@ - + + @@ -411,7 +430,9 @@
- + + + @@ -419,7 +440,8 @@ - + + @@ -452,7 +474,8 @@ - @@ -511,7 +534,8 @@ - + - + - + - + - + - + - +
   + +   
+ @@ -553,7 +577,8 @@ + @@ -578,7 +603,8 @@ + @@ -603,13 +629,15 @@ + + @@ -634,13 +662,15 @@ + + @@ -653,44 +683,69 @@ - +
+ - + @@ -778,7 +834,10 @@ - + @@ -840,7 +899,8 @@ - + @@ -850,7 +910,8 @@ - + diff --git a/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/ui.xsl b/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/ui.xsl index 354fb460a..20d91476d 100644 --- a/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/ui.xsl +++ b/ccm-portalserver/web/themes/heirloom/packages/portalserver/xsl/ui.xsl @@ -1,7 +1,7 @@ + xmlns:bebop="http://www.arsdigita.com/bebop/1.0" + xmlns:ui="http://www.arsdigita.com/ui/1.0">
- Move Portlet left + + Move Portlet left + - Move Portlet Up + + Move Portlet Up - Move Portlet Down + + Move Portlet Down - Move Portlet right + + Move Portlet right - Customize Portlet + + Customize Portlet - Remove Portlet + + Remove Portlet - Zoom In + + Zoom In - + @@ -760,7 +815,8 @@
1. + +