示例#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;
 }
 public function RunWorkflow($json, $key)
 {
     //Setup the logger
     $logger = \Swiftriver\Core\Setup::GetLogger();
     $logger->log("Core::ServiceAPI::ContentServices::ChangeContentState::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     $logger->log("Core::ServiceAPI::ContentServices::ChangeContentState::RunWorkflow [START: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     try {
         $newState = parent::ParseJSONToNewContentState($json);
     } catch (\Exception $e) {
         //get the exception message
         $message = $e->getMessage();
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeContentState::RunWorkflow [An exception was thrown]", \PEAR_LOG_DEBUG);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeContentState::RunWorkflow [{$e}]", \PEAR_LOG_ERR);
         $logger->log("Core::ServiceAPI::ChannelProcessingJobs::ChangeContentState::RunWorkflow [Method finished]", \PEAR_LOG_INFO);
         return parent::FormatErrorMessage("An exception was thrown: {$message}");
     }
     $logger->log("Core::ServiceAPI::ContentServices::ChangeContentState::RunWorkflow [END: Parsing the JSON input]", \PEAR_LOG_DEBUG);
     $workflow = null;
     switch ($newState) {
         case "accurate":
             $workflow = new MarkContentAsAcurate();
             break;
         case "chatter":
             $workflow = new MarkContentAsChatter();
             break;
         case "inaccurate":
             $workflow = new MarkContentAsInacurate();
             break;
         case "irrelevant":
             $workflow = new MarkContentAsIrrelevant();
             break;
     }
     $return = $workflow != null ? $workflow->RunWorkflow($json, $key) : parent::FormatErrorMessage("the state '{$newState}' could not be matched to a workflow.");
     $logger->log("Core::ServiceAPI::ContentServices::ChangeContentState::RunWorkflow [Method invoked]", \PEAR_LOG_INFO);
     return $return;
 }
 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;
 }
 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;
 }