public function create($data)
 {
     if (!array_key_exists("collect_data_trigger", $data)) {
         return new ApiProblemResponse(new ApiProblem(422, 'Root key collect_data_trigger missing in request data'));
     }
     $data = $data["collect_data_trigger"];
     if (!array_key_exists('processing_type', $data)) {
         return new ApiProblemResponse(new ApiProblem(422, 'Key processing_type is missing'));
     }
     $processingType = $data['processing_type'];
     if (!class_exists($processingType)) {
         return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is unknown'));
     }
     try {
         Assertion::implementsInterface($processingType, 'Prooph\\Processing\\Type\\Type');
     } catch (\InvalidArgumentException $ex) {
         return new ApiProblemResponse(new ApiProblem(422, 'Provided processing type is not valid'));
     }
     $wfMessage = WorkflowMessage::collectDataOf($processingType::prototype(), __CLASS__, $this->ProcessingConfig->getNodeName());
     $this->messageLogger->logIncomingMessage($wfMessage);
     $this->workflowEngine->dispatch($wfMessage);
     /** @var $response Response */
     $response = $this->getResponse();
     $response->getHeaders()->addHeaderLine('Location', $this->url()->fromRoute('prooph.link/processor_proxy/api/messages', ['id' => $wfMessage->uuid()->toString()]));
     $response->setStatusCode(201);
     return $response;
 }
Ejemplo n.º 2
0
 /**
  * @param string $id
  * @return mixed
  */
 public function get($id)
 {
     $message = $this->messageLogger->getEntryForMessageId(Uuid::fromString($id));
     if (is_null($message)) {
         return new ApiProblemResponse(new ApiProblem(404, "Message can not be found"));
     }
     return ["message" => $message->toArray()];
 }
 /**
  * @param $message
  * @return null|MessageLogEntry
  */
 private function getLogEntryForMessage($message)
 {
     $messageId = null;
     if ($message instanceof RemoteMessage) {
         $messageId = $message->header()->uuid();
     } elseif ($message instanceof WorkflowMessage) {
         $messageId = $message->uuid();
     } elseif ($message instanceof LogMessage) {
         $messageId = $message->uuid();
     } elseif ($message instanceof StartSubProcess) {
         $messageId = $message->uuid();
     } elseif ($message instanceof SubProcessFinished) {
         $messageId = $message->uuid();
     }
     if (!$messageId) {
         return null;
     }
     $entry = $this->messageLogger->getEntryForMessageId($messageId);
     if (!$entry) {
         return null;
     }
     return $entry;
 }
 /**
  * @param ActionEvent $event
  */
 public function onProcessWasStartedByMessage(ActionEvent $event)
 {
     $this->messageLogger->logProcessStartedByMessage(ProcessId::fromString($event->getParam('process_id')), Uuid::fromString($event->getParam('message_id')));
 }