diff --git a/ccm-weblog/src/ccm-weblog.load b/ccm-weblog/src/ccm-weblog.load
index 53875621a..739fc5d05 100755
--- a/ccm-weblog/src/ccm-weblog.load
+++ b/ccm-weblog/src/ccm-weblog.load
@@ -9,5 +9,6 @@
+
diff --git a/ccm-weblog/src/org/undp/weblog/Initializer.java b/ccm-weblog/src/org/undp/weblog/Initializer.java
index 5bfc83e63..7d42960a2 100755
--- a/ccm-weblog/src/org/undp/weblog/Initializer.java
+++ b/ccm-weblog/src/org/undp/weblog/Initializer.java
@@ -1,122 +1,90 @@
package org.undp.weblog;
-import org.apache.log4j.Logger;
-import org.undp.weblog.ui.WebLogPortlet;
-
import com.arsdigita.db.DbHelper;
-import com.arsdigita.domain.DataObjectNotFoundException;
import com.arsdigita.domain.DomainObject;
-import com.arsdigita.domain.DomainObjectFactory;
-import com.arsdigita.domain.DomainObjectInstantiator;
-// import com.arsdigita.initializer.InitializationException;
import com.arsdigita.kernel.ACSObjectInstantiator;
-import com.arsdigita.kernel.PackageType;
-// import com.arsdigita.kernel.Stylesheet;
import com.arsdigita.persistence.DataObject;
-import com.arsdigita.persistence.SessionManager;
-import com.arsdigita.persistence.TransactionContext;
import com.arsdigita.persistence.pdl.ManifestSource;
import com.arsdigita.persistence.pdl.NameFilter;
-import com.arsdigita.portal.apportlet.AppPortletType;
import com.arsdigita.runtime.CompoundInitializer;
import com.arsdigita.runtime.DomainInitEvent;
import com.arsdigita.runtime.PDLInitializer;
import com.arsdigita.runtime.RuntimeConfig;
-import com.arsdigita.web.ApplicationType;
+
+import org.apache.log4j.Logger;
+import org.undp.weblog.ui.WebLogPortlet;
+
/**
* @author Peter Kopunec
*/
public class Initializer extends CompoundInitializer {
+ /** Creates a s_logging category with name = full name of class */
private static final Logger s_log = Logger.getLogger(Initializer.class);
-//ublic Initializer() throws InitializationException {
+ /**
+ *
+ */
public Initializer() {
final String url = RuntimeConfig.getConfig().getJDBCURL();
final int database = DbHelper.getDatabaseFromURL(url);
- add(new PDLInitializer(new ManifestSource("ccm-weblog.pdl.mf",
- new NameFilter(DbHelper.
- getDatabaseSuffix(database), "pdl"))));
+ add(new PDLInitializer(
+ new ManifestSource("ccm-weblog.pdl.mf",
+ new NameFilter(DbHelper.
+ getDatabaseSuffix(database), "pdl"))));
}
+ /**
+ *
+ * @param e
+ */
@Override
public void init(DomainInitEvent e) {
s_log.info("WebLog Initializer starting.");
-
- boolean isMyTransaction = false;
- TransactionContext txn = SessionManager.getSession().
- getTransactionContext();
- if (!txn.inTxn()) {
- txn.beginTxn();
- isMyTransaction = true;
- }
+ super.init(e);
// register application
- DomainObjectInstantiator instantiator = new ACSObjectInstantiator() {
-
+/* DomainObjectInstantiator instantiator = new ACSObjectInstantiator() {
@Override
protected DomainObject doNewInstance(DataObject dataObject) {
return new WebLogApplication(dataObject);
}
};
DomainObjectFactory.registerInstantiator(
- WebLogApplication.BASE_DATA_OBJECT_TYPE, instantiator);
- checkSetup();
+ WebLogApplication.BASE_DATA_OBJECT_TYPE, instantiator); */
+ /* Register object instantiator for Bookmarks Application */
+ e.getFactory().registerInstantiator(
+ WebLogApplication.BASE_DATA_OBJECT_TYPE,
+ new ACSObjectInstantiator() {
+ @Override
+ public DomainObject doNewInstance(DataObject dataObject) {
+ return new WebLogApplication(dataObject);
+ }
+ });
+
// Register the portlets
- instantiator = new ACSObjectInstantiator() {
-
+/* instantiator = new ACSObjectInstantiator() {
@Override
protected DomainObject doNewInstance(DataObject dataObject) {
return new WebLogPortlet(dataObject);
}
};
DomainObjectFactory.registerInstantiator(
- WebLogPortlet.BASE_DATA_OBJECT_TYPE, instantiator);
+ WebLogPortlet.BASE_DATA_OBJECT_TYPE, instantiator); */
- if (isMyTransaction) {
- txn.commitTxn();
- }
+ /* Register object instantiator for Bookmarks Portlet */
+ e.getFactory().registerInstantiator(
+ WebLogPortlet.BASE_DATA_OBJECT_TYPE,
+ new ACSObjectInstantiator() {
+ public DomainObject doNewInstance(DataObject dataObject) {
+ return new WebLogPortlet(dataObject);
+ }
+ });
s_log.debug("WebLog Initializer done.");
}
- private void checkSetup() {
- try {
- s_log.debug("WebLog Initializer - verifying setup.");
- PackageType entityType = PackageType.findByKey("weblog");
- } catch (DataObjectNotFoundException e) {
- setup();
- }
- }
-
- private void setup() {
- s_log.info("WebLog Initializer - setting up new package");
-
- PackageType entityType = PackageType.create("weblog", "WebLog",
- "WebLogs",
- "http://www.undp.org/weblog");
- s_log.debug("Just added package type WebLog ");
-
-
- entityType.setDispatcherClass(WebLogDispatcher.class.getName());
-
- entityType.save();
-
- final ApplicationType entityAppType = ApplicationType.
- createApplicationType(entityType, "WebLog Application",
- WebLogApplication.BASE_DATA_OBJECT_TYPE);
- entityAppType.save();
-
- // portlet
- AppPortletType portletType = AppPortletType.createAppPortletType(
- "WebLog Portlet", AppPortletType.WIDE_PROFILE,
- WebLogPortlet.BASE_DATA_OBJECT_TYPE);
- portletType.setProviderApplicationType(entityAppType);
- portletType.setPortalApplication(true);
- portletType.save();
-
- }
}
diff --git a/ccm-weblog/src/org/undp/weblog/Loader.java b/ccm-weblog/src/org/undp/weblog/Loader.java
new file mode 100644
index 000000000..7f2a265e1
--- /dev/null
+++ b/ccm-weblog/src/org/undp/weblog/Loader.java
@@ -0,0 +1,142 @@
+/*
+ * 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 org.undp.weblog;
+
+import com.arsdigita.kernel.Kernel;
+import com.arsdigita.kernel.KernelExcursion;
+import com.arsdigita.loader.PackageLoader;
+
+import com.arsdigita.portal.apportlet.AppPortletType;
+import com.arsdigita.runtime.ScriptContext;
+import com.arsdigita.web.Application;
+import com.arsdigita.web.ApplicationType;
+import org.apache.log4j.Logger;
+import org.undp.weblog.ui.WebLogPortlet;
+
+/**
+ * Executes nonrecurring at install time and loads (installs and initializes)
+ * the WebLog application and type persistently into database.
+ *
+ * @author pboy <pboy@barkhof.uni-bremen.de>
+ * @version $Id: Loader.java $
+ */
+public class Loader extends PackageLoader {
+
+ /** Logger instance for debugging */
+ private static final Logger s_log = Logger.getLogger(Loader.class);
+
+
+ /**
+ * Run script invoked by com.arsdigita.packing loader script.
+ *
+ * @param ctx
+ */
+ public void run(final ScriptContext ctx) {
+
+ new KernelExcursion() {
+ public void excurse() {
+ setEffectiveParty(Kernel.getSystemParty());
+
+ ApplicationType weblogType = loadWebLogApplicationType();
+ loadWebLogPortletType(weblogType);
+
+ // NOTE: Perhaps it is not usefull to create a default instance,
+ // because a site might have more than one blog and a more
+ // appropriate location has to be determined.
+ setupDefaultWebLogApplicationInstance();
+
+ }
+ }.run();
+
+ s_log.info("Done");
+
+ }
+ /**
+ * Creates a WebLog application type, the domain class of the weblog
+ * package, as a legacy-free type of application.
+ *
+ * Creates an entry in table application_types
+ *
+ */
+ private ApplicationType loadWebLogApplicationType() {
+ s_log.info("WebLog Loader - setting up application type");
+
+ /* NOTE: The wording in the title parameter of ApplicationType determines
+ * the name of the subdirectory for the XSL stylesheets.
+ * It gets "urlized", i.e. trimming leading and trailing blanks and replacing
+ * blanks between words and illegal characters with an hyphen and converted
+ * to lower case.
+ * Example: "WebLog" will become "weblog".
+ */
+ ApplicationType type = new ApplicationType("WebLog",
+ WebLogApplication.BASE_DATA_OBJECT_TYPE );
+ type.setDescription("The WebLog application enables user .....");
+ type.save();
+
+ return type;
+ }
+
+
+ /**
+ *
+ * @param webLogAppType
+ */
+ private void loadWebLogPortletType(ApplicationType webLogAppType ) {
+
+ AppPortletType type = AppPortletType.createAppPortletType(
+ "WebLog Portlet",
+ AppPortletType.WIDE_PROFILE,
+ WebLogPortlet.BASE_DATA_OBJECT_TYPE);
+ type.setDescription("Displays WebLogs for this portal.");
+ type.setProviderApplicationType(webLogAppType);
+ type.setPortalApplication(true);
+
+ type.save();
+
+ }
+
+
+ /**
+ * Instantiates the WebLog application admin instance.
+ *
+ */
+ public static void setupDefaultWebLogApplicationInstance() {
+
+ /* Determine a parent application. WebLog default page will be
+ * installed beyond the admin's applications URL. It enshures
+ * the user has to be logged in. */
+ /* NOTE: The location /admin/ might not be a good selection and a
+ * more appropriate one should be found. */
+ Application parent = Application.retrieveApplicationForPath("/admin/");
+
+ // create application instance
+ // Whether a legacy compatible or a legacy free application is
+ // created depends on the type of ApplicationType above. No need to
+ // modify anything here in the migration process
+ // old-style package key used as url fragment where to install the instance
+ s_log.debug("Creating WebLogApplication instance ...");
+
+ WebLogApplication app = WebLogApplication.create("blog",
+ "Weblog",
+ parent);
+ app.setDescription("Default WebLog application instance.");
+ app.save();
+
+ s_log.debug("WebLog instance " + " created.");
+ }
+
+}
diff --git a/ccm-weblog/src/org/undp/weblog/WebLogApplication.java b/ccm-weblog/src/org/undp/weblog/WebLogApplication.java
index d80071e56..1383a4917 100755
--- a/ccm-weblog/src/org/undp/weblog/WebLogApplication.java
+++ b/ccm-weblog/src/org/undp/weblog/WebLogApplication.java
@@ -16,20 +16,36 @@ import com.arsdigita.persistence.OID;
import com.arsdigita.web.Application;
/**
+ * Application domain class for the WebLog application.
+ *
* @author Peter Kopunec
+ * @version $Id: WebLogApplication.java $
*/
public class WebLogApplication extends Application {
- public static final String BASE_DATA_OBJECT_TYPE = WebLogApplication.class
- .getName();
-
+ /** Logger instance for debugging */
private static final Logger s_log = Logger
.getLogger(WebLogApplication.class);
- public WebLogApplication(DataObject data) {
- super(data);
+ // pdl stuff (constants)
+ public static final String BASE_DATA_OBJECT_TYPE = WebLogApplication.class
+ .getName();
+
+ /**
+ * Constructs a service domain object from the underlying data object.
+ *
+ * @param obj the DataObject
+ */
+ public WebLogApplication(DataObject obj) {
+ super(obj);
}
+ /**
+ * Constructor retrieving WebLogApplication from the database usings its OID.
+ *
+ * @param obj
+ * @throws DataObjectNotFoundException
+ */
public WebLogApplication(OID oid) throws DataObjectNotFoundException {
super(oid);
}
@@ -38,6 +54,12 @@ public class WebLogApplication extends Application {
this(new OID(BASE_DATA_OBJECT_TYPE, id));
}
+ /**
+ * Getter to retrieve the base database object type name
+ *
+ * @return base data aoject type as String
+ */
+ @Override
protected String getBaseDataObjectType() {
return BASE_DATA_OBJECT_TYPE;
}
@@ -60,6 +82,7 @@ public class WebLogApplication extends Application {
/**
* Overrides the superclass adding some permissions.
*/
+ @Override
protected void afterSave() {
super.afterSave();
Party currentParty = Kernel.getContext().getParty();
@@ -73,4 +96,12 @@ public class WebLogApplication extends Application {
}
}.run();
}
+
+ /**
+ *
+ */
+ @Override
+ public String getServletPath() {
+ return "/weblog";
+ }
}
diff --git a/ccm-weblog/src/org/undp/weblog/WebLogDispatcher.java b/ccm-weblog/src/org/undp/weblog/WebLogDispatcher.java.nolongerInUse
similarity index 100%
rename from ccm-weblog/src/org/undp/weblog/WebLogDispatcher.java
rename to ccm-weblog/src/org/undp/weblog/WebLogDispatcher.java.nolongerInUse
diff --git a/ccm-weblog/src/org/undp/weblog/WebLogServlet.java b/ccm-weblog/src/org/undp/weblog/WebLogServlet.java
new file mode 100644
index 000000000..9972c7e79
--- /dev/null
+++ b/ccm-weblog/src/org/undp/weblog/WebLogServlet.java
@@ -0,0 +1,63 @@
+/*
+ * 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 org.undp.weblog;
+
+import com.arsdigita.bebop.Page;
+import com.arsdigita.bebop.page.BebopApplicationServlet;
+
+import javax.servlet.ServletException;
+
+import org.apache.log4j.Logger;
+import org.undp.weblog.ui.WebLogPage;
+
+
+/**
+ * WebLog Application Servlet class, central entry point to create and process
+ * the applications UI.
+ *
+ * We should have subclassed BebopApplicationServlet but couldn't overwrite
+ * doService() method to add permission checking. So we use our own page
+ * mapping. The general logic is the same as for BebopApplicationServlet.
+ * {@see com.arsdigita.bebop.page.BebopApplicationServlet}
+ *
+ * @author pb
+ */
+public class WebLogServlet extends BebopApplicationServlet {
+
+ /** Logger instance for debugging */
+ private static final Logger s_log = Logger.getLogger(WebLogServlet.class);
+
+ /**
+ * User extension point used to create the pages to server and setup a
+ * URL - page mapping.
+ *
+ * @throws ServletException
+ */
+ @Override
+ public void doInit() throws ServletException {
+ s_log.debug(" Initialize WebLogServlet ...");
+
+ Page indexPage = new WebLogPage();
+ put("/",indexPage);
+ put("/index.jsp",indexPage);
+
+ }
+
+}
diff --git a/ccm-weblog/src/overview.html b/ccm-weblog/src/overview.html
new file mode 100755
index 000000000..4d152c4c3
--- /dev/null
+++ b/ccm-weblog/src/overview.html
@@ -0,0 +1,90 @@
+
+
+
+ Package WebLog
+
+ 1. Purpose
+
+ Weblog provides a Blogging facility. The package provides a portlet
+ (“WebLog Portlet”) to display and edit a blog. Each blogging entry
+ has the structure of an CCM article: Title, lead, and body. A reader
+ can create comments to each blogging entry.
+
+
+
+ 2. Status
+
+ Under evaluation.
+
+
+
+ Application is supported by the default internal theme, not by the
+ APLAWS standard theme. Currently only English is available for public
+ site and admin UI.
+
+
+
+ Recommendations
¶
+
+ The application requires a portal to display the blog. So the site must
+ at least use one portal page (e.g. the front page at root).
+
+
+ As an alternative the blog can be displayed on its own page, but can not
+ be integrated into the navigation menue (Navigation application).
+
+
+
+ Additional Application Details
+
+ By default the blogging page shows a list of all blog entries by title
+ and lead (abstract) and provides a “more” link the a details page which
+ contains the complete text and all comments. This page enables the reader
+ to add a comment.
+
+
+ Currently no information about permission management!
+
+
+
+ Usage
+
+ Before a blog can be used, an instance of WebLog must be created using
+ one of the administration facilities. By default one instance is created
+ at admin/blog, e.g. http://my.domain/ccm/admin/blog.
+
+
+ To display the blog on a portal page, an instance of WebLog portlet must
+ be installed on a portal page. It's installation UI provides (besides the
+ standard properties title and description) a drop-down list to select the
+ list provider, “/admin/blog” in case of the default installation in the
+ above example.
+
+
+ For each additional, separate blog it is necessary to install an additional
+ WebLog instance. This may be done using the UI at ~/portal/admin/sitemap.jsp
+ or the administration UI of portalserver's ~/ccm/administration portal page.
+ It is good practice to install the WebLog UI beyond admin of eventually
+ the default content section.
+
+
+ Guess: An instance may not installed as root application.
+
+
+ Additional instances of WebLog portlet have to be installed with (one of)
+ the additionally installed WebLog application instance(s) selected as
+ provider.
+
+
+
+ Last modified: $Date: 2012/03/28 $
+
+
+
+
diff --git a/ccm-weblog/web/WEB-INF/web.ccm-weblog.xml b/ccm-weblog/web/WEB-INF/web.ccm-weblog.xml
new file mode 100644
index 000000000..3f5e848a7
--- /dev/null
+++ b/ccm-weblog/web/WEB-INF/web.ccm-weblog.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+ weblog
+ org.undp.weblog.WebLogServlet
+
+
+
+ weblog
+ /weblog/*
+
+
+
\ No newline at end of file
diff --git a/ccm-weblog/web/__ccm__/apps/weblog/xsl/index.xsl b/ccm-weblog/web/__ccm__/apps/weblog/xsl/index.xsl
deleted file mode 100755
index ffff230e6..000000000
--- a/ccm-weblog/web/__ccm__/apps/weblog/xsl/index.xsl
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
diff --git a/ccm-weblog/web/themes/heirloom/apps/weblog/xsl/index.xsl b/ccm-weblog/web/themes/heirloom/apps/weblog/xsl/index.xsl
new file mode 100755
index 000000000..95a638292
--- /dev/null
+++ b/ccm-weblog/web/themes/heirloom/apps/weblog/xsl/index.xsl
@@ -0,0 +1,7 @@
+
+
+
+
+
+
diff --git a/ccm-weblog/web/packages/weblog/xsl/weblog-portlet.xsl b/ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog-portlet.xsl
similarity index 72%
rename from ccm-weblog/web/packages/weblog/xsl/weblog-portlet.xsl
rename to ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog-portlet.xsl
index 177b4fec9..0c28b0dda 100755
--- a/ccm-weblog/web/packages/weblog/xsl/weblog-portlet.xsl
+++ b/ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog-portlet.xsl
@@ -1,12 +1,11 @@
-
+
diff --git a/ccm-weblog/web/packages/weblog/xsl/weblog.xsl b/ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog.xsl
similarity index 85%
rename from ccm-weblog/web/packages/weblog/xsl/weblog.xsl
rename to ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog.xsl
index 6c0dcaead..0e7bd53e1 100755
--- a/ccm-weblog/web/packages/weblog/xsl/weblog.xsl
+++ b/ccm-weblog/web/themes/heirloom/packages/weblog/xsl/weblog.xsl
@@ -1,11 +1,9 @@
-
-