GetLogger() public static method

Get the shared instance for the logger
public static GetLogger ( ) : Log
return Log
 public function RunWorkflow($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [START: Constructing the PreProcessor]", \PEAR_LOG_DEBUG);
     $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [END: Constructing the PreProcessor]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [START: Listing all preprocessors]", \PEAR_LOG_DEBUG);
     $steps = $preProcessor->ListAllAvailablePreProcessingSteps();
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [END: Listing all preprocessors]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [START: Finding out which are active]", \PEAR_LOG_DEBUG);
     //Get the currently configured steps
     $config = \Swiftriver\Core\Setup::PreProcessingStepsConfiguration();
     $activeSteps = $config->PreProcessingSteps;
     if ($activeSteps != null && is_array($activeSteps) && $steps != null && is_array($steps)) {
         foreach ($activeSteps as $activeStep) {
             foreach ($steps as $step) {
                 if ($step->Name() == $activeStep->name) {
                     $step->active = true;
                 }
             }
         }
     }
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [END: Finding out which are active]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [START: Encoding results to JSON]", \PEAR_LOG_DEBUG);
     $json = parent::ParseStepsToJson($steps);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [END: Encoding results to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::ListAllPreProcessingSteps::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatReturn($json);
 }
 /**
  * Function that when called with appropriate json will
  * initiate an Analytics call that may return data that
  * can be used by the calling class.
  *
  * @param string $json
  * @param string $key
  * @return string
  */
 public function RunQuery($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [START: Parsing input JSON]", \PEAR_LOG_DEBUG);
     try {
         $requestType = parent::ParseJSONToRequestType($json);
         $parameters = parent::ParseJSONToRequestParameters($json);
         $request = new \Swiftriver\Core\Analytics\AnalyticsRequest();
         $request->RequestType = $requestType;
         $request->Parameters = $parameters;
     } catch (\Exception $e) {
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [An Exception was thrown]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: " . $e->getMessage());
     }
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [END: Parsing input JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [START: Running Analytics Query]", \PEAR_LOG_DEBUG);
     try {
         $analyticsEngine = new \Swiftriver\Core\Analytics\AnalyticsEngine();
         $response = $analyticsEngine->RunAnalyticsRequest($request);
         $return = \json_encode($response->Result);
     } catch (\Exception $e) {
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [An Exception was thrown]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: " . $e->getMessage());
     }
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [END: Running Analytics Query]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::Analaytics::RunAnalyticsQuery::RunQuery [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatReturn($return);
 }
Exemplo n.º 3
0
 public static function ReturnAllAvailableParsers()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [Method invoked]", \PEAR_LOG_DEBUG);
     $parsers = array();
     $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [START: Directory Itteration]", \PEAR_LOG_DEBUG);
     $dirItterator = new \RecursiveDirectoryIterator(dirname(__FILE__) . "/Parsers/");
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isFile()) {
             $filePath = $file->getPathname();
             if (strpos($filePath, ".php") && !strpos($filePath, "IParser")) {
                 try {
                     $typeString = "\\Swiftriver\\Core\\Modules\\SiSPS\\Parsers\\" . $file->getFilename();
                     $type = str_replace(".php", "", $typeString);
                     $object = new $type();
                     if ($object instanceof Parsers\IParser) {
                         $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [Adding type {$type}]", \PEAR_LOG_DEBUG);
                         $parsers[] = $object;
                     }
                 } catch (\Exception $e) {
                     $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [error adding type {$type}]", \PEAR_LOG_DEBUG);
                     $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [{$e}]", \PEAR_LOG_ERR);
                     continue;
                 }
             }
         }
     }
     $logger->log("Core::Modules::SiSPS::ParserFactory::ReturnAllAvailableParsers [END: Directory Itteration]", \PEAR_LOG_DEBUG);
     return $parsers;
 }
 /**
  * Activates the channel processing job
  *
  * @param string $json
  * @return string $json
  */
 public function RunService($json)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     //Parse the JSON input
     $channel = parent::ParseJSONToChannel($json);
     if (!isset($channel)) {
         $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [ERROR: Method ParseIncommingJSON returned null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [ERROR: Registering new processing job with Core]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("There were errors in you JSON. Please review the API documentation and try again.");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     //Construct a new repository
     $repository = new \Swiftriver\Core\DAL\Repositories\ChannelProcessingJobRepository();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [START: Activatin Processing Job]", \PEAR_LOG_DEBUG);
     //Activate the channel processing job
     $repository->ActivateChannelProcessingJob($channel);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [END: Activating Processing Job]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::ActivateChannelProcessingJob::RunService [Method finished]", \PEAR_LOG_INFO);
     //return an OK messagae
     return parent::FormatMessage("OK");
 }
Exemplo n.º 5
0
 /**
  * Returns all the classes that implment the IPreProcessor interface
  * @return IPreProcessingStep[]
  */
 public function ListAllAvailablePreProcessingSteps()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method invoked]", \PEAR_LOG_DEBUG);
     $steps = array();
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     $dirItterator = new \RecursiveDirectoryIterator($modulesDirectory);
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $file) {
         if ($file->isFile()) {
             $filePath = $file->getPathname();
             if (strpos($filePath, "PreProcessingStep.php")) {
                 try {
                     include_once $filePath;
                     $typeString = "\\Swiftriver\\PreProcessingSteps\\" . $file->getFilename();
                     $type = str_replace(".php", "", $typeString);
                     $object = new $type();
                     if ($object instanceof IPreProcessingStep) {
                         $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Adding type {$type}]", \PEAR_LOG_DEBUG);
                         $object->filePath = str_replace($modulesDirectory, "", $filePath);
                         $object->type = $type;
                         $steps[] = $object;
                     }
                 } catch (\Exception $e) {
                     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [error adding type {$type}]", \PEAR_LOG_DEBUG);
                     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [{$e}]", \PEAR_LOG_ERR);
                     continue;
                 }
             }
         }
     }
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method finished]", \PEAR_LOG_DEBUG);
     return $steps;
 }
 /**
  * Implementation of IParser::GetAndParse
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @return Swiftriver\Core\ObjectModel\Content[] contentItems
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Create the Content array
     $contentItems = array();
     switch ($channel->subType) {
         case "Remote":
             $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [START: Parsing SMS items from Remote API]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
             //Extract the Server URL
             $serverURL = $channel->parameters["ServerURL"];
             if (!isset($serverURL)) {
                 $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [the parameter 'ServerURL' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
                 $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
                 return null;
             }
             $contentItems = $this->getRemoteContentItems($channel, $logger, $serverURL);
             $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [END: Parsing SMS items from Remote API]", \PEAR_LOG_DEBUG);
             break;
         case "Local":
             $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [START: Parsing SMS items from Local DB]", \PEAR_LOG_DEBUG);
             $contentItems = $this->getLocalContentItems($channel, $logger);
             $logger->log("Core::Modules::SiSPS::Parsers::FrontlineSMSParser::GetAndParse [END: Parsing SMS items from Local DB]", \PEAR_LOG_DEBUG);
             break;
     }
     //return the content array
     return $contentItems;
 }
 public function RunWorkflow($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Constructing the Event Distributor]", \PEAR_LOG_DEBUG);
     $eventDistributer = new \Swiftriver\Core\EventDistribution\EventDistributor();
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Constructing the Event Distributor]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Getting a full list of Event Handlers from the event distributor]", \PEAR_LOG_DEBUG);
     $handlers = $eventDistributer->ListAllAvailableEventHandlers();
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Getting a full list of Event Handlers from the event distributor]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Finding out which event handlers are active]", \PEAR_LOG_DEBUG);
     $config = \Swiftriver\Core\Setup::EventDistributionConfiguration();
     $activeHandlers = $config->EventHandlers;
     if ($activeHandlers != null && is_array($activeHandlers) && $handlers != null && is_array($handlers)) {
         foreach ($activeHandlers as $activeHandler) {
             foreach ($handlers as $handler) {
                 if ($handler->Name() == $activeHandler->name) {
                     $handler->active = true;
                 }
             }
         }
     }
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Finding out which event handlers are active]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [START: Parsing the handlers to JSON]", \PEAR_LOG_DEBUG);
     $json = parent::ParseHandlersToJson($handlers);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [END: Parsing the handlers to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ListAllEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatReturn($json);
 }
Exemplo n.º 8
0
 /**
  * Implementation of IParser::GetAndParse
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @param datetime $lassucess
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Extract the IMAP parameters
     $imapHostName = $channel->parameters["IMAPHostName"];
     $imapUserName = $channel->parameters["IMAPUserName"];
     $imapPassword = $channel->parameters["IMAPPassword"];
     if (!isset($imapHostName) || $imapHostName == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [the parameter 'IMAPHostName' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     if (!isset($imapUserName) || $imapUserName == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [the parameter 'IMAPUserName' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     if (!isset($imapPassword) || $imapPassword == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [the parameter 'IMAPPassword' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Create the Content array
     $contentItems = array();
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [START: Parsing IMAP items]", \PEAR_LOG_DEBUG);
     //Get information regarding the source
     $contentItems = $this->GetIMAPContent($imapHostName, $imapUserName, $imapPassword, $channel);
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [END: Parsing IMAP items]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::IMAPParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
     //return the content array
     return $contentItems;
 }
Exemplo n.º 9
0
 public static function CreateChannel($json)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Calling json_decode]", \PEAR_LOG_DEBUG);
     $data = json_decode($json);
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Extracting data from the JSON objects]", \PEAR_LOG_DEBUG);
     if (!isset($data) || !$data) {
         throw new \InvalidArgumentException("There was an error in the JSON. No Channel can be constructed.");
     }
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Extracting values from the data]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Constructing Channel object]", \PEAR_LOG_DEBUG);
     $channel = new \Swiftriver\Core\ObjectModel\Channel();
     $channel->id = isset($data->id) ? $data->id : null;
     $channel->type = $data->type;
     $channel->updatePeriod = $data->updatePeriod;
     $channel->active = isset($data->active) ? $data->active : true;
     $channel->lastSucess = isset($data->lastSucess) ? $data->lastSucess : null;
     $channel->inprocess = isset($data->inprocess) ? $data->inprocess : false;
     $params = array();
     foreach ($data->parameters as $key => $value) {
         $params[$key] = $value;
     }
     $channel->parameters = $params;
     //set key values if they have not been set
     $channel = ChannelFactory::SetValuesIfNotSet($channel, array("id" => md5(uniqid(rand(), true)), "active" => true, "nextrun" => time() + $channel->updatePeriod * 60));
     $logger->log("Core::ObjectModel::ObjectFactories::ChannelFactory::CreateChannel [Method finished]", \PEAR_LOG_DEBUG);
     return $channel;
 }
 public function RunWorkflow($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         $name = parent::ParseJsonToEventHandlerName($json);
     } catch (\Exception $e) {
         $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         return parent::FormatErrorMessage($e);
     }
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Instanciating the event distributor]", \PEAR_LOG_DEBUG);
     $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Instanciating the event distributor]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Getting all the availabel event handlers]", \PEAR_LOG_DEBUG);
     $handlers = $eventDistributor->ListAllAvailableEventHandlers();
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Getting all the availabel event handlers]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Looking for a handler with the matching name]", \PEAR_LOG_DEBUG);
     foreach ($handlers as $handler) {
         if ($handler->Name() == $name) {
             $thisHandler = $handler;
         }
     }
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Looking for a handler with the matching name]", \PEAR_LOG_DEBUG);
     if (!isset($thisHandler) || $thisHandler == null) {
         return parent::FormatErrorMessage("No event handler found matching the name {$name}");
     }
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Constructing the configuration entry]", \PEAR_LOG_DEBUG);
     $className = $thisHandler->type;
     $filePath = $thisHandler->filePath;
     $configEntry = new \Swiftriver\Core\ObjectModel\EventHandlerEntry($name, $className, $filePath);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Constructing the configuration entry]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Extracting the configured event handlers from the config system]", \PEAR_LOG_DEBUG);
     $config = \Swiftriver\Core\Setup::EventDistributionConfiguration();
     $configuredEventHandlers = $config->EventHandlers;
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Extracting the configured event handlers from the config system]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Looking for an existing config entry for this handler]", \PEAR_LOG_DEBUG);
     for ($i = 0; $i < count($configuredEventHandlers); $i++) {
         if ($configuredEventHandlers[$i]->name == $name) {
             $index = $i;
         }
     }
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Looking for an existing config entry for this handler]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Adding a configuration entry for this event handler]", \PEAR_LOG_DEBUG);
     if (isset($index)) {
         $configuredEventHandlers[$index] = $configEntry;
     } else {
         $configuredEventHandlers[] = $configEntry;
     }
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Adding a configuration entry for this event handler]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [START: Saving the configuration]", \PEAR_LOG_DEBUG);
     $config->EventHandlers = $configuredEventHandlers;
     $config->Save();
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [END: Saving the configuration]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::ActivateEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatMessage("OK");
 }
 function mongo_analytics($request)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $parameters = $request->Parameters;
     $yearDay = (int) \date('z');
     $timeLimit = 5;
     if (\is_array($parameters)) {
         if (\key_exists("TimeLimit", $parameters)) {
             $timeLimit = (int) $parameters["TimeLimit"];
         }
     }
     $date = \strtotime("-{$timeLimit} days");
     $channel_array = array();
     $request->Result = null;
     try {
         $db_content = parent::PDOConnection($request);
         $db_sources = parent::PDOConnection($request);
         $db_channels = parent::PDOConnection($request);
         $db_content->where(array("date" => array('$gte' => $date)));
         $content_items = $db_content->get("content");
         $logger->log("Swiftriver::AnalyticsProviders::TotalContentByChannelAnalyticsProvider::ProvideAnalytics [Selected date: {$date}]", \PEAR_LOG_INFO);
         $logger->log("Swiftriver::AnalyticsProviders::TotalContentByChannelAnalyticsProvider::ProvideAnalytics [" . \count($content_items) . " number of content items retrieved]", \PEAR_LOG_INFO);
         $channel_array = array();
         foreach ($content_items as $content_item) {
             $source_id = $content_item["source"]["id"];
             $source_items = $db_sources->get_where("sources", array("id" => $source_id));
             $logger->log("Swiftriver::AnalyticsProviders::TotalContentByChannelAnalyticsProvider::ProvideAnalytics [" . \count($source_items) . " number of source items retrieved]", \PEAR_LOG_INFO);
             foreach ($source_items as $source_item) {
                 $channel_id = $source_item["channelId"];
                 if (!\in_array($channel_id, $channel_array)) {
                     $channel_array[$channel_id] = array();
                 }
                 $channels = $db_channels->get_where("channels", array("id" => $channel_id));
                 $logger->log("Swiftriver::AnalyticsProviders::TotalContentByChannelAnalyticsProvider::ProvideAnalytics [" . \count($channels) . " number of channels retrieved]", \PEAR_LOG_INFO);
                 foreach ($channels as $channel) {
                     $channel_array[$channel_id]["channelId"] = $channel_id;
                     $channel_array[$channel_id]["channelName"] = $channel["name"];
                     if (!\in_array($channel_id, $channel_array[$channel_id]["numberOfContentItems"])) {
                         $channel_array[$channel_id]["numberOfContentItems"] = 1;
                     } else {
                         $channel_array[$channel_id]["numberOfContentItems"] += 1;
                     }
                     $channel_array[$channel_id]["channelType"] = $content_item["source"]["type"];
                     $channel_array[$channel_id]["channelSubType"] = $content_item["source"]["subType"];
                 }
             }
         }
     } catch (\MongoException $e) {
         $logger->log("Swiftriver::AnalyticsProviders::ContentByChannelOverTimeAnalyticsProvider::ProvideAnalytics [An exception was thrown]", \PEAR_LOG_ERR);
         $logger->log("Swiftriver::AnalyticsProviders::ContentByChannelOverTimeAnalyticsProvider::ProvideAnalytics [{$e}]", \PEAR_LOG_ERR);
     }
     foreach ($channel_array as $channel_array_item) {
         if ($request->Result == null) {
             $request->Result = array();
         }
         $request->Result[] = $channel_array_item;
     }
     return $request;
 }
Exemplo n.º 12
0
 /**
  * This method redords the fact that a marker (sweeper) has changed the score
  * of a source by marking a content items as either 'acurate', 'chatter' or
  * 'inacurate'
  *
  * @param string $sourceId
  * @param string $markerId
  * @param int $change
  */
 public function RecordSourceScoreChange($sourceId, $markerId, $change, $reason = null)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::DAL::Repositories::TrustLogRepository::RecordSourceScoreChange [Method invoked]", \PEAR_LOG_DEBUG);
     $dc = new $this->dataContext();
     $dc::RecordSourceScoreChange($sourceId, $markerId, $change, $reason);
     $logger->log("Core::DAL::Repositories::TrustLogRepository::RecordSourceScoreChange [Method Finished]", \PEAR_LOG_DEBUG);
 }
