1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.xds.core.validate.requests;
17
18 import org.openehealth.ipf.commons.core.modules.api.Validator;
19 import org.openehealth.ipf.commons.ihe.xds.core.ebxml.EbXMLRetrieveImagingDocumentSetRequest;
20 import org.openehealth.ipf.commons.ihe.xds.core.requests.DocumentReference;
21 import org.openehealth.ipf.commons.ihe.xds.core.requests.RetrieveSeries;
22 import org.openehealth.ipf.commons.ihe.xds.core.requests.RetrieveStudy;
23 import org.openehealth.ipf.commons.ihe.xds.core.validate.HomeCommunityIdValidator;
24 import org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationProfile;
25
26 import java.util.List;
27
28 import static org.apache.commons.lang3.StringUtils.isNotEmpty;
29 import static org.apache.commons.lang3.Validate.notNull;
30 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.DOC_ID_MUST_BE_SPECIFIED;
31 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.REPO_ID_MUST_BE_SPECIFIED;
32 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.SERIES_INSTANCE_UID_MUST_BE_SPECIFIED;
33 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.STUDY_INSTANCE_UID_MUST_BE_SPECIFIED;
34 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidationMessage.TRANSFER_SYNTAX_UID_LIST_MUST_BE_SPECIFIED;
35 import static org.openehealth.ipf.commons.ihe.xds.core.validate.ValidatorAssertions.metaDataAssert;
36
37
38
39
40
41
42 public class RetrieveImagingDocumentSetRequestValidator implements Validator<EbXMLRetrieveImagingDocumentSetRequest, ValidationProfile> {
43 private final HomeCommunityIdValidator hcValidator = new HomeCommunityIdValidator(true);
44
45 @Override
46 public void validate(EbXMLRetrieveImagingDocumentSetRequest request, ValidationProfile profile) {
47 notNull(request, "request cannot be null");
48
49 for (RetrieveStudy retrieveStudy : request.getRetrieveStudies()) {
50 String studyInstanceUID = retrieveStudy.getStudyInstanceUID();
51 metaDataAssert(isNotEmpty(studyInstanceUID), STUDY_INSTANCE_UID_MUST_BE_SPECIFIED);
52
53 List<String> transferSyntaxUIDList = request.getTransferSyntaxUIDList();
54 metaDataAssert(transferSyntaxUIDList != null && !transferSyntaxUIDList.isEmpty(), TRANSFER_SYNTAX_UID_LIST_MUST_BE_SPECIFIED);
55
56 for (RetrieveSeries retrieveSeries : retrieveStudy.getRetrieveSerieses()) {
57 String seriesInstanceUID = retrieveSeries.getSeriesInstanceUID();
58 metaDataAssert(isNotEmpty(seriesInstanceUID), SERIES_INSTANCE_UID_MUST_BE_SPECIFIED);
59
60 for (DocumentReference document : retrieveSeries.getDocuments()) {
61
62 String repoId = document.getRepositoryUniqueId();
63 metaDataAssert(isNotEmpty(repoId), REPO_ID_MUST_BE_SPECIFIED);
64
65 String docId = document.getDocumentUniqueId();
66 metaDataAssert(isNotEmpty(docId), DOC_ID_MUST_BE_SPECIFIED);
67
68 if (profile.getInteractionProfile().requiresHomeCommunityId()) {
69 hcValidator.validate(document.getHomeCommunityId());
70 }
71 }
72 }
73 }
74 }
75 }