/* this belongs to the WebRaveler package */ package webraveler.vurl; import java.util.*; import webraveler.http.HTTPRequest; import webraveler.http.HTTPResponse; import webraveler.ravel.Raveler; import webraveler.ravel.RavelerException; import webraveler.ravel.RavelerPlugin; import webraveler.ravel.RavelerUser; /** * Disables the given set of plugins * * @author The Web Raveler Development Squad * @version 1.0 */ public class PluginsDisabled implements VURL { /** * */ public PluginsDisabled () { } // PluginSequenceVURL() /** * Removes the specified plugins from the user's active plugins and updates the status of the plugins. * Returns a response indicating whether or not the operation was successful */ public HTTPResponse resolveVURL(String username, String query, HTTPRequest request, Raveler ravel) { /* Get the RavelerUser for the given username */ RavelerUser user = new RavelerUser(); String message = new String(); try { user = ravel.getUser(username); /* Parse the query */ /* First check if all the plugins should be disabled */ String allTest = null; if (query != null && !query.equals("")) allTest = query.substring(0,3); if (allTest != null && allTest.equals("all")) { /* Disable all the plugins */ /* Set the status of each plugin to disabled */ for (Enumeration f = ravel.getPlugins(); f.hasMoreElements() ;) { RavelerPlugin plugin = (RavelerPlugin) f.nextElement(); user.setStatus(plugin.name,"disabled"); } //for /* Remove all plugins from the user's active plugins */ user.activePlugins.clear(); } //if else { /* Disable only the specified plugins */ int equalsIndex; int amperIndex=0; String pluginName; Hashtable pref; while ((equalsIndex = query.indexOf('=',amperIndex)) != -1) { /* Check if we are past the first part, if so increment the * amperIndex so that we don't include the & in the pluginName */ if (amperIndex != 0) amperIndex++; pluginName = query.substring(amperIndex,equalsIndex); /* If the plugin is active, remove it from the user's active plugins */ if (user.activePlugins.contains(pluginName)) { user.removeActivePlugin(pluginName); } //if /* Change the status of the plugin to disabled in the preferences for the user */ user.setStatus(pluginName,"disabled"); amperIndex = query.indexOf('&',equalsIndex); /* Check if we are at the last part, if so, stop */ if (amperIndex == -1) break; } //while } //else message = "
"; } catch (RavelerException re) { message = ""; } //catch /* Generate the response - include the user configuration page with note about plugins activated being changed */ UserConfigVURL userConfig = new UserConfigVURL();userConfig.printMessage(message); HTTPResponse response = userConfig.resolveVURL(username,query,request,ravel); return response; } //resolveVURL }