KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > properties > wizards > forms > ProfileDetailsForm


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.wizards.forms;
21
22 import java.util.ArrayList 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
30 import com.sslexplorer.core.CoreServlet;
31 import com.sslexplorer.core.forms.AbstractResourceDetailsWizardForm;
32 import com.sslexplorer.policyframework.PolicyConstants;
33 import com.sslexplorer.policyframework.ResourceUtil;
34 import com.sslexplorer.properties.ProfilesFactory;
35 import com.sslexplorer.properties.wizards.actions.ProfileDetailsAction;
36 import com.sslexplorer.security.Constants;
37 import com.sslexplorer.security.LogonControllerFactory;
38 import com.sslexplorer.security.User;
39 import com.sslexplorer.wizard.AbstractWizardSequence;
40
41 public class ProfileDetailsForm extends AbstractResourceDetailsWizardForm {
42     private List JavaDoc availableProfiles;
43     private int baseOn;
44
45     final static Log log = LogFactory.getLog(ProfileDetailsForm.class);
46
47     // Statics for sequence attributes
48
public final static String JavaDoc ATTR_BASE_ON = "baseOn";
49
50     public ProfileDetailsForm() {
51         super(true, false, "/WEB-INF/jsp/content/properties/profileWizard/profileDetails.jspf", "resourceName", true, false,
52                         "profileDetails", "properties", "profileWizard.profileDetails", 1, PolicyConstants.PROFILE_RESOURCE_TYPE);
53         availableProfiles = new ArrayList JavaDoc();
54     }
55
56     /*
57      * (non-Javadoc)
58      *
59      * @see com.sslexplorer.wizard.forms.DefaultWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence)
60      */

61     public void init(AbstractWizardSequence sequence, HttpServletRequest JavaDoc request) throws Exception JavaDoc {
62         super.init(sequence, request);
63         baseOn = ((Integer JavaDoc) sequence.getAttribute(ATTR_BASE_ON, new Integer JavaDoc(0))).intValue();
64         availableProfiles.clear();
65         try {
66             String JavaDoc scope = (String JavaDoc) sequence.getAttribute(ProfileDetailsAction.ATTR_PROFILE_SCOPE, null);
67             User user = LogonControllerFactory.getInstance().getUser(request);
68             availableProfiles = ResourceUtil.filterResources(user, ProfilesFactory.getInstance()
69                             .getPropertyProfiles(Constants.SCOPE_PERSONAL.equals(scope) ? user.getPrincipalName() : "", true,
70                             user.getRealm().getResourceId()), Constants.SCOPE_PERSONAL.equals(scope) ? false : true);
71         } catch (Exception JavaDoc e) {
72             log.error("Could not get available profiles.", e);
73         }
74     }
75
76     /**
77      * @return Returns the baseOn.
78      */

79     public int getBaseOn() {
80         return baseOn;
81     }
82
83     /**
84      * @param baseOn The baseOn to set.
85      */

86     public void setBaseOn(int baseOn) {
87         this.baseOn = baseOn;
88     }
89
90     /**
91      * @return Returns the availableProfiles.
92      */

93     public List JavaDoc getAvailableProfiles() {
94         return availableProfiles;
95     }
96
97     /*
98      * (non-Javadoc)
99      *
100      * @see com.sslexplorer.core.forms.AbstractResourceWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
101      */

102     public void apply(AbstractWizardSequence sequence) throws Exception JavaDoc {
103         super.apply(sequence);
104         sequence.putAttribute(ATTR_BASE_ON, new Integer JavaDoc(baseOn));
105     }
106     }
107
108
Popular Tags