From 71fc621f8defa91116bfabd95d049928fbbec872 Mon Sep 17 00:00:00 2001 From: pb Date: Tue, 24 May 2011 20:33:37 +0000 Subject: [PATCH] =?UTF-8?q?Erster=20Versuch,=20anhand=20von=20ccm-faq=20ei?= =?UTF-8?q?ne=20legacy=20compatible=20app=20mit=20dispatcher=20zu=20ersetz?= =?UTF-8?q?en=20durch=20eine=20legacy=20free=20app=20ohne=20dispatcher=20s?= =?UTF-8?q?ondern=20mit=20application=20servlet.=20Noch=20nicht=20vollst?= =?UTF-8?q?=C3=A4ndig=20erfolgreich.=20Weitere=20Formatierungen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@939 8810af33-2d31-482b-a856-94f89814c4df --- .../bebop/page/BebopMapDispatcher.java | 4 +- .../arsdigita/web/BaseApplicationServlet.java | 3 +- .../src/com/arsdigita/faq/FaqDispatcher.java | 11 ++- ccm-faq/src/com/arsdigita/faq/FaqServlet.java | 92 +++++++++++++++++++ ccm-faq/src/com/arsdigita/faq/Loader.java | 28 +++--- .../src/com/arsdigita/forum/ForumServlet.java | 29 +++--- ccm-forum/src/com/arsdigita/forum/Loader.java | 1 + .../bundles/develpb/cfg/applications.cfg | 2 +- environment/project.xml.gen-dev | 2 + 9 files changed, 138 insertions(+), 34 deletions(-) create mode 100644 ccm-faq/src/com/arsdigita/faq/FaqServlet.java diff --git a/ccm-core/src/com/arsdigita/bebop/page/BebopMapDispatcher.java b/ccm-core/src/com/arsdigita/bebop/page/BebopMapDispatcher.java index ec202e4e8..815beefb5 100755 --- a/ccm-core/src/com/arsdigita/bebop/page/BebopMapDispatcher.java +++ b/ccm-core/src/com/arsdigita/bebop/page/BebopMapDispatcher.java @@ -42,8 +42,8 @@ public class BebopMapDispatcher extends MapDispatcher { private PresentationManager m_presManager; - private static final Logger s_log = - Logger.getLogger(BebopMapDispatcher.class); + /** Private logger instance to help debugging. */ + private static final Logger s_log = Logger.getLogger(BebopMapDispatcher.class); /** * Constructor creates BebopMapDispatcher with empty URL mapped to "/" and diff --git a/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java b/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java index 9020827ca..1ae45eaa6 100755 --- a/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java +++ b/ccm-core/src/com/arsdigita/web/BaseApplicationServlet.java @@ -98,7 +98,8 @@ public abstract class BaseApplicationServlet extends BaseServlet { @Override protected final void doService(final HttpServletRequest sreq, final HttpServletResponse sresp) - throws ServletException, IOException { + throws ServletException, IOException { + final Application app = getApplication(sreq); if (app == null) { diff --git a/ccm-faq/src/com/arsdigita/faq/FaqDispatcher.java b/ccm-faq/src/com/arsdigita/faq/FaqDispatcher.java index b34fa77bf..b630448e6 100644 --- a/ccm-faq/src/com/arsdigita/faq/FaqDispatcher.java +++ b/ccm-faq/src/com/arsdigita/faq/FaqDispatcher.java @@ -43,7 +43,8 @@ public class FaqDispatcher extends BebopMapDispatcher { Logger.getLogger(FaqDispatcher.class); /** - * + * Constructor, sets up internal data structures and builds the user + * interface (public [index] page and admin page) */ public FaqDispatcher() { super(); @@ -63,6 +64,10 @@ public class FaqDispatcher extends BebopMapDispatcher { setMap(m); } + /** + * + * @return + */ private FaqPage buildIndexPage() { FaqPage p = new FaqPage(); @@ -79,6 +84,10 @@ public class FaqDispatcher extends BebopMapDispatcher { } + /** + * + * @return + */ private FaqPage buildAdminIndexPage() { FaqPage p = new FaqPage("admin"); diff --git a/ccm-faq/src/com/arsdigita/faq/FaqServlet.java b/ccm-faq/src/com/arsdigita/faq/FaqServlet.java new file mode 100644 index 000000000..033d12180 --- /dev/null +++ b/ccm-faq/src/com/arsdigita/faq/FaqServlet.java @@ -0,0 +1,92 @@ +/* + * Copyright (C) 2011 Peter boy (pboy@barkhof.uni-bremen.de + * + * 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.faq; + +import com.arsdigita.bebop.Page; +import com.arsdigita.bebop.page.BebopApplicationServlet; +import com.arsdigita.faq.ui.FaqAdminView; +import com.arsdigita.faq.ui.FaqPage; +import com.arsdigita.faq.ui.FaqUserView; +import javax.servlet.ServletException; + +import org.apache.log4j.Logger; + +/** + * + * @author pb + */ +public class FaqServlet extends BebopApplicationServlet { + + /** Private logger instance to faciliate debugging procedures */ + private static final Logger s_log = Logger.getLogger(FaqServlet.class); + + + public void init() throws ServletException { + super.init(); + + Page index = buildIndexPage(); + Page admin = buildAdminIndexPage(); + + put("/", index); + put("/index.jsp", index); + put("/one.jsp", index); + + put("admin/", admin); + put("admin/index.jsp", admin); + + } + + /** + * + * @return + */ + private FaqPage buildIndexPage() { + FaqPage p = new FaqPage(); + + p.add(new FaqUserView()); + + /*CommentsService commentsService = + * new CommentsService(req, FaqHelper.getFaqID(req)); + * p.add(commentsService.buildCommentsComponent( + * "comments/one-object")); + */ + + p.lock(); + return p; + } + + + /** + * + * @return + */ + private FaqPage buildAdminIndexPage() { + + FaqPage p = new FaqPage("admin"); + + FaqAdminView faqAdminTabs = new FaqAdminView(); + faqAdminTabs.setKey("FaqAdminTabs"); + p.add(faqAdminTabs); + + p.lock(); + return p; + } + +} diff --git a/ccm-faq/src/com/arsdigita/faq/Loader.java b/ccm-faq/src/com/arsdigita/faq/Loader.java index c3fefed48..ec8934b8d 100644 --- a/ccm-faq/src/com/arsdigita/faq/Loader.java +++ b/ccm-faq/src/com/arsdigita/faq/Loader.java @@ -18,16 +18,10 @@ */ package com.arsdigita.faq; -// import com.arsdigita.mimetypes.*; -//import com.arsdigita.domain.DomainObject; import com.arsdigita.faq.ui.FaqQuestionsPortlet; -//import com.arsdigita.kernel.ACSObjectInstantiator; import com.arsdigita.kernel.Kernel; import com.arsdigita.kernel.KernelExcursion; import com.arsdigita.loader.PackageLoader; -//import com.arsdigita.persistence.DataObject; -//import com.arsdigita.portal.PortletType; -//import com.arsdigita.portal.apportlet.AppPortletSetup; import com.arsdigita.portal.apportlet.AppPortletType; import com.arsdigita.runtime.ScriptContext; import com.arsdigita.web.ApplicationType; @@ -85,16 +79,22 @@ public class Loader extends PackageLoader { */ private void loadFAQApplicationType() { - ApplicationType type = ApplicationType.createApplicationType( - "faq", - "Frequently Asked Questions", - Faq.BASE_DATA_OBJECT_TYPE); - type.setDescription - ("FAQ's empower users to share knowledge."); + /* Setup a new style legacy compatible application type. */ + // ApplicationType type = ApplicationType.createApplicationType( + // "faq", + // "Frequently Asked Questions", + // Faq.BASE_DATA_OBJECT_TYPE); // 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.faq.FaqDispatcher"); + // type.setDispatcherClass + // ("com.arsdigita.faq.FaqDispatcher"); + + /* Setup as new stype legacy free aplcation */ + ApplicationType type = new ApplicationType("FAQ", + Faq.BASE_DATA_OBJECT_TYPE); + // type independent: + type.setDescription + ("Frequently Asked Questions empower users to share knowledge."); } diff --git a/ccm-forum/src/com/arsdigita/forum/ForumServlet.java b/ccm-forum/src/com/arsdigita/forum/ForumServlet.java index 22e47109e..7e0eb697c 100755 --- a/ccm-forum/src/com/arsdigita/forum/ForumServlet.java +++ b/ccm-forum/src/com/arsdigita/forum/ForumServlet.java @@ -53,19 +53,20 @@ public class ForumServlet extends BebopApplicationServlet @Override public void init() throws ServletException { super.init(); - s_log.debug("creating forum page"); + s_log.debug("creating forum page"); + final Page forum = ForumPageFactory.getPage(ForumPageFactory.FORUM_PAGE); - s_log.debug("creating thread page"); + s_log.debug("creating thread page"); final Page thread = ForumPageFactory.getPage(ForumPageFactory.THREAD_PAGE); put("/", forum); put("/index.jsp", forum); put("/thread.jsp", thread); if (Forum.getConfig().disableClientPageCaching()) { - s_log.debug("caching disabled"); - disableClientCaching("/"); - disableClientCaching("/index.jsp"); - disableClientCaching("/thread.jsp"); + s_log.debug("caching disabled"); + disableClientCaching("/"); + disableClientCaching("/index.jsp"); + disableClientCaching("/thread.jsp"); } // allow other pages to be added @@ -73,19 +74,17 @@ public class ForumServlet extends BebopApplicationServlet // for AJAX category asignment Iterator it = ForumPageFactory.getPages(); while (it.hasNext()) { - Object key = (Object)it.next(); - if (!key.equals(ForumPageFactory.FORUM_PAGE) && + Object key = (Object)it.next(); + if (!key.equals(ForumPageFactory.FORUM_PAGE) && !key.equals(ForumPageFactory.THREAD_PAGE)) { - put("/" + key, ForumPageFactory.getPage((String)key)); - if (Forum.getConfig().disableClientPageCaching()) { - disableClientCaching("/" + key); - + put("/" + key, ForumPageFactory.getPage((String)key)); + if (Forum.getConfig().disableClientPageCaching()) { + disableClientCaching("/" + key); } } } } - - - + + } diff --git a/ccm-forum/src/com/arsdigita/forum/Loader.java b/ccm-forum/src/com/arsdigita/forum/Loader.java index a01e9a9bf..4d06bd77e 100755 --- a/ccm-forum/src/com/arsdigita/forum/Loader.java +++ b/ccm-forum/src/com/arsdigita/forum/Loader.java @@ -88,6 +88,7 @@ public class Loader extends PackageLoader { /** * TODO: What is it for? Execution is currently commented out. + * Referenced class com.arsdigita.forum.Inbox does not exist. * @return */ private static ApplicationType setupInboxAppType() { diff --git a/ccm-gen-aplaws/bundles/develpb/cfg/applications.cfg b/ccm-gen-aplaws/bundles/develpb/cfg/applications.cfg index c29ab9108..132b3fd7d 100644 --- a/ccm-gen-aplaws/bundles/develpb/cfg/applications.cfg +++ b/ccm-gen-aplaws/bundles/develpb/cfg/applications.cfg @@ -47,7 +47,7 @@ ccm-cms-types-newsitem # ccm-auth-http # ccm-bookmarks ccm-docmgr -ccm-docrepo +# ccm-docrepo ccm-faq # ccm-formbuilder-pdf ccm-forum diff --git a/environment/project.xml.gen-dev b/environment/project.xml.gen-dev index bad868b17..eb26be3d7 100644 --- a/environment/project.xml.gen-dev +++ b/environment/project.xml.gen-dev @@ -63,6 +63,8 @@ + +