📄 installextensionsform.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.sslexplorer.install.forms;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sslexplorer.extensions.ExtensionBundle;
import com.sslexplorer.extensions.ExtensionBundleItem;
import com.sslexplorer.extensions.store.ExtensionStore;
import com.sslexplorer.extensions.store.ExtensionStoreDescriptor;
import com.sslexplorer.wizard.AbstractWizardSequence;
import com.sslexplorer.wizard.forms.DefaultWizardForm;
public class InstallExtensionsForm extends DefaultWizardForm {
final static Log log = LogFactory.getLog(InstallExtensionsForm.class);
// Private statics for sequence attributes
public final static String ATTR_INSTALL_BUNDLE_PREFIX = "installBundle.";
// Private instance variables
private List installable;
private Exception connectionException;
public InstallExtensionsForm() {
super(true, true, "/WEB-INF/jsp/content/install/installExtensions.jspf",
"", true, false, "installExtensions", "install", "installation.installExtensions",
7);
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.wizard.forms.AbstractWizardForm#init(com.sslexplorer.wizard.AbstractWizardSequence)
*/
public void init(AbstractWizardSequence sequence, HttpServletRequest request) throws Exception {
if (log.isInfoEnabled())
log.info("Checking for available extension updates.");
try {
ExtensionStoreDescriptor descriptor = ExtensionStore.getInstance().getDownloadableExtensionStoreDescriptor(true);
installable = new ArrayList();
for (Iterator i = descriptor.getExtensionBundles().iterator(); i.hasNext();) {
ExtensionBundle bundle = (ExtensionBundle) i.next();
if(!bundle.getId().startsWith("sslexplorer-enterprise") && bundle.getType() != ExtensionBundle.TYPE_CONFIGUREABLE) {
if (ExtensionStore.getInstance().isExtensionLoaded(bundle.getId())) {
ExtensionBundle installed = ExtensionStore.getInstance().getExtensionBundle(bundle.getId());
if (bundle.getVersion().compareTo(installed.getVersion()) > 0) {
installable.add(new ExtensionBundleItem(bundle, false));
}
}
else {
installable.add(new ExtensionBundleItem(bundle, false));
}
}
}
sequence.removeAttribute(ConfigureProxiesForm.ATTR_EXTENSION_STORE_EXCEPTION);
}
catch(Exception e) {
log.error("Failed to get downloadable extensions.", e);
sequence.putAttribute(ConfigureProxiesForm.ATTR_EXTENSION_STORE_EXCEPTION, e);
}
connectionException = (Exception)sequence.getAttribute(ConfigureProxiesForm.ATTR_EXTENSION_STORE_EXCEPTION, null);
if(connectionException == null && installable != null) {
for(Iterator i = installable.iterator(); i.hasNext(); ) {
ExtensionBundleItem item = (ExtensionBundleItem)i.next();
String sel = (String)sequence.getAttribute(ATTR_INSTALL_BUNDLE_PREFIX + item.getBundle().getId(), "false");
item.setSelected(sel);
}
}
}
/*
* (non-Javadoc)
*
* @see com.sslexplorer.wizard.forms.AbstractWizardForm#apply(com.sslexplorer.wizard.AbstractWizardSequence)
*/
public void apply(AbstractWizardSequence sequence) throws Exception {
if(installable != null) {
for(Iterator i = installable.iterator(); i.hasNext(); ) {
ExtensionBundleItem item = (ExtensionBundleItem)i.next();
sequence.putAttribute(ATTR_INSTALL_BUNDLE_PREFIX + item.getBundle().getId(),
item.getSelected());
}
}
}
/**
* @return Returns the installable.
*/
public List getInstallable() {
return installable;
}
/**
* @return Returns the connectionException.
*/
public Exception getConnectionException() {
return connectionException;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -