KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > networkplaces > itemactions > OpenWebFolderAction


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.networkplaces.itemactions;
21
22 import com.sslexplorer.core.BrowserChecker;
23 import com.sslexplorer.core.CoreUtil;
24 import com.sslexplorer.networkplaces.NetworkPlaceItem;
25 import com.sslexplorer.networkplaces.NetworkPlacePlugin;
26 import com.sslexplorer.policyframework.ResourceItem;
27 import com.sslexplorer.properties.Property;
28 import com.sslexplorer.properties.impl.systemconfig.SystemConfigKey;
29 import com.sslexplorer.security.WebDAVAuthenticationModule;
30 import com.sslexplorer.table.AvailableTableItemAction;
31 import com.sslexplorer.table.TableItemAction;
32
33 public class OpenWebFolderAction extends TableItemAction {
34
35     public static final String JavaDoc TABLE_ITEM_ACTION_ID = "addToFavorites";
36
37     public OpenWebFolderAction(String JavaDoc messageResourcesKey) {
38         super("openWebFolder", messageResourcesKey, 100, "_self", false);
39     }
40     
41     public ResourceItem getResourceItem(AvailableTableItemAction availableItem) {
42         return (ResourceItem)availableItem.getRowItem();
43     }
44     
45
46     public boolean isEnabled(AvailableTableItemAction availableItem) {
47         ResourceItem item = getResourceItem(availableItem);
48         try {
49             BrowserChecker checker = new BrowserChecker(availableItem.getRequest().getHeader("user-agent"));
50             if (item.getResource().getResourceType().equals(
51                     NetworkPlacePlugin.NETWORK_PLACE_RESOURCE_TYPE)
52                     && CoreUtil
53                             .isAuthenticationModuleInUse(WebDAVAuthenticationModule.MODULE_NAME)
54                     && ( checker.isBrowserVersionExpression(BrowserChecker.BROWSER_IE, "+=5") ||
55                         ( Property.getPropertyBoolean(
56                             new SystemConfigKey("ui.allowOpenWebFolderInFirefox")) && checker.isBrowserVersion(BrowserChecker.BROWSER_FIREFOX, -1) ) ) ) {
57                 return true;
58             }
59         } catch (Exception JavaDoc e) {
60         }
61         return false;
62     }
63
64     public String JavaDoc getPath(AvailableTableItemAction availableItem) {
65         NetworkPlaceItem npi = (NetworkPlaceItem)getResourceItem(availableItem);
66         return npi.getWebFolderPath(-1, availableItem.getRequest());
67     }
68     
69     public String JavaDoc getAdditionalAttributeName() {
70         return "folder";
71     }
72     
73     public String JavaDoc getAdditionalAttributeValue(AvailableTableItemAction availableItem) {
74         //return getPath(availableItem) + "?ticket=" + availableItem.getRequest().getSession().getAttribute(Constants.WEB_FOLDER_LAUNCH_TICKET);
75
return getPath(availableItem);
76     }
77 }
Popular Tags