/// <summary>
        /// Validates an <see cref="StoreRequest"/>.
        /// </summary>
        /// <param name="request">The request to validate.</param>
        /// <exception cref="BadRequestException">Thrown when request body is missing.</exception>
        /// <exception cref="UidValidation">Thrown when the specified StudyInstanceUID is not a valid identifier.</exception>
        // TODO cleanup this method with Unit tests #72595
        public static void ValidateRequest(StoreRequest request)
        {
            EnsureArg.IsNotNull(request, nameof(request));
            if (request.RequestBody == null)
            {
                throw new BadRequestException(DicomCoreResource.MissingRequestBody);
            }

            UidValidation.Validate(request.StudyInstanceUid, nameof(request.StudyInstanceUid), allowEmpty: true);
        }
Ejemplo n.º 2
0
        private static void ValidateDeleteResourcesRequest(DeleteResourcesRequest request)
        {
            UidValidation.Validate(request.StudyInstanceUid, nameof(request.StudyInstanceUid));

            switch (request.ResourceType)
            {
            case ResourceType.Series:
                UidValidation.Validate(request.SeriesInstanceUid, nameof(request.SeriesInstanceUid));
                break;

            case ResourceType.Instance:
                UidValidation.Validate(request.SeriesInstanceUid, nameof(request.SeriesInstanceUid));
                UidValidation.Validate(request.SopInstanceUid, nameof(request.SopInstanceUid));
                break;
            }
        }
        private static void ValidateInstanceIdentifiersAreValid(ResourceType resourceType, string studyInstanceUid, string seriesInstanceUid, string sopInstanceUid)
        {
            UidValidation.Validate(studyInstanceUid, nameof(StudyInstanceUid));

            switch (resourceType)
            {
            case ResourceType.Series:
                UidValidation.Validate(seriesInstanceUid, nameof(SeriesInstanceUid));
                break;

            case ResourceType.Instance:
            case ResourceType.Frames:
                UidValidation.Validate(seriesInstanceUid, nameof(SeriesInstanceUid));
                UidValidation.Validate(sopInstanceUid, nameof(SopInstanceUid));
                break;
            }
        }
Ejemplo n.º 4
0
        private static void ValidateRequestIdentifiers(QueryParameters parameters)
        {
            switch (parameters.QueryResourceType)
            {
            case QueryResource.StudySeries:
            case QueryResource.StudyInstances:
                UidValidation.Validate(parameters.StudyInstanceUid, nameof(parameters.StudyInstanceUid));
                break;

            case QueryResource.StudySeriesInstances:
                UidValidation.Validate(parameters.StudyInstanceUid, nameof(parameters.StudyInstanceUid));
                UidValidation.Validate(parameters.SeriesInstanceUid, nameof(parameters.SeriesInstanceUid));
                break;

            case QueryResource.AllStudies:
            case QueryResource.AllSeries:
            case QueryResource.AllInstances:
                break;

            default:
                Debug.Fail("A newly added query resource is not handled.");
                break;
            }
        }