//
// XMLFeatures.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 XMLFeatures.java
// 
// The Initial Developer of the Original Code is David Simons.
//
// Contributor(s):
//
//
// This source uses the Solaris WBEM APIs version 2.2. 
// Synchronization will be maintained with the Solaris WBEM APIS,
// which are being standardized through the Java Community Process.
//
//
// $Id: XMLFeatures.java,v 1.1 2003/07/17 18:32:55 kumpf Exp $
//
// $Log: XMLFeatures.java,v $
// Revision 1.1  2003/07/17 18:32:55  kumpf
// HP-BAPU: PEP-64 CIM Client and CIM Listener Java Interface
//
// Revision 1.1.1.1  2001/10/31 18:17:43  karl
// import of SNIA 0_7
//
// Revision 1.8  2001/07/01 11:17:00  davidsi
// - When extract validation information it was possible that the substring
//   was not found which would then result in an exception
//   (from Klaus Olszowi).
//
// Revision 1.7  2001/01/07 16:55:33  davidsi
// - Fixed exception handling so that null references aren't used when
//   building exceptions.
//
// Revision 1.6  2000/08/16 05:59:59  shawn
// merge P_TOMCAT31 branch
//
// Revision 1.5.6.1  2000/08/10 00:03:36  shawn
// head merge
//
// Revision 1.5  2000/07/10 18:52:12  davidsi
// - Fixes to workout using HTTPWriter mode switching.
//
// Revision 1.4  2000/05/11 10:11:24  davidsi
// - Fixed tabs.
//
// Revision 1.3  2000/05/06 17:20:03  davidsi
// - Brought in line with SUN WBEM APIs 2.2
//
// Revision 1.2  2000/02/13 15:10:06  davidsi
// - Added text to cover re-use of Solaris WBEM APIs.
//
// Revision 1.1.1.1  2000/02/06 16:41:02  davidsi
// Initial version.
//
//
//
package org.snia.wbemcmd.xml;

import java.util.Enumeration;
import java.util.Vector;
import java.net.MalformedURLException;
import java.io.*;
import org.snia.wbem.cim.CIMException;
import org.snia.wbem.cim.CIMObjectPath;
import org.snia.wbemcmd.cimom.CIMFeatures;


public class XMLFeatures extends CIMFeatures {

   /***
    *
    * Fetches the supported features from the server
    *
    * @param output
    *   The HTTPOutput stream
    */
    public void getFeatures(HTTPOutput output) throws CIMException {
	int index;
	String value;
	
	//
	// Set to default values
	//
	cimValidation=null;
	basicread=false;
	basicwrite=false;
	schemamanipulation=false;
	instancemanipulation=false;
	qualifierdeclaration=false;
	associationtraversal=false;
	queryexecution=false;
		
	String str=output.getFeatures().toLowerCase();
    
	index=str.indexOf("cimvalidation");
	if (index!=-1) {
	    value=str.substring(index);
	    index=value.indexOf(":");
	    if (index!=-1) {
		while (value.charAt(index+1)==' ')
		    index++;
		value=value.substring(index+1);
		int retIndex=value.indexOf(13);
		if (retIndex>=0)
		    cimValidation=value.substring(0,retIndex);
	    }
	}
	index=str.indexOf("cimsupportedfunctionalgroups");
	if (index>0) {
	    value=str.substring(index+"cimsupportedfunctionalgroups".length());
	    basicread=value.indexOf("basic-read")>=0;
	    basicwrite=value.indexOf("basic-write")>=0;
	    schemamanipulation=value.indexOf("schema-manipulation")>=0;
	    instancemanipulation=value.indexOf("instance-manipulation")>=0;
	    qualifierdeclaration=value.indexOf("qualifier-declaration")>=0;
	    associationtraversal=value.indexOf("association-traversal")>=0;
	    queryexecution=value.indexOf("query-execution")>=0;
	}
	
	/*
	if (basicread)
		System.err.println("Basic read");
	if (basicwrite)
		System.err.println("Basic Write");
	if (schemamanipulation)
		System.err.println("Schema Manipulation");
	if (instancemanipulation)
		System.err.println("Instance Manipulation");
	if (qualifierdeclaration)
		System.err.println("Qualifier Declaration");
	if (associationtraversal)
		System.err.println("Association Traversal");
	if (queryexecution)
		System.err.println("QueryExecution");
	try {
	Thread.sleep(10000);
	} catch (Exception e) {}
	*/

	}
}
