1 4 package com.sslexplorer.policyframework.itemactions; 5 6 import org.apache.struts.action.ActionMapping; 7 8 import com.sslexplorer.navigation.AbstractFavoriteItem; 9 import com.sslexplorer.policyframework.NoPermissionException; 10 import com.sslexplorer.policyframework.PolicyConstants; 11 import com.sslexplorer.policyframework.PolicyUtil; 12 import com.sslexplorer.policyframework.ResourceItem; 13 import com.sslexplorer.security.Constants; 14 import com.sslexplorer.security.SessionInfo; 15 import com.sslexplorer.table.AvailableTableItemAction; 16 import com.sslexplorer.table.TableItemAction; 17 18 public final class AddToFavoritesAction extends AbstractPathAction { 19 20 public static final String TABLE_ITEM_ACTION_ID = "addToFavorites"; 21 22 public AddToFavoritesAction(String messageResourcesKey) { 23 super(TABLE_ITEM_ACTION_ID, messageResourcesKey, 100, false, SessionInfo.USER_CONSOLE_CONTEXT, 24 "{2}.do?actionTarget=favorite&selectedResource={0}"); 25 } 26 27 public boolean isEnabled(AvailableTableItemAction availableItem) { 28 AbstractFavoriteItem item = (AbstractFavoriteItem) availableItem.getRowItem(); 29 if(item.getFavoriteType().equals(AbstractFavoriteItem.NO_FAVORITE)) { 30 try { 31 PolicyUtil.checkPermission(PolicyConstants.FAVORITES_RESOURCE_TYPE, PolicyConstants.PERM_USE, availableItem.getRequest()); 32 return true; 33 } catch (NoPermissionException npe) { 34 } 35 } 36 return false; 37 } 38 } | Popular Tags |