AdapterComponentDocRepositoryOrchImpl { public RegistryResponseType registerDocumentSet(RegisterDocumentSetRequestType body) { RegistryResponseType registryResponse = new ObjectFactory().createRegistryResponseType(); RegistryErrorList errorList = new RegistryErrorList(); if (body == null) { RegistryError error = docRepoHelper.setRegistryError(FIND_A_REQUIRED_ELEMENT, "", DocRepoConstants.XDS_ERROR_CODE_MISSING_REQUEST_MESSAGE_DATA, DocRepoConstants.XDS_MISSING_REQUEST_MESSAGE_DATA + " RegisterDocumentSetRequestType element is null."); errorList.getRegistryError().add(error); } else { SubmitObjectsRequest submitObjectsRequest = body.getSubmitObjectsRequest(); RegistryObjectListType regObjectList = submitObjectsRequest.getRegistryObjectList(); List<JAXBElement<? extends IdentifiableType>> identifiableObjectList = regObjectList.getIdentifiable(); boolean hasReplacementReq = checkForReplacementAssociation(identifiableObjectList, errorList); for (JAXBElement<? extends IdentifiableType> identifiable : identifiableObjectList) { IdentifiableType identType = identifiable.getValue(); if (identType instanceof ExtrinsicObjectType) { saveExtrinsicObject((ExtrinsicObjectType) identType, errorList, null, hasReplacementReq); } } } String responseStatus; if (errorList.getRegistryError().isEmpty()) { responseStatus = DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_SUCCESS; } else { responseStatus = DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_FAILURE; registryResponse.setRegistryErrorList(errorList); } registryResponse.setStatus(responseStatus); return registryResponse; } AdapterComponentDocRepositoryOrchImpl(); DocumentService getDocumentService(); LargeFileUtils getLargeFileUtils(); UTCDateUtil getDateUtil(); RetrieveDocumentSetResponseType documentRepositoryRetrieveDocumentSet(RetrieveDocumentSetRequestType body); RegistryResponseType registerDocumentSet(RegisterDocumentSetRequestType body); RegistryResponseType documentRepositoryProvideAndRegisterDocumentSet(
        ProvideAndRegisterDocumentSetRequestType body); DocumentMetadata saveExtrinsicObject(ExtrinsicObjectType extrinsicObject, RegistryErrorList errorList,
        Map<String, DataHandler> docMap, boolean hasReplacementRequest);  }
@Test public void testRegisterDocument_BlankPayload() { AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl(); RegisterDocumentSetRequestType body = makeBlankRegisterPayload( new ArrayList<JAXBElement<? extends IdentifiableType>>()); RegistryResponseType result = docRepo.registerDocumentSet(body); assertNotNull(result); assertEquals(DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_SUCCESS, result.getStatus()); }
@Test public void testRegisterDocument_MissingExternalId() { AdapterComponentDocRepositoryOrchImpl docRepo = new AdapterComponentDocRepositoryOrchImpl(); ArrayList<JAXBElement<? extends IdentifiableType>> documentList = new ArrayList<JAXBElement<? extends IdentifiableType>>(); ExtrinsicObjectType extrinsicObject = new ExtrinsicObjectType(); JAXBElement<ExtrinsicObjectType> xmlElement = new JAXBElement<ExtrinsicObjectType>( new QName("ExtrinsicObjectType"), ExtrinsicObjectType.class, extrinsicObject); documentList.add(xmlElement); RegisterDocumentSetRequestType body = makeBlankRegisterPayload(documentList); RegistryResponseType result = docRepo.registerDocumentSet(body); assertNotNull(result); assertEquals(DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_FAILURE, result.getStatus()); List<RegistryError> registryErrorList = result.getRegistryErrorList().getRegistryError(); assertEquals(1, registryErrorList.size()); assertEquals(DocRepoConstants.XDS_ERROR_CODE_MISSING_DOCUMENT_METADATA, registryErrorList.get(0).getErrorCode()); assertEquals( DocRepoConstants.XDS_MISSING_DOCUMENT_METADATA + " extrinsicObject.getExternalIdentifier() element is null or empty.", registryErrorList.get(0).getValue()); }
@Test public void testRegisterDocument_MissingDocIdAndPatientId() { AdapterComponentDocRepositoryOrchImpl docRepo = getDocRepoWithMockDocService(); ArrayList<JAXBElement<? extends IdentifiableType>> documentList = new ArrayList<JAXBElement<? extends IdentifiableType>>(); ExtrinsicObjectType extrinsicObject = new ExtrinsicObjectType(); JAXBElement<ExtrinsicObjectType> xmlElement = new JAXBElement<ExtrinsicObjectType>( new QName("ExtrinsicObjectType"), ExtrinsicObjectType.class, extrinsicObject); documentList.add(xmlElement); RegisterDocumentSetRequestType body = makeBlankRegisterPayload(documentList); ExternalIdentifierType identifier = new ExternalIdentifierType(); InternationalStringType name = new InternationalStringType(); LocalizedStringType localizedName = new LocalizedStringType(); localizedName.setValue("1"); name.getLocalizedString().add(localizedName); identifier.setName(name); extrinsicObject.getExternalIdentifier().add(identifier); RegistryResponseType result = docRepo.registerDocumentSet(body); assertNotNull(result); assertEquals(DocRepoConstants.XDS_RETRIEVE_RESPONSE_STATUS_FAILURE, result.getStatus()); List<RegistryError> registryErrorList = result.getRegistryErrorList().getRegistryError(); assertEquals(2, registryErrorList.size()); assertEquals(DocRepoConstants.XDS_ERROR_CODE_MISSING_DOCUMENT_METADATA, registryErrorList.get(0).getErrorCode()); assertEquals( DocRepoConstants.XDS_MISSING_DOCUMENT_METADATA + " DocumentUniqueId was missing.", registryErrorList.get(0).getValue()); assertEquals(DocRepoConstants.XDS_ERROR_CODE_MISSING_DOCUMENT_METADATA, registryErrorList.get(1).getErrorCode()); assertEquals(DocRepoConstants.XDS_MISSING_DOCUMENT_METADATA + " PatientId was missing.", registryErrorList.get(1).getValue()); }