protected function getDeliveryClassByParameters()
    {
        $rootDeliveryClass = $this->getDeliveryRootClass();

        // If an uri is provided, check if it's an existing delivery class
        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_URI)) {
            $deliveryClass = $this->getClass($this->getRequestParameter(self::REST_DELIVERY_CLASS_URI));
            if ($deliveryClass == $rootDeliveryClass
                || ($deliveryClass->exists() && $deliveryClass->isSubClassOf($rootDeliveryClass))) {
                return $deliveryClass;
            }
            throw new \common_Exception(__('Delivery class uri provided is not a valid delivery class.'));
        }

        if ($this->hasRequestParameter(self::REST_DELIVERY_CLASS_LABEL)) {
            $label = $this->getRequestParameter(self::REST_DELIVERY_CLASS_LABEL);

            $deliveryClasses = $rootDeliveryClass->getSubClasses(true);
            $classes = [$rootDeliveryClass->getUri()];
            foreach ($deliveryClasses as $class) {
                $classes[] = $class->getUri();
            }

            /** @var ComplexSearchService $search */
            $search = $this->getServiceManager()->get(ComplexSearchService::SERVICE_ID);
            $queryBuilder = $search->query();
            $criteria = $queryBuilder->newQuery()
                ->add(OntologyRdfs::RDFS_LABEL)->equals($label)
                ->add(OntologyRdfs::RDFS_SUBCLASSOF)->in($classes)
            ;
            $queryBuilder->setCriteria($criteria);
            $result = $search->getGateway()->search($queryBuilder);

            switch ($result->count()) {
                case 0:
                    throw new \common_exception_NotFound(__('Delivery with label "%s" not found', $label));
                case 1:
                    return $this->getClass($result->current()->getUri());
                default:
                    $availableClasses = [];
                    foreach ($result as $raw) {
                        $availableClasses[] = $raw->getUri();
                    }
                    throw new \common_exception_NotFound(__('Multiple delivery class found for label "%s": %s',
                        $label, implode(',',$availableClasses)
                    ));
            }
        }

        return $rootDeliveryClass;
    }