示例#1
0
 /**
  * {inheritdoc}
  *
  * Return codes:
  * 0 = no execution errors
  * 1 = execution errors occured
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->metrics->setMetricClass('background')->setTransactionName('cron');
     $this->initGlobals();
     $this->logger->debug('--------------------------------------------> at cron.php <--------------------------------------------');
     $driver = $this->getCronDriver();
     $driver->runCycle();
     $this->cleanup();
     return $driver->runOk() ? 0 : 1;
 }
示例#2
0
 /**
  * Singleton initialization
  *
  * @return SugarMetric_Manager
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new SugarMetric_Manager();
     }
     return self::$instance;
 }
示例#3
0
 /**
  * Helper method to load SugarMetric_Manager and set endPoints and transaction name
  *
  * @param string|bool $transaction is $transaction is FALSE do not call setTransactionName method
  */
 public static function run($transaction = '')
 {
     self::loadSugarConfig();
     self::loadManagerClass();
     $instance = SugarMetric_Manager::getInstance();
     if ($transaction !== false) {
         $instance->setTransactionName($transaction);
     }
 }
示例#4
0
 /**
  * Called on sugar_cleanup
  *
  * Serve "server_round_trip" hook handling
  */
 public function serverRoundTrip()
 {
     $instance = SugarMetric_Manager::getInstance();
     // Check transaction name was set on endPoints
     if (!$instance->isNamedTransaction()) {
         if (isset($GLOBALS['log']) && !empty($_SERVER['REQUEST_URI'])) {
             // Log REQUEST_URI to debug "dead" entryPoints
             $GLOBALS['log']->debug('Unregistered Transaction name for URI: ' . $_SERVER['REQUEST_URI']);
         }
     }
 }
