mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ETHREEOH-274 and handling of potentially missing cm:modifiedDate property in DownloadContentServlet.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@11254 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -243,6 +243,8 @@ public abstract class BaseDownloadContentServlet extends BaseServlet
|
||||
|
||||
// check If-Modified-Since header and set Last-Modified header as appropriate
|
||||
Date modified = (Date)nodeService.getProperty(nodeRef, ContentModel.PROP_MODIFIED);
|
||||
if (modified != null)
|
||||
{
|
||||
long modifiedSince = req.getDateHeader("If-Modified-Since");
|
||||
if (modifiedSince > 0L)
|
||||
{
|
||||
@@ -257,6 +259,7 @@ public abstract class BaseDownloadContentServlet extends BaseServlet
|
||||
}
|
||||
}
|
||||
res.setDateHeader("Last-Modified", modified.getTime());
|
||||
}
|
||||
|
||||
if (attachment == true)
|
||||
{
|
||||
|
@@ -76,7 +76,7 @@ public class UserShortcutsBean implements Serializable
|
||||
/** List of shortcut nodes */
|
||||
private List<Node> shortcuts = null;
|
||||
|
||||
private String PREF_SHORTCUTS = "shortcuts";
|
||||
private static final String PREF_SHORTCUTS = "shortcuts";
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
@@ -142,8 +142,8 @@ public class UserShortcutsBean implements Serializable
|
||||
tx.begin();
|
||||
|
||||
// get the shortcuts from the preferences for this user
|
||||
shortcuts = (List<String>)PreferencesService.getPreferences(context).getValue(PREF_SHORTCUTS);
|
||||
if (shortcuts != null)
|
||||
shortcuts = getShortcutList(context);
|
||||
if (shortcuts.size() != 0)
|
||||
{
|
||||
// each shortcut node ID is persisted as a list item in a well known property
|
||||
this.shortcuts = new ArrayList<Node>(shortcuts.size());
|
||||
@@ -274,11 +274,7 @@ public class UserShortcutsBean implements Serializable
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
List<String> shortcuts = (List<String>)PreferencesService.getPreferences(context).getValue(PREF_SHORTCUTS);
|
||||
if (shortcuts == null)
|
||||
{
|
||||
shortcuts = new ArrayList<String>(1);
|
||||
}
|
||||
List<String> shortcuts = getShortcutList(context);
|
||||
shortcuts.add(node.getNodeRef().getId());
|
||||
PreferencesService.getPreferences(context).setValue(PREF_SHORTCUTS, (Serializable)shortcuts);
|
||||
|
||||
@@ -322,8 +318,8 @@ public class UserShortcutsBean implements Serializable
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
List<String> shortcuts = (List<String>)PreferencesService.getPreferences(context).getValue(PREF_SHORTCUTS);
|
||||
if (shortcuts != null && shortcuts.size() > shortcutEvent.Index)
|
||||
List<String> shortcuts = getShortcutList(context);
|
||||
if (shortcuts.size() > shortcutEvent.Index)
|
||||
{
|
||||
// remove the shortcut from the saved list and persist back
|
||||
shortcuts.remove(shortcutEvent.Index);
|
||||
@@ -347,6 +343,32 @@ public class UserShortcutsBean implements Serializable
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the List of shortcut values - will always return at least an empty List
|
||||
*/
|
||||
private static List<String> getShortcutList(FacesContext context)
|
||||
{
|
||||
List<String> shortcuts = null;
|
||||
|
||||
Object prefValue = PreferencesService.getPreferences(context).getValue(PREF_SHORTCUTS);
|
||||
if (prefValue instanceof List)
|
||||
{
|
||||
shortcuts = (List<String>)prefValue;
|
||||
}
|
||||
else if (prefValue instanceof String)
|
||||
{
|
||||
shortcuts = new ArrayList<String>(1);
|
||||
shortcuts.add((String)prefValue);
|
||||
}
|
||||
|
||||
// handle missing and empty (immutable) list collection
|
||||
if (shortcuts == null || shortcuts.size() == 0)
|
||||
{
|
||||
shortcuts = new ArrayList<String>(1);
|
||||
}
|
||||
return shortcuts;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler bound to the user shortcuts Shelf component called when a node is clicked
|
||||
*/
|
||||
@@ -398,8 +420,8 @@ public class UserShortcutsBean implements Serializable
|
||||
tx = Repository.getUserTransaction(context);
|
||||
tx.begin();
|
||||
|
||||
List<String> shortcuts = (List<String>)PreferencesService.getPreferences(context).getValue(PREF_SHORTCUTS);
|
||||
if (shortcuts != null && shortcuts.size() > shortcutEvent.Index)
|
||||
List<String> shortcuts = getShortcutList(context);
|
||||
if (shortcuts.size() > shortcutEvent.Index)
|
||||
{
|
||||
// remove the shortcut from the saved list and persist back
|
||||
shortcuts.remove(shortcutEvent.Index);
|
||||
|
Reference in New Issue
Block a user