/*
 * dbXML License, Version 1.0
 *
 *
 * Copyright (c) 1999-2001 The dbXML Group, L.L.C.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in
 *    the documentation and/or other materials provided with the
 *    distribution.
 *
 * 3. The end-user documentation included with the redistribution,
 *    if any, must include the following acknowledgment:
 *       "This product includes software developed by
 *        The dbXML Group (http://www.dbxml.com/)."
 *    Alternately, this acknowledgment may appear in the software
 *    itself, if and wherever such third-party acknowledgments normally
 *    appear.
 *
 * 4. The names "dbXML" and "The dbXML Group" must not be used to
 *    endorse or promote products derived from this software without
 *    prior written permission. For written permission, please contact
 *    info@dbxml.com.
 *
 * 5. Products derived from this software may not be called "dbXML",
 *    nor may "dbXML" appear in their name, without prior written
 *    permission of The dbXML Group.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED.  IN NO EVENT SHALL THE DBXML GROUP OR ITS CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * $Id: dbXML.idl,v 1.59 2001/09/04 11:12:49 kstaken Exp $
 */

#ifndef DBXML_IDL
#define DBXML_IDL

module org {
module dbxml {
module core {
module corba {
module db {

   // Content Encoding Timestamping *********************************
   typedef long long Timestamp;
   const Timestamp STAMP_TEXT = -1;  // Non-Compressed
      
   // Global Type Definitions ***************************************
   typedef string Name;
   typedef sequence<Name> Names;
   typedef string Value;
   typedef sequence<octet> Buffer;

   struct NamedVal {
      Name nam;
      Value val;
   };
   
   typedef sequence<NamedVal> NamedVals;
   
   struct EncodedBuffer {
      Timestamp stamp; // Last modified for Symbol Table
      Buffer sym;      // Compressed Symbol Table (if any)
      Buffer buf;      // Text or Compressed Buffer (if stamp != -1)
   };

   typedef Buffer Key;
   typedef Buffer Data;

   exception APIException {
      long faultCode;
      string faultMessage;
      string exceptionMessage;
   };
   
   interface FaultCodes {
      // Categories
      const long GEN = 0;     // General
      const long OBJ = 100;   // XMLObjects
      const long COL = 200;   // Collections
      const long IDX = 300;   // Indexes
      const long TRX = 400;   // Transactions
      const long DBE = 500;   // Database Engine
      const long QRY = 600;   // Queries
      const long SEC = 700;   // Security
      const long URI = 800;   // URI
      const long JAVA = 2000; // Java
      
      // General errors 0 series
      const long GEN_UNKNOWN = 0;
      const long GEN_GENERAL_ERROR = 40;
      const long GEN_CRITICAL_ERROR = 70;
      const long GEN_FATAL_ERROR = 90;
      
      // XMLObject invocation errors 100 series
      const long OBJ_OBJECT_NOT_FOUND = 100;
      const long OBJ_METHOD_NOT_FOUND = 101;
      const long OBJ_NULL_RESULT = 140;
      const long OBJ_INVALID_RESULT = 141;
      const long OBJ_DUPLICATE_OBJECT = 142;
      const long OBJ_RUNTIME_EXCEPTION = 170;
      const long OBJ_CLASS_FORMAT_ERROR = 171;
      const long OBJ_INVALID_CONTEXT = 172;
      const long OBJ_CANNOT_CREATE = 173;
      
      // Collection-related errors 200 series
      const long COL_COLLECTION_NOT_FOUND = 200;
      const long COL_DOCUMENT_NOT_FOUND = 201;
      const long COL_DUPLICATE_COLLECTION = 240;
      const long COL_NULL_RESULT = 241;
      const long COL_NO_FILER = 242;
      const long COL_NO_INDEXMANAGER = 242;
      const long COL_DOCUMENT_MALFORMED = 243;
      const long COL_CANNOT_STORE = 244;
      const long COL_CANNOT_RETRIEVE = 245;
      const long COL_COLLECTION_READ_ONLY = 246;
      const long COL_COLLECTION_CLOSED = 247;
      const long COL_CANNOT_CREATE = 270;
      const long COL_CANNOT_DROP = 271;
      
