KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > install > forms > InstallXtraForm


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.install.forms;
21
22 import java.util.Iterator JavaDoc;
23
24 import javax.servlet.http.HttpServletRequest JavaDoc;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28 import org.apache.struts.action.ActionMapping;
29
30 import com.sslexplorer.extensions.ExtensionBundle;
31 import com.sslexplorer.extensions.store.ExtensionStore;
32 import com.sslexplorer.extensions.store.ExtensionStoreDescriptor;
33 import com.sslexplorer.wizard.AbstractWizardSequence;
34 import com.sslexplorer.wizard.forms.DefaultWizardForm;
35
36 public class InstallXtraForm extends DefaultWizardForm {
37     
38     final static Log log = LogFactory.getLog(InstallXtraForm.class);
39
40     // Private statics for sequence attributes
41
public final static String JavaDoc ATTR_INSTALL_XTRA = "installXtra";
42     
43     // Private instance variables
44
private boolean installXtra;
45     private boolean xtraInstalled;
46     private boolean xtraAvailable;
47     private boolean updateRequired;
48     private Exception JavaDoc connectionException;
49
50     public static final String JavaDoc ENTERPRISE_CORE_BUNDLE_ID = "sslexplorer-enterprise-core";
51     
52     public InstallXtraForm() {
53         super(true, true, "/WEB-INF/jsp/content/install/installXtra.jspf",
54             "", true, false, "installXtra", "install", "installation.installXtra", 6);
55     }
56
57     /*
58      * (non-Javadoc)
59      *
60      * @see com.sslexplorer.wizard.forms.AbstractWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence)
61      */

62     public void init(AbstractWizardSequence sequence, HttpServletRequest JavaDoc request) throws Exception JavaDoc {
63         try {
64             ExtensionStore.getInstance().getExtensionBundle(ENTERPRISE_CORE_BUNDLE_ID);
65             xtraInstalled = true;
66         }
67         catch(Exception JavaDoc e) {
68             xtraInstalled = false;
69         }
70         xtraAvailable = false;
71         updateRequired = false;
72         connectionException = (Exception JavaDoc)sequence.getAttribute(ConfigureProxiesForm.ATTR_EXTENSION_STORE_EXCEPTION, null);
73         if(connectionException != null) {
74             installXtra = false;
75         }
76         else {
77             ExtensionStoreDescriptor installable = ExtensionStore.getInstance().getDownloadableExtensionStoreDescriptor(true);
78             xtraAvailable = installable.getApplicationBundle(ENTERPRISE_CORE_BUNDLE_ID)!=null;
79             
80             boolean found = false;
81             for (Iterator JavaDoc i = installable.getExtensionBundles().iterator(); i.hasNext();) {
82                 ExtensionBundle bundle = (ExtensionBundle) i.next();
83                 if (bundle.getId().equals(ENTERPRISE_CORE_BUNDLE_ID) && ExtensionStore.getInstance().isExtensionLoaded(bundle.getId())) {
84                     ExtensionBundle installed = ExtensionStore.getInstance().getExtensionBundle(bundle.getId());
85                     found = true;
86                     xtraAvailable = true;
87                     if (bundle.getVersion().compareTo(installed.getVersion()) > 0) {
88                         updateRequired = true;
89                     }
90                 }
91             }
92
93             installXtra = updateRequired || "true".equals(
94                 sequence.getAttribute(ATTR_INSTALL_XTRA, "true"));
95         }
96     }
97
98     /*
99      * (non-Javadoc)
100      *
101      * @see com.sslexplorer.wizard.forms.AbstractWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
102      */

103     public void apply(AbstractWizardSequence sequence) throws Exception JavaDoc {
104         sequence.putAttribute(ATTR_INSTALL_XTRA, String.valueOf(installXtra));
105     }
106
107     /**
108      * @return Returns the installXtra.
109      */

110     public boolean getInstallXtra() {
111         return installXtra;
112     }
113
114     /**
115      * @param installXtra The installXtra to set.
116      */

117     public void setInstallXtra(boolean installXtra) {
118         this.installXtra = installXtra;
119     }
120
121     /**
122      * @return Returns the connectionException.
123      */

124     public Exception JavaDoc getConnectionException() {
125         return connectionException;
126     }
127
128     /**
129      * @return Returns the updateRequired.
130      */

131     public boolean getUpdateRequired() {
132         return updateRequired;
133     }
134
135     /**
136      * @return Returns the xtraInstalled.
137      */

138     public boolean getXtraInstalled() {
139         return xtraInstalled;
140     }
141
142     public void reset(ActionMapping mapping, HttpServletRequest JavaDoc request) {
143         super.reset(mapping, request);
144         installXtra = false;
145     }
146
147     public boolean getXtraAvailable() {
148         return xtraAvailable;
149     }
150 }
151
Popular Tags