Esempio n. 1
0
 /**
  * Given a JSON string describing the pagination and state
  * required, this method will return a set of content items
  *
  * @param string $json
  * @return string
  */
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $parameters = parent::ParseJSONToLooseParameters($json);
     if (!isset($parameters)) {
         $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [ERROR: Method ParseJSONToPagedContentByStateParameters returned null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [ERROR: Getting paged content by state]", \PEAR_LOG_INFO);
         parent::FormatErrorMessage("There was an error in the JSON supplied, please consult the API documentation and try again.");
     }
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Constructing Content repository]", \PEAR_LOG_DEBUG);
     $repository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Constructing Content repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Querying repository]", \PEAR_LOG_DEBUG);
     $results = $repository->GetContentList($parameters);
     if (!isset($results) || !is_array($results) || !isset($results["totalCount"]) || !isset($results["contentItems"]) || !is_numeric($results["totalCount"]) || $results["totalCount"] < 1) {
         $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [No results were returned from the repository]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Querying repository with supplied parameters]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return '{"totalcount":"0"}';
     }
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Querying repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Raising the 'Before Content Sent to Client' event]", \PEAR_LOG_DEBUG);
     $event = new \Swiftriver\Core\EventDistribution\GenericEvent(\Swiftriver\Core\EventDistribution\EventEnumeration::$BeforeContentSentToClient, $results["contentItems"]);
     $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
     $returnEvent = $eventDistributor->RaiseAndDistributeEvent($event);
     $contentitems = $returnEvent->arguments;
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Raising the 'Before Content Sent to Client' event]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Parsing content to JSON]", \PEAR_LOG_DEBUG);
     $contentJson = parent::ParseContentToJSON($contentitems);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Parsing content to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Parsing navigation to JSON]", \PEAR_LOG_DEBUG);
     $navigationJson = isset($results["navigation"]) && $results["navigation"] != null ? json_encode($results["navigation"]) : "[]";
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Parsing navigation to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [START: Constructing return JSON]", \PEAR_LOG_DEBUG);
     $returnJson = '{"totalcount":"' . $results["totalCount"] . '","contentitems":' . $contentJson . ',"navigation":' . $navigationJson . '}';
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [END: Constructing return JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetContent::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return $returnJson;
 }
 public function RunWorkflow($content, $preProcessContent = true)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [START: Running core processing]", \PEAR_LOG_DEBUG);
     if ($preProcessContent) {
         try {
             $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
             $content = $preProcessor->PreProcessContent($content);
         } catch (\Exception $e) {
             //get the exception message
             $message = $e->getMessage();
             $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
             return parent::FormatErrorMessage("An exception was thrown: {$message}");
         }
     }
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [END: Running core processing]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [START: Save content to the data store]", \PEAR_LOG_DEBUG);
     try {
         $contentRepository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
         $contentRepository->SaveContent($content);
         // Raise the event handler that handles the post processing of content
         $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [Raise the Ushahidi Push Event Handler]", \PEAR_LOG_DEBUG);
         $event = new \Swiftriver\Core\EventDistribution\GenericEvent(\Swiftriver\Core\EventDistribution\EventEnumeration::$ContentPostProcessing, $content);
         $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
         $eventDistributor->RaiseAndDistributeEvent($event);
         $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [End Ushahidi Push event]", \PEAR_LOG_DEBUG);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [END: Save content to the data store]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ContentServices::ProcessContent::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
 }
 /**
  * Given a JSON string describing the pagination and state
  * required, this method will return a set of content items
  *
  * @param string $json
  * @return string
  */
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $parameters = parent::ParseJSONToPagedContentByStateAndSourceVeracityParameters($json);
     if (!isset($parameters)) {
         $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [ERROR: Method ParseJSONToPagedContentByStateAndSourceVeracityParameters returned null]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [ERROR: Getting paged content by state]", \PEAR_LOG_INFO);
         parent::FormatErrorMessage("There was an error in the JSON supplied, please consult the API documentation and try again.");
     }
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [START: Constructing Content repository]", \PEAR_LOG_DEBUG);
     $repository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Constructing Content repository]", \PEAR_LOG_DEBUG);
     $state = $parameters["state"];
     $pagestart = $parameters["pagestart"];
     $pagesize = $parameters["pagesize"];
     $minVeracity = $parameters["minVeracity"];
     $maxVeracity = $parameters["maxVeracity"];
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [START: Querying repository with supplied parameters - state: {$state}, pagesize: {$pagesize}, pagestart: {$pagestart}]", \PEAR_LOG_DEBUG);
     $results = $repository->GetPagedContentByStateAndSourceVeracity($state, $pagesize, $pagestart, $minVeracity, $maxVeracity);
     if (!isset($results) || !is_array($results) || !isset($results["totalCount"]) || !isset($results["contentItems"]) || !is_numeric($results["totalCount"]) || $results["totalCount"] < 1) {
         $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [No results were returned from the repository]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Querying repository with supplied parameters]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return '{"totalcount":"0"}';
     }
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Querying repository with supplied parameters]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [START: Parsing content to JSON]", \PEAR_LOG_DEBUG);
     $contentJson = parent::ParseContentToJSON($results["contentItems"]);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Parsing content to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [START: Constructing return JSON]", \PEAR_LOG_DEBUG);
     $returnJson = '{"totalcount":"' . $results["totalCount"] . '","contentitems":' . $contentJson . '}';
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [END: Constructing return JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::GetPagedContentByStateAndSourceVeracity::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return $returnJson;
 }
 /**
  * Selects the next due processing job and runs it through the core
  *
  * @return string $json
  */
 public function RunService()
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     //Construct a new repository
     $channelRepository = new \Swiftriver\Core\DAL\Repositories\ChannelProcessingJobRepository();
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Fetching next processing Job]", \PEAR_LOG_DEBUG);
     //Get the next due channel processign job
     $channel = $channelRepository->SelectNextDueChannelProcessingJob();
     if ($channel == null) {
         $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [INFO: No processing jobs due]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Fetching next processing Job]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatMessage("OK");
     }
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Fetching next processing Job]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Get and parse content]", \PEAR_LOG_DEBUG);
     $SiSPS = new \Swiftriver\Core\Modules\SiSPS\SwiftriverSourceParsingService();
     $rawContent = $SiSPS->FetchContentFromChannel($channel);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Get and parse content]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Running core processing]", \PEAR_LOG_DEBUG);
     $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
     $processedContent = $preProcessor->PreProcessContent($rawContent);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Parsing channel processing jobs to JSON]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Save content to the data store]", \PEAR_LOG_DEBUG);
     $contentRepository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     $contentRepository->SaveContent($processedContent);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Save content to the data store]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [START: Mark channel processing job as complete]", \PEAR_LOG_DEBUG);
     $channelRepository->MarkChannelProcessingJobAsComplete($channel);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [END: Mark channel processing job as complete]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ChannelProcessingJobClasses::RunNextProcessingJob::RunService [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatMessage("OK");
 }
 public function RunWorkflow($json, $key)
 {
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Parsing JSON input]", \PEAR_LOG_DEBUG);
     try {
         $contentId = $this->ParseJSONToContentID($json);
         $tagsRemoved = $this->ParseJSONToTags($json, "tagsRemoved");
         $tagsAdded = $this->ParseJSONToTags($json, "tagsAdded");
         if (\count($tagsRemoved) < 1 && \count($tagsAdded) < 1) {
             throw new \InvalidArgumentException("No tagsRemoved or tagsAdded were supplied");
         }
     } catch (\Exception $e) {
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [An exception was thrown:]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         $message = $e->getMessage();
         return parent::FormatErrorMessage("An exception was thrown: {$message})");
     }
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Parsing JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Constructing the repository]", \PEAR_LOG_DEBUG);
     try {
         //Get the content repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     } catch (\Exception $e) {
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         $message = $e->getMessage();
         return parent::FormatErrorMessage("An exception was thrown: {$message})");
     }
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Constructing the repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Getting the subject content]", \PEAR_LOG_DEBUG);
     try {
         //get the content array for the repo
         $contentArray = $repository->GetContent(array($contentId));
         //try and get the first item
         $content = reset($contentArray);
         //check that its not null
         if (!isset($content) || $content == null) {
             throw new \Exception("No content was returned for the ID: {$contentId}");
         }
     } catch (\Exception $e) {
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         $message = $e->getMessage();
         return parent::FormatErrorMessage("An exception was thrown: {$message})");
     }
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Getting the subject content]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Making Tagging Changes]", \PEAR_LOG_DEBUG);
     $originalTags = $content->tags;
     $content->tags = array();
     foreach ($originalTags as $originalTag) {
         $shouldBeRemoved = false;
         foreach ($tagsRemoved as $tagRemoved) {
             if ($tagRemoved->text == $originalTag->text) {
                 $shouldBeRemoved = true;
             }
         }
         if (!$shouldBeRemoved) {
             $content->tags[] = $originalTag;
         }
     }
     foreach ($tagsAdded as $tag) {
         $content->tags[] = $tag;
     }
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Making Tagging Changes]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Saving Content]", \PEAR_LOG_DEBUG);
     try {
         $repository->SaveContent(array($content));
     } catch (\Exception $e) {
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         $message = $e->getMessage();
         return parent::FormatErrorMessage("An exception was thrown: {$message})");
     }
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Saving Content]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [START: Event Distribution]", \PEAR_LOG_DEBUG);
     $eventArguments = array("originalTags" => $originalTags, "tagsAdded" => $tagsAdded, "tagsRemoved" => $tagsRemoved);
     $event = new \Swiftriver\Core\EventDistribution\GenericEvent(\Swiftriver\Core\EventDistribution\EventEnumeration::$UpdateContentTagging, $eventArguments);
     $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
     $eventDistributor->RaiseAndDistributeEvent($event);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [END: Event Distribution]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::UpdateContentTagging::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatMessage("OK");
 }
 /**
  *
  */
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         //call the parser to get the ID
         $id = parent::ParseJSONToContentID($json);
         $markerId = parent::ParseJSONToMarkerID($json);
         $reason = parent::ParseJSONToInacurateReason($json);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Constructing the repository]", \PEAR_LOG_DEBUG);
     try {
         //Get the content repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Constructing the repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Getting the subject content]", \PEAR_LOG_DEBUG);
     try {
         //get the content array for the repo
         $contentArray = $repository->GetContent(array($id));
         //try and get the first item
         $content = reset($contentArray);
         //check that its not null
         if (!isset($content) || $content == null) {
             throw new \Exception("No content was returned for the ID: {$id}");
         }
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Getting the subject content]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Setting the state to acurate]", \PEAR_LOG_DEBUG);
     //Use the state controller to change the state of the the content to acurate
     $content = \Swiftriver\Core\StateTransition\StateController::MarkContentInaccurate($content);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Setting the state to acurate]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Increment source score]", \PEAR_LOG_DEBUG);
     //get the source from the content
     $source = $content->source;
     //if the score is null - not yet rated, then set it
     if (!isset($source->score) || $source->score == null) {
         $source->score = 0;
         //baseline of 0%
     }
     if ($reason == "falsehood") {
         $decrement = 2;
     } else {
         $decrement = 1;
     }
     //if the scoure is not already at the maximum
     if ($source->score > $decrement - 1) {
         //increment the score of the source
         $source->score = $source->score - $decrement;
     }
     //set the scource back to the content
     $content->source = $source;
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Increment source score]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Saving the content and source]", \PEAR_LOG_DEBUG);
     try {
         //save the content to the repo
         $repository->SaveContent(array($content));
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Saving the content and source]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [START: Recording the transaction]", \PEAR_LOG_DEBUG);
     try {
         //get the trust log repo
         $trustLogRepo = new \Swiftriver\Core\DAL\Repositories\TrustLogRepository();
         //get the source id
         $sourceId = $content->source->id;
         //record the new entry
         $trustLogRepo->RecordSourceScoreChange($sourceId, $markerId, -1);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [END: Recording the transaction]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::MarkContentAsInacurate::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     $return = json_encode(array("sourceId" => $content->source->id, "sourceScore" => $content->source->score));
     return $return;
 }
