//
// WBEMResponse.java
//
// The contents of this file are subject to the SNIA Public License Version 1.0
// (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.snia.org/resources/openSource.html
//
// 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 WBEMResponse.java
// 
// The Initial Developer of the Original Code is Hewlett-Packard Company.
// (c) Copyright 2001 Hewlett-Packard Company 
//
// Contributor(s): 
//

package org.snia.wbemcmd.xml;

import java.io.Serializable;
import java.util.Properties;
import java.util.Enumeration;


/**
 * CIM Server uses this class to pass HTTP response back to CIM servlet 
 * over an RMI connect. This class holds the HTTP response header information
 * and also the XmlCIM Response sent by CIM Server. CIM servlet then receives 
 * this object and forms an HTTP response back to CIM client.
 *
 * This class implements Java Serializable class since it is used to pass
 * over RMI connection
 *
 * @author      Hewlett-Packard Company
 */

public class WBEMResponse implements Serializable
{
   
    
    //
    // Response code, Response Protocol, and Response message
    // are set by CIM Server once the request is processed.
    // The CIM Servlet uses these to set HTTP reponse header.
    //
    private String  wbemResProtocol;
    private int     wbemResCode;
    private String  wbemResMessage;

    /**
     Response result that is set by CIM Server once the request 
     is processed. We are using byte Array to send
     the result data over RMI.
     The CIM Servlet uses this data and sends to the clients.
    */
    private byte[]  resByteArray;

    //
    // Length of the XmlCIM response to client
    //
    private int     contentLength;

    // CIM Specific Headers
    private String cimOperation;
    private String cimProtocolVersion;
    private String cimSupportedOperations;
    private String cimValidation;


    //******************************************************************
    /**
    * default constructor
    */
    //******************************************************************
    public WBEMResponse()
    {
        wbemResProtocol        = null;
        wbemResCode            = -1;
        wbemResMessage         = null;
        cimOperation           = null;
        cimProtocolVersion     = null;
        contentLength          = -1;
        cimSupportedOperations = null;
        cimValidation          = null;
        resByteArray           = null;
    }

    //******************************************************************
    /**
    * sets the response protocol type, i.e. HTTP/1.1 or HTTP/1.0
    *
    * @param resProtocol 
    *        HTTP response protocol 
    */
    //******************************************************************
    public void setResProtocol(String resProtocol) 
    {
       wbemResProtocol = resProtocol;
    } 

    //******************************************************************
    /**
    * get the HTTP Response protocol. This is same as one sent in
    * request.
    *
    * @return response protocol
    */
    //******************************************************************
    public String getResProtocol() 
    {
       return ( wbemResProtocol );
    } 

    //******************************************************************
    /**
    * sets the Response Code
    *
    * @param resCode 
    *        response Code ( example - 200 for valid response)
    */
    //******************************************************************
    public void setResCode(int resCode) 
    {
       wbemResCode = resCode;
    } 

    //******************************************************************
    /**
    * get the HTTP Response Code
    *
    * @return response Code ( example - 200 for valid response) 
    */
    //******************************************************************
    public int getResCode() 
    {
       return ( wbemResCode );
    } 

    //******************************************************************
    /**
    * sets the response Message
    *
    * @param resMesg
    *        response message ( such as 'OK' string)
    */
    //******************************************************************
    public void setResMessage(String resMesg) 
    {
       wbemResMessage = resMesg;
    } 

    //******************************************************************
    /**
    * get the response message
    *
    * @return response message ( such as 'OK' string) 
    */
    //******************************************************************
    public String getResMessage() 
    {
       return (wbemResMessage);
    } 

    //******************************************************************
    /**
    * sets the response ByteArray
    *
    * @param  byteArray 
    *         response byte array
    */
    //******************************************************************
    public void setResByteArray(byte[] byteArray)
    {
       resByteArray = byteArray;
    } 
    
    //******************************************************************
    /**
    * get the response Byte Array
    *
    * @return response byte array 
    */
    //******************************************************************
    public byte[] getResByteArray() 
    {
       return(resByteArray);
    } 

    //******************************************************************
    /**
    * get content length of the response
    *
    * @return content length of the response
    */
    //******************************************************************
    public int getContentLength() 
    {
       return (contentLength);
    } 
    //******************************************************************
    /**
    * sets content length of the response
    *
    * @param len
    *        content length of the response
    */
    //******************************************************************
    public void setContentLength(int len) 
    {
       contentLength = len;
    }

    //******************************************************************
    /**
    * sets CIM Operation type
    *
    * @param operation
    *        CIM Operation type  ( i.e. MethodResponse)
    */
    //******************************************************************
    public void setCIMOperation(String operation)
    {
       cimOperation = operation;
    }

    //******************************************************************
    /**
    * get CIM Operation type
    *
    * @return  CIM Operation type ( i.e. MethodResponse)
    */
    //******************************************************************
    public String getCIMOperation()
    {
       return (cimOperation);
    }

    //******************************************************************
    /**
    * sets CIM Protocol Version
    *
    * @param protocolVer
    *        CIM Protocol version
    */
    //******************************************************************
    public void setCIMProtocolVersion(String protocolVer)
    {
       cimProtocolVersion = protocolVer;
    }

    //******************************************************************
    /**
    * get CIM Protocol Version
    *
    * @return CIM Protocol version
    */
    //******************************************************************
    public String getCIMProtocolVersion()
    {
       return (cimProtocolVersion);
    }

    //******************************************************************
    /**
    * sets CIM Validation Header
    *
    * @param validation 
    *        CIM Validation Header 
    */
    //******************************************************************
    public void setCIMValidation(String validation)
    {
       cimValidation = validation;
    }

    //******************************************************************
    /**
    * get CIM Validation Header
    *
    * @return CIM Validation Header 
    */
    //******************************************************************
    public String getCIMValidation()
    {
       return (cimValidation);
    }


    //******************************************************************
    /**
    * set CIM Supported Functional Groups
    *
    * @param cimOps 
    *        CIM Supported Functional Groups 
    */
    //******************************************************************
    public void setCIMSupportedOps(String cimOps)
    {
       cimSupportedOperations = cimOps;
    }

    //******************************************************************
    /**
    * get CIM Supported Functional Groups
    *
    * @return CIM Supported Functional Groups 
    */
    //******************************************************************
    public String getCIMSupportedOps()
    {
       return (cimSupportedOperations);
    }

}
