KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > forms > ProfilePropertiesForm


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.properties.forms;
21
22 import java.util.Arrays JavaDoc;
23 import java.util.List JavaDoc;
24
25 import javax.servlet.http.HttpServletRequest JavaDoc;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.action.ActionMapping;
30
31 import com.sslexplorer.boot.PropertyClass;
32 import com.sslexplorer.boot.PropertyClassManager;
33 import com.sslexplorer.core.CoreServlet;
34 import com.sslexplorer.properties.ProfilesFactory;
35 import com.sslexplorer.properties.PropertyProfile;
36 import com.sslexplorer.properties.impl.profile.ProfileProperties;
37 import com.sslexplorer.security.Constants;
38
39 /**
40  * @author Brett Smith
41  */

42 public class ProfilePropertiesForm extends AbstractPropertiesForm {
43
44     static Log log = LogFactory.getLog(ProfilePropertiesForm.class);
45
46     private List JavaDoc propertyProfiles;
47     private int selectedPropertyProfile;
48     private String JavaDoc profileScope;
49
50     public ProfilePropertiesForm() {
51         super(Arrays.asList(new PropertyClass[] { PropertyClassManager.getInstance().getPropertyClass(ProfileProperties.NAME) } ), true);
52     }
53
54     public boolean getEnabled() {
55         try {
56             PropertyProfile profile = ProfilesFactory.getInstance()
57                             .getPropertyProfile(getSelectedPropertyProfile());
58             boolean global = profile.getOwnerUsername() == null || profile.getOwnerUsername().equals("");
59             return (Constants.SCOPE_PERSONAL.equals(getProfileScope()) && !global) || (Constants.SCOPE_GLOBAL.equals(getProfileScope()) && global);
60         } catch (Exception JavaDoc e) {
61             log.error("Failed to get property profile details. Disabling form.", e);
62             return false;
63         }
64
65     }
66
67     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
68         super.reset(mapping, request);
69 // selectedPropertyProfile = -1;
70
}
71
72     public void setPropertyProfiles(List JavaDoc propertyProfiles) {
73         this.propertyProfiles = propertyProfiles;
74     }
75
76     public List JavaDoc getPropertyProfiles() {
77         return propertyProfiles;
78     }
79
80     public void setSelectedPropertyProfile(int id) {
81         selectedPropertyProfile = id;
82     }
83
84     public int getSelectedPropertyProfile() {
85         return selectedPropertyProfile;
86     }
87
88     public boolean getHasProfiles() {
89         return propertyProfiles != null && !Constants.SCOPE_SETUP.equals(profileScope);
90     }
91     public String JavaDoc getProfileScope() {
92         return profileScope;
93     }
94
95     public void setProfileScope(String JavaDoc profileScope) {
96         this.profileScope = profileScope;
97     }
98 }
Popular Tags