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