KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.policyframework.itemactions;
21
22 import java.text.MessageFormat JavaDoc;
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 /**
34  */

35 public class AbstractPathAction extends TableItemAction {
36
37     protected final String JavaDoc requiredPath;
38
39
40     
41     /**
42      * Constructor for all navigation contexts.
43      *
44      * @param id table model ID to
45      * @param messageResourcesKey
46      * @param weight weight
47      * @param important important
48      * @param requiredPath
49      */

50     public AbstractPathAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, boolean important, String JavaDoc requiredPath) {
51         this(id, messageResourcesKey, weight, null, important, requiredPath);
52     }
53     
54     /**
55      * Constructor for all navigation contexts.
56      *
57      * @param id table model ID to
58      * @param messageResourcesKey
59      * @param weight weight
60      * @param target target frame
61      * @param important important
62      * @param requiredPath
63      */

64     public AbstractPathAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, String JavaDoc target, boolean important, String JavaDoc requiredPath) {
65         this(id, messageResourcesKey, weight, target, important, SessionInfo.ALL_CONTEXTS, requiredPath);
66     }
67     
68     /**
69      * Constructor.
70      *
71      * @param id table model ID to
72      * @param messageResourcesKey
73      * @param weight weight
74      * @param important important
75      * @param navigationContext navigation context mask
76      * @param requiredPath
77      */

78     public AbstractPathAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, boolean important, int navigationContext, String JavaDoc requiredPath) {
79         this(id, messageResourcesKey, weight, null, important, navigationContext, requiredPath);
80     }
81     
82     /**
83      * Constructor.
84      *
85      * @param id table model ID to
86      * @param messageResourcesKey
87      * @param weight weight
88      * @param target target frame
89      * @param important important
90      * @param navigationContext navigation context mask
91      * @param requiredPath
92      */

93     public AbstractPathAction(String JavaDoc id, String JavaDoc messageResourcesKey, int weight, String JavaDoc target, boolean important, int navigationContext, String JavaDoc requiredPath) {
94         super(id, messageResourcesKey, weight, target, important, navigationContext, null, null);
95         this.requiredPath = requiredPath;
96     }
97
98     /*
99      * (non-Javadoc)
100      * @see com.sslexplorer.table.TableItemAction#getPath(com.sslexplorer.table.AvailableTableItemAction)
101      */

102     public String JavaDoc getPath(AvailableTableItemAction availableItem) {
103         ResourceItem item = (ResourceItem) availableItem.getRowItem();
104         return getPath(String.valueOf(item.getResource().getResourceId()), availableItem);
105     }
106     
107     /**
108      * @param parameterId
109      * @param availableItem
110      * @return String
111      */

112     public String JavaDoc getPath(String JavaDoc parameterId, AvailableTableItemAction availableItem) {
113         ActionMapping attribute = (ActionMapping)availableItem.getRequest().getAttribute(Constants.REQ_ATTR_ACTION_MAPPING);
114         String JavaDoc formattedPath = MessageFormat.format(requiredPath, new Object JavaDoc[] {parameterId, attribute.getName(), attribute.getPath()});
115         return formattedPath;
116     }
117 }
Popular Tags