[ 'prefix' => 'd', 'longPrefix' => 'deliveryExecution', 'required' => true, 'description' => 'A delivery execution ID.' ] ]; } /** * @return Report * @throws \oat\oatbox\service\exception\InvalidServiceManagerException */ public function run() { // Main report. $report = new \common_report_Report( \common_report_Report::TYPE_INFO, "Script ended gracefully." ); /** @var DeliveryExecutionDeleteService $deleteDeliveryExecutionService */ $deleteDeliveryExecutionService = $this->getServiceManager()->get(DeliveryExecutionDeleteService::SERVICE_ID); /** @var ServiceProxy $serviceProxy */ $serviceProxy = $this->getServiceManager()->get(ServiceProxy::SERVICE_ID); $deliveryExecutionIdentifier = $this->getOption('deliveryExecution'); $deliveryExecution = $serviceProxy->getDeliveryExecution($deliveryExecutionIdentifier); try { $deleteRequest = new DeliveryExecutionDeleteRequest( $deliveryExecution->getDelivery(), $deliveryExecution ); $deleteDeliveryExecutionService->execute($deleteRequest); $report->add($deleteDeliveryExecutionService->getReport()); } catch (\Exception $e) { $msg = "An unexpected error occurred while deleting Delivery Execution '${deliveryExecutionIdentifier}'."; $msg .= "System returned: " . $e->getMessage(); return new Report(Report::TYPE_ERROR, $msg); } return $report; } protected function provideUsage() { return [ 'prefix' => 'h', 'longPrefix' => 'help', 'description' => 'Prints a help statement' ]; } }