示例#5
0
 * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
 * If you do not agree to all of the applicable terms or do not have the
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
//change directories to where this file is located.
chdir(dirname(__FILE__));
define('ENTRY_POINT_TYPE', 'api');
require_once 'include/entryPoint.php';
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != 'cli') {
    sugar_die("cron.php is CLI only.");
}
SugarMetric_Manager::getInstance()->setMetricClass('background')->setTransactionName('cron');
if (empty($current_language)) {
    $current_language = $sugar_config['default_language'];
}
$app_list_strings = return_app_list_strings_language($current_language);
$app_strings = return_application_language($current_language);
global $current_user;
$current_user = BeanFactory::getBean('Users');
$current_user->getSystemUser();
$GLOBALS['log']->debug('--------------------------------------------> at cron.php <--------------------------------------------');
$cron_driver = !empty($sugar_config['cron_class']) ? $sugar_config['cron_class'] : 'SugarCronJobs';
$GLOBALS['log']->debug("Using {$cron_driver} as CRON driver");
SugarAutoLoader::requireWithCustom("include/SugarQueue/{$cron_driver}.php");
$jobq = new $cron_driver();
$jobq->runCycle();
$exit_on_cleanup = true;
示例#6
0
 /**
  * This function executes the current request and outputs the response directly.
  */
 public function execute()
 {
     ob_start();
     $this->response = $this->getResponse();
     try {
         $this->request = $this->getRequest();
         $this->request_headers = $this->request->request_headers;
         if ($this->min_version > $this->request->version || $this->max_version < $this->request->version) {
             throw new SugarApiExceptionIncorrectVersion("Please change your url to reflect version between {$this->min_version} and {$this->max_version}");
         }
         $authenticateUser = $this->authenticateUser();
         $isLoggedIn = $authenticateUser['isLoggedIn'];
         $loginException = $authenticateUser['exception'];
         // Figure out the platform
         if ($isLoggedIn) {
             if (isset($_SESSION['platform'])) {
                 $this->platform = $_SESSION['platform'];
             }
         } else {
             // Since we don't have a session we have to allow the user to specify their platform
             // However, since the results from the same URL will be different with
             // no variation in the oauth_token header we need to only take it as a GET request.
             if (!empty($_GET['platform'])) {
                 $this->platform = basename($_GET['platform']);
             }
         }
         $this->request->setPlatform($this->platform);
         $GLOBALS['logic_hook']->call_custom_logic('', 'before_routing', array("api" => $this, "request" => $this->request));
         $route = $this->findRoute($this->request);
         if ($route == false) {
             throw new SugarApiExceptionNoMethod('Could not find any route that accepted a path like: ' . $this->request->rawPath);
         }
         $this->request->setRoute($route);
         $GLOBALS['logic_hook']->call_custom_logic('', 'after_routing', array("api" => $this, "request" => $this->request));
         // Get it back in case hook changed it
         $route = $this->request->getRoute();
         if (empty($route['keepSession'])) {
             $this->releaseSession();
         }
         // Get the request args early for use in current user api
         $argArray = $this->getRequestArgs($route);
         if (!$isLoggedIn && !empty($route['allowDownloadCookie'])) {
             $isLoggedIn = $this->authenticateUserForDownload();
         }
         // Make sure the system is ready for them
         // This section of code is a portion of the code referred
         // to as Critical Control Software under the End User
         // License Agreement.  Neither the Company nor the Users
         // may modify any portion of the Critical Control Software.
         $systemStatus = apiCheckSystemStatus();
         if ($systemStatus !== true && $systemStatus['level'] != 'warning' && !($systemStatus['level'] == 'maintenance' && isset($this->user) && $this->user->isAdmin()) && empty($route['ignoreSystemStatusError'])) {
             // The system is unhappy and the route isn't flagged to let them through
             $e = new SugarApiExceptionMaintenance($systemStatus['message'], null, null, 0, $systemStatus['level']);
             $e->setExtraData("url", $systemStatus['url']);
             throw $e;
         }
         //END REQUIRED CODE DO NOT MODIFY
         if (!isset($route['noLoginRequired']) || $route['noLoginRequired'] == false) {
             if (!$isLoggedIn) {
                 if (!$loginException) {
                     $this->needLogin();
                 } else {
                     throw $loginException;
                 }
             } else {
                 if (empty($route['ignoreMetaHash'])) {
                     // Check metadata hash state and return an error to force a
                     // resync so that the new metadata gets picked up if it is
                     // out of date
                     if (!$this->isMetadataCurrent()) {
                         // Mismatch in hashes... Return error so the client will
                         // resync its metadata and try again.
                         throw new SugarApiExceptionInvalidHash();
                     }
                 }
             }
         }
         if ($isLoggedIn) {
             // This is needed to load in the app_strings and the app_list_strings and the such
             $this->loadUserEnvironment();
         } else {
             $this->loadGuestEnvironment();
         }
         $headers = array();
         foreach ($this->special_headers as $header) {
             if (isset($this->request_headers[$header])) {
                 $headers[$header] = $this->request_headers[$header];
             }
         }
         if (!empty($headers)) {
             $argArray['_headers'] = $headers;
         }
         $this->request->setArgs($argArray)->setRoute($route);
         $GLOBALS['logic_hook']->call_custom_logic('', 'before_api_call', array("api" => $this, "request" => $this->request));
         // Get it back in case hook changed it
         $route = $this->request->getRoute();
         $argArray = $this->request->getArgs();
         // Trying to fetch correct module while API use search
         $module = $route['className'];
         if (isset($argArray['module'])) {
             $module = $argArray['module'];
         } elseif (isset($argArray['module_list'])) {
             $module = $argArray['module_list'];
         }
         SugarMetric_Manager::getInstance()->setTransactionName('rest_' . $module . '_' . $route['method']);
         $apiClass = $this->loadApiClass($route);
         $apiMethod = $route['method'];
         $this->handleErrorOutput('php_error_before_api');
         $this->response->setContent($apiClass->{$apiMethod}($this, $argArray));
         $this->respond($route, $argArray);
         if (empty($route['rawReply'])) {
             $this->handleErrorOutput('php_error_after_api');
         }
     } catch (Exception $e) {
         $this->handleException($e);
     }
     // last chance for hooks to mess with the response
     $GLOBALS['logic_hook']->call_custom_logic('', "before_respond", $this->response);
     $this->response->send();
 }
