1 19 20 package com.sslexplorer.policyframework.itemactions; 21 22 import com.sslexplorer.core.UserDatabaseManager; 23 import com.sslexplorer.policyframework.NoPermissionException; 24 import com.sslexplorer.policyframework.Permission; 25 import com.sslexplorer.policyframework.Policy; 26 import com.sslexplorer.policyframework.PolicyConstants; 27 import com.sslexplorer.policyframework.PolicyDatabaseFactory; 28 import com.sslexplorer.policyframework.ResourceItem; 29 import com.sslexplorer.policyframework.ResourceUtil; 30 import com.sslexplorer.realms.Realm; 31 import com.sslexplorer.table.AvailableTableItemAction; 32 33 public class RemovePolicyAction extends RemoveResourceAction { 34 35 39 public RemovePolicyAction(int navigationContext, String messageResourcesKey) { 40 super(navigationContext, messageResourcesKey); 41 } 42 43 public boolean isEnabled(AvailableTableItemAction availableItem) { 44 try { 45 ResourceItem item = (ResourceItem) availableItem.getRowItem(); 46 try { 47 Realm realm = UserDatabaseManager.getInstance().getRealm(item.getResource().getRealmID()); 48 if (item.getResource().getResourceId() == PolicyDatabaseFactory.getInstance().getEveryonePolicyIDForRealm(realm)){ 49 return false; 51 } 52 } catch (Exception e) { 53 return false; 55 } 56 57 Permission[] permissions = new Permission[] { PolicyConstants.PERM_DELETE }; 58 ResourceUtil.checkResourceManagementRights(item.getResource(), availableItem.getSessionInfo(), permissions); 59 return true; 60 } catch (NoPermissionException e) { 61 return false; 62 } 63 } 64 65 } 66 | Popular Tags |