Exemplo n.º 13
0
 /**
  * Removes a registered API key
  * Returns true on sucess
  *
  * @param string $key
  * @return bool
  */
 public function RemoveRegisteredAPIKey($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::DAL::Repositories::APIKeyRepository::RemoveRegisteredAPIKey [Method invoked]", \PEAR_LOG_DEBUG);
     $dc = $this->dataContext;
     $dc::RemoveRegisteredCoreAPIKey($key);
     $logger->log("Core::DAL::Repositories::APIKeyRepository::RemoveRegisteredAPIKey [Method finished]", \PEAR_LOG_DEBUG);
 }
Exemplo n.º 14
0
 /**
  * Lists all the current Source in the core
  * @return \Swiftriver\Core\ObjectModel\Source[]
  */
 public function ListAllSources()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::DAL::Repositories::SourceRepository::ListAllSources [Method invoked]", \PEAR_LOG_DEBUG);
     $dc = $this->dataContext;
     $sources = $dc::ListAllSources();
     $logger->log("Core::DAL::Repositories::SourceRepository::ListAllSources [Method Finished]", \PEAR_LOG_DEBUG);
     return $sources;
 }
 public function test()
 {
     include_once dirname(__FILE__) . "/../../../Setup.php";
     include_once dirname(__FILE__) . "/../../../Modules/UshahidiAPIInterface/UshahidiAPIEventHandler.php";
     $event->arguments = new \Swiftriver\Core\ObjectModel\Content();
     $configuration->ModulesDirectory = dirname(__FILE__) . "/../../../Modules/";
     $handler = new \Swiftriver\EventHandlers\UshahidiAPIEventHandler();
     $handler->HandleEvent($event, $configuration, \Swiftriver\Core\Setup::GetLogger());
 }
 public function ListAvailableParsers()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [START: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG);
     $parsers = ParserFactory::ReturnAllAvailablePushParsers();
     $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [END: Getting All Parsers from the ParserFactory]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::SwiftriverPushParsingService::ListAvailableChannels [Method finished]", \PEAR_LOG_DEBUG);
     return $parsers;
 }
 public function RunWorkflow($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         //Call the parent to decode the json
         $preProcessingStepName = parent::ParseJsonToPreProcessingStepName($json);
         $configuration = parent::ParseJsonToPreProcessingStepConfiguration($json);
     } catch (\Exception $e) {
         //Catch and report the exception if one is thrown
         $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         return parent::FormatErrorMessage($e);
     }
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Listing all available pre processors]", \PEAR_LOG_DEBUG);
     //Build a new pre processor
     $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
     //list all the availaibel steps
     $steps = $preProcessor->ListAllAvailablePreProcessingSteps();
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [END: Listing all available pre processors]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Looking for the pre processor to activate]", \PEAR_LOG_DEBUG);
     //Loop throught the steps looking for one with the same name as came from the JOSN
     foreach ($steps as $s) {
         if ($s->Name() == $preProcessingStepName) {
             $step = $s;
         }
     }
     //If not found, return an error.
     if (!isset($step) || $step == null) {
         $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [No pre processor with a name matching {$preProcessingStepName} was found.]", \PEAR_LOG_DEBUG);
         return parent::FormatErrorMessage("No pre processor matching the name {$preProcessingStepName} could be found");
     }
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [END: Looking for the pre processor to activate]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Collecting Configuration properties for Pre Processing Step]", \PEAR_LOG_DEBUG);
     $thisConfig = array();
     foreach ($step->ReturnRequiredParameters() as $param) {
         foreach ($configuration as $key => $value) {
             if ($param->name == $key) {
                 $param->value = $value;
             }
         }
         $thisConfig[] = $param;
     }
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [END: Collecting Configuration properties for Pre Processing Step]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Saving configuration properties for Pre Processing Step]", \PEAR_LOG_DEBUG);
     $config = \Swiftriver\Core\Setup::DynamicModuleConfiguration();
     $config->Configuration[$preProcessingStepName] = $thisConfig;
     $config->Save();
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [START: Saving configuration properties for Pre Processing Step]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::PreProcessingSteps::SavePreProcessingStep::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     parent::FormatMessage("OK");
 }
 public function RunWorkflow($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StopTwitterStreamer::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $filename = \Swiftriver\Core\Setup::Configuration()->CachingDirectory . "/TwitterStreamingController.go";
     if (\file_exists($filename)) {
         \unlink($filename);
     }
     $logger->log("Core::ServiceAPI::TwitterStreamingServices::StopTwitterStreamer::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return '{"message":"OK"}';
 }
Exemplo n.º 19
0
 /**
  * Implementation of IParser::GetAndParse
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @param datetime $lassucess
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $contentItems = array();
     $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Extract the required variables
     $apikey = $channel->parameters["APIKEY"];
     if (!isset($apikey) || $apikey == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [the parameter 'APIKEY' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     try {
         $json = \file_get_contents("http://api.eventful.com/rest/demands/members/list?app_key=" . $apikey);
         $object = \json_decode($json);
         $source_name = "Eventful";
         $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name, $channel->trusted);
         $source->name = $source_name;
         $source->link = "http://eventful.com";
         $source->parent = $channel->id;
         $source->type = $channel->type;
         $source->subType = $channel->subType;
         foreach ($object->members as $event) {
             if (!isset($event->time_stamp) || !isset($event->longitude) || !isset($event->latitude) || !isset($event->location) || !isset($event->unique_id)) {
                 $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [One event did not have the required parameters]", \PEAR_LOG_ERR);
                 continue;
             }
             $contentdate = \strtotime($event->time_stamp);
             if (isset($channel->lastSuccess) && is_numeric($channel->lastSuccess) && isset($contentdate) && is_numeric($contentdate)) {
                 if ($contentdate < $channel->lastSuccess) {
                     $textContentDate = date("c", $contentdate);
                     $textlastSuccess = date("c", $channel->lastSuccess);
                     $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [Skipped feed item as date {$textContentDate} less than last sucessful run ({$textlastSuccess})]", \PEAR_LOG_DEBUG);
                     continue;
                 }
             }
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             //Fill the Content Item
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, "Eventful event in " . $event->location, array("Eventful event in " . $event->location));
             $item->link = "http://eventful.com";
             $item->date = $contentdate;
             $item->gisData[] = new \Swiftriver\Core\ObjectModel\GisData($event->longitude, $event->latitude, $event->location);
             $contentItems[] = $item;
         }
     } catch (\Exception $e) {
         $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [{$e}]", \PEAR_LOG_ERR);
     }
     $logger->log("Core::Modules::SiSPS::Parsers::EventfulParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
     //return the content array
     return $contentItems;
 }
Exemplo n.º 20
0
 /**
  * Given a set of parameters, this method should
  * fetch content from a channel and parse each
  * content into the Swiftriver object model :
  * Content Item. The $lastSuccess datetime is passed
  * to the function to ensure that content that has
  * already been parsed is not duplicated.
  *
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @return Swiftriver\Core\ObjectModel\Content[] contentItems
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     $searchPhrase = $channel->parameters["SearchPhrase"];
     $this->searchPhrase = $searchPhrase;
     $selectedServices = array();
     $currentServiceID = 0;
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Establishing number of parsers]", \PEAR_LOG_DEBUG);
     while (true) {
         if (!isset($channel->parameters["SearchServices_" . $currentServiceID])) {
             break;
         }
         if ($channel->parameters["SearchServices_" . $currentServiceID] == "true") {
             $selectedServices[] = $currentServiceID;
         }
         $currentServiceID++;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Number of Parsers:" . count($selectedServices) . "]", \PEAR_LOG_DEBUG);
     if (!isset($searchPhrase) || $searchPhrase == null || !\is_string($searchPhrase)) {
         $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [the parameter 'SearchPhrase' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [START: Including the SimplePie module]", \PEAR_LOG_DEBUG);
     $contentItems = array();
     foreach ($selectedServices as $selectedService) {
         switch ($selectedService) {
             case 0:
                 // Google news
                 $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Invoking Google Search]", \PEAR_LOG_INFO);
                 $newItems = $this->GoogleNewsSearch($searchPhrase, $logger, $channel);
                 $contentItems = is_array($newItems) ? array_merge($contentItems, $newItems) : $contentItems;
                 break;
             case 1:
                 // Wordpress
                 $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Invoking Wordpress Search]", \PEAR_LOG_INFO);
                 $newItems = $this->WordpressSearch($searchPhrase, $logger, $channel);
                 $contentItems = is_array($newItems) ? array_merge($contentItems, $newItems) : $contentItems;
                 break;
             case 2:
                 // Blogger
                 $logger->log("Core::Modules::SiSPS::Parsers::GoogleNewsParser::GetAndParse [Invoking Blogger Search]", \PEAR_LOG_INFO);
                 $newItems = $this->BloggerSearch($searchPhrase, $logger, $channel);
                 $contentItems = is_array($newItems) ? array_merge($contentItems, $newItems) : $contentItems;
                 break;
         }
     }
     //return the content array
     return $contentItems;
 }
 /**
  * Adds the pre processing job to the DAL
  *
  * @param string $json
  * @return string $json
  */
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         //Parse the JSON input
         $channel = parent::ParseJSONToChannel($json);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     if (!isset($channel)) {
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [ERROR: Method ParseIncommingJSON returned null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [ERROR: Registering new processing job with Core]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("There were errors in you JSON. Please review the API documentation and try again.");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     try {
         //Construct a new repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ChannelProcessingJobRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [START: Saving Processing Job]", \PEAR_LOG_DEBUG);
     try {
         //Add the channel processign job to the repository
         $repository->SaveChannelProgessingJob($channel);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [END: Saving Processing Job]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::RegisterNewProcessingJob::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     //return an OK messagae
     return parent::FormatMessage("OK");
 }
Exemplo n.º 22
0
 /**
  * Returns all the classes that implment the IPreProcessor interface
  *
  * @return IPreProcessingStep[]
  */
 public function ListAllAvailablePreProcessingSteps()
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method invoked]", \PEAR_LOG_DEBUG);
     //set up the array to hold the steps
     $steps = array();
     //Get the path of the modules directory
     $modulesDirectory = \Swiftriver\Core\Setup::Configuration()->ModulesDirectory;
     //Create a recursive directory ittorator
     $dirItterator = new \RecursiveDirectoryIterator($modulesDirectory);
     $iterator = new \RecursiveIteratorIterator($dirItterator, \RecursiveIteratorIterator::SELF_FIRST);
     //Itterate over all the files in all the directories
     foreach ($iterator as $file) {
         //If not a file continue
         if (!$file->isFile()) {
             continue;
         }
         //get the full file path
         $filePath = $file->getPathname();
         //If not a pre processing step then continue
         if (!strpos($filePath, "PreProcessingStep.php")) {
             continue;
         }
         try {
             //Include the file
             include_once $filePath;
             //create a type string for the pre processing step
             $typeString = "\\Swiftriver\\PreProcessingSteps\\" . $file->getFilename();
             //remove the .php extension
             $type = str_replace(".php", "", $typeString);
             //instanciate the pre processing step
             $object = new $type();
             //Check that the object implements the IPreProcessingStep
             if (!$object instanceof IPreProcessingStep) {
                 continue;
             }
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Adding type {$type}]", \PEAR_LOG_DEBUG);
             //Add the file name to the step element
             $object->filePath = str_replace($modulesDirectory, "", $filePath);
             //Add the type to the step element
             $object->type = $type;
             //Add the object to the array
             $steps[] = $object;
         } catch (\Exception $e) {
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [error adding type {$type}]", \PEAR_LOG_DEBUG);
             $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [{$e}]", \PEAR_LOG_ERR);
             continue;
         }
     }
     $logger->log("Core::PreProcessing::PreProcessor::ListAllAvailablePreProcessingSteps [Method finished]", \PEAR_LOG_DEBUG);
     return $steps;
 }
Exemplo n.º 23
0
 /**
  * Implementation of IParser::GetAndParse
  * @param \Swiftriver\Core\ObjectModel\Channel $channel
  * @param datetime $lassucess
  */
 public function GetAndParse($channel)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [Method invoked]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [START: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Extract the required variables
     $feedUrl = "";
     switch ($channel->subType) {
         case "Wordpress Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/?feed=atom";
             break;
         case "Blogger Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/feeds/posts/default";
             break;
         case "Tumblr Blog":
             $feedUrl = $channel->parameters["BlogUrl"];
             $feedUrl = rtrim($feedUrl, "/") . "/api/read";
             break;
         case "News Feeds":
             $feedUrl = $channel->parameters["feedUrl"];
             break;
     }
     if (!isset($feedUrl) || $feedUrl == "") {
         $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [the parameter 'feedUrl' was not supplied. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::Parsers::FeedsParser::GetAndParse [END: Extracting required parameters]", \PEAR_LOG_DEBUG);
     //Include the Simple Pie Framework to get and parse feeds
     $config = \Swiftriver\Core\Setup::Configuration();
     $contentItems = null;
     switch ($channel->subType) {
         case "Wordpress Blog":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "Blogger Blog":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "Tumblr Blog":
             $contentItems = $this->GetXMLContentEntries($channel, $config, $logger, $feedUrl);
             break;
         case "News Feeds":
             $contentItems = $this->GetSimplePieContentEntries($channel, $config, $logger, $feedUrl);
             break;
     }
     //return the content array
     return $contentItems;
 }
Exemplo n.º 24
0
 /**
  * Implementation of IPushParser::PushAndParse
  * @param $raw_content
  * @param $post_content
  * @param $get_content
  * @param $file_content
  * @return \Swiftriver\Core\ObjectModel\Content[] contentItems
  */
 public function PushAndParse($raw_content = null, $post_content = null, $get_content = null, $file_content = null)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::PushParsers::CSVParser::PushAndParse [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Modules::SiSPS::PushParsers::CSVParser::PushAndParse [START: Extracting required parameters]", \PEAR_LOG_INFO);
     $contentItems = array();
     $settings = $this->GetSettings();
     $file_name = "file_upload_" . $settings["file_upload_id"];
     if (!isset($file_content[$file_name])) {
         $logger->log("Core::Modules::SiSPS::PushParsers::CSVParser::PushAndParse [No file uploaded with file_upload file name]", \PEAR_LOG_ERR);
         return $contentItems;
     }
     $logger->log("Core::Modules::SiSPS::PushParsers::CSVParser::PushAndParse [END: Extracting required parameters]", \PEAR_LOG_INFO);
     $file_handle = fopen($file_content[$file_name]["tmp_name"], "r");
     if ($file_handle) {
         while (($data = fgetcsv($file_handle, 0, ",")) !== FALSE) {
             $title = $data[0];
             $text = $data[1];
             $link = $data[2];
             $date = $data[3];
             if (strrpos($date, "-")) {
                 // Convert date to timestamp
                 $date = explode("-", $date);
                 $date = strptime($date[0] . "-" . $date[1] . "-" . $date[2], "%Y-%m-%d");
                 $date = mktime(0, 0, 0, $date['tm_month'], $date['tm_day'], $date['tm_year']);
             }
             $source_name = $this->ReturnType();
             $source = \Swiftriver\Core\ObjectModel\ObjectFactories\SourceFactory::CreateSourceFromIdentifier($source_name, $settings["trusted"]);
             $source->parent = $this->ReturnType();
             $source->name = $source_name;
             $source->link = $link;
             $source->type = $this->ReturnType();
             $source->subType = $this->ReturnType();
             //Create a new Content item
             $item = \Swiftriver\Core\ObjectModel\ObjectFactories\ContentFactory::CreateContent($source);
             //Fill the Content Item
             $item->text[] = new \Swiftriver\Core\ObjectModel\LanguageSpecificText(null, $title, array($text));
             $item->link = $link;
             $item->date = $date;
             //Add the item to the Content array
             $contentItems[] = $item;
         }
     } else {
         $logger->log("Core::Modules::SiSPS::PushParsers::CSVParser::PushAndParse [Method finished]", \PEAR_LOG_INFO);
         return $contentItems;
     }
     fclose($file_handle);
     //return the content array
     return $contentItems;
 }
Exemplo n.º 25
0
 public function RunWorkflow($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Parsing the input JSON]", \PEAR_LOG_DEBUG);
     try {
         $name = parent::ParseJsonToEventHandlerName($json);
         $config = parent::ParseJsonToEventHandlerConfiguration($json);
     } catch (\Exception $e) {
         $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [An Exception was thrown]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         return parent::FormatErrorMessage($e);
     }
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Parsing the input JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Instanciating the event distributor]", \PEAR_LOG_DEBUG);
     $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Instanciating the event distributor]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Listing all event handlers]", \PEAR_LOG_DEBUG);
     $handlers = $eventDistributor->ListAllAvailableEventHandlers();
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Listing all event handlers]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Looking for an event handler with matching name]", \PEAR_LOG_DEBUG);
     foreach ($handlers as $handler) {
         if ($handler->Name() == $name) {
             $thisHandler = $handler;
         }
     }
     if (!isset($thisHandler) || $thisHandler == null) {
         $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [No event handler was found matching the name {$name}]", \PEAR_LOG_DEBUG);
         return parent::FormatErrorMessage("No event handler was found matching the name {$name}");
     }
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Looking for an event handler with matching name]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Adding all the configured properties to the event handler]", \PEAR_LOG_DEBUG);
     $thisConfig = array();
     foreach ($thisHandler->ReturnRequiredParameters() as $param) {
         foreach ($config as $key => $value) {
             if ($param->name == $key) {
                 $param->value = $value;
             }
         }
         $thisConfig[] = $param;
     }
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Adding all the configured properties to the event handler]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [START: Saving the configuration]", \PEAR_LOG_DEBUG);
     $configuration = \Swiftriver\Core\Setup::DynamicModuleConfiguration();
     $configuration->Configuration[$name] = $thisConfig;
     $configuration->Save();
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [END: Saving the configuration]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::EventHandlers::SaveEventHandlers::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     parent::FormatMessage("OK");
 }
