public function generate()
    {
        try {
            if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
            }

            $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
            if (!$test->exists()) {
                throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
            }

            $label = 'Delivery of ' . $test->getLabel();
            $deliveryClass = $this->getDeliveryClassByParameters();

            $deliveryFactory = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            /** @var \common_report_Report $report */
            $report = $deliveryFactory->create($deliveryClass, $test, $label);

            if ($report->getType() == \common_report_Report::TYPE_ERROR) {
                $this->logInfo('Unable to generate delivery execution ' .
                    'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri());
                throw new \common_Exception('Unable to generate delivery execution.');
            }
            $delivery = $report->getData();

            /** @var DeliveryFactory $deliveryFactoryService */
            $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest());
            $delivery = $deliveryFactoryService->setInitialProperties($initialProperties, $delivery);
            $this->returnSuccess(array('delivery' => $delivery->getUri()));
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function generate()
    {
        try {
            if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
                throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
            }

            $test = $this->getResource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
            if (!$test->exists()) {
                throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
            }

            $label = 'Delivery of ' . $test->getLabel();
            $deliveryClass = $this->getDeliveryClassByParameters();

            $deliveryFactory = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            /** @var \common_report_Report $report */
            $report = $deliveryFactory->create($deliveryClass, $test, $label);

            if ($report->getType() == \common_report_Report::TYPE_ERROR) {
                $this->logInfo('Unable to generate delivery execution ' .
                    'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri());
                throw new \common_Exception('Unable to generate delivery execution.');
            }
            $delivery = $report->getData();

            /** @var DeliveryFactory $deliveryFactoryService */
            $deliveryFactoryService = $this->getServiceManager()->get(DeliveryFactory::SERVICE_ID);
            $initialProperties = $deliveryFactoryService->getInitialPropertiesFromRequest($this->getRequest());
            $delivery = $deliveryFactoryService->setInitialProperties($initialProperties, $delivery);
            $this->returnSuccess(array('delivery' => $delivery->getUri()));
        } catch (\Exception $e) {
            $this->returnFailure($e);
        }
    }
public function generate ( ) { try { if ( ! $ this -> hasRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) { throw new \ common_exception_MissingParameter ( self :: REST_DELIVERY_TEST_ID , $ this -> getRequestURI ( ) ) ; } $ test = $ this -> getResource ( $ this -> getRequestParameter ( self :: REST_DELIVERY_TEST_ID ) ) ; if ( ! $ test -> exists ( ) ) { throw new \ common_exception_NotFound ( 'Unable to find a test associated to the given uri.' ) ; } $ label = 'Delivery of ' . $ test -> getLabel ( ) ; $ deliveryClass = $ this -> getDeliveryClassByParameters ( ) ; $ deliveryFactory = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; /** @var \common_report_Report $report */ $ report = $ deliveryFactory -> create ( $ deliveryClass , $ test , $ label ) ; if ( $ report -> getType ( ) == \ common_report_Report :: TYPE_ERROR ) { $ this -> logInfo ( 'Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $ test -> getUri ( ) ) ; throw new \ common_Exception ( 'Unable to generate delivery execution.' ) ; } $ delivery = $ report -> getData ( ) ; /** @var DeliveryFactory $deliveryFactoryService */ $ deliveryFactoryService = $ this -> getServiceManager ( ) -> get ( DeliveryFactory :: SERVICE_ID ) ; $ initialProperties = $ deliveryFactoryService -> getInitialPropertiesFromRequest ( $ this -> getRequest ( ) ) ; $ delivery = $ deliveryFactoryService -> setInitialProperties ( $ initialProperties , $ delivery ) ; $ this -> returnSuccess ( array ( 'delivery' => $ delivery -> getUri ( ) ) ) ; } catch ( \ Exception $ e ) { $ this -> returnFailure ( $ e ) ; } }
Generate a delivery from test uri
Test uri has to be set and existing
Generate a delivery from test uri Test uri has to be set and existing