Esempio n. 7
0
 /**
  * Pushes content to a specific channel via its parser
  *
  * @return string $json
  */
 public function RunWorkflow($key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [START: Setting time out]", \PEAR_LOG_DEBUG);
     set_time_limit(300);
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Getting the appropriate parser]", \PEAR_LOG_DEBUG);
     $origin = $_GET["origin"];
     $parser = \Swiftriver\Core\Modules\SiSPS\ParserFactory::GetParserByPushOrigin($origin);
     if (is_null($parser)) {
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [INFO: No Parser for origin '{$origin}']", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: PushToChannel]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("No parser exists for '{$origin}'");
     }
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Extracting raw data]", \PEAR_LOG_DEBUG);
     $raw_content = file_get_contents('php://input');
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: Fetching next Channel]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [START: Get and parse content]", \PEAR_LOG_DEBUG);
     try {
         $post_content = null;
         if ($_POST) {
             $post_content = $_POST;
         }
         $get_content = null;
         if ($_GET) {
             $get_content = $_GET;
         }
         $file_content = null;
         if ($_FILES) {
             $file_content = $_FILES;
         }
         $SiSPS = new \Swiftriver\Core\Modules\SiSPS\SwiftriverPushParsingService();
         $rawContent = $SiSPS->FetchContentFromChannel($parser, $raw_content, $post_content, $get_content, $file_content);
     } catch (\Exception $e) {
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     if (isset($rawContent) && is_array($rawContent) && count($rawContent) > 0) {
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: Get and parse content]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [START: Running core processing]", \PEAR_LOG_DEBUG);
         try {
             $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
             $processedContent = $preProcessor->PreProcessContent($rawContent);
         } catch (\Exception $e) {
             //get the exception message
             $message = $e->getMessage();
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
             return parent::FormatErrorMessage("An exception was thrown: {$message}");
         }
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: Running core processing]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [START: Save content to the data store]", \PEAR_LOG_DEBUG);
         try {
             $contentRepository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
             $contentRepository->SaveContent($processedContent);
             // Raise the event handler that handles the post processing of content
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Raise the Ushahidi Push Event Handler]", \PEAR_LOG_DEBUG);
             $event = new \Swiftriver\Core\EventDistribution\GenericEvent(\Swiftriver\Core\EventDistribution\EventEnumeration::$ContentPostProcessing, $processedContent);
             $eventDistributor = new \Swiftriver\Core\EventDistribution\EventDistributor();
             $eventDistributor->RaiseAndDistributeEvent($event);
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [End Ushahidi Push event]", \PEAR_LOG_DEBUG);
         } catch (\Exception $e) {
             //get the exception message
             $message = $e->getMessage();
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
             return parent::FormatErrorMessage("An exception was thrown: {$message}");
         }
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: Save content to the data store]", \PEAR_LOG_DEBUG);
     } else {
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [END: Get and parse content]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [No content found.]", \PEAR_LOG_DEBUG);
     }
     $logger->log("Core::Workflows::ChannelServices::PushToChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatMessage("OK");
 }
