Changeset 3733
- Timestamp:
- Sep 14, 2007, 2:08:01 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/net/sf/basedb/util/PluginConfigInfo.java
r3704 r3733 57 57 private String description; 58 58 59 /** 60 Constructor to create a new instance with information for a plugin configuration. 61 @param pluginClassName The class name of PluginDefinition this configuration belongs to, 62 see{@link net.sf.basedb.core.PluginConfiguration#getPluginDefinition()} 63 @param configName Name of the plugin configuration, 64 see{@link net.sf.basedb.core.PluginConfiguration#getName()} 65 @param descr Description about the configuration 66 see {@link net.sf.basedb.core.PluginConfiguration#getDescription()} 67 */ 59 68 public PluginConfigInfo(String pluginClassName, String configName, String descr) 60 69 { -
trunk/src/core/net/sf/basedb/util/PluginInfo.java
r3706 r3733 81 81 about each plugin class in the jar file. 82 82 */ 83 private static final String xmlFile = "base-plugins.xml"; 84 85 83 private static final String xmlFile = "META-INF/base-plugins.xml"; 84 85 /** 86 The path in a jar-file to the file that holds 87 configurations to import 88 */ 89 private static final String configurationImportFile = "META-INF/base-configurations.xml"; 86 90 87 91 /** … … 91 95 @param minBaseVersion BASE version that the plugin at least requires 92 96 @param about Information about the plugin. 93 @param config urations A list with configurations for this plugin.97 @param configs A list with configurations for this plugin. 94 98 */ 95 99 public PluginInfo (String jarPath, String className, String minBaseVersion, About about, List<PluginConfigInfo> configs) … … 108 112 {@link net.sf.basedb.core.plugin.Plugin} will not be included in the list but already 109 113 installed plugins will. 110 @param jar PathThe jar file to load the plugin info from.111 @return sList with PluginInfo about the plugins that were found in jar file.114 @param jarFile The jar file to load the plugin info from. 115 @return List with PluginInfo about the plugins that were found in jar file. 112 116 @throws JDOMException If any error loading the XML-document 113 117 @throws IOException If any error with file reading, eg when … … 131 135 //Get the info in base-plugins.xml file. 132 136 //An exception is thrown if the jar file's name is not the same as the xml-file suggest. 133 is = jar.getInputStream(new JarEntry( "META-INF/" +xmlFile));137 is = jar.getInputStream(new JarEntry(xmlFile)); 134 138 URL installDtdURL = PluginInfo.class.getResource("/net/sf/basedb/core/dtd/" + dtdFile); 135 139 Element rootElement = XMLUtil.getValidatedXML(is , installDtdURL, null).getRootElement(); … … 196 200 return pluginInfos; 197 201 } 198 //TODO Methods to load new plugins, installed plugins and199 //plugins which class already exist but in another jar-file.200 202 201 203 /** … … 235 237 } 236 238 239 /** 240 Gets information about the configurations that come together with the plugin in the jar. 241 @return A list with information about each plugin configuration. 242 */ 237 243 public List<PluginConfigInfo> getConfigurations() 238 244 { 239 245 return configs; 246 } 247 248 /** 249 The path inside a jar to the xml-file that holds 250 the pluginconfigurations that can be imported. 251 @return String format path. 252 */ 253 public String getConfigurationsPath() 254 { 255 return configurationImportFile; 240 256 } 241 257 -
trunk/www/admin/plugindefinitions/auto_install.jsp
r3714 r3733 40 40 import="net.sf.basedb.core.query.Expressions" 41 41 import="net.sf.basedb.util.FileUtil" 42 import="net.sf.basedb.util.JarClassLoader" 42 43 import="net.sf.basedb.util.PluginInfo" 43 44 import="net.sf.basedb.util.PluginConfigInfo" … … 65 66 message.append("<b>").append("Class: ").append("</b>"); 66 67 message.append(HTML.encodeTags(info.getClassName())).append("<br>"); 68 69 message.append("<b>").append("Version: ").append("</b>"); 70 message.append(HTML.encodeTags(info.getAbout().getVersion())).append("<br>"); 67 71 68 72 message.append("<b>").append("Works with: ").append("</b>"); … … 148 152 { 149 153 150 if (cnf[i].value == ' yes')154 if (cnf[i].value == '1') 151 155 { 152 156 cnf.selectedIndex = i; … … 167 171 { 168 172 169 if (cnf[i].value == ' no')173 if (cnf[i].value == '0') 170 174 { 171 175 cnf.selectedIndex = i; … … 183 187 var pluginList = document.getElementById('setplugin.' + pluginId); 184 188 var pluginOption = pluginList[pluginList.selectedIndex].value; 185 if ( (configOption == ' yes' && !pluginExists && pluginOption == '') ||186 (configOption == ' no' && pluginOption == 'plugin+confs') )189 if ( (configOption == '1' && !pluginExists && pluginOption == '') || 190 (configOption == '0' && pluginOption == 'plugin+confs') ) 187 191 { 188 192 for (var i=0; i<pluginList.length;i++) … … 239 243 boolean hasConfigs = cnfInfos != null && !cnfInfos.isEmpty(); 240 244 boolean classExists = true; 241 boolean jarExists = true;245 boolean jarExists = false; 242 246 PluginDefinition pd = null; 243 247 try … … 308 312 <input type="hidden" name="<%=info.getClassName()%>.jarExists" value="<%=jarExists%>"> 309 313 <base:icon image="<%=classExists&&!jarExists ? "itemexists.gif" : "" %>" 310 tooltip=" Plugin from another jar-file but with the same class-name is installed"314 tooltip="The plugin is loaded from a different jar-file" 311 315 /> 312 316 <base:icon image="<%=classExists&&jarExists ? "hasvalues.gif" : "" %>" … … 370 374 <select id="setconfig.<%=plugin%>.<%=cnf%>" name="<%=info.getClassName()%>.<%=cnfInfo.getName()%>" 371 375 onChange="setPluginOnChange(<%=plugin%>, this, <%=classExists%>)"> 372 <option value=" no" title="Configuration will not be imported">no</option>373 <option value=" yes" title="Configuration will be imported">yes</option>376 <option value="0" title="Configuration will not be imported">no</option> 377 <option value="1" title="Configuration will be imported">yes</option> 374 378 </select> 375 379 <base:icon image="<%=isDublicate ? "warning.gif" : ""%>" tooltip="Plugin already has a configuration with this name"/> … … 386 390 <i><base:icon image="warning.gif" /> = dublicate configuration</i><br> 387 391 <i><base:icon image="hasvalues.gif" /> = plugin already installed</i><br> 388 <i><base:icon image="itemexists.gif" /> = installed using a different jar-file</i><br> 392 <i><base:icon image="itemexists.gif" /> = exists in a different jar-file,<br> 393 installing will change the jar path.</i><br> 389 394 </div> 390 395 </t:tab> -
trunk/www/admin/plugindefinitions/index.jsp
r3714 r3733 49 49 import="net.sf.basedb.util.FileUtil" 50 50 import="net.sf.basedb.util.PluginInfo" 51 import="net.sf.basedb.util.PluginConfigInfo" 51 52 import="net.sf.basedb.util.RemovableUtil" 52 53 import="net.sf.basedb.util.ShareableUtil" … … 58 59 import="net.sf.basedb.util.Values" 59 60 import="net.sf.basedb.clients.web.util.HTML" 61 import="net.sf.basedb.plugins.PluginConfigurationImporter" 60 62 import="java.util.Enumeration" 61 63 import="java.util.Set" 64 import="java.util.HashMap" 62 65 import="java.util.HashSet" 63 66 import="java.util.List" … … 133 136 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, pageContext, defaultContext); 134 137 cc.setId(0); 135 if (Application.getNonCorePluginDirectory() == null)136 {137 redirect = editPage;138 }139 else138 139 //Go directly to manually installation if plugin directory isn't specified in base.config, plugin directory doesn't exists or 140 // no jar files were found in that directory. 141 if (Application.getNonCorePluginDirectory() != null && Application.getNonCorePluginDirectory().exists() && 142 !FileUtil.findFiles(Application.getNonCorePluginDirectory(), null, "jar", true ).isEmpty()) 140 143 { 141 144 String pluginPath = Application.getNonCorePluginDirectory().getPath(); 142 145 redirect = "select_installation_type.jsp?ID="+ID+"&plugin_path="+pluginPath; 143 146 } 147 else 148 { 149 redirect = editPage; 150 } 144 151 } 145 152 else if("InstallationType".equals(cmd)) … … 159 166 else if("LoadPlugins".equals(cmd)) 160 167 { 161 //Loads plugins from jars that have been selected in auto_installer.jsp168 //Loads and install plugins that have been selected in auto_installer.jsp 162 169 ItemContext cc = Base.getAndSetCurrentContext(sc, itemType, null, defaultContext); 163 170 dc = sc.newDbControl(); … … 165 172 List<PluginInfo> pluginInfos = new ArrayList<PluginInfo>(); 166 173 List<java.io.File> jarFiles = FileUtil.findFiles(pluginDir, null, "jar", true); 174 StringBuilder notInstalledPlugins = new StringBuilder(); 167 175 176 //Get information about all plugins in jar-files that were found. 168 177 for (java.io.File file : jarFiles) 169 178 { 170 179 pluginInfos.addAll(PluginInfo.loadFromJar(file)); 171 180 } 181 //Load selected plugins. 172 182 for (PluginInfo info : pluginInfos) 173 183 { 174 184 String selectedOption = request.getParameter(info.getJarPath() + "." + info.getClassName()); 175 if (selectedOption == null) selectedOption = ""; 176 StringBuilder installedPlugins = new StringBuilder(); 177 StringBuilder notInstalledPlugins = new StringBuilder(); 185 if (selectedOption == null) selectedOption = ""; 178 186 boolean classExists = Values.getBoolean(request.getParameter(info.getClassName()+".classExists")); 187 boolean jarExists = Values.getBoolean(request.getParameter(info.getClassName()+".jarExists")); 179 188 int usePermissions = Values.getInt(request.getParameter("use_permissions")); 180 if (selectedOption.equals("plugin") || selectedOption.equals("plugin+conf igurations"))189 if (selectedOption.equals("plugin") || selectedOption.equals("plugin+confs")) 181 190 { 191 //The plugin doesn't exists 182 192 if (!classExists) 183 193 { … … 189 199 catch(BaseException bex) 190 200 { 191 notInstalledPlugins.append("Could not install: " +201 notInstalledPlugins.append("Could not install: " + 192 202 info.getClassName() + " in jar:" + info.getJarPath() + "\n"); 193 203 } 194 204 if (pd != null) 195 205 { 196 installedPlugins.append("Installed :" + pd.getClassName() + "\n");197 206 dc.saveItem(pd); 198 207 pd.setTrusted(Values.getBoolean(request.getParameter("trusted"))); … … 202 211 } 203 212 } 213 //The plugin exists but in a different jar, this will change the plugin's jarpath 214 else if (classExists && !jarExists) 215 { 216 try 217 { 218 PluginDefinition pd = PluginDefinition.getByClassName(dc, info.getClassName()); 219 pd.loadPluginInformation(info.getJarPath(), info.getClassName(), usePermissions == 2); 220 } 221 catch(BaseException bex) 222 { 223 notInstalledPlugins.append("Could not update the jarpath for plugin: " + info.getClassName()); 224 } 225 } 226 } 227 } 228 dc.commit(); 229 230 //Import selected configurations for each plugin in pluginInfos 231 dc = sc.newDbControl(); 232 for (PluginInfo info : pluginInfos) 233 { 234 List<PluginConfigInfo> configInfos = info.getConfigurations(); 235 if (configInfos != null && configInfos.size() > 0) 236 { 237 HashMap<Integer, Boolean> configurations = new HashMap<Integer, Boolean>(); 238 int configurationNumber = 0; 239 for (PluginConfigInfo cnfInfo : configInfos) 240 { 241 Boolean toImport = Values.getBoolean(request.getParameter(info.getClassName() + "." + cnfInfo.getName())); 242 configurations.put(configurationNumber, toImport); 243 configurationNumber++; 244 } 245 try 246 { 247 PluginConfigurationImporter configImporter = new PluginConfigurationImporter(); 248 configImporter.init(sc, null, null); 249 configImporter.importPluginConfigurationsFromJar(info.getJarPath(), info.getConfigurationsPath(), configurations, false, true ); 250 } 251 catch (Throwable th) 252 { 253 notInstalledPlugins.append("Could not import configurations: " + th.getMessage() + "\n"); 254 } 204 255 } 205 256 } 206 dc.commit();207 cc.removeObject("item");257 message = notInstalledPlugins.length() > 0 ? 258 notInstalledPlugins.toString() : "All selected plugins and configurations were installed"; 208 259 } 209 260 else if ("UpdateItem".equals(cmd))
Note: See TracChangeset
for help on using the changeset viewer.