WebLog legacy free. Update nicht erforderlich, da bisher nicht benutzt. Dokumentation hinzugefügt.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1557 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2012-03-28 06:42:21 +00:00
parent c2a160ae6b
commit d7327b5e9a
12 changed files with 408 additions and 100 deletions

View File

@ -9,5 +9,6 @@
</provides>
<scripts>
<schema directory="ccm-weblog"/>
<data class="org.undp.weblog.Loader"/>
</scripts>
</load>

View File

@ -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();
}
}

View File

@ -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.</p>
*
* @author pboy &lt;pboy@barkhof.uni-bremen.de&gt;
* @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.");
}
}

View File

@ -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";
}
}

View File

@ -0,0 +1,63 @@
/*
* Copyright (C) 2012 Peter Boy <pb@zes.uni-bremen.de> 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);
}
}

View File

@ -0,0 +1,90 @@
<html>
<!--
README: This HTML page is the overview documentation comment for the
entire Core; javadoc copies everything inside the &lt;body&gt; into
the front page of the HTML documentation it produces.
-->
<body>
<h1>Package WebLog</h1>
<h2>1. Purpose</h2>
<p>
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.
</p>
<h2>2. Status</h2>
<p>
Under evaluation.
</p>
<p>
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.
</p>
<h2>Recommendations </h2>
<p>
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).
</p>
<p>
As an alternative the blog can be displayed on its own page, but can not
be integrated into the navigation menue (Navigation application).
</p>
<h2>Additional Application Details</h2>
<p>
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.
</p>
<p>
Currently no information about permission management!
</p>
<h2>Usage</h2>
<p>
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.
</p>
<p>
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.
</p>
<p>
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.
</p>
<p>
<b>Guess:</b> An instance may not installed as root application.
</p>
<p>
Additional instances of WebLog portlet have to be installed with (one of)
the additionally installed WebLog application instance(s) selected as
provider.
</p>
<p>
Last modified: $Date: 2012/03/28 $
</p>
</body>
</html>

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">
<!-- Servlets for the weblog application -->
<servlet>
<servlet-name>weblog</servlet-name>
<servlet-class>org.undp.weblog.WebLogServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>weblog</servlet-name>
<url-pattern>/weblog/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="../../../../packages/weblog/xsl/weblog.xsl"/>
</xsl:stylesheet>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:import href="../../../packages/weblog/xsl/weblog.xsl"/>
</xsl:stylesheet>

View File

@ -1,12 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:forum="http://www.arsdigita.com/forum/1.0"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:portlet="http://www.uk.arsdigita.com/portlet/1.0"
xmlns:portal="http://www.uk.arsdigita.com/portal/1.0"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
version="1.0">
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:forum="http://www.arsdigita.com/forum/1.0"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:portlet="http://www.uk.arsdigita.com/portlet/1.0"
xmlns:portal="http://www.uk.arsdigita.com/portal/1.0"
xmlns:ui="http://www.arsdigita.com/ui/1.0"
version="1.0">
<xsl:output method="html"/>

View File

@ -1,11 +1,9 @@
<?xml version="1.0"?>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:weblog="http://www.undp.org/weblog/1.0"
xmlns:unport="http://www.undp.org/unport/1.0"
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:bebop="http://www.arsdigita.com/bebop/1.0"
xmlns:weblog="http://www.undp.org/weblog/1.0"
xmlns:unport="http://www.undp.org/unport/1.0"
version="1.0"
>
<xsl:import href="../../bebop/xsl/bebop.xsl"/>