mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
. Added RSS Feed panel to Space Details page
- Selectable template for RSS feed for a folder - RSS feed link for drag/drop into RSS reader . Added new folder "RSS Templates" in Data Dictionary in bootstrap . Example RSS Template for new folder (docs in last 7 days) . Created patch to add above folder+example to current schema . Added 'app:feedsource' aspect to application data model . Cleaned up some obsolete code in Apply/Remove Template actions . Simplified Apply/Remove Template dialog navigation to use dialog framework git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@3527 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -71,6 +71,7 @@ public class Application
|
||||
private static String spaceTemplatesFolderName;
|
||||
private static String contentTemplatesFolderName;
|
||||
private static String emailTemplatesFolderName;
|
||||
private static String rssTemplatesFolderName;
|
||||
private static String savedSearchesFolderName;
|
||||
private static String scriptsFolderName;
|
||||
private static String guestHomeFolderName;
|
||||
@@ -376,6 +377,22 @@ public class Application
|
||||
return getEmailTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the RSS templates folder name
|
||||
*/
|
||||
public static String getRSSTemplatesFolderName(ServletContext context)
|
||||
{
|
||||
return getRSSTemplatesFolderName(WebApplicationContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the RSS templates folder name
|
||||
*/
|
||||
public static String getRSSTemplatesFolderName(FacesContext context)
|
||||
{
|
||||
return getRSSTemplatesFolderName(FacesContextUtils.getRequiredWebApplicationContext(context));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the Saved Searches folder name
|
||||
*/
|
||||
@@ -750,6 +767,24 @@ public class Application
|
||||
return emailTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RSS Templates folder name
|
||||
*
|
||||
* @param context The spring context
|
||||
* @return The RSS folder name
|
||||
*/
|
||||
private static String getRSSTemplatesFolderName(WebApplicationContext context)
|
||||
{
|
||||
if (rssTemplatesFolderName == null)
|
||||
{
|
||||
ImporterBootstrap bootstrap = (ImporterBootstrap)context.getBean(BEAN_IMPORTER_BOOTSTRAP);
|
||||
Properties configuration = bootstrap.getConfiguration();
|
||||
rssTemplatesFolderName = configuration.getProperty("spaces.templates.rss.childname");
|
||||
}
|
||||
|
||||
return rssTemplatesFolderName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Saved Searches folder name
|
||||
*
|
||||
|
@@ -256,7 +256,7 @@ public abstract class BaseDetailsBean
|
||||
/**
|
||||
* Action handler to apply the selected Template and Templatable aspect to the current Space
|
||||
*/
|
||||
public String applyTemplate()
|
||||
public void applyTemplate(ActionEvent event)
|
||||
{
|
||||
if (this.template != null && this.template.equals(TemplateSupportBean.NO_SELECTION) == false)
|
||||
{
|
||||
@@ -283,13 +283,12 @@ public abstract class BaseDetailsBean
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
return getReturnOutcome();
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler to remove a dashboard template from the current Space
|
||||
*/
|
||||
public String removeTemplate()
|
||||
public void removeTemplate(ActionEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -305,14 +304,8 @@ public abstract class BaseDetailsBean
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
return getReturnOutcome();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return return to details page JSF navigation outcome
|
||||
*/
|
||||
protected abstract String getReturnOutcome();
|
||||
|
||||
/**
|
||||
* Action Handler to take Ownership of the current Space
|
||||
*/
|
||||
|
@@ -989,14 +989,6 @@ public class DocumentDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
return "document-props";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.BaseDetailsBean#getReturnOutcome()
|
||||
*/
|
||||
protected String getReturnOutcome()
|
||||
{
|
||||
return OUTCOME_RETURN;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a model for use by a template on the Document Details page.
|
||||
|
@@ -34,6 +34,7 @@ import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.TemplateContentServlet;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
@@ -46,8 +47,6 @@ import org.alfresco.web.ui.common.component.UIActionLink;
|
||||
*/
|
||||
public class SpaceDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
private static final String OUTCOME_RETURN = "showSpaceDetails";
|
||||
|
||||
private static final String MSG_HAS_FOLLOWING_CATEGORIES = "has_following_categories_space";
|
||||
private static final String MSG_NO_CATEGORIES_APPLIED = "no_categories_applied_space";
|
||||
private static final String MSG_ERROR_UPDATE_CATEGORY = "error_update_category";
|
||||
@@ -60,6 +59,9 @@ public class SpaceDetailsBean extends BaseDetailsBean
|
||||
private NodeRef addedCategory;
|
||||
private List categories;
|
||||
|
||||
/** RSS Template ID */
|
||||
private String rssTemplate;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Construction
|
||||
@@ -149,14 +151,6 @@ public class SpaceDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
return "space-props";
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.BaseDetailsBean#getReturnOutcome()
|
||||
*/
|
||||
protected String getReturnOutcome()
|
||||
{
|
||||
return OUTCOME_RETURN;
|
||||
}
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
@@ -471,4 +465,94 @@ public class SpaceDetailsBean extends BaseDetailsBean
|
||||
{
|
||||
return getSpace().isLocked();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the current space has an RSS feed applied
|
||||
*/
|
||||
public boolean isRSSFeed()
|
||||
{
|
||||
return (getSpace().hasAspect(ContentModel.ASPECT_FEEDSOURCE) &&
|
||||
getSpace().getProperties().get(ContentModel.PROP_FEEDTEMPLATE) != null);
|
||||
}
|
||||
|
||||
public String getRSSFeedURL()
|
||||
{
|
||||
// build RSS feed template URL from selected template and current space NodeRef and
|
||||
// add the guest=true URL parameter - this is required for no login access and
|
||||
// add the mimetype=text/xml URL parameter - required to return correct stream type
|
||||
return TemplateContentServlet.generateURL(getSpace().getNodeRef(),
|
||||
(NodeRef)getSpace().getProperties().get(ContentModel.PROP_FEEDTEMPLATE))
|
||||
+ "?guest=true" + "&mimetype=text%2Fxml";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the current RSS Template ID.
|
||||
*/
|
||||
public String getRSSTemplate()
|
||||
{
|
||||
// return current template if it exists
|
||||
NodeRef ref = (NodeRef)getNode().getProperties().get(ContentModel.PROP_FEEDTEMPLATE);
|
||||
return ref != null ? ref.getId() : this.rssTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rssTemplate The RSS Template Id to set.
|
||||
*/
|
||||
public void setRSSTemplate(String rssTemplate)
|
||||
{
|
||||
this.rssTemplate = rssTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler to apply the selected RSS Template and FeedSource aspect to the current Space
|
||||
*/
|
||||
public void applyRSSTemplate(ActionEvent event)
|
||||
{
|
||||
if (this.rssTemplate != null && this.rssTemplate.equals(TemplateSupportBean.NO_SELECTION) == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
// apply the feedsource aspect if required
|
||||
if (getNode().hasAspect(ContentModel.ASPECT_FEEDSOURCE) == false)
|
||||
{
|
||||
this.nodeService.addAspect(getNode().getNodeRef(), ContentModel.ASPECT_FEEDSOURCE, null);
|
||||
}
|
||||
|
||||
// get the selected template Id from the Template Picker
|
||||
NodeRef templateRef = new NodeRef(Repository.getStoreRef(), this.rssTemplate);
|
||||
|
||||
// set the template NodeRef into the templatable aspect property
|
||||
this.nodeService.setProperty(getNode().getNodeRef(), ContentModel.PROP_FEEDTEMPLATE, templateRef);
|
||||
|
||||
// reset node details for next refresh of details page
|
||||
getNode().reset();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler to remove a RSS template from the current Space
|
||||
*/
|
||||
public void removeRSSTemplate(ActionEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
// clear template property
|
||||
this.nodeService.setProperty(getNode().getNodeRef(), ContentModel.PROP_FEEDTEMPLATE, null);
|
||||
this.nodeService.removeAspect(getNode().getNodeRef(), ContentModel.ASPECT_FEEDSOURCE);
|
||||
|
||||
// reset node details for next refresh of details page
|
||||
getNode().reset();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Utils.addErrorMessage(MessageFormat.format(Application.getMessage(
|
||||
FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), e.getMessage()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,9 @@ public class TemplateSupportBean
|
||||
/** cache of email templates that lasts 30 seconds - enough for a few page refreshes */
|
||||
private ExpiringValueCache<List<SelectItem>> emailTemplates = new ExpiringValueCache<List<SelectItem>>(1000*30);
|
||||
|
||||
/** cache of RSS templates that lasts 30 seconds - enough for a few page refreshes */
|
||||
private ExpiringValueCache<List<SelectItem>> rssTemplates = new ExpiringValueCache<List<SelectItem>>(1000*30);
|
||||
|
||||
/** cache of JavaScript files that lasts 30 seconds - enough for a few page refreshes */
|
||||
private ExpiringValueCache<List<SelectItem>> scriptFiles = new ExpiringValueCache<List<SelectItem>>(1000*30);
|
||||
|
||||
@@ -128,6 +131,28 @@ public class TemplateSupportBean
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of available RSS Templates.
|
||||
*/
|
||||
public List<SelectItem> getRSSTemplates()
|
||||
{
|
||||
List<SelectItem> templates = rssTemplates.get();
|
||||
if (templates == null)
|
||||
{
|
||||
// get the template from the special Email Templates folder
|
||||
FacesContext fc = FacesContext.getCurrentInstance();
|
||||
String xpath = Application.getRootPath(fc) + "/" +
|
||||
Application.getGlossaryFolderName(fc) + "/" +
|
||||
Application.getRSSTemplatesFolderName(fc) + "//*";
|
||||
|
||||
templates = selectDictionaryNodes(fc, xpath, MSG_SELECT_TEMPLATE);
|
||||
|
||||
rssTemplates.put(templates);
|
||||
}
|
||||
|
||||
return templates;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of available JavaScript files that can be applied to the current document.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user