KickJava   Java API By Example, From Geeks To Geeks.

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


1 /**
2  *
3  */

4 package com.sslexplorer.policyframework.itemactions;
5
6 import com.sslexplorer.policyframework.NoPermissionException;
7 import com.sslexplorer.policyframework.Permission;
8 import com.sslexplorer.policyframework.PolicyConstants;
9 import com.sslexplorer.policyframework.ResourceItem;
10 import com.sslexplorer.policyframework.ResourceUtil;
11 import com.sslexplorer.table.AvailableTableItemAction;
12
13 /**
14  */

15 public class RemoveResourceAction extends AbstractPathAction {
16     /**
17      */

18     public static final String JavaDoc TABLE_ITEM_ACTION_ID = "remove";
19
20     /**
21      * @param navigationContext
22      * @param messageResourcesKey
23      */

24     public RemoveResourceAction(int navigationContext, String JavaDoc messageResourcesKey) {
25         this(navigationContext, messageResourcesKey, "{2}.do?actionTarget=confirmRemove&selectedResource={0}");
26     }
27
28     /**
29      * @param navigationContext
30      * @param messageResourcesKey
31      * @param requiredPath
32      */

33     public RemoveResourceAction(int navigationContext, String JavaDoc messageResourcesKey, String JavaDoc requiredPath) {
34         super(TABLE_ITEM_ACTION_ID, messageResourcesKey, 200, true, navigationContext, requiredPath);
35     }
36
37     /* (non-Javadoc)
38      * @see com.sslexplorer.table.TableItemAction#isEnabled(com.sslexplorer.table.AvailableTableItemAction)
39      */

40     public boolean isEnabled(AvailableTableItemAction availableItem) {
41         try {
42             ResourceItem item = (ResourceItem) availableItem.getRowItem();
43             Permission[] permissions = new Permission[] { PolicyConstants.PERM_DELETE };
44             ResourceUtil.checkResourceManagementRights(item.getResource(), availableItem.getSessionInfo(), permissions);
45             return true;
46         } catch (NoPermissionException e) {
47             return false;
48         }
49     }
50 }
Popular Tags