Esempio n. 8
0
 /**
  * Selects the next due processing job and runs it through the core
  *
  * @return string $json
  */
 public function RunWorkflow($key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Setting time out]", \PEAR_LOG_DEBUG);
     set_time_limit(300);
     $timeout = ini_get('max_execution_time');
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Setting time out to {$timeout}]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Constructing Repository]", \PEAR_LOG_DEBUG);
     try {
         //Construct a new repository
         $channelRepository = new \Swiftriver\Core\DAL\Repositories\ChannelRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Constructing Repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Fetching next Channel]", \PEAR_LOG_DEBUG);
     try {
         //Get the next due channel processign job
         $channel = $channelRepository->SelectNextDueChannel(time());
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     if ($channel == null) {
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [INFO: No Channel due]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Fetching next Channel]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatMessage("OK");
     }
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Fetching next Channel]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Get and parse content]", \PEAR_LOG_DEBUG);
     try {
         $SiSPS = new \Swiftriver\Core\Modules\SiSPS\SwiftriverSourceParsingService();
         $rawContent = $SiSPS->FetchContentFromChannel($channel);
     } catch (\Exception $e) {
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         try {
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Mark Channel as in error]", \PEAR_LOG_DEBUG);
             $channel->inprocess = false;
             $channelRepository->SaveChannels(array($channel));
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Mark Channel as in error]", \PEAR_LOG_DEBUG);
         } catch (\Exception $innerE) {
             $message = $innerE->getMessage();
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [This Channel will remain in state - in progress - and will not be run again, manual action must be taken.]", \PEAR_LOG_ERR);
         }
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     if (isset($rawContent) && is_array($rawContent) && count($rawContent) > 0) {
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Get and parse content]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Running core processing]", \PEAR_LOG_DEBUG);
         try {
             $preProcessor = new \Swiftriver\Core\PreProcessing\PreProcessor();
             $processedContent = $preProcessor->PreProcessContent($rawContent);
         } catch (\Exception $e) {
             //get the exception message
             $message = $e->getMessage();
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
             return parent::FormatErrorMessage("An exception was thrown: {$message}");
         }
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Running core processing]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Save content to the data store]", \PEAR_LOG_DEBUG);
         try {
             $contentRepository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
             $contentRepository->SaveContent($processedContent);
         } catch (\Exception $e) {
             //get the exception message
             $message = $e->getMessage();
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
             $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
             return parent::FormatErrorMessage("An exception was thrown: {$message}");
         }
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Save content to the data store]", \PEAR_LOG_DEBUG);
     } else {
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Get and parse content]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [No content found.]", \PEAR_LOG_DEBUG);
     }
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [START: Mark channel processing job as complete]", \PEAR_LOG_DEBUG);
     try {
         $channel->inprocess = false;
         $channel->lastSucess = time();
         $channelRepository->SaveChannels(array($channel));
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [END: Mark channel processing job as complete]", \PEAR_LOG_DEBUG);
     $logger->log("Core::Workflows::ChannelServices::RunNextChannel::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return parent::FormatMessage("OK");
 }
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         $gis = parent::ParseJSONToGIS($json);
         $id = parent::ParseJSONToContentID($json);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         //Get the content repository
         $repository = new \Swiftriver\Core\DAL\Repositories\ContentRepository();
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [END: Constructing the repository]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [START: Getting the subject content]", \PEAR_LOG_DEBUG);
     try {
         //get the content array for the repo
         $contentArray = $repository->GetContent(array($id));
         //try and get the first item
         $content = reset($contentArray);
         //check that its not null
         if (!isset($content) || $content == null) {
             throw new \Exception("No content was returned for the ID: {$id}");
         }
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [END: Getting the subject content]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [START: Setting the GIS Data]", \PEAR_LOG_DEBUG);
     //Use the state controller to change the state of the the content to acurate
     $content->gisData = $gis;
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [END: Setting the GIS Data]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [START: Saving the content and source]", \PEAR_LOG_DEBUG);
     try {
         //save the content to the repo
         $repository->SaveContent(array($content));
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [{$message}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeLocationData::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [END: Saving the content and source]", \PEAR_LOG_DEBUG);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeLocationData::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
     return $return;
 }