KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > policyframework > itemactions > RemoveFromFavoritesAction


1 /**
2  *
3  */

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 RemoveFromFavoritesAction extends AbstractPathAction {
19     
20     public static final String JavaDoc TABLE_ITEM_ACTION_ID = "removeFromFavorites";
21
22     public RemoveFromFavoritesAction(String JavaDoc messageResourcesKey) {
23         super(TABLE_ITEM_ACTION_ID, messageResourcesKey, 100, false, SessionInfo.USER_CONSOLE_CONTEXT,
24             "{2}.do?actionTarget=removeFavorite&selectedResource={0}");
25     }
26
27     public boolean isEnabled(AvailableTableItemAction availableItem) {
28         AbstractFavoriteItem item = (AbstractFavoriteItem) availableItem.getRowItem();
29         if(item.getFavoriteType().equals(AbstractFavoriteItem.USER_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