Minor fixes, added documentation, improved formatting.
git-svn-id: https://svn.libreccm.org/ccm/trunk@2072 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
18196e775a
commit
91c2b394a5
|
|
@ -228,7 +228,7 @@ waf.admin.password=lib2000
|
||||||
waf.admin.password.question=12345
|
waf.admin.password.question=12345
|
||||||
waf.admin.password.answer=6
|
waf.admin.password.answer=6
|
||||||
|
|
||||||
waf.runtime.jdbc_url=jdbc\:postgresql\://localhost/openccm?user\=ccm&password\=ccm42web
|
waf.runtime.jdbc_url=jdbc\:postgresql\://localhost/ccm?user\=ccm&password\=ccm42web
|
||||||
waf.runtime.jdbc_pool_size=40
|
waf.runtime.jdbc_pool_size=40
|
||||||
|
|
||||||
waf.web.server=localhost\:8080
|
waf.web.server=localhost\:8080
|
||||||
|
|
|
||||||
|
|
@ -66,19 +66,25 @@
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
|
|
||||||
<!-- Content Assets -->
|
<!-- Content Assets -->
|
||||||
|
<!--
|
||||||
<ccm:application name="ccm-cms-assets-fileattachment"/>
|
<ccm:application name="ccm-cms-assets-fileattachment"/>
|
||||||
<ccm:application name="ccm-cms-assets-notes"/>
|
<ccm:application name="ccm-cms-assets-notes"/>
|
||||||
|
-->
|
||||||
<!-- Content Types -->
|
<!-- Content Types -->
|
||||||
<ccm:application name="ccm-cms-types-bookmark"/>
|
<ccm:application name="ccm-cms-types-bookmark"/>
|
||||||
|
<!--
|
||||||
<ccm:application name="ccm-cms-types-event"/>
|
<ccm:application name="ccm-cms-types-event"/>
|
||||||
<ccm:application name="ccm-cms-types-image"/>
|
<ccm:application name="ccm-cms-types-image"/>
|
||||||
<ccm:application name="ccm-cms-types-mparticle"/>
|
<ccm:application name="ccm-cms-types-mparticle"/>
|
||||||
|
-->
|
||||||
<ccm:application name="ccm-cms-types-newsitem"/>
|
<ccm:application name="ccm-cms-types-newsitem"/>
|
||||||
|
<!--
|
||||||
<ccm:application name="ccm-cms-types-person"/>
|
<ccm:application name="ccm-cms-types-person"/>
|
||||||
|
-->
|
||||||
<!-- Applications -->
|
<!-- Applications -->
|
||||||
|
<!--
|
||||||
<ccm:application name="ccm-cms-publicpersonalprofile"/>
|
<ccm:application name="ccm-cms-publicpersonalprofile"/>
|
||||||
|
-->
|
||||||
|
|
||||||
<!-- LDN extension -->
|
<!-- LDN extension -->
|
||||||
<!-- temporarily excluded because configuration issues have to be resolved
|
<!-- temporarily excluded because configuration issues have to be resolved
|
||||||
|
|
@ -117,9 +123,9 @@
|
||||||
<ccm:application name="ccm-bookmarks"/>
|
<ccm:application name="ccm-bookmarks"/>
|
||||||
<ccm:application name="ccm-docmgr"/>
|
<ccm:application name="ccm-docmgr"/>
|
||||||
<ccm:application name="ccm-docrepo"/>
|
<ccm:application name="ccm-docrepo"/>
|
||||||
-->
|
|
||||||
<ccm:application name="ccm-forum"/>
|
<ccm:application name="ccm-forum"/>
|
||||||
<ccm:application name="ccm-forum-categorised"/>
|
<ccm:application name="ccm-forum-categorised"/>
|
||||||
|
-->
|
||||||
<!--
|
<!--
|
||||||
<ccm:application name="ccm-portalserver"/>
|
<ccm:application name="ccm-portalserver"/>
|
||||||
<ccm:application name="ccm-weblog"/>
|
<ccm:application name="ccm-weblog"/>
|
||||||
|
|
@ -133,6 +139,12 @@
|
||||||
<ccm:application name="ccm-ldn-importer"/>
|
<ccm:application name="ccm-ldn-importer"/>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
|
<!-- Libre CMS modules under development -->
|
||||||
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
|
<ccm:application name="ccm-portlet-bookmarks"/>
|
||||||
|
<ccm:application name="ccm-portlet-latestnews"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
<!-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -->
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,11 @@ import org.apache.log4j.Logger;
|
||||||
* @see com.arsdigita.kernel.Resource
|
* @see com.arsdigita.kernel.Resource
|
||||||
* @author Justin Ross <<a href="mailto:jross@redhat.com">jross@redhat.com</a>>
|
* @author Justin Ross <<a href="mailto:jross@redhat.com">jross@redhat.com</a>>
|
||||||
* @author Eric Lorenzo
|
* @author Eric Lorenzo
|
||||||
|
* @version $Id: ResourceConfigFormSection.java 287 2005-02-22 00:29:02Z sskracic $
|
||||||
*/
|
*/
|
||||||
public abstract class ResourceConfigFormSection extends FormSection {
|
public abstract class ResourceConfigFormSection extends FormSection {
|
||||||
public static final String versionId =
|
|
||||||
"$Id: ResourceConfigFormSection.java 287 2005-02-22 00:29:02Z sskracic $" +
|
|
||||||
"$Author: sskracic $" +
|
|
||||||
"$DateTime: 2004/08/16 18:10:38 $";
|
|
||||||
|
|
||||||
|
/** Private logger instance for debugging purpose */
|
||||||
private static final Logger s_log = Logger.getLogger
|
private static final Logger s_log = Logger.getLogger
|
||||||
(ResourceConfigFormSection.class);
|
(ResourceConfigFormSection.class);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ import com.arsdigita.cms.ui.authoring.TextAssetBody.PageTextForm;
|
||||||
import com.arsdigita.kernel.ResourceType;
|
import com.arsdigita.kernel.ResourceType;
|
||||||
import com.arsdigita.portalworkspace.Workspace;
|
import com.arsdigita.portalworkspace.Workspace;
|
||||||
import com.arsdigita.portalworkspace.portlet.FreeformHTMLPortlet;
|
import com.arsdigita.portalworkspace.portlet.FreeformHTMLPortlet;
|
||||||
// @deprecated use com.arsdigita.bebop.portal.PortletConfigFormSection
|
|
||||||
// import com.arsdigita.london.portal.ui.PortletConfigFormSection;
|
|
||||||
import com.arsdigita.portal.Portlet;
|
import com.arsdigita.portal.Portlet;
|
||||||
|
|
||||||
public class FreeformHTMLPortletEditor extends PortletConfigFormSection {
|
public class FreeformHTMLPortletEditor extends PortletConfigFormSection {
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,11 @@ import com.arsdigita.bebop.parameters.StringInRangeValidationListener;
|
||||||
import com.arsdigita.bebop.parameters.StringParameter;
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
import com.arsdigita.kernel.ResourceType;
|
import com.arsdigita.kernel.ResourceType;
|
||||||
import com.arsdigita.portalworkspace.portlet.RSSFeedPortlet;
|
import com.arsdigita.portalworkspace.portlet.RSSFeedPortlet;
|
||||||
// @deprecated use com.arsdigita.bebop.portal.PortletConfigFormSection
|
|
||||||
// import com.arsdigita.london.portal.ui.PortletConfigFormSection;
|
|
||||||
import com.arsdigita.portal.Portlet;
|
import com.arsdigita.portal.Portlet;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author pb
|
* @author
|
||||||
*/
|
*/
|
||||||
public class RSSFeedPortletEditorForm extends PortletConfigFormSection {
|
public class RSSFeedPortletEditorForm extends PortletConfigFormSection {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
// author chris gilbert
|
// author chris gilbert
|
||||||
// model for a portlet that holds a list of bookmark links
|
// model for a portlet that holds a list of bookmark links
|
||||||
|
|
||||||
model uk.gov.westsussex.portlet;
|
// model uk.gov.westsussex.portlet;
|
||||||
|
model com.arsdigita.portlet;
|
||||||
|
|
||||||
import com.arsdigita.portal.Portlet;
|
import com.arsdigita.portal.Portlet;
|
||||||
import com.arsdigita.cms.contenttypes.Link;
|
import com.arsdigita.cms.contenttypes.Link;
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
public interface BookmarkConstants {
|
public interface BookmarkConstants {
|
||||||
|
|
||||||
public static final String BUNDLE_NAME = "uk.gov.westsussex.portlet.bookmarks.ui.BookmarkResources";
|
public static final String BUNDLE_NAME = "com.arsdigita.portlet.bookmarks.ui.BookmarkResources";
|
||||||
|
|
||||||
|
|
||||||
// bookmark portlet attributes
|
// bookmark portlet attributes
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ public class BookmarksPortlet extends Portlet implements BookmarkConstants {
|
||||||
public static final Logger s_log = Logger.getLogger(BookmarksPortlet.class);
|
public static final Logger s_log = Logger.getLogger(BookmarksPortlet.class);
|
||||||
|
|
||||||
public static final String BASE_DATA_OBJECT_TYPE =
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
"uk.gov.westsussex.portlet.BookmarksPortlet";
|
"com.arsdigita.portlet.BookmarksPortlet";
|
||||||
|
|
||||||
private static BookmarksPortletConfig s_config =
|
private static BookmarksPortletConfig s_config =
|
||||||
new BookmarksPortletConfig();
|
new BookmarksPortletConfig();
|
||||||
|
|
@ -103,15 +103,15 @@ public class BookmarksPortlet extends Portlet implements BookmarkConstants {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a url for an internal or external link - used for displaying
|
* Return a url for an internal or external link - used for displaying
|
||||||
* the link in edit view (we don't want to just display an item id
|
* the link in edit view (we don't want to just display an item id
|
||||||
* when the link is internal as that doesn't mean anything to non authors)
|
* when the link is internal as that doesn't mean anything to non authors)
|
||||||
*
|
*
|
||||||
* @param link
|
* @param link
|
||||||
* @param state
|
* @param state
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static String getURIForBookmark(Bookmark bookmark, PageState state) {
|
public static String getURIForBookmark(Bookmark bookmark, PageState state) {
|
||||||
|
|
||||||
String url = null;
|
String url = null;
|
||||||
|
|
|
||||||
|
|
@ -32,9 +32,9 @@ import com.arsdigita.util.parameter.Parameter;
|
||||||
*/
|
*/
|
||||||
public class BookmarksPortletConfig extends AbstractConfig {
|
public class BookmarksPortletConfig extends AbstractConfig {
|
||||||
|
|
||||||
private BooleanParameter checkPermissions = new BooleanParameter(
|
private BooleanParameter checkPermissions = new BooleanParameter(
|
||||||
"uk.gov.westsussex.portlet.bookmarks.checkPermissions",
|
"com.arsdigita.portlet.bookmarks.checkPermissions",
|
||||||
Parameter.REQUIRED, new Boolean(false));
|
Parameter.REQUIRED, new Boolean(false));
|
||||||
|
|
||||||
public BookmarksPortletConfig() {
|
public BookmarksPortletConfig() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ public class Initializer extends CompoundInitializer {
|
||||||
add(
|
add(
|
||||||
new PDLInitializer(
|
new PDLInitializer(
|
||||||
new ManifestSource(
|
new ManifestSource(
|
||||||
"ccm-wsx-bookmarks-portlet.pdl.mf",
|
"ccm-portlet-bookmarks.pdl.mf",
|
||||||
new NameFilter(
|
new NameFilter(
|
||||||
DbHelper.getDatabaseSuffix(database),
|
DbHelper.getDatabaseSuffix(database),
|
||||||
"pdl"))));
|
"pdl"))));
|
||||||
|
|
@ -112,12 +112,12 @@ public class Initializer extends CompoundInitializer {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* implementation of framework that allows portlets to be bundled up
|
* implementation of framework that allows portlets to be bundled up
|
||||||
* as discrete applications
|
* as discrete applications
|
||||||
*/
|
*/
|
||||||
PortletType.registerXSLFile(BookmarksPortlet.BASE_DATA_OBJECT_TYPE,
|
PortletType.registerXSLFile(BookmarksPortlet.BASE_DATA_OBJECT_TYPE,
|
||||||
"/packages/westsussex-portlets/xsl/bookmarks-portlet.xsl");
|
"/packages/westsussex-portlets/xsl/bookmarks-portlet.xsl");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -92,283 +92,266 @@ public class BookmarksPortletEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* store item in requestlocal for access by various methods
|
* store item in requestlocal for access by various methods
|
||||||
*
|
*
|
||||||
* code copied from content item portlet - > may be problems when items
|
* code copied from content item portlet - > may be problems when items
|
||||||
* unpublished - check
|
* unpublished - check
|
||||||
*/
|
*/
|
||||||
private RequestLocal contentItem = new RequestLocal() {
|
private RequestLocal contentItem = new RequestLocal() {
|
||||||
@Override
|
@Override
|
||||||
protected Object initialValue(PageState ps) {
|
protected Object initialValue(PageState ps) {
|
||||||
String userURL = (String) m_url.getValue(ps);
|
String userURL = (String) m_url.getValue(ps);
|
||||||
java.net.URL contextURL;
|
|
||||||
try {
|
|
||||||
contextURL =
|
|
||||||
new java.net.URL(
|
|
||||||
Web.getRequest().getRequestURL().toString());
|
|
||||||
} catch (MalformedURLException ex) {
|
|
||||||
throw new UncheckedWrapperException(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
java.net.URL url;
|
java.net.URL contextURL;
|
||||||
try {
|
try {
|
||||||
url = new java.net.URL(contextURL, userURL);
|
contextURL = new java.net.URL(Web.getRequest().getRequestURL()
|
||||||
} catch (MalformedURLException ex) {
|
.toString());
|
||||||
s_log.info("Malformed URL " + userURL);
|
} catch (MalformedURLException ex) {
|
||||||
return null;
|
throw new UncheckedWrapperException(ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
String dp = URL.getDispatcherPath();
|
java.net.URL url;
|
||||||
String path = url.getPath();
|
try {
|
||||||
if (path.startsWith(dp)) {
|
url = new java.net.URL(contextURL, userURL);
|
||||||
path = path.substring(dp.length());
|
} catch (MalformedURLException ex) {
|
||||||
}
|
s_log.info("Malformed URL " + userURL);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
StringTokenizer tok = new StringTokenizer(path, "/");
|
String dp = URL.getDispatcherPath();
|
||||||
if (!tok.hasMoreTokens()) {
|
String path = url.getPath();
|
||||||
s_log.info(
|
if (path.startsWith(dp)) {
|
||||||
"Couldn't find a content section for "
|
path = path.substring(dp.length());
|
||||||
+ path
|
}
|
||||||
+ " in "
|
|
||||||
+ userURL);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String sectionPath = '/' + tok.nextToken() + '/';
|
StringTokenizer tok = new StringTokenizer(path, "/");
|
||||||
|
if (!tok.hasMoreTokens()) {
|
||||||
|
s_log.info("Couldn't find a content section for "
|
||||||
|
+ path + " in " + userURL);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
String context = ContentItem.LIVE;
|
String sectionPath = '/' + tok.nextToken() + '/';
|
||||||
if (tok.hasMoreTokens()
|
|
||||||
&& CMSDispatcher.PREVIEW.equals(tok.nextToken())) {
|
|
||||||
|
|
||||||
context = CMSDispatcher.PREVIEW;
|
String context = ContentItem.LIVE;
|
||||||
}
|
if (tok.hasMoreTokens()
|
||||||
|
&& CMSDispatcher.PREVIEW.equals(tok.nextToken())) {
|
||||||
|
|
||||||
ContentSectionCollection sections = ContentSection.getAllSections();
|
context = CMSDispatcher.PREVIEW;
|
||||||
sections.addEqualsFilter(Application.PRIMARY_URL, sectionPath);
|
}
|
||||||
|
|
||||||
ContentSection section;
|
ContentSectionCollection sections = ContentSection.getAllSections();
|
||||||
if (sections.next()) {
|
sections.addEqualsFilter(Application.PRIMARY_URL, sectionPath);
|
||||||
section = sections.getContentSection();
|
|
||||||
sections.close();
|
|
||||||
} else {
|
|
||||||
s_log.info(
|
|
||||||
"Content section "
|
|
||||||
+ sectionPath
|
|
||||||
+ " in "
|
|
||||||
+ userURL
|
|
||||||
+ " doesn't exist.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemResolver resolver = section.getItemResolver();
|
ContentSection section;
|
||||||
|
if (sections.next()) {
|
||||||
|
section = sections.getContentSection();
|
||||||
|
sections.close();
|
||||||
|
} else {
|
||||||
|
s_log.info("Content section " + sectionPath + " in "
|
||||||
|
+ userURL + " doesn't exist.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
path = path.substring(sectionPath.length());
|
ItemResolver resolver = section.getItemResolver();
|
||||||
|
|
||||||
if (path.endsWith(".jsp")) {
|
path = path.substring(sectionPath.length());
|
||||||
path = path.substring(0, path.length() - 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
ContentItem item = resolver.getItem(section, path, context);
|
if (path.endsWith(".jsp")) {
|
||||||
if (item == null) {
|
path = path.substring(0, path.length() - 4);
|
||||||
s_log.debug("Couldn't resolve item " + path);
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
SecurityManager sm = new SecurityManager(item.getContentSection());
|
ContentItem item = resolver.getItem(section, path, context);
|
||||||
|
if (item == null) {
|
||||||
|
s_log.debug("Couldn't resolve item " + path);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
boolean canRead =
|
SecurityManager sm = new SecurityManager(item.getContentSection());
|
||||||
sm.canAccess(
|
|
||||||
ps.getRequest(),
|
|
||||||
SecurityManager.PUBLIC_PAGES,
|
|
||||||
item);
|
|
||||||
if (!canRead) {
|
|
||||||
s_log.debug("User not allowed access to item");
|
|
||||||
return null;
|
|
||||||
|
|
||||||
}
|
boolean canRead = sm.canAccess(ps.getRequest(),
|
||||||
|
SecurityManager.PUBLIC_PAGES,
|
||||||
|
item);
|
||||||
|
if (!canRead) {
|
||||||
|
s_log.debug("User not allowed access to item");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return item.getDraftVersion();
|
return item.getDraftVersion();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* register the parameter that records the current selected bookmark
|
* register the parameter that records the current selected bookmark
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void register (Page p) {
|
public void register (Page p) {
|
||||||
super.register(p);
|
super.register(p);
|
||||||
p.addComponentStateParam(this, m_selectedBookmark);
|
p.addComponentStateParam(this, m_selectedBookmark);
|
||||||
p.addComponentStateParam(this, m_selectedPortlet);
|
p.addComponentStateParam(this, m_selectedPortlet);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
// create widgets
|
// create widgets
|
||||||
m_url = new TextField(new StringParameter(Link.TARGET_URI));
|
m_url = new TextField(new StringParameter(Link.TARGET_URI));
|
||||||
m_url.addValidationListener(new NotNullValidationListener());
|
m_url.addValidationListener(new NotNullValidationListener());
|
||||||
|
|
||||||
m_title = new TextField(new StringParameter(Link.DISPLAY_NAME));
|
m_title = new TextField(new StringParameter(Link.DISPLAY_NAME));
|
||||||
m_title.addValidationListener(new NotNullValidationListener());
|
m_title.addValidationListener(new NotNullValidationListener());
|
||||||
|
|
||||||
m_description = new TextField(new StringParameter(Link.DESCRIPTION));
|
m_description = new TextField(new StringParameter(Link.DESCRIPTION));
|
||||||
|
|
||||||
m_newWindow = new CheckboxGroup(Link.TARGET_WINDOW);
|
m_newWindow = new CheckboxGroup(Link.TARGET_WINDOW);
|
||||||
m_newWindow.addOption(new Option(NEW_WINDOW_YES, NEW_WINDOW));
|
m_newWindow.addOption(new Option(NEW_WINDOW_YES, NEW_WINDOW));
|
||||||
|
try {
|
||||||
|
m_newWindow.addPrintListener(new PrintListener() {
|
||||||
|
|
||||||
try {
|
public void prepare(PrintEvent e) {
|
||||||
m_newWindow.addPrintListener(new PrintListener() {
|
PageState state = e.getPageState();
|
||||||
|
CheckboxGroup newWindow = (CheckboxGroup)e.getTarget();
|
||||||
|
if (m_bookmarkSelectionModel.isSelected(state)) {
|
||||||
|
Link link = m_bookmarkSelectionModel.getSelectedLink(state);
|
||||||
|
newWindow.setValue(state, link.getTargetWindow());
|
||||||
|
}
|
||||||
|
|
||||||
public void prepare(PrintEvent e) {
|
}
|
||||||
PageState state = e.getPageState();
|
});
|
||||||
CheckboxGroup newWindow = (CheckboxGroup)e.getTarget();
|
} catch (IllegalArgumentException e) {
|
||||||
if (m_bookmarkSelectionModel.isSelected(state)) {
|
s_log.warn("exception when trying to set checkbox value", e);
|
||||||
Link link = m_bookmarkSelectionModel.getSelectedLink(state);
|
} catch (TooManyListenersException e) {
|
||||||
newWindow.setValue(state, link.getTargetWindow());
|
s_log.warn("exception when trying to set checkbox value", e);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
s_log.warn("exception when trying to set checkbox value", e);
|
|
||||||
} catch (TooManyListenersException e) {
|
|
||||||
s_log.warn("exception when trying to set checkbox value", e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_selectedPortlet = new BigDecimalParameter("bookmark_portlet");
|
m_selectedPortlet = new BigDecimalParameter("bookmark_portlet");
|
||||||
m_portletSelectionModel = new PortletSelectionModel(m_selectedPortlet);
|
m_portletSelectionModel = new PortletSelectionModel(m_selectedPortlet);
|
||||||
m_selectedBookmark = new BigDecimalParameter("bookmark");
|
m_selectedBookmark = new BigDecimalParameter("bookmark");
|
||||||
m_bookmarkSelectionModel = new BookmarkSelectionModel(
|
m_bookmarkSelectionModel = new BookmarkSelectionModel(
|
||||||
"uk.gov.westsussex.portlet.bookmarks.Bookmark",
|
"com.arsdigita.portlet.bookmarks.Bookmark",
|
||||||
Bookmark.BASE_DATA_OBJECT_TYPE, m_selectedBookmark);
|
Bookmark.BASE_DATA_OBJECT_TYPE, m_selectedBookmark);
|
||||||
m_existingBookmarks = new BookmarksTable(m_bookmarkSelectionModel,
|
m_existingBookmarks = new BookmarksTable(m_bookmarkSelectionModel,
|
||||||
m_portletSelectionModel);
|
m_portletSelectionModel);
|
||||||
|
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
add(new HorizontalLine(), ColumnPanel.FULL_WIDTH);
|
add(new HorizontalLine(), ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
|
|
||||||
add(m_existingBookmarks, ColumnPanel.FULL_WIDTH);
|
add(m_existingBookmarks, ColumnPanel.FULL_WIDTH);
|
||||||
add(new HorizontalLine(), ColumnPanel.FULL_WIDTH);
|
add(new HorizontalLine(), ColumnPanel.FULL_WIDTH);
|
||||||
|
|
||||||
add(ADD_NEW_BOOKMARK_LABEL, ColumnPanel.FULL_WIDTH);
|
add(ADD_NEW_BOOKMARK_LABEL, ColumnPanel.FULL_WIDTH);
|
||||||
add(TITLE_LABEL, ColumnPanel.RIGHT);
|
add(TITLE_LABEL, ColumnPanel.RIGHT);
|
||||||
add(m_title);
|
add(m_title);
|
||||||
add(DESCRIPTION_LABEL, ColumnPanel.RIGHT);
|
add(DESCRIPTION_LABEL, ColumnPanel.RIGHT);
|
||||||
add(m_description);
|
add(m_description);
|
||||||
|
|
||||||
|
|
||||||
add(URL_LABEL, ColumnPanel.RIGHT);
|
add(URL_LABEL, ColumnPanel.RIGHT);
|
||||||
add(m_url);
|
add(m_url);
|
||||||
add(new Label("")); // fill up the left hand column
|
add(new Label("")); // fill up the left hand column
|
||||||
add(m_newWindow);
|
add(m_newWindow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* specify current portlet for reference by table
|
* specify current portlet for reference by table
|
||||||
*
|
*
|
||||||
* fill in values if user has selected edit on an existing bookmark
|
* fill in values if user has selected edit on an existing bookmark
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initWidgets(PageState state, Portlet portlet)
|
protected void initWidgets(PageState state, Portlet portlet)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
s_log.debug("init widgets - set selected portlet to " + portlet.getOID());
|
s_log.debug("init widgets - set selected portlet to " + portlet.getOID());
|
||||||
// set cached version as dirty here rather than during process
|
// set cached version as dirty here rather than during process
|
||||||
// in case an action link is pressed (eg to move links up/down)
|
// in case an action link is pressed (eg to move links up/down)
|
||||||
portlet.getPortletRenderer().invalidateCachedVersion(state);
|
portlet.getPortletRenderer().invalidateCachedVersion(state);
|
||||||
m_portletSelectionModel.setSelectedObject(state, portlet);
|
m_portletSelectionModel.setSelectedObject(state, portlet);
|
||||||
super.initWidgets(state, portlet);
|
super.initWidgets(state, portlet);
|
||||||
if (m_bookmarkSelectionModel.isSelected(state)) {
|
|
||||||
Bookmark link = m_bookmarkSelectionModel.getSelectedLink(state);
|
|
||||||
m_url.setValue(state, BookmarksPortlet.getURIForBookmark(link, state));
|
|
||||||
m_description.setValue(state, link.getDescription());
|
|
||||||
m_title.setValue(state, link.getTitle());
|
|
||||||
|
|
||||||
}
|
if (m_bookmarkSelectionModel.isSelected(state)) {
|
||||||
}
|
Bookmark link = m_bookmarkSelectionModel.getSelectedLink(state);
|
||||||
|
m_url.setValue(state, BookmarksPortlet.getURIForBookmark(link, state));
|
||||||
|
m_description.setValue(state, link.getDescription());
|
||||||
|
m_title.setValue(state, link.getTitle());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates url if it looks like it is trying to be a content item
|
* Validates url if it looks like it is trying to be a content item
|
||||||
* but is failing
|
* but is failing
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void validateWidgets(PageState state, Portlet portlet)
|
public void validateWidgets(PageState state, Portlet portlet)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
// m_selectedPortlet.set(state, portlet);
|
// m_selectedPortlet.set(state, portlet);
|
||||||
super.validateWidgets(state, portlet);
|
super.validateWidgets(state, portlet);
|
||||||
|
|
||||||
String fullUrl = (String) m_url.getValue(state);
|
String fullUrl = (String) m_url.getValue(state);
|
||||||
s_log.debug("fullURL = " + fullUrl);
|
s_log.debug("fullURL = " + fullUrl);
|
||||||
|
|
||||||
Object item = contentItem.get(state);
|
Object item = contentItem.get(state);
|
||||||
URL here = URL.here(state.getRequest(), null);
|
URL here = URL.here(state.getRequest(), null);
|
||||||
String thisSite = here.getServerURI();
|
String thisSite = here.getServerURI();
|
||||||
s_log.debug("This site is " + thisSite);
|
s_log.debug("This site is " + thisSite);
|
||||||
if (item == null && fullUrl.indexOf(thisSite) != -1
|
if (item == null && fullUrl.indexOf(thisSite) != -1
|
||||||
&& fullUrl.indexOf("/ccm/") != -1
|
&& fullUrl.indexOf("/ccm/") != -1
|
||||||
&& fullUrl.indexOf("/content/") != -1 ) {
|
&& fullUrl.indexOf("/content/") != -1 ) {
|
||||||
// not watertight, but is reasonable check that user is trying
|
// not watertight, but is reasonable check that user is trying
|
||||||
// to specify a content item on this site
|
// to specify a content item on this site
|
||||||
throw new FormProcessException(CONTENT_ITEM_NOT_FOUND);
|
throw new FormProcessException(CONTENT_ITEM_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
* add new bookmark to portlet, or amend existing one if we are editing
|
/**
|
||||||
|
* add new bookmark to portlet, or amend existing one if we are editing
|
||||||
* a selected bookmark
|
* a selected bookmark
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processWidgets(PageState state, Portlet portlet)
|
protected void processWidgets(PageState state, Portlet portlet)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
s_log.debug("START processWidgets");
|
s_log.debug("START processWidgets");
|
||||||
super.processWidgets(state, portlet);
|
super.processWidgets(state, portlet);
|
||||||
|
|
||||||
|
BookmarksPortlet myportlet = (BookmarksPortlet) portlet;
|
||||||
|
|
||||||
BookmarksPortlet myportlet = (BookmarksPortlet) portlet;
|
String titleText = (String) m_title.getValue(state);
|
||||||
|
String urlText = (String) m_url.getValue(state);
|
||||||
|
String descriptionText = (String)m_description.getValue(state);
|
||||||
|
|
||||||
String titleText = (String) m_title.getValue(state);
|
ContentItem item = (ContentItem) contentItem.get(state);
|
||||||
String urlText = (String) m_url.getValue(state);
|
String[] newWindowValue = (String[]) m_newWindow.getValue(state);
|
||||||
String descriptionText = (String)m_description.getValue(state);
|
String newWindow = newWindowValue == null ? NEW_WINDOW_NO
|
||||||
|
: NEW_WINDOW_YES;
|
||||||
|
|
||||||
ContentItem item = (ContentItem) contentItem.get(state);
|
Bookmark newBookmark;
|
||||||
String[] newWindowValue = (String[]) m_newWindow.getValue(state);
|
if (m_bookmarkSelectionModel.isSelected(state)) {
|
||||||
String newWindow =
|
newBookmark = m_bookmarkSelectionModel.getSelectedLink(state);
|
||||||
newWindowValue == null ? NEW_WINDOW_NO : NEW_WINDOW_YES;
|
} else {
|
||||||
|
newBookmark = new Bookmark();
|
||||||
|
myportlet.addBookmark(newBookmark);
|
||||||
|
}
|
||||||
|
newBookmark.setTitle(titleText);
|
||||||
|
newBookmark.setDescription(descriptionText);
|
||||||
|
newBookmark.setTargetWindow(newWindow);
|
||||||
|
if (item == null) {
|
||||||
|
newBookmark.setTargetType(Link.EXTERNAL_LINK);
|
||||||
|
newBookmark.setTargetURI(urlText);
|
||||||
|
} else {
|
||||||
|
newBookmark.setTargetType(Link.INTERNAL_LINK);
|
||||||
|
newBookmark.setTargetItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
Bookmark newBookmark;
|
m_bookmarkSelectionModel.clearSelection(state);
|
||||||
|
s_log.debug("END processWidgets");
|
||||||
if (m_bookmarkSelectionModel.isSelected(state)) {
|
|
||||||
newBookmark = m_bookmarkSelectionModel.getSelectedLink(state);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
newBookmark = new Bookmark();
|
|
||||||
myportlet.addBookmark(newBookmark);
|
|
||||||
|
|
||||||
}
|
|
||||||
newBookmark.setTitle(titleText);
|
|
||||||
newBookmark.setDescription(descriptionText);
|
|
||||||
newBookmark.setTargetWindow(newWindow);
|
|
||||||
if (item == null) {
|
|
||||||
newBookmark.setTargetType(Link.EXTERNAL_LINK);
|
|
||||||
newBookmark.setTargetURI(urlText);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
newBookmark.setTargetType(Link.INTERNAL_LINK);
|
|
||||||
newBookmark.setTargetItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
m_bookmarkSelectionModel.clearSelection(state);
|
|
||||||
s_log.debug("END processWidgets");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||||
|
|
||||||
<ccm:application name="ccm-wsx-news-portlet"
|
<ccm:application name="ccm-portlet-latestnews"
|
||||||
prettyName="Personalised News Portlet"
|
prettyName="Personalised News Portlet"
|
||||||
version="1.0.1"
|
version="1.0.1"
|
||||||
release="1"
|
release="1"
|
||||||
|
|
@ -9,6 +9,9 @@
|
||||||
|
|
||||||
<ccm:dependencies>
|
<ccm:dependencies>
|
||||||
<ccm:requires name="ccm-cms-types-newsitem" version="6.1.0"/>
|
<ccm:requires name="ccm-cms-types-newsitem" version="6.1.0"/>
|
||||||
|
<ccm:requires name="ccm-navigation" version="6.6.0"/>
|
||||||
|
<ccm:requires name="ccm-ldn-terms" version="6.6.0"/>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
<ccm:requires name="ccm-ldn-portal" version="1.4.2"/>
|
<ccm:requires name="ccm-ldn-portal" version="1.4.2"/>
|
||||||
<ccm:requires name="ccm-wsx-authentication" version="1.0.1"/>
|
<ccm:requires name="ccm-wsx-authentication" version="1.0.1"/>
|
||||||
|
|
|
||||||
|
|
@ -37,54 +37,52 @@ import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Provides configuration pane for NewsPortlet.
|
||||||
*
|
*
|
||||||
* @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
|
* @author Chris Gilbert (cgyg9330) <chris.gilbert@westsussex.gov.uk>
|
||||||
* @version $Id: NewsPortletEditor.java 2005/03/07 13:48:49 cgyg9330 Exp $
|
* @version $Id: NewsPortletEditor.java 2005/03/07 13:48:49 cgyg9330 Exp $
|
||||||
*/
|
*/
|
||||||
public class NewsPortletEditor extends PortletConfigFormSection {
|
public class NewsPortletEditor extends PortletConfigFormSection {
|
||||||
|
|
||||||
private TextField m_itemCount;
|
private static final Logger s_log = Logger.getLogger(NewsPortletEditor.class);
|
||||||
private static final Logger s_log = Logger.getLogger(NewsPortletEditor.class);
|
|
||||||
|
private TextField m_itemCount;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param resType
|
* @param resType
|
||||||
* @param parentAppRL
|
* @param parentAppRL
|
||||||
*/
|
*/
|
||||||
public NewsPortletEditor(ResourceType resType, RequestLocal parentAppRL) {
|
public NewsPortletEditor(ResourceType resType, RequestLocal parentAppRL) {
|
||||||
super(resType, parentAppRL);
|
super(resType, parentAppRL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param application
|
* @param application
|
||||||
*/
|
*/
|
||||||
public NewsPortletEditor(RequestLocal application) {
|
public NewsPortletEditor(RequestLocal application) {
|
||||||
super(application);
|
super(application);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Add widgets to the form containing the configuration options.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void addWidgets() {
|
protected void addWidgets() {
|
||||||
super.addWidgets();
|
super.addWidgets();
|
||||||
|
|
||||||
m_itemCount =
|
/* Define the number of news item to display */
|
||||||
new TextField(new StringParameter(NewsPortlet.ITEM_COUNT));
|
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);
|
||||||
|
|
||||||
add(new Label("Number of items:", Label.BOLD), ColumnPanel.RIGHT);
|
}
|
||||||
|
|
||||||
m_itemCount.addValidationListener(new IntegerValidationListener());
|
|
||||||
|
|
||||||
add(m_itemCount);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -96,16 +94,16 @@ public class NewsPortletEditor extends PortletConfigFormSection {
|
||||||
* TODO: add validation or set up drop down list with contents of Static folder?
|
* TODO: add validation or set up drop down list with contents of Static folder?
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void initWidgets(PageState state, Portlet portlet)
|
protected void initWidgets(PageState state, Portlet portlet)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
super.initWidgets(state, portlet);
|
super.initWidgets(state, portlet);
|
||||||
|
|
||||||
if (portlet != null) {
|
if (portlet != null) {
|
||||||
NewsPortlet myportlet = (NewsPortlet) portlet;
|
NewsPortlet myportlet = (NewsPortlet) portlet;
|
||||||
|
m_itemCount.setValue(state, myportlet.getItemCount()+ "");
|
||||||
|
}
|
||||||
|
|
||||||
m_itemCount.setValue(state, myportlet.getItemCount()+ "");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,14 +113,15 @@ public class NewsPortletEditor extends PortletConfigFormSection {
|
||||||
* @throws FormProcessException
|
* @throws FormProcessException
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void processWidgets(PageState state, Portlet portlet)
|
protected void processWidgets(PageState state, Portlet portlet)
|
||||||
throws FormProcessException {
|
throws FormProcessException {
|
||||||
s_log.debug("START processWidgets");
|
s_log.debug("START processWidgets");
|
||||||
super.processWidgets(state, portlet);
|
super.processWidgets(state, portlet);
|
||||||
|
|
||||||
|
NewsPortlet myportlet = (NewsPortlet) portlet;
|
||||||
|
myportlet.setItemCount(new Integer(
|
||||||
|
(String) m_itemCount.getValue(state)).intValue());
|
||||||
|
s_log.debug("END processWidgets");
|
||||||
|
}
|
||||||
|
|
||||||
NewsPortlet myportlet = (NewsPortlet) portlet;
|
|
||||||
myportlet.setItemCount(new Integer(
|
|
||||||
(String) m_itemCount.getValue(state)).intValue());
|
|
||||||
s_log.debug("END processWidgets");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -58,15 +58,17 @@ import org.apache.log4j.Logger;
|
||||||
* @version $Id: NewsPortletRenderer.java 2005/03/07 13:48:49 cgyg9330 Exp $
|
* @version $Id: NewsPortletRenderer.java 2005/03/07 13:48:49 cgyg9330 Exp $
|
||||||
*/
|
*/
|
||||||
public class NewsPortletRenderer extends AbstractPortletRenderer
|
public class NewsPortletRenderer extends AbstractPortletRenderer
|
||||||
implements NewsConstants {
|
implements NewsConstants {
|
||||||
|
|
||||||
private static final Logger s_log =
|
/** Private logger instance for debugging purpose */
|
||||||
Logger.getLogger(NewsPortletRenderer.class);
|
private static final Logger s_log =
|
||||||
|
Logger.getLogger(NewsPortletRenderer.class);
|
||||||
|
|
||||||
private NewsPortlet m_portlet;
|
private NewsPortlet m_portlet;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param portlet
|
* @param portlet
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,48 +76,50 @@ public class NewsPortletRenderer extends AbstractPortletRenderer
|
||||||
m_portlet = portlet;
|
m_portlet = portlet;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see
|
* @see
|
||||||
* com.arsdigita.bebop.portal.AbstractPortletRenderer#generateBodyXML(
|
* com.arsdigita.bebop.portal.AbstractPortletRenderer#generateBodyXML(
|
||||||
* com.arsdigita.bebop.PageState,
|
* com.arsdigita.bebop.PageState,
|
||||||
* com.arsdigita.xml.Element)
|
* com.arsdigita.xml.Element)
|
||||||
*/
|
*/
|
||||||
protected void generateBodyXML(PageState state, Element parent) {
|
protected void generateBodyXML(PageState state, Element parent) {
|
||||||
s_log.debug("START - generateBodyXML");
|
s_log.debug("START - generateBodyXML");
|
||||||
|
|
||||||
Element newsPortlet = parent.newChildElement( MAIN_PORTLET_ELEMENT,
|
Element newsPortlet = parent.newChildElement(MAIN_PORTLET_ELEMENT,
|
||||||
PortletType.PORTLET_XML_NS);
|
PortletType.PORTLET_XML_NS);
|
||||||
DateFormat formatter = new SimpleDateFormat("dd/MM/yy");
|
DateFormat formatter = new SimpleDateFormat("dd/MM/yy");
|
||||||
|
|
||||||
User thisUser = (User) Kernel.getContext().getParty();
|
User thisUser = (User) Kernel.getContext().getParty();
|
||||||
if (null == thisUser) {
|
if (null == thisUser) {
|
||||||
thisUser = Kernel.getPublicUser();
|
thisUser = Kernel.getPublicUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Object customUser = ExternalUserFactory.getCustomUserObject(thisUser);
|
// Object customUser = ExternalUserFactory.getCustomUserObject(thisUser);
|
||||||
// if (customUser instanceof PersonalisedNewsTarget) {
|
// if (customUser instanceof PersonalisedNewsTarget) {
|
||||||
// newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "true");
|
// newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "true");
|
||||||
// getPersonalisedNews(
|
// getPersonalisedNews(state,
|
||||||
// state,
|
// newsPortlet,
|
||||||
// newsPortlet,
|
// (PersonalisedNewsTarget) customUser,
|
||||||
// (PersonalisedNewsTarget) customUser,
|
// formatter);
|
||||||
// formatter);
|
|
||||||
//
|
//
|
||||||
// } else {
|
// } else {
|
||||||
newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "false");
|
|
||||||
getGeneralNews(newsPortlet, formatter);
|
|
||||||
|
|
||||||
// }
|
newsPortlet.addAttribute(PERSONALISED_ATTRIBUTE, "false");
|
||||||
|
getGeneralNews(newsPortlet, formatter);
|
||||||
|
|
||||||
newsPortlet.addAttribute(NEWS_ROOM_ATTRIBUTE,
|
// }
|
||||||
NewsPortlet.getConfig().getNewsroomShortcut());
|
|
||||||
|
|
||||||
s_log.debug("FINISH - generateBodyXML");
|
newsPortlet.addAttribute(NEWS_ROOM_ATTRIBUTE,
|
||||||
}
|
NewsPortlet.getConfig().getNewsroomShortcut());
|
||||||
|
|
||||||
/**
|
s_log.debug("FINISH - generateBodyXML");
|
||||||
* @param newsPortlet
|
}
|
||||||
* @param profiledUser
|
|
||||||
*/
|
/**
|
||||||
|
*
|
||||||
|
* @param newsPortlet
|
||||||
|
* @param profiledUser
|
||||||
|
*/
|
||||||
/* CURRENTLY NOT AVAILABLE
|
/* CURRENTLY NOT AVAILABLE
|
||||||
private void getPersonalisedNews( PageState state,
|
private void getPersonalisedNews( PageState state,
|
||||||
Element main,
|
Element main,
|
||||||
|
|
@ -124,24 +128,24 @@ public class NewsPortletRenderer extends AbstractPortletRenderer
|
||||||
s_log.debug("START - getPersonalisedNews");
|
s_log.debug("START - getPersonalisedNews");
|
||||||
|
|
||||||
DomainCollection myNews = profiledUser.getMyNews();
|
DomainCollection myNews = profiledUser.getMyNews();
|
||||||
if (myNews == null) {
|
if (myNews == null) {
|
||||||
// method in personalised user class has been implemented to just return null
|
// method in personalised user class has been implemented to just return null
|
||||||
getGeneralNews(main, formatter);
|
getGeneralNews(main, formatter);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myNews.addOrder(ContentPage.LAUNCH_DATE + " desc");
|
myNews.addOrder(ContentPage.LAUNCH_DATE + " desc");
|
||||||
|
|
||||||
PermissionService.filterObjects(
|
PermissionService.filterObjects(
|
||||||
myNews,
|
myNews,
|
||||||
PrivilegeDescriptor.get(SecurityManager.CMS_READ_ITEM),
|
PrivilegeDescriptor.get(SecurityManager.CMS_READ_ITEM),
|
||||||
Kernel.getContext().getParty().getOID());
|
Kernel.getContext().getParty().getOID());
|
||||||
|
|
||||||
myNews.setRange(
|
myNews.setRange(
|
||||||
new Integer(1),
|
new Integer(1),
|
||||||
new Integer(m_portlet.getItemCount() + 1));
|
new Integer(m_portlet.getItemCount() + 1));
|
||||||
|
|
||||||
while (myNews.next()) {
|
while (myNews.next()) {
|
||||||
ContentPage page = (ContentPage) myNews.getDomainObject();
|
ContentPage page = (ContentPage) myNews.getDomainObject();
|
||||||
|
|
||||||
Element item = main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
|
Element item = main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
|
||||||
|
|
@ -155,57 +159,55 @@ public class NewsPortletRenderer extends AbstractPortletRenderer
|
||||||
URL_ATTRIBUTE,
|
URL_ATTRIBUTE,
|
||||||
Navigation.redirectURL(page.getOID()));
|
Navigation.redirectURL(page.getOID()));
|
||||||
|
|
||||||
}
|
}
|
||||||
s_log.debug("END - getPersonalisedNews");
|
s_log.debug("END - getPersonalisedNews");
|
||||||
|
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
private void getGeneralNews(Element main, DateFormat formatter) {
|
private void getGeneralNews(Element main, DateFormat formatter) {
|
||||||
s_log.debug("START - getGeneralNews");
|
s_log.debug("START - getGeneralNews");
|
||||||
|
|
||||||
// this is the default key - maybe should parametrise
|
// this is the default key - maybe should parametrise
|
||||||
Domain rss = Domain.retrieve("APLAWS-RSS");
|
Domain rss = Domain.retrieve("APLAWS-RSS");
|
||||||
DomainCollection rssRoots = rss.getRootTerms();
|
DomainCollection rssRoots = rss.getRootTerms();
|
||||||
rssRoots.addEqualsFilter(Term.NAME, "News");
|
rssRoots.addEqualsFilter(Term.NAME, "News");
|
||||||
Term newsTerm = null;
|
Term newsTerm = null;
|
||||||
while (rssRoots.next()) {
|
|
||||||
newsTerm = (Term) rssRoots.getDomainObject();
|
while (rssRoots.next()) {
|
||||||
s_log.debug("found the news rss feed term");
|
newsTerm = (Term) rssRoots.getDomainObject();
|
||||||
Category cat = newsTerm.getModel();
|
s_log.debug("found the news rss feed term");
|
||||||
DataCollection newsItems = SessionManager.getSession()
|
Category cat = newsTerm.getModel();
|
||||||
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
DataCollection newsItems = SessionManager.getSession()
|
||||||
newsItems.addEqualsFilter("parent.categories.id",
|
.retrieve(ContentPage.BASE_DATA_OBJECT_TYPE);
|
||||||
cat.getID());
|
newsItems.addEqualsFilter("parent.categories.id",cat.getID());
|
||||||
|
|
||||||
newsItems.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
|
newsItems.addEqualsFilter(ContentItem.VERSION, ContentItem.LIVE);
|
||||||
newsItems.addOrder(ContentPage.LAUNCH_DATE + " desc");
|
newsItems.addOrder(ContentPage.LAUNCH_DATE + " desc");
|
||||||
|
|
||||||
// CategorizedCollection newsItems =
|
// CategorizedCollection newsItems =
|
||||||
// cat.getObjects(ContentPage.BASE_DATA_OBJECT_TYPE);
|
// cat.getObjects(ContentPage.BASE_DATA_OBJECT_TYPE);
|
||||||
s_log.debug("total items = " + newsItems.size());
|
s_log.debug("total items = " + newsItems.size());
|
||||||
newsItems.setRange(
|
newsItems.setRange(new Integer(1),
|
||||||
new Integer(1),
|
new Integer(m_portlet.getItemCount() + 1));
|
||||||
new Integer(m_portlet.getItemCount() + 1));
|
|
||||||
|
|
||||||
ContentPage newsItem = null;
|
ContentPage newsItem = null;
|
||||||
while (newsItems.next()) {
|
while (newsItems.next()) {
|
||||||
Element item =
|
Element item = main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
|
||||||
main.newChildElement(NEWS_ITEM_ELEMENT, XML_NEWS_NS);
|
//newsItem = (ContentPage) newsItems.getDomainObject();
|
||||||
//newsItem = (ContentPage) newsItems.getDomainObject();
|
newsItem = (ContentPage)DomainObjectFactory
|
||||||
newsItem = (ContentPage)DomainObjectFactory
|
.newInstance(newsItems.getDataObject());
|
||||||
.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());
|
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(LEAD_ATTRIBUTE, newsItem.getSearchSummary());
|
||||||
item.addAttribute(
|
item.addAttribute(URL_ATTRIBUTE,
|
||||||
URL_ATTRIBUTE,
|
Navigation.redirectURL(newsItem.getOID()));
|
||||||
Navigation.redirectURL(newsItem.getOID()));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -214,39 +216,34 @@ public class NewsPortletRenderer extends AbstractPortletRenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
public Object getCacheKey() {
|
public Object getCacheKey() {
|
||||||
|
|
||||||
if (getProfiledUser() == null) {
|
if (getProfiledUser() == null) {
|
||||||
return GENERAL_NEWS_CACHE_KEY;
|
return GENERAL_NEWS_CACHE_KEY;
|
||||||
} else {
|
} else {
|
||||||
|
return m_portlet.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
// is dirty if edited, as this means the number of entries has changed.
|
public boolean isDirty() {
|
||||||
// For non personalised news, dirty if homepage
|
// has it been edited? - add in this condition when response
|
||||||
// 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
|
// 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;
|
||||||
|
*/
|
||||||
|
|
||||||
// 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;
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue