From 6df515c801193c7eb2a851da7eaa4d1c6ff06351 Mon Sep 17 00:00:00 2001 From: Kevin Roast Date: Thu, 22 Dec 2005 11:35:47 +0000 Subject: [PATCH] Fix to minor bug in UserShortcutsBean git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2055 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../alfresco/web/bean/UserShortcutsBean.java | 80 +++++++++++++------ 1 file changed, 55 insertions(+), 25 deletions(-) diff --git a/source/java/org/alfresco/web/bean/UserShortcutsBean.java b/source/java/org/alfresco/web/bean/UserShortcutsBean.java index 14e39b8e91..7ecb58afaa 100644 --- a/source/java/org/alfresco/web/bean/UserShortcutsBean.java +++ b/source/java/org/alfresco/web/bean/UserShortcutsBean.java @@ -27,6 +27,7 @@ import javax.faces.event.ActionEvent; import javax.transaction.UserTransaction; import org.alfresco.model.ContentModel; +import org.alfresco.repo.security.permissions.AccessDeniedException; import org.alfresco.service.cmr.dictionary.DictionaryService; import org.alfresco.service.cmr.repository.InvalidNodeRefException; import org.alfresco.service.cmr.repository.NodeRef; @@ -88,16 +89,19 @@ public class UserShortcutsBean { if (this.shortcuts == null) { + List shortcuts = null; + NodeRef prefRef = null; UserTransaction tx = null; + boolean rollback = false; try { FacesContext context = FacesContext.getCurrentInstance(); - tx = Repository.getUserTransaction(context); + tx = Repository.getUserTransaction(context, true); tx.begin(); // get the shortcuts from the preferences for this user - NodeRef prefRef = getShortcutsNodeRef(); - List shortcuts = (List)this.nodeService.getProperty(prefRef, QNAME_SHORTCUTS); + prefRef = getShortcutsNodeRef(); + shortcuts = (List)this.nodeService.getProperty(prefRef, QNAME_SHORTCUTS); if (shortcuts != null) { // each shortcut node ID is persisted as a list item in a well known property @@ -105,43 +109,49 @@ public class UserShortcutsBean for (int i=0; i(this.shortcuts.size()); - for (int i=0; i(5); } - tx.commit(); + if (rollback == false) + { + tx.commit(); + } + else + { + tx.rollback(); + } } catch (Exception err) { @@ -149,6 +159,26 @@ public class UserShortcutsBean FacesContext.getCurrentInstance(), Repository.ERROR_GENERIC), err.getMessage()), err); try { if (tx != null) {tx.rollback();} } catch (Exception tex) {} } + + // if the count of accessable shortcuts is different to our original list then + // write the valid shortcut IDs back to correct invalid node refs + if (shortcuts != null && shortcuts.size() != this.shortcuts.size()) + { + try + { + shortcuts = new ArrayList(this.shortcuts.size()); + for (int i=0; i