Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP
  • Overview
  • Namespace
  • Class
  • Tree
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 
<?php
namespace Apptus\ESales\Connector;

use Apptus\Util\Cache\PrefixStateCache;
use Apptus\Util\Cache\SQLite3StateCache;
use Apptus\Util\Cache\StateCache;

/**
 * Connector for Apptus eSales when hosted in the cloud.
 *
 * This class acts as a facade to the connector library. All requests to the eSales service are initiated by method calls to a
 * CloudConnector object, or an object obtained via the CloudConnector.
 *
 */
class CloudConnector extends Connector {
    /**
     * Creates a connector for the given eSales cluster URI.
     *
     * The URI should be on the following format:
     *
     * esales://username:password[?parameter1=value1[&parameter2=value2[&...]]]
     *
     * Example: esales://john:fjQ947Haq9jnFh?query_timeout=3500&notification_timeout=3500
     *
     * Unspecified port defaults to 443.
     *
     * The available parameters are:
     * <ul>
     * <li>connection_timeout - the connection timeout in milliseconds, default 2000</li>
     * <li>query_timeout - the query timeout in milliseconds, default 3000</li>
     * <li>export_timeout - the export timeout in milliseconds, default 60000</li>
     * <li>import_timeout - the import timeout in milliseconds, default 600000</li>
     * <li>notification_timeout - the notification timeout in milliseconds, default 3000</li>
     * <li>health_check_timeout - the health check timeout in milliseconds, default 500</li>
     * <li>compression_mode - what compression should be used when sending imports. Available settings:
     * <ul>
     *     <li>none - No compression.</li>
     *     <li>gzip - Compress with GZIP. This is the default.</li>
     *     <li>pre_compressed_gzip - Send headers to indicate the import is compressed with GZIP, but don't do any compression.
     *     Use this if the file or InputStream you supply is already compressed.</li>
     * </ul>
     * Note that files with names that end with ".gz" or ".gzip" will behave as if compression_mode=pre_compressed_gzip,
     * regardless of what compression_mode is actually set to.
     * </li>
     * </ul>
     *
     * Parameter values must be URL encoded in order to avoid ambiguity.
     *
     * @param string
     *            The base URI to an eSales cluster.
     * @param \Apptus\Util\Cache\StateCache
     *            An instance of an object implementing the {@see StateCache} interface.
     *            Defaults to an SQLite3StateCache using the file 'esales.statecache' in the current working directory.
     * @throws MalformedURLException
     *             If the URI contains errors.
     * @return CloudConnector
     *            A connector instance.
     */
    public function __construct($uriString, StateCache $stateCache = null) {
        $uri = ClusterUri::parse($uriString);
        $connectorSettings = ConnectorSettings::defaultsForCloud()->update($uri->getQueryString(), true);

        if ($stateCache === null) {
            $testResult = SQLite3StateCache::testSQLite('esales.statecache');
            if ($testResult !== true) {
                throw new \InvalidArgumentException('No StateCache given, and SQLite3 test returned the following problem: ' . $testResult);
            }
            $stateCache = new SQLite3StateCache('esales.statecache');
        }

        $secureCluster = new CloudCluster($uriString, $uri, $connectorSettings, $stateCache, true);
        if($connectorSettings->highSecurity()) {
            $cluster = $secureCluster;
        } else {
            $cluster = new CloudCluster($uriString, $uri, $connectorSettings, new PrefixStateCache("http_",$stateCache), false);
        }
        parent::__construct($secureCluster, $cluster);
    }
}
Apptus ESales Connector PHP API documentation generated by ApiGen