KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > webforwards > forms > WebForwardsForm


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.webforwards.forms;
21
22 import java.util.Iterator JavaDoc;
23 import java.util.List JavaDoc;
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import com.sslexplorer.boot.HostService;
29 import com.sslexplorer.policyframework.PolicyDatabaseFactory;
30 import com.sslexplorer.policyframework.forms.AbstractResourcesForm;
31 import com.sslexplorer.security.SessionInfo;
32 import com.sslexplorer.webforwards.WebForward;
33 import com.sslexplorer.webforwards.WebForwardItem;
34 import com.sslexplorer.webforwards.WebForwardItemModel;
35
36 /**
37  * <p>
38  * Form providing the list of web forwards to the jspf.
39  *
40  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
41  *
42  */

43 public class WebForwardsForm extends AbstractResourcesForm {
44
45     private static Log log = LogFactory.getLog(WebForwardsForm.class);
46     private String JavaDoc type;
47
48     /**
49      * Construtor
50      */

51     public WebForwardsForm() {
52         super(new WebForwardItemModel("webForward"));
53     }
54
55     /**
56      * <p>
57      * Initialise the pager and the items and the ability to sort.
58      *
59      * @param webForwards List of Web Forwards to be added.
60      * @param hostService host service
61      * @param vpnSession vpn session
62      * @param sessionInfo session
63      */

64     public void initialise(List JavaDoc webForwards, HostService hostService, SessionInfo sessionInfo) {
65         super.initialize(sessionInfo.getHttpSession(), "category");
66         try {
67             for (Iterator JavaDoc i = webForwards.iterator(); i.hasNext();) {
68                 WebForward wf = (WebForward) i.next();
69                 List JavaDoc policies = PolicyDatabaseFactory.getInstance().getPoliciesAttachedToResource(wf, sessionInfo.getUser().getRealm());
70                 WebForwardItem wfi = new WebForwardItem(wf, hostService, policies, wf.sessionPasswordRequired(sessionInfo));
71                 wfi.setFavoriteType(getFavoriteType(wf.getResourceId()));
72                 getModel().addItem(wfi);
73             }
74             checkSort();
75             getPager().rebuild(getFilterText());
76         } catch (Throwable JavaDoc t) {
77             log.error("Failed to initialise resources form.", t);
78         }
79     }
80
81     public String JavaDoc getType() {
82         return type;
83     }
84
85     public void setType(String JavaDoc type) {
86         this.type = type;
87     }
88 }
Popular Tags