/* 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; /** * Enables the given set of plugins * * @author The Web Raveler Development Squad * @version 1.0 */ public class PluginsEnabled implements VURL { /** * */ public PluginsEnabled () { } // PluginSequenceVURL() /** * Updates the status of the specified 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 enabled */ String allTest = null; if (query != null && !query.equals("")) allTest = query.substring(0,3); if (allTest != null && allTest.equals("all")) { /* Enable all the plugins */ for (Enumeration f = ravel.getPlugins(); f.hasMoreElements() ;) { RavelerPlugin plugin = (RavelerPlugin) f.nextElement(); if (user.getStatus(plugin.name).equals("disabled")) { user.setStatus(plugin.name,"inactive"); } //if } //for } //if else { /* Enable 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); /* Change the status of the plugin to inactive in the preferences for the user */ user.setStatus(pluginName,"inactive"); 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 }