@Override
 public List<Shortcut> getAllowedShortcuts(UserDetails user) throws ApsSystemException {
   List<Shortcut> allowedShortcuts = new ArrayList<Shortcut>();
   if (null == user) {
     ApsSystemUtils.getLogger().info("Required allowed shortcut for null user");
     return allowedShortcuts;
   }
   try {
     Iterator<Shortcut> shorCutIter = this.getShortcuts().values().iterator();
     while (shorCutIter.hasNext()) {
       Shortcut shortcut = shorCutIter.next();
       String permissionName = shortcut.getRequiredPermission();
       if (null == permissionName
           || this.getAuthorizationManager().isAuthOnPermission(user, permissionName)) {
         allowedShortcuts.add(shortcut.clone());
       }
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "getAllowedShortcuts");
     throw new ApsSystemException(
         "Error extracting allowed shortcuts by user " + user.getUsername(), t);
   }
   BeanComparator comparator = new BeanComparator("source");
   Collections.sort(allowedShortcuts, comparator);
   return allowedShortcuts;
 }
 private String[] checkShortcutConfig(UserDetails user, String[] config) throws Throwable {
   if (null == config) {
     config = new String[this.getUserShortcutsMaxNumber()];
   }
   try {
     if (config.length != this.getUserShortcutsMaxNumber()) {
       String[] newConfig = new String[this.getUserShortcutsMaxNumber()];
       for (int i = 0; i < config.length; i++) {
         if (i >= newConfig.length) continue;
         newConfig[i] = config[i];
       }
       config = newConfig;
     }
     for (int i = 0; i < config.length; i++) {
       String code = config[i];
       Shortcut shortcut = this.getShortcuts().get(code);
       String reqPerm = (null == shortcut) ? null : shortcut.getRequiredPermission();
       if (null == shortcut
           || (null != reqPerm
               && !this.getAuthorizationManager().isAuthOnPermission(user, reqPerm))) {
         config[i] = null;
       }
     }
   } catch (Throwable t) {
     ApsSystemUtils.logThrowable(t, this, "checkShortcutConfig");
     throw new ApsSystemException(
         "Error checking Shortcut Config by user " + user.getUsername(), t);
   }
   return config;
 }
 @Override
 public Shortcut getShortcut(String code) {
   Shortcut shortcut = this.getShortcuts().get(code);
   if (null == shortcut) {
     return null;
   }
   return shortcut.clone();
 }
 private boolean containsShortcut(List<Shortcut> shortcuts, String expectedShortcut) {
   for (int i = 0; i < shortcuts.size(); i++) {
     Shortcut shortcut = shortcuts.get(i);
     if (shortcut.getId().equals(expectedShortcut)) {
       return true;
     }
   }
   return false;
 }