/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.xmlrpc;

import java.util.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.dynamo.xmlrpc.*;

public class VeniceCreateSession implements XmlRpcDispatcher, XmlRpcTypeNames
{
  /*--------------------------------------------------------------------------------
   * Static data members
   *--------------------------------------------------------------------------------
   */

  private static final List SUPPORTED_METHODS;
  private static final List SIGNATURES;

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  public VeniceCreateSession()
  { // do nothing
  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface XmlRpcDispatcher
   *--------------------------------------------------------------------------------
   */

  public String getSessionIDParamValue(Request r, Application app)
  {
    return null;

  } // end getSessionIDParamValue

  public Object dispatchXmlRpcCall(Request r, Application app) throws Exception, FaultCode
  {
    if (r.getParameters().size()!=0)
      throw new XmlRpcParameterError("parameter count mismatch");
    XmlRpcCreateSession creator = (XmlRpcCreateSession)(r.queryService(XmlRpcCreateSession.class));
    SessionInfo session = creator.createNewSession(r);
    return session.getID();

  } // end dispatchXmlRpcCall

  public Collection getSupportedMethods(Request r)
  {
    return SUPPORTED_METHODS;

  } // end getSupportedMethods

  public List getMethodSignature(Request r, String method) throws FaultCode
  {
    return SIGNATURES;

  } // end getMethodSignature

  public String getMethodHelp(Request r, String method) throws FaultCode
  {
    ResourceBundle b = ResourceBundle.getBundle("com.silverwrist.venice.xmlrpc.VeniceXmlRpcMessages",
						Locale.getDefault());
    return b.getString("help.createSess");

  } // end getMethodHelp

  /*--------------------------------------------------------------------------------
   * Static initializer
   *--------------------------------------------------------------------------------
   */

  static
  { // create the supported methods list
    SUPPORTED_METHODS = Collections.singletonList("venice:session.create");

    // create the signatures list
    List l = Collections.singletonList(TYPE_STRING);
    SIGNATURES = Collections.singletonList(l);

  } // end static initializer

} // end class VeniceCreateSession
