diff --git a/ccm-portlet-latestnews/application.xml b/ccm-portlet-latestnews/application.xml
new file mode 100644
index 000000000..19181345e
--- /dev/null
+++ b/ccm-portlet-latestnews/application.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Portlet either displays the latest news content, or the latest personalised items
+
+
diff --git a/ccm-portlet-latestnews/pdl/com/arsdigita/portlet/NewsPortlet.pdl b/ccm-portlet-latestnews/pdl/com/arsdigita/portlet/NewsPortlet.pdl
new file mode 100644
index 000000000..fee477421
--- /dev/null
+++ b/ccm-portlet-latestnews/pdl/com/arsdigita/portlet/NewsPortlet.pdl
@@ -0,0 +1,29 @@
+//
+// Copyright (C) 2003 Chris Gilbert 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
+
+
+// model for a portlet that displays the latest news
+
+model com.arsdigita.portlet;
+
+import com.arsdigita.portal.Portlet;
+
+object type NewsPortlet extends Portlet {
+ Integer[0..1] itemCount = portlet_news.item_count INTEGER;
+
+ reference key (portlet_news.portlet_id);
+}
diff --git a/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/oracle-se-create.sql b/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/oracle-se-create.sql
new file mode 100644
index 000000000..1c59f651a
--- /dev/null
+++ b/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/oracle-se-create.sql
@@ -0,0 +1,2 @@
+@ ddl/oracle-se/create.sql
+@ ddl/oracle-se/deferred.sql
diff --git a/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/postgres-create.sql b/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/postgres-create.sql
new file mode 100644
index 000000000..2a326455c
--- /dev/null
+++ b/ccm-portlet-latestnews/sql/ccm-portlet-latestnews/postgres-create.sql
@@ -0,0 +1,4 @@
+begin;
+\i ddl/postgres/create.sql
+\i ddl/postgres/deferred.sql
+end;
diff --git a/ccm-portlet-latestnews/src/ccm-portlet-latestnews.config b/ccm-portlet-latestnews/src/ccm-portlet-latestnews.config
new file mode 100644
index 000000000..51fcef4fd
--- /dev/null
+++ b/ccm-portlet-latestnews/src/ccm-portlet-latestnews.config
@@ -0,0 +1,5 @@
+
+
+
+
diff --git a/ccm-portlet-latestnews/src/ccm-portlet-latestnews.load b/ccm-portlet-latestnews/src/ccm-portlet-latestnews.load
new file mode 100644
index 000000000..50bd7d8f3
--- /dev/null
+++ b/ccm-portlet-latestnews/src/ccm-portlet-latestnews.load
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Initializer.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Initializer.java
new file mode 100644
index 000000000..290fc61f9
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Initializer.java
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2003 Chris Gilbert 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.portlet.news;
+
+import com.arsdigita.bebop.RequestLocal;
+import com.arsdigita.db.DbHelper;
+import com.arsdigita.domain.DomainObject;
+import com.arsdigita.kernel.ACSObjectInstantiator;
+import com.arsdigita.kernel.ResourceType;
+import com.arsdigita.kernel.ResourceTypeConfig;
+import com.arsdigita.kernel.ui.ResourceConfigFormSection;
+import com.arsdigita.persistence.DataObject;
+import com.arsdigita.persistence.pdl.ManifestSource;
+import com.arsdigita.persistence.pdl.NameFilter;
+import com.arsdigita.portal.PortletType;
+import com.arsdigita.runtime.CompoundInitializer;
+import com.arsdigita.runtime.DomainInitEvent;
+import com.arsdigita.runtime.PDLInitializer;
+import com.arsdigita.runtime.RuntimeConfig;
+
+import com.arsdigita.portlet.news.ui.NewsPortletEditor;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * based on com.arsdigita.london.portal.installer.portlet
+ * @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: Initializer.java,v 1.2 2005/03/07 13:48:49 cgyg9330 Exp $
+ */
+public class Initializer extends CompoundInitializer {
+
+ /** Private Logger instance for debugging purpose. */
+ private static final Logger s_log = Logger.getLogger(Initializer.class);
+
+ public Initializer() {
+ final String url = RuntimeConfig.getConfig().getJDBCURL();
+ final int database = DbHelper.getDatabaseFromURL(url);
+
+ add(
+ new PDLInitializer(
+ new ManifestSource(
+ "ccm-portlet-latestnews.pdl.mf",
+ new NameFilter(
+ DbHelper.getDatabaseSuffix(database),
+ "pdl"))));
+ }
+
+ /**
+ *
+ * @param e
+ */
+ @Override
+ public void init(DomainInitEvent e) {
+ super.init(e);
+
+
+ /* Register portlet with the domain coupling machinery */
+ e.getFactory().registerInstantiator(
+ NewsPortlet.BASE_DATA_OBJECT_TYPE,
+ new ACSObjectInstantiator() {
+ @Override
+ public DomainObject doNewInstance(DataObject dataObject) {
+ return new NewsPortlet(dataObject);
+ }
+ });
+
+
+ /* */
+ new ResourceTypeConfig(NewsPortlet.BASE_DATA_OBJECT_TYPE) {
+ @Override
+ public ResourceConfigFormSection getCreateFormSection(
+ final ResourceType resType,
+ final RequestLocal parentAppRL) {
+ final ResourceConfigFormSection config = new
+ NewsPortletEditor(resType, parentAppRL);
+ return config;
+ }
+
+ @Override
+ public ResourceConfigFormSection getModifyFormSection(
+ final RequestLocal application) {
+ final NewsPortletEditor config = new
+ NewsPortletEditor(application);
+ return config;
+ }
+ };
+
+ /* Register internal default themes's stylesheet which concomitantly
+ * serves as a fallback if a custom theme is used without supporting
+ * this portlet. */
+ PortletType.registerXSLFile(
+ NewsPortlet.BASE_DATA_OBJECT_TYPE,
+ PortletType.INTERNAL_THEME_PORTLET_DIR + "news-portlet.xsl");
+
+ }
+}
\ No newline at end of file
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader.java
new file mode 100644
index 000000000..79ed75c0d
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2003 Chris Gilbert 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.portlet.news;
+
+import com.arsdigita.kernel.Kernel;
+import com.arsdigita.kernel.KernelExcursion;
+import com.arsdigita.loader.PackageLoader;
+import com.arsdigita.portal.PortletType;
+import com.arsdigita.runtime.ScriptContext;
+import com.arsdigita.util.parameter.Parameter;
+import com.arsdigita.util.parameter.StringParameter;
+
+import org.apache.log4j.Logger;
+
+
+
+/**
+ *
+ * @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: Loader.java, 2005/02/28 16:28:49 cgyg9330 $
+ */
+public class Loader extends PackageLoader {
+
+ private static final Logger s_log = Logger.getLogger(Loader.class);
+
+ private StringParameter typeName = new StringParameter
+ ("uk.gov.westsussex.portlet.news.name",
+ Parameter.REQUIRED, "News");
+
+ public Loader() {
+ register(typeName);
+
+ }
+ public void run(final ScriptContext ctx) {
+ new KernelExcursion() {
+ public void excurse() {
+ setEffectiveParty(Kernel.getSystemParty());
+ PortletType type = PortletType
+ .createPortletType((String)get(typeName),
+ PortletType.WIDE_PROFILE,
+ NewsPortlet.BASE_DATA_OBJECT_TYPE);
+ type.setDescription("See your personalised news");
+ }
+ }.run();
+ }
+
+
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader_parameter.properties b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader_parameter.properties
new file mode 100644
index 000000000..8ee7ac908
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/Loader_parameter.properties
@@ -0,0 +1,5 @@
+uk.gov.westsussex.portlet.news.name.title=Portlet Type Name
+uk.gov.westsussex.portlet.news.name.purpose=The name of the portlet type that appears in the drop down list of portlet types
+uk.gov.westsussex.portlet.news.name.example=News
+uk.gov.westsussex.portlet.news.name.format=[string]
+
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsConstants.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsConstants.java
new file mode 100644
index 000000000..d886518db
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsConstants.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2003 - 2004 Chris Gilbert 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.portlet.news;
+
+
+/**
+ * Constants used by classes in the news portlet application.
+ *
+ * @author cgyg9330
+ */
+ public interface NewsConstants {
+
+
+
+ public static final String ITEM_COUNT = "itemCount";
+
+
+
+ public static final String GENERAL_NEWS_CACHE_KEY = "generalNews";
+
+ //queries
+ public static final String RECENT_NEWS =
+ "uk.gov.westsussex.portal.portlet.RecentNews";
+ public static final String PERSONALISED_NEWS =
+ "uk.gov.westsussex.portal.portlet.PersonalisedNews";
+ public static final String LAST_UPDATE =
+ "uk.gov.westsussex.portal.portlet.LatestNewsDate";
+
+
+
+
+
+ // rendering
+
+ public static final String XML_NEWS_NS = "http://wsgfl.westsussex.gov.uk/portlet/news/1.0";
+ public static final String MAIN_PORTLET_ELEMENT = "portlet:news";
+ public static final String NEWS_ITEM_ELEMENT = "news-portlet:newsItem";
+ public static final String NEWS_ROOM_ATTRIBUTE = "newsroom-shortcut";
+ public static final String PERSONALISED_ATTRIBUTE = "personalised";
+ public static final String DATE_ATTRIBUTE = "date";
+ public static final String TITLE_ATTRIBUTE = "title";
+ public static final String LEAD_ATTRIBUTE = "lead";
+ public static final String URL_ATTRIBUTE = "url";
+
+
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortlet.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortlet.java
new file mode 100644
index 000000000..7daa4ff88
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortlet.java
@@ -0,0 +1,126 @@
+/*
+ * Copyright (C) 2003 Chris Gilbert 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.portlet.news;
+
+import java.math.BigDecimal;
+// import java.util.Date;
+
+import com.arsdigita.portlet.news.ui.NewsPortletRenderer;
+
+import com.arsdigita.bebop.portal.AbstractPortletRenderer;
+// import com.arsdigita.cms.contenttypes.NewsItem;
+// import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.persistence.DataObject;
+// import com.arsdigita.persistence.SessionManager;
+import com.arsdigita.portal.Portlet;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ * List of news content types items, in descending order of date. The number
+ * of items retrieved is set by the administrator.
+ *
+ * @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: NewsPortlet.java, 2007/08/08 09:28:26 cgyg9330 $
+ */
+public class NewsPortlet extends Portlet implements NewsConstants {
+
+ /** Private Logger instance for debugging purpose. */
+ private static final Logger s_log = Logger.getLogger(NewsPortlet.class);
+
+ /** PDL stuff */
+ public static final String BASE_DATA_OBJECT_TYPE =
+ "com.arsdigita.portlet.NewsPortlet";
+
+ /**
+ * allows non personalised news page to be cached between updates
+ */
+ private static BigDecimal s_latestNews = new BigDecimal(0);
+ private static long s_newsCount = 0;
+
+
+ private static final NewsPortletConfig s_config = NewsPortletConfig.getConfig();
+
+ static {
+ s_config.load();
+ }
+
+ public static NewsPortletConfig getConfig() {
+ return s_config;
+ }
+
+
+ public NewsPortlet(DataObject dataObject) {
+ super(dataObject);
+ }
+
+
+ @Override
+ protected String getBaseDataObjectType() {
+ return BASE_DATA_OBJECT_TYPE;
+ }
+
+ @Override
+ protected AbstractPortletRenderer doGetPortletRenderer() {
+ return new NewsPortletRenderer(this);
+ }
+
+ public int getItemCount() {
+ return ((Integer) get(ITEM_COUNT)).intValue();
+ }
+
+ public void setItemCount(int count) {
+ set(ITEM_COUNT, new Integer(count));
+ }
+
+ /**
+ *
+ * @return whether any homepage news items have been added or edited since last checked.
+ * If news has been updated, the stored value of the last update is changed. Note
+ * deleted news items do not cause true to be returned.
+ *
+ */
+ /*
+ *
+ * starting to look doubtful whether this would actually save any time
+ *
+ * will recheck when more data on database
+ public boolean isNewNews() {
+ NewsItem latest = NewsItem.getMostRecentNewsItem();
+
+ if (!latest.getID().equals(s_latestNews)) {
+ s_latestNews = latest.getID();
+ return true;
+ }
+ DataCollection news = SessionManager.getSession().retrieve(NewsItem.BASE_DATA_OBJECT_TYPE);
+ news.addEqualsFilter(NewsItem.IS_HOMEPAGE, new Boolean(true));
+ long newsCount = news.size();
+ if (newsCount != s_newsCount) {
+ s_newsCount = newsCount;
+ return true;
+ }
+ return false;
+
+
+
+ }*/
+
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig.java
new file mode 100644
index 000000000..8a701cc82
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2003 - 2004 Chris Gilbert 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.portlet.news;
+
+import com.arsdigita.runtime.AbstractConfig;
+// import com.arsdigita.util.parameter.IntegerParameter;
+import com.arsdigita.util.parameter.Parameter;
+// import com.arsdigita.util.parameter.StringArrayParameter;
+// import com.arsdigita.util.parameter.URLParameter;
+import com.arsdigita.util.parameter.StringParameter;
+// import com.arsdigita.util.UncheckedWrapperException;
+
+// import java.io.InputStream;
+// import java.io.IOException;
+// import java.net.URL;
+// import java.net.MalformedURLException;
+import org.apache.log4j.Logger;
+
+/**
+ * Specification of datasources required by Atomwide application
+ *
+ * @author Chris Gilbert <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: NewsPortletConfig.java,v 1.1 2005/03/07 13:48:49 cgyg9330 Exp $
+ */
+public class NewsPortletConfig extends AbstractConfig {
+
+ /** A logger instance to assist debugging. */
+ private static final Logger s_log = Logger.getLogger(NewsPortletConfig.class);
+
+ /** Singelton config object. */
+ private static NewsPortletConfig s_conf;
+
+ /**
+ * Gain a NewsPortletConfig object.
+ *
+ * Singelton pattern, don't instantiate a config object using the
+ * constructor directly!
+ * use RSSFeedConfig.getConfig(); instead
+ * @return
+ */
+ public static synchronized NewsPortletConfig getConfig() {
+ if (s_conf == null) {
+ s_conf = new NewsPortletConfig();
+ s_conf.load();
+ }
+
+ return s_conf;
+ }
+
+
+ // ////////////////////////////////////////////////////////////////////////
+ // Set of configuration parameters
+
+ /** */
+ private final Parameter newsroomShortcut = new StringParameter
+ ( "com.arsdigita.portlet.news.newsroom-shortcut",
+ Parameter.REQUIRED,
+ "/news");
+
+ /**
+ * Constructor initializes class.
+ */
+ public NewsPortletConfig() {
+
+ register(newsroomShortcut);
+ loadInfo();
+ }
+
+
+ /**
+ * Getter newsroom shortcut parameter
+ */
+ public final String getNewsroomShortcut() {
+ return (String)get(newsroomShortcut);
+ }
+
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig_parameter.properties b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig_parameter.properties
new file mode 100644
index 000000000..78c9a49dd
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/NewsPortletConfig_parameter.properties
@@ -0,0 +1,4 @@
+com.artsdigita.portlet.news.newsroom-shortcut.title=Newsroom Shortcut
+com.artsdigita.portlet.news.newsroom-shortcut.purpose=used as a link at the bottom of the news portlet
+com.artsdigita.portlet.news.newsroom-shortcut.example=/news
+com.artsdigita.portlet.news.newsroom-shortcut.format=[string]
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/PersonalisedNewsTarget.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/PersonalisedNewsTarget.java
new file mode 100644
index 000000000..4f35433ab
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/PersonalisedNewsTarget.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2005 Chris Gilbert 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.portlet.news;
+
+import com.arsdigita.domain.DomainCollection;
+
+/**
+ * Service is used by news portlet to display potentially useful articles
+ * to the user.
+ *
+ * An implementation will require a mapping between content pages and some
+ * attributes of the user. In the atomwide authentication module, user profile
+ * values are modelled as terms in domains mapped to /content/ and so authors
+ * may specify which user groups their articles are to be promoted to
+ *
+ * @author chris.gilbert@westsussex.gov.uk
+ */
+ public interface PersonalisedNewsTarget {
+
+ /**
+ *
+ * @return a domainCollection of com.arsdigita.cms.ContentPage objects
+ */
+ public DomainCollection getMyNews();
+
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletEditor.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletEditor.java
new file mode 100644
index 000000000..83300b7ad
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletEditor.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2003 - 2004 Chris Gilbert 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.portlet.news.ui;
+
+import com.arsdigita.bebop.ColumnPanel;
+import com.arsdigita.bebop.FormProcessException;
+import com.arsdigita.bebop.Label;
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.RequestLocal;
+import com.arsdigita.bebop.form.TextField;
+import com.arsdigita.bebop.parameters.IntegerValidationListener;
+import com.arsdigita.bebop.parameters.StringParameter;
+import com.arsdigita.bebop.portal.PortletConfigFormSection;
+import com.arsdigita.kernel.ResourceType;
+import com.arsdigita.portal.Portlet;
+
+import com.arsdigita.portlet.news.NewsPortlet;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ *
+ *
+ * @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: NewsPortletEditor.java 2005/03/07 13:48:49 cgyg9330 Exp $
+ */
+public class NewsPortletEditor extends PortletConfigFormSection {
+
+ private TextField m_itemCount;
+ private static final Logger s_log = Logger.getLogger(NewsPortletEditor.class);
+
+
+ /**
+ * Constructor
+ *
+ * @param resType
+ * @param parentAppRL
+ */
+ public NewsPortletEditor(ResourceType resType, RequestLocal parentAppRL) {
+ super(resType, parentAppRL);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param application
+ */
+ public NewsPortletEditor(RequestLocal application) {
+ super(application);
+ }
+
+
+ /**
+ *
+ */
+ @Override
+ protected void addWidgets() {
+ super.addWidgets();
+
+ m_itemCount =
+ new TextField(new StringParameter(NewsPortlet.ITEM_COUNT));
+
+ add(new Label("Number of items:", Label.BOLD), ColumnPanel.RIGHT);
+
+ m_itemCount.addValidationListener(new IntegerValidationListener());
+
+ add(m_itemCount);
+
+ }
+
+
+ /**
+ *
+ * @param state
+ * @param portlet
+ * @throws FormProcessException
+ *
+ * TODO: add validation or set up drop down list with contents of Static folder?
+ */
+ @Override
+ protected void initWidgets(PageState state, Portlet portlet)
+ throws FormProcessException {
+ super.initWidgets(state, portlet);
+
+ if (portlet != null) {
+ NewsPortlet myportlet = (NewsPortlet) portlet;
+
+ m_itemCount.setValue(state, myportlet.getItemCount()+ "");
+ }
+ }
+
+
+ /**
+ *
+ * @param state
+ * @param portlet
+ * @throws FormProcessException
+ */
+ @Override
+ protected void processWidgets(PageState state, Portlet portlet)
+ throws FormProcessException {
+ s_log.debug("START processWidgets");
+ super.processWidgets(state, portlet);
+
+ NewsPortlet myportlet = (NewsPortlet) portlet;
+ myportlet.setItemCount(new Integer(
+ (String) m_itemCount.getValue(state)).intValue());
+ s_log.debug("END processWidgets");
+ }
+}
diff --git a/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletRenderer.java b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletRenderer.java
new file mode 100644
index 000000000..24b5f0ce4
--- /dev/null
+++ b/ccm-portlet-latestnews/src/com/arsdigita/portlet/news/ui/NewsPortletRenderer.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2003 - 2004 Chris Gilbert 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.portlet.news.ui;
+
+//import uk.gov.westsussex.authentication.ExternalUserFactory;
+import com.arsdigita.portlet.news.NewsConstants;
+import com.arsdigita.portlet.news.NewsPortlet;
+import com.arsdigita.portlet.news.PersonalisedNewsTarget;
+
+import com.arsdigita.bebop.PageState;
+import com.arsdigita.bebop.portal.AbstractPortletRenderer;
+import com.arsdigita.categorization.Category;
+import com.arsdigita.cms.ContentItem;
+import com.arsdigita.cms.ContentPage;
+import com.arsdigita.cms.SecurityManager;
+import com.arsdigita.domain.DomainCollection;
+import com.arsdigita.domain.DomainObjectFactory;
+import com.arsdigita.kernel.Kernel;
+import com.arsdigita.kernel.User;
+import com.arsdigita.kernel.permissions.PermissionService;
+import com.arsdigita.kernel.permissions.PrivilegeDescriptor;
+import com.arsdigita.navigation.Navigation;
+// import com.arsdigita.portalworkspace.ui.PortalConstants;
+import com.arsdigita.london.terms.Domain;
+import com.arsdigita.london.terms.Term;
+import com.arsdigita.persistence.DataCollection;
+import com.arsdigita.persistence.SessionManager;
+import com.arsdigita.portal.PortletType;
+import com.arsdigita.xml.Element;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import org.apache.log4j.Logger;
+
+
+/**
+ *
+ *
+ * @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
+ * @version $Id: NewsPortletRenderer.java 2005/03/07 13:48:49 cgyg9330 Exp $
+ */
+public class NewsPortletRenderer extends AbstractPortletRenderer
+ implements NewsConstants {
+
+ private static final Logger s_log =
+ Logger.getLogger(NewsPortletRenderer.class);
+
+ private NewsPortlet m_portlet;
+
+
+ /**
+ *
+ * @param portlet
+ */
+ public NewsPortletRenderer(NewsPortlet portlet) {
+ m_portlet = portlet;
+ }
+
+ /* (non-Javadoc)
+ * @see
+ * com.arsdigita.bebop.portal.AbstractPortletRenderer#generateBodyXML(
+ * com.arsdigita.bebop.PageState,
+ * com.arsdigita.xml.Element)
+ */
+ protected void generateBodyXML(PageState state, Element parent) {
+ s_log.debug("START - generateBodyXML");
+
+ Element newsPortlet = parent.newChildElement( MAIN_PORTLET_ELEMENT,
+ PortletType.PORTLET_XML_NS);
+ DateFormat formatter = new SimpleDateFormat("dd/MM/yy");
+ User thisUser = (User) Kernel.getContext().getParty();
+ if (null == thisUser) {
+ thisUser = Kernel.getPublicUser();
+ }
+
+// Object customUser = ExternalUserFactory.getCustomUserObject(thisUser);
+// if (customUser instanceof PersonalisedNewsTarget) {
+// newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "true");
+// getPersonalisedNews(
+// state,
+// newsPortlet,
+// (PersonalisedNewsTarget) customUser,
+// formatter);
+//
+// } else {
+ newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "false");
+ getGeneralNews(newsPortlet, formatter);
+
+// }
+
+ newsPortlet.addAttribute(NEWS_ROOM_ATTRIBUTE,
+ NewsPortlet.getConfig().getNewsroomShortcut());
+
+ s_log.debug("FINISH - generateBodyXML");
+ }
+
+ /**
+ * @param newsPortlet
+ * @param profiledUser
+ */
+/* CURRENTLY NOT AVAILABLE
+ private void getPersonalisedNews( PageState state,
+ Element main,
+ PersonalisedNewsTarget profiledUser,
+ DateFormat formatter) {
+ s_log.debug("START - getPersonalisedNews");
+
+ DomainCollection myNews = profiledUser.getMyNews();
+ if (myNews == null) {
+ // method in personalised user class has been implemented to just return null
+ getGeneralNews(main, formatter);
+ return;
+ }
+
+ myNews.addOrder(ContentPage.LAUNCH_DATE + " desc");
+
+ PermissionService.filterObjects(
+ myNews,
+ PrivilegeDescriptor.get(SecurityManager.CMS_READ_ITEM),
+ Kernel.getContext().getParty().getOID());
+
+ myNews.setRange(
+ new Integer(1),
+ new Integer(m_portlet.getItemCount() + 1));
+
+ while (myNews.next()) {
+ ContentPage page = (ContentPage) myNews.getDomainObject();
+
+ Element item = main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
+ Date d = page.getLaunchDate();
+ String date = (d != null) ? formatter.format(d) : "";
+ item.addAttribute(DATE_ATTRIBUTE, date);
+
+ item.addAttribute(TITLE_ATTRIBUTE, page.getTitle());
+ item.addAttribute(LEAD_ATTRIBUTE, page.getSearchSummary());
+ item.addAttribute(
+ URL_ATTRIBUTE,
+ Navigation.redirectURL(page.getOID()));
+
+ }
+ s_log.debug("END - getPersonalisedNews");
+
+ }
+*/
+
+
+ private void getGeneralNews(Element main, DateFormat formatter) {
+ s_log.debug("START - getGeneralNews");
+
+ // this is the default key - maybe should parametrise
+ Domain rss = Domain.retrieve("APLAWS-RSS");
+ DomainCollection rssRoots = rss.getRootTerms();
+ rssRoots.addEqualsFilter(Term.NAME, "News");
+ Term newsTerm = null;
+ while (rssRoots.next()) {
+ newsTerm = (Term) rssRoots.getDomainObject();
+ s_log.debug("found the news rss feed term");
+ Category cat = newsTerm.getModel();
+ DataCollection newsItems = SessionManager.getSession()
+ .retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
+ newsItems.addEqualsFilter("parent.categories.id",
+ cat.getID());
+
+ newsItems.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
+ newsItems.addOrder(ContentPage.LAUNCH_DATE + " desc");
+
+ // CategorizedCollection newsItems =
+ // cat.getObjects(ContentPage.BASE_DATA_OBJECT_TYPE);
+ s_log.debug("total items = " + newsItems.size());
+ newsItems.setRange(
+ new Integer(1),
+ new Integer(m_portlet.getItemCount() + 1));
+
+ ContentPage newsItem = null;
+ while (newsItems.next()) {
+ Element item =
+ main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
+ //newsItem = (ContentPage) newsItems.getDomainObject();
+ newsItem = (ContentPage)DomainObjectFactory
+ .newInstance(newsItems.getDataObject());
+ Date d = newsItem.getLaunchDate();
+ String date = (d != null) ? formatter.format(d) : "";
+ item.addAttribute(DATE_ATTRIBUTE, date);
+
+ item.addAttribute(TITLE_ATTRIBUTE, newsItem.getTitle());
+
+ item.addAttribute(LEAD_ATTRIBUTE, newsItem.getSearchSummary());
+ item.addAttribute(
+ URL_ATTRIBUTE,
+ Navigation.redirectURL(newsItem.getOID()));
+
+ }
+ }
+
+ s_log.debug("END - getGeneralNews");
+ }
+
+
+ /*
+ public Object getCacheKey() {
+
+ if (getProfiledUser() == null) {
+ return GENERAL_NEWS_CACHE_KEY;
+ } else {
+
+
+ return m_portlet.getID();
+ }
+ }
+
+ // is dirty if edited, as this means the number of entries has changed.
+ // For non personalised news, dirty if homepage
+ // newsitems are added or edited.
+ // For personalised, dirty if pushed items added or edited.
+
+ public boolean isDirty() {
+
+
+ // has it been edited? - add in this condition when response
+ // from Redhat about AbstractPortletRenderer
+
+ // if not has news changed
+ if (getCacheKey().equals(GENERAL_NEWS_CACHE_KEY)) {
+ isDirty = m_portlet.isNewNews();
+ s_log.debug("general news: dirty? " + isDirty);
+
+ } else {
+ // implement later
+ isDirty = true;
+ }
+ }
+ return isDirty;
+ */
+ }
diff --git a/ccm-portlet-latestnews/web/themes/heirloom/images/portlets/news_arrow.gif b/ccm-portlet-latestnews/web/themes/heirloom/images/portlets/news_arrow.gif
new file mode 100644
index 000000000..08835787c
Binary files /dev/null and b/ccm-portlet-latestnews/web/themes/heirloom/images/portlets/news_arrow.gif differ
diff --git a/ccm-portlet-latestnews/web/themes/heirloom/portlets/news-portlet.xsl b/ccm-portlet-latestnews/web/themes/heirloom/portlets/news-portlet.xsl
new file mode 100644
index 000000000..113141f02
--- /dev/null
+++ b/ccm-portlet-latestnews/web/themes/heirloom/portlets/news-portlet.xsl
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+