/* 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.RavelerUser; /** * Changes the sequence in which plugins are executed for the given user * * @author The Web Raveler Development Squad * @version 1.0 */ public class PluginSequenceVURL implements VURL { /** * */ public PluginSequenceVURL () { } // PluginSequenceVURL() /** * Updates the user's preferences to reflect the given changes in the sequence of plugins. * Returns a response indicating whether or not the update was successful */ public HTTPResponse resolveVURL(String username, String query, HTTPRequest request, Raveler ravel) { /* Parse the query */ /* Get the total number of active plugins */ String pluginNumString; int pluginNum; int length = query.length(); pluginNumString = query.substring(length-1,length); pluginNum = Integer.parseInt(pluginNumString); int equalsIndex; int amperIndex=0; String pluginName; String seqString; int seqNum; boolean error=false; Vector modifiedPlugins = new Vector(); modifiedPlugins.setSize(pluginNum); 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); /* Check if we are at the last part, if so, stop */ if (pluginName.equals("pluginNum")) break; amperIndex = query.indexOf('&',equalsIndex); seqString = query.substring(equalsIndex+1,amperIndex); seqNum = Integer.parseInt(seqString)-1; if (modifiedPlugins.elementAt(seqNum) == null) { modifiedPlugins.remove(seqNum); modifiedPlugins.insertElementAt(pluginName,seqNum); } else { System.out.println("Error: Multiple occurences of same sequence number"); error=true; break; } //else } //while UserConfigVURL userConfig = new UserConfigVURL(); String message; if (error) { /* Generate error response */ message = "