      // Index-related errors 300 series
      const long IDX_VALUE_NOT_FOUND = 300;
      const long IDX_INDEX_NOT_FOUND = 301;
      const long IDX_MATCHES_NOT_FOUND = 340;
      const long IDX_DUPLICATE_INDEX = 341;
      const long IDX_NOT_SUPPORTED = 370;
      const long IDX_STYLE_NOT_FOUND = 371;
      const long IDX_CORRUPTED = 372;
      const long IDX_CANNOT_CREATE = 373;
      
      // Transaction-related errors 400 series
      const long TRX_DOC_LOCKED = 400;
      const long TRX_NO_CONTEXT = 440;
      const long TRX_NOT_ACTIVE = 441;
      const long TRX_NOT_SUPPORTED = 470;
      
      // Database-related errors 500 series
      const long DBE_NO_PARENT = 500;
      const long DBE_CANNOT_DROP = 570;
      
      // Query-related errors 600 series
      const long QRY_NULL_RESULT = 600;
      const long QRY_COMPILATION_ERROR = 640;
      const long QRY_PROCESSING_ERROR = 641;
      const long QRY_NOT_SUPPORTED = 670;
      const long QRY_STYLE_NOT_FOUND = 671;
      
      // Security-related errors 700 series
      const long SEC_INVALID_USER = 770;
      const long SEC_INVALID_GROUP = 771;
      const long SEC_INVALID_ACCESS = 772;
      const long SEC_INVALID_CREDENTIALS = 773;
      
      // URI Mapper errors 800 series
      const long URI_EMPTY = 800;
      const long URI_NULL = 801;
      const long URI_PARSE_ERROR = 820;
      
      // Java errors 2000 series
      const long JAVA_RUNTIME_ERROR = 2070;
   };
   
   interface ServantManagement {
      void remove();
   };

   interface DocumentSet : ServantManagement {
      boolean hasMoreDocuments() raises (APIException);
      EncodedBuffer getNextDocument(in Timestamp stamp) raises (APIException);
   };
   
   interface CollectionManager;
   interface DatabaseManager;
   
   interface Collection : ServantManagement {
      string getName() raises (APIException);
      string getCanonicalName() raises (APIException);

      CollectionManager getCollectionManager() raises (APIException);
      
      Collection getParentCollection() raises (APIException);
      Names listCollections() raises (APIException);
      Collection getCollection(in Name path) raises (APIException);
      
      string insertDocument(in Name nam, in EncodedBuffer doc)
         raises (APIException);
      void removeDocument(in string id) raises (APIException);
      EncodedBuffer getDocument(in string id, in Timestamp stamp) raises (APIException);
      void setDocument(in string id, in EncodedBuffer doc) raises (APIException);
      
      DocumentSet getDocuments() raises (APIException);
      Names listDocuments() raises (APIException);
      long getDocumentCount() raises (APIException);
      
      string createNewOID() raises (APIException);
      
      EncodedBuffer queryCollection(in string style, in Value query, in NamedVals namespaces, in Timestamp stamp) raises (APIException);
      EncodedBuffer queryDocument(in string style, in Value query, in NamedVals namespaces, in string id, in Timestamp stamp) raises (APIException);

      EncodedBuffer invokeXMLObject(in string uri) raises (APIException);
   };
   
   
   interface CollectionManager : ServantManagement {
      string getName() raises (APIException);
      string getCanonicalName() raises (APIException);
            
      Collection createCollection(in Name path, in EncodedBuffer config)
         raises (APIException);
      void dropCollection(in Name path) raises (APIException);

      Names listIndexers() raises (APIException);
      void createIndexer(in EncodedBuffer config) raises (APIException);
      void dropIndexer(in Name nam) raises (APIException);
      
      Names listXMLObjects() raises (APIException);
      void createXMLObject(in EncodedBuffer config) raises (APIException);
      void dropXMLObject(in Name nam) raises (APIException);
   };

   
   interface Database : ServantManagement {
      string getName() raises (APIException);
            
      DatabaseManager getDatabaseManager() raises (APIException);
      
      Names listCollections() raises (APIException);
      Collection getCollection(in Name path) raises (APIException);
   };

   
   interface DatabaseManager : ServantManagement {
      string getName() raises (APIException);
      oneway void shutdown();
   };
   
}; // database
}; // corba
}; // core
}; // dbxml
}; // org

#endif // DBXML_IDL





