Exemple #1
0
 /**
  * Proxy constructor
  *
  * @param string $target                       Target URI
  * @param string $base_path_for_relative_paths Base path
  * @param string $binding_config               Config
  */
 public function __construct($target, $base_path_for_relative_paths, $binding_config)
 {
     SCA::$logger->log('Entering');
     if (!SCA_Bindings_ebaysoap_Proxy::dependenciesLoaded()) {
         SCA::$logger->log('eBay soap binding requires the openssl extension, but it is not loaded.');
         throw new SCA_RuntimeException('eBay soap binding requires the openssl extension, but it is not loaded.');
     }
     $binding_config = SCA_Helper::mergeBindingIniAndConfig($binding_config, $base_path_for_relative_paths);
     // Check that all the required configuration has been provided
     if (!key_exists('siteid', $binding_config) || empty($binding_config['siteid'])) {
         SCA::$logger->log('eBay soap binding configuration missing: siteid.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: siteid.');
     }
     if (!key_exists('version', $binding_config) || empty($binding_config['version'])) {
         SCA::$logger->log('eBay soap binding configuration missing: version.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: version.');
     }
     if (!key_exists('authtoken', $binding_config) || empty($binding_config['authtoken'])) {
         SCA::$logger->log('eBay soap binding configuration missing: authtoken.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: authtoken.');
     }
     if (!key_exists('routing', $binding_config) || empty($binding_config['routing'])) {
         SCA::$logger->log('eBay soap binding configuration missing: routing.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: routing.');
     }
     if (!key_exists('appid', $binding_config) || empty($binding_config['appid'])) {
         SCA::$logger->log('eBay soap binding configuration missing: appid.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: appid.');
     }
     if (!key_exists('devid', $binding_config) || empty($binding_config['devid'])) {
         SCA::$logger->log('eBay soap binding configuration missing: devid.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: devid.');
     }
     if (!key_exists('authcert', $binding_config) || empty($binding_config['authcert'])) {
         SCA::$logger->log('eBay soap binding configuration missing: authcert.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: authcert.');
     }
     if (!key_exists('location', $binding_config) || empty($binding_config['location'])) {
         SCA::$logger->log('eBay soap binding configuration missing: location.');
         throw new SCA_RuntimeException('eBay soap binding configuration missing: location.');
     }
     parent::__construct($target, $base_path_for_relative_paths, $binding_config);
     SCA::$logger->log('Leaving');
 }
Exemple #2
0
 /**
  * Constructor for simpledb Proxy
  * Use the values from the configuration file provided to create a PDO for the database
  * Query the database to obtain column metadata and primary key
  *
  * @param string $target                     Target
  * @param string $immediate_caller_directory Directory
  * @param string $binding_config             Config
  */
 public function __construct($target, $immediate_caller_directory, $binding_config)
 {
     SCA::$logger->log('Entering constructor');
     try {
         $this->table = $target;
         $this->config = SCA_Helper::mergeBindingIniAndConfig($binding_config, $immediate_caller_directory);
         if (array_key_exists('username', $this->config)) {
             $username = $this->config['username'];
         } else {
             $username = null;
         }
         if (array_key_exists('password', $this->config)) {
             $password = $this->config['password'];
         } else {
             $password = null;
         }
         if (array_key_exists('namespace', $this->config)) {
             $this->namespace = $this->config['namespace'];
         }
         if (array_key_exists('case', $this->config)) {
             $this->case = $this->config['case'];
         } else {
             $this->case = 'lower';
         }
         if (!array_key_exists('dsn', $this->config)) {
             throw new SCA_RuntimeException("Data source name should be specified");
         }
         $tableName = $this->table;
         // Special processing for IBM databases:
         // IBM table names can contain schema name as prefix
         // Column metadata returned by pdo_ibm does not specify the primary key
         // Hence primary key for IBM databases has to be obtained using
         // db2_primary_key.
         if (strpos($this->config["dsn"], "ibm:") === 0 || strpos($this->config["dsn"], "IBM:") === 0) {
             $this->isIBM = true;
             // Table could be of format schemaName.tableName
             $schemaName = null;
             if (($pos = strrpos($tableName, '.')) !== false) {
                 $schemaName = substr($tableName, 0, $pos);
                 $tableName = substr($tableName, $pos + 1);
             }
             // DSN for IBM databases can be a database name or a connection string
             // Both can be passed onto db2_connect. Remove the dsn prefix if specified
             $database = substr($this->config["dsn"], 4);
             if (strpos($database, "dsn=") === 0 || strpos($database, "DSN=") === 0) {
                 $database = substr($database, 4);
             }
             // Need to make sure the name is in DB2 uppercase style
             $db2TableName = strtoupper($tableName);
             $conn = db2_connect($database, $username, $password);
             $stmt = db2_primary_keys($conn, null, $schemaName, $db2TableName);
             $keys = db2_fetch_array($stmt);
             if (count($keys) > 3) {
                 $this->primary_key = $keys[3];
             } else {
                 throw new SCA_RuntimeException("Table '{$tableName}' does not appear to have a primary key.");
             }
         }
         $this->table_name = $this->_getName($tableName);
         if ($username != null) {
             $this->pdo = new PDO($this->config["dsn"], $username, $password, $this->config);
         } else {
             $this->pdo = new PDO($this->config["dsn"]);
         }
         $this->pdo_driver = $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
         $stmt = $this->pdo->prepare('SELECT * FROM ' . $this->table);
         if (!$stmt->execute()) {
             throw new SCA_RuntimeException(self::_getPDOError($stmt, "select"));
         }
         $columns = array();
         for ($i = 0; $i < $stmt->columnCount(); $i++) {
             $meta = $stmt->getColumnMeta($i);
             $name = $this->_getName($meta["name"]);
             if (in_array("primary_key", $meta["flags"], true)) {
                 $this->primary_key = $name;
             }
             $columns[] = $name;
         }
         //$pk = $this->_getName($this->primary_key);
         SCA::$logger->log("Table {$tableName} PrimaryKey {$this->primary_key}");
         /*
         $metadata = array(
         'name' => $this->table_name,
         'columns' => $columns,
         'PK' => $pk
         );
         */
         $this->datafactory = SDO_DAS_DataFactory::getDataFactory();
         // Define the model on the data factory (from the database)
         $this->datafactory->addType(SCA_Bindings_simpledb_Proxy::ROOT_NS, SCA_Bindings_simpledb_Proxy::ROOT_TYPE);
         $this->datafactory->addType($this->namespace, $this->table_name);
         foreach ($columns as $name) {
             $this->datafactory->addPropertyToType($this->namespace, $this->table_name, $name, 'commonj.sdo', 'String');
         }
         $this->datafactory->addPropertyToType(SCA_Bindings_simpledb_Proxy::ROOT_NS, SCA_Bindings_simpledb_Proxy::ROOT_TYPE, $this->table_name, $this->namespace, $this->table_name, array('many' => true));
     } catch (Exception $e) {
         throw new SCA_RuntimeException($e->getMessage());
     }
     SCA::$logger->log("Exiting constructor");
 }