KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > sample > forms > SamplesForm


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.sample.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.core.CoreServlet;
29 import com.sslexplorer.policyframework.forms.AbstractResourcesForm;
30 import com.sslexplorer.sample.Sample;
31 import com.sslexplorer.sample.SampleItem;
32 import com.sslexplorer.security.SessionInfo;
33
34 /**
35  * <p>
36  * Form providing the list of samples to the jspf.
37  *
38  * @author James D Robinson <a HREF="mailto:james@3sp.com">&lt;james@3sp.com&gt;</a>
39  *
40  */

41 public class SamplesForm extends AbstractResourcesForm {
42
43     static Log log = LogFactory.getLog(SamplesForm.class);
44
45     /**
46      * Constructor
47      */

48     public SamplesForm() {
49         super("samples");
50     }
51
52     /**
53      * <p>
54      * Initialise the pager and the items and the ability to sort.
55      *
56      * @param samples List of SampleDatabase to be added.
57      * @param session The sessin information.
58      */

59     public void initialise(List JavaDoc samples, SessionInfo session, String JavaDoc defaultSortColumnId) {
60         super.initialize(session.getHttpSession(), defaultSortColumnId);
61         try {
62             for (Iterator JavaDoc i = samples.iterator(); i.hasNext();) {
63                 Sample sample = (Sample) i.next();
64                 List JavaDoc policies = CoreServlet.getServlet().getPolicyDatabase().getPoliciesAttachedToResource(sample);
65                 SampleItem si = new SampleItem(sample, policies);
66                 si.setFavoriteType(getFavoriteType(si.getResource().getResourceId()));
67                 getModel().addItem(si);
68             }
69             checkSort();
70             getPager().rebuild(getFilterText());
71         } catch (Throwable JavaDoc t) {
72             log.error("Failed to initialise resources form.", t);
73         }
74     }
75 }
76
Popular Tags