KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > itemactions > ViewProfileAction


1 /**
2  *
3  */

4 package com.sslexplorer.properties.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.properties.PropertyProfile;
12 import com.sslexplorer.security.SessionInfo;
13 import com.sslexplorer.table.AvailableTableItemAction;
14 import com.sslexplorer.table.TableItemAction;
15
16 public final class ViewProfileAction extends TableItemAction {
17     public ViewProfileAction() {
18         super("view", "properties", 50, false);
19     }
20
21     public boolean isEnabled(AvailableTableItemAction availableItem) {
22         ResourceItem item = (ResourceItem) availableItem
23                 .getRowItem();
24         try {
25             ResourceUtil.checkResourceManagementRights(item.getResource(), availableItem.getSessionInfo(), new Permission[] { PolicyConstants.PERM_CREATE_EDIT_AND_ASSIGN, PolicyConstants.PERM_EDIT_AND_ASSIGN });
26             return true;
27         }
28         catch(NoPermissionException npe) {
29             try {
30                 ResourceUtil.checkResourceAccessRights(item.getResource(), availableItem.getSessionInfo());
31                 return true;
32             } catch (NoPermissionException e) {
33             }
34         }
35         return false;
36     }
37
38     public String JavaDoc getPath(AvailableTableItemAction availableItem) {
39         ResourceItem item = (ResourceItem) availableItem
40                 .getRowItem();
41         PropertyProfile p = (PropertyProfile)item.getResource();
42         return p.getOwnerUsername() != null || ( p.getOwnerUsername() == null && availableItem.getSessionInfo().getNavigationContext() == SessionInfo.USER_CONSOLE_CONTEXT) ? "/showUserProperties.do?selectedPropertyProfile=" + item.getResource().getResourceId() :
43             "/showGlobalProperties.do?selectedPropertyProfile=" + item.getResource().getResourceId();
44     }
45 }
Popular Tags