Exemplo n.º 26
0
 /**
  * Removes a Channel from the DAL
  * 
  * @param string $json
  * @return string 
  */
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     //try to parse the id from the JSON
     try {
         //get the ID from the JSON
         $id = parent::ParseJSONToId($json);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     try {
         //Construct a new repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ChannelRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [START: Deleting the Channel]", \PEAR_LOG_DEBUG);
     try {
         //Delete the Channel from the data store
         $repository->RemoveChannels(array($id));
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [END: Deletig the Channel]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::DeleteChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     //return an OK messagae
     return parent::FormatMessage("OK");
 }
 /**
  *
  * @param \Swiftriver\Core\ObjectModel\Channel[] $channels
  * @return string
  */
 public function ParseChannelsToJSON($channels)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChannelProcessingJobBase::ParseChannelsToJSON [Method invoked]", \PEAR_LOG_INFO);
     //$logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChannelProcessingJobBase::ParseChannelsToJSON [Calling json_decode]", \PEAR_LOG_DEBUG);
     $json = '{"channels":[';
     if (isset($channels) && is_array($channels) && count($channels) > 0) {
         foreach ($channels as $channel) {
             $json .= json_encode($channel) . ",";
         }
     }
     $json = rtrim($json, ",") . ']}';
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChannelProcessingJobBase::ParseChannelsToJSON [Method finsihed]", \PEAR_LOG_INFO);
     return $json;
 }
 /**
  * List all Channel Processing Jobs in the Data Store
  *
  * @param string $json
  * @return string $json
  */
 public function RunWorkflow($key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     try {
         //Construct a new repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ChannelProcessingJobRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [START: Listing all processing jobs]", \PEAR_LOG_DEBUG);
     try {
         //Get all the channel processing jobs
         $channels = $repository->ListAllChannelProcessingJobs();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [END: Listing all processing jobs]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [START: Parsing channel processing jobs to JSON]", \PEAR_LOG_DEBUG);
     try {
         //Parse the JSON input
         $json = parent::ParseChannelsToJSON($channels);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [END: Parsing channel processing jobs to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAllChannelProcessingJobs::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     //return the channels as JSON
     return $json;
 }
 /**
  * List all the Available types of Channels that can be configured in
  * the core
  *
  * @param string $key
  * @return string $json
  */
 public function RunWorkflow($key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [START: Constructing SiSPS]", \PEAR_LOG_DEBUG);
     $service = new \Swiftriver\Core\Modules\SiSPS\SwiftriverSourceParsingService();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [END: Constructing SiSPS]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [START: Getting the list of available parsers]", \PEAR_LOG_DEBUG);
     $parsers = $service->ListAvailableParsers();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [END: Getting the list of available parsers]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [START: Parsing to return JSON]", \PEAR_LOG_DEBUG);
     $json = parent::ParseParsersToJSON($parsers);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [END: Parsing to return JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ListAvailableChannelTypes::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatReturn($json);
 }
Exemplo n.º 30
0
 /**
  * Expects a string reprosenting the class
  * name of an object that implements the
  * SiSPS\IParser interface. The param $type
  * must not include the word 'Parser'. For
  * example, supplying the $type Email will
  * return an instance of the EmailParser
  * object.
  *
  * @param string $type
  * @return SiSPS\Parsers\IParser $parser
  */
 public static function GetParser($type)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Modules::SiSPS::ParserFactory::GetParser [Method invoked]", \PEAR_LOG_DEBUG);
     //Append the word Parser to the type
     $type = $type . "Parser";
     //If the class is not defined, return null
     $type = "\\Swiftriver\\Core\\Modules\\SiSPS\\Parsers\\" . $type;
     if (!class_exists($type)) {
         $logger->log("Core::Modules::SiSPS::ParserFactory::GetParser [Class {$type} not found. Returning null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Modules::SiSPS::ParserFactory::GetParser [Method finished]", \PEAR_LOG_DEBUG);
         return null;
     }
     $logger->log("Core::Modules::SiSPS::ParserFactory::GetParser [Method finished]", \PEAR_LOG_DEBUG);
     //Finally, return a new Parser
     return new $type();
 }