/* 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; /** * Activates the plugin for the given user * * @author The Web Raveler Development Squad * @version 1.0 */ public class ActivatePluginVURL implements VURL { String pluginName; /** * Constructs an ActivatePluginVURL for the given plugin * * @param pluginName a String containing the name of the plugin to be activated */ public ActivatePluginVURL (String pluginName) { this.pluginName = pluginName; } // ActivatePluginVURL() /** * Adds the plugin to the user's active plugins and updates the status of the plugin. * Returns a response indicating whether or not the activation was successful */ public HTTPResponse resolveVURL(String username, String query, HTTPRequest request, Raveler ravel) { String responseString = new String(""); responseString += ""+Raveler.ravelerCSS; /* Get the RavelerUser for the given username */ RavelerUser user = new RavelerUser(); try { user = ravel.getUser(username); /* Add the plugin the user's set of active plugins */ user.addActivePlugin(pluginName); /* Set the status of the plugin to active */ user.setStatus(pluginName,"active"); responseString += "" + pluginName + " Activated \n"; responseString += "

Web Raveler Configuration for " + username + "

\n"; responseString += "

" + pluginName + " was successfully activated

\n"; responseString += "

Save Configuration\n"; } catch (RavelerException re) { responseString += "Error Activating Plugin\n"; responseString += "

Web Raveler Configuration for " + username + "

\n"; responseString += "

" + re.getMessage() + "

\n"; } //catch responseString += "\n"; return new HTTPResponse("HTTP/1.0",200,"OK",responseString.getBytes(),new Hashtable()); } // resolveVURL } // class ActivatePluginVURL