示例#7
0
 /**
  * Handle exception
  * @param Exception $e
  */
 protected function handleException(Exception $e)
 {
     $GLOBALS['log']->fatal('Exception in Controller: ' . $e);
     $logicHook = new LogicHook();
     SugarMetric_Manager::getInstance()->handleException($e);
     if (isset($this->bean)) {
         $logicHook->setBean($this->bean);
         $logicHook->call_custom_logic($this->bean->module_dir, "handle_exception", $e);
     } else {
         $logicHook->call_custom_logic('', "handle_exception", $e);
     }
 }
示例#8
0
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
/**
 * This file intialize the service class and does all the setters based on the values provided in soap/rest entry point
 * and calls serve method which takes the request and send response back to the client
 */
ob_start();
chdir(dirname(__FILE__) . '/../../');
define('ENTRY_POINT_TYPE', 'api');
require 'include/entryPoint.php';
require_once 'soap/SoapError.php';
require_once 'SoapHelperWebService.php';
require_once 'SugarRestUtils.php';
require_once $webservice_path;
require_once $registry_path;
if (isset($webservice_impl_class_path)) {
    require_once $webservice_impl_class_path;
}
$url = $GLOBALS['sugar_config']['site_url'] . $location;
$service = new $webservice_class($url);
$service->registerClass($registry_class);
$service->register();
$service->registerImplClass($webservice_impl_class);
SugarMetric_Manager::getInstance()->setTransactionName('soap_' . $_REQUEST['method']);
// set the service object in the global scope so that any error, if happens, can be set on this object
global $service_object;
$service_object = $service;
$service->serve();
 /**
  * Register active instance commands
  */
 protected function registerActiveInstanceCommands()
 {
     // API wrapper commands
     $this->add(new SearchReindexCommand());
     $this->add(new SearchStatusCommand());
     $this->add(new SearchFieldsCommand());
     $this->add(new ElasticsearchQueueCommand());
     $this->add(new ElasticsearchRoutingCommand());
     $this->add(new ElasticsearchIndicesCommand());
     // Legacy commands
     $this->add(new CronCommand($this->logger, $this->config, \SugarMetric_Manager::getInstance()));
 }
示例#10
0
}
require_once 'soap/SoapSugarUsers.php';
//require_once('soap/SoapSugarUsers_version2.php');
require_once 'soap/SoapData.php';
require_once 'soap/SoapDeprecated.php';
require_once 'soap/SoapSync.php';
require_once 'soap/SoapUpgradeUtils.php';
/* Begin the HTTP listener service and exit. */
ob_clean();
if (!isset($HTTP_RAW_POST_DATA)) {
    $HTTP_RAW_POST_DATA = file_get_contents('php://input');
}
require_once 'include/resource/ResourceManager.php';
$resourceManager = ResourceManager::getInstance();
$resourceManager->setup('Soap');
$observers = $resourceManager->getObservers();
//Call set_soap_server for SoapResourceObserver instance(s)
foreach ($observers as $observer) {
    if (method_exists($observer, 'set_soap_server')) {
        $observer->set_soap_server($server);
    }
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
global $soap_server_object;
$soap_server_object = $server;
$server->service($HTTP_RAW_POST_DATA);
$action = substr($server->SOAPAction, strpos($server->SOAPAction, 'soap.php/') + 9);
SugarMetric_Manager::getInstance()->setTransactionName('soap_' . $action);
ob_end_flush();
flush();
sugar_cleanup(true);