1 19 20 package com.sslexplorer.policyframework.itemactions; 21 22 import java.text.MessageFormat ; 23 24 import org.apache.struts.action.ActionMapping; 25 26 import com.sslexplorer.boot.Util; 27 import com.sslexplorer.policyframework.ResourceItem; 28 import com.sslexplorer.security.Constants; 29 import com.sslexplorer.security.SessionInfo; 30 import com.sslexplorer.table.AvailableTableItemAction; 31 import com.sslexplorer.table.TableItemAction; 32 33 35 public class AbstractPathAction extends TableItemAction { 36 37 protected final String requiredPath; 38 39 40 41 50 public AbstractPathAction(String id, String messageResourcesKey, int weight, boolean important, String requiredPath) { 51 this(id, messageResourcesKey, weight, null, important, requiredPath); 52 } 53 54 64 public AbstractPathAction(String id, String messageResourcesKey, int weight, String target, boolean important, String requiredPath) { 65 this(id, messageResourcesKey, weight, target, important, SessionInfo.ALL_CONTEXTS, requiredPath); 66 } 67 68 78 public AbstractPathAction(String id, String messageResourcesKey, int weight, boolean important, int navigationContext, String requiredPath) { 79 this(id, messageResourcesKey, weight, null, important, navigationContext, requiredPath); 80 } 81 82 93 public AbstractPathAction(String id, String messageResourcesKey, int weight, String target, boolean important, int navigationContext, String requiredPath) { 94 super(id, messageResourcesKey, weight, target, important, navigationContext, null, null); 95 this.requiredPath = requiredPath; 96 } 97 98 102 public String getPath(AvailableTableItemAction availableItem) { 103 ResourceItem item = (ResourceItem) availableItem.getRowItem(); 104 return getPath(String.valueOf(item.getResource().getResourceId()), availableItem); 105 } 106 107 112 public String getPath(String parameterId, AvailableTableItemAction availableItem) { 113 ActionMapping attribute = (ActionMapping)availableItem.getRequest().getAttribute(Constants.REQ_ATTR_ACTION_MAPPING); 114 String formattedPath = MessageFormat.format(requiredPath, new Object [] {parameterId, attribute.getName(), attribute.getPath()}); 115 return formattedPath; 116 } 117 } | Popular Tags |