public static Map<String, SlotType1> addOrOverwriteSlot(RegistryObjectType ro, String slotName, String... val) throws JAXBException { Map<String, SlotType1> slots = getSlotsFromRegistryObject(ro); addOrOverwriteSlot(ro, slots, slotName, val); return slots; } /*
private String checkPatientIDs(ProvideAndRegisterDocumentSetRequestType req, RegistryPackageType submissionSet, List<ExtrinsicObjectType> extrObjs) throws XDSException { String submissionPatId = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSSubmissionSet_patientId, submissionSet); String docPatId; ExtrinsicObjectType eo; for ( int i = 0, len = extrObjs.size() ; i < len ; i++ ) { eo = extrObjs.get(i); docPatId = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSDocumentEntry_patientId, eo); if ( docPatId != null && !docPatId.equals(submissionPatId)) { String msg = "XDSDocumentEntry.patientId ("+docPatId+")and XDSSubmissionSet.patientId ("+submissionPatId+") doesn't match! ExtrinsicObject.Id:"+eo.getId(); log.warn(msg); throw new XDSException(XDSException.XDS_ERR_PATID_DOESNOT_MATCH, msg, null); } } RegistryPackageType folder = InfosetUtil.getRegistryPackage(req.getSubmitObjectsRequest(), XDSConstants.UUID_XDSFolder); String folderPatId = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSFolder_patientId, folder); if ( folderPatId != null && !folderPatId.equals(submissionPatId)) { String msg = "XDSFolder.patientId ("+folderPatId+")and XDSSubmissionSet.patientId ("+submissionPatId+") doesn't match!"; log.warn(msg); throw new XDSException(XDSException.XDS_ERR_PATID_DOESNOT_MATCH, msg, null); } return submissionPatId; }
public static String marshallObject(Object o, boolean indent) throws JAXBException { StringWriter sw = new StringWriter(); Marshaller m = jaxbCtx().createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, indent); m.marshal(o, sw); return sw.toString(); }
private String[] storeDocuments(ProvideAndRegisterDocumentSetRequestType req, List<ExtrinsicObjectType> extrObjs) throws XDSException { Map<String, Document> docs = InfosetUtil.getDocuments(req); Document doc; ExtrinsicObjectType eo; eo = extrObjs.get(i); doc = docs.get(eo.getId()); docUID = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSDocumentEntry_uniqueId, eo); if (mimetypes != null) { boolean unsupportedMimetype = true; new String[]{String.class.getName(), byte[].class.getName(), String.class.getName()}); if ( xdsDoc != null ) { Map<String, SlotType1> slots = InfosetUtil.addOrOverwriteSlot(eo, XDSConstants.SLOT_NAME_REPOSITORY_UNIQUE_ID, getRepositoryUniqueId()); String oldValue = InfosetUtil.addOrCheckedOverwriteSlot(eo, slots, XDSConstants.SLOT_NAME_SIZE, String.valueOf(xdsDoc.getSize())); if (oldValue != null) { throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Slot 'size' already exists but has different value! old:"+oldValue+" new:"+xdsDoc.getSize(), null); oldValue = InfosetUtil.addOrCheckedOverwriteSlot(eo, slots, XDSConstants.SLOT_NAME_HASH, xdsDoc.getHashString()); if (oldValue != null) { throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Slot 'hash' already exists but has different value! old:"+oldValue+" new:"+xdsDoc.getHashString(), null);
private List<ExtrinsicObjectType> checkRequest(ProvideAndRegisterDocumentSetRequestType req) throws XDSException { SubmitObjectsRequest sor = req.getSubmitObjectsRequest(); RegistryPackageType submissionSet = InfosetUtil.getRegistryPackage(sor, XDSConstants.UUID_XDSSubmissionSet); if ( submissionSet == null ) { log.error("No RegistryPackage id=SubmissionSet found!"); throw new XDSException( XDSException.XDS_ERR_REPOSITORY_ERROR, XDSException.XDS_ERR_MISSING_REGISTRY_PACKAGE, null); } List<ExtrinsicObjectType> extrObjs = InfosetUtil.getExtrinsicObjects(req.getSubmitObjectsRequest()); checkPatientIDs(req, submissionSet, extrObjs); Map<String, Document> docs = InfosetUtil.getDocuments(req); if ( extrObjs.size() > docs.size() ) { log.warn("Missing Documents! Found more ExtrinsicObjects("+extrObjs.size()+") than Documents("+docs.size()+")!"); throw new XDSException(XDSException.XDS_ERR_MISSING_DOCUMENT, "", null); } else if ( extrObjs.size() < docs.size() ) { log.warn("Missing Document Metadata! Found less ExtrinsicObjects("+extrObjs.size()+") than Documents("+docs.size()+")!"); throw new XDSException(XDSException.XDS_ERR_MISSING_DOCUMENT_METADATA, "", null); } return extrObjs; }
private String getSourceID(ProvideAndRegisterDocumentSetRequestType req) { List<JAXBElement<? extends IdentifiableType>> objs = req.getSubmitObjectsRequest().getRegistryObjectList().getIdentifiable(); IdentifiableType obj; for (int i = 0, len = objs.size() ; i < len ; i++) { obj = objs.get(i).getValue(); if (obj instanceof RegistryPackageType) { return InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSSubmissionSet_sourceId, (RegistryPackageType)obj); } } return null; }
private AdhocQueryResponse sendStoredQuery(String url, AdhocQueryRequest req) { AdhocQueryResponse rsp; URL registryURL = null; try { DocumentRegistryPortType port = DocumentRegistryPortTypeFactory.getDocumentRegistryPortSoap12(url); log.info("####################################################"); log.info("####################################################"); log.info("XCA Initiating Gateway: Send Stored Query Request to registry:"+url); log.info("####################################################"); log.info("####################################################"); log.info("org.jboss.security.ignoreHttpsHost:"+System.getProperty("org.jboss.security.ignoreHttpsHost")); registryURL = new URL(url); try { rsp = port.documentRegistryRegistryStoredQuery(req); } catch ( Exception x) { throw new XDSException( XDSException.XDS_ERR_REG_NOT_AVAIL, "Document Registry not available: "+url, x); } } catch (Exception x) { rsp = InfosetUtil.emptyAdhocQueryResponse(); if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException) x); } else { XDSUtil.addError(rsp, new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Unexpected error in XDS service !: "+x.getMessage(),x)); } } XDSAudit.logClientQuery(req, XDSConstants.WS_ADDRESSING_ANONYMOUS, null, registryURL, !XDSConstants.XDS_B_STATUS_FAILURE.equals(rsp.getStatus())); return addHomeCommunityId(rsp); }
private XDSDocument[] storeDocuments(ProvideAndRegisterDocumentSetRequestType req, List<ExtrinsicObjectType> extrObjs, String groupID) throws XDSException { Map<String, Document> docs = InfosetUtil.getDocuments(req); Document doc; ExtrinsicObjectType eo; throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Missing XDSDocumentEntry.entryUUID!", null); doc = docs.get(eo.getId()); docUID = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSDocumentEntry_uniqueId, eo); if (docUID == null) throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Missing XDSDocumentEntry.uniqueId!", null); log.warn("Document already exists! docUid:"+docUID); Map<String, SlotType1> slots = InfosetUtil.addOrOverwriteSlot(eo, XDSConstants.SLOT_NAME_REPOSITORY_UNIQUE_ID, getRepositoryUniqueId()); String oldValue = InfosetUtil.addOrCheckedOverwriteSlot(eo, slots, XDSConstants.SLOT_NAME_SIZE, String.valueOf(storedDocs[i].getSize()), false); if (oldValue != null) { throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Slot 'size' already exists but has different value! old:"+oldValue+" new:"+storedDocs[i].getSize(), null); oldValue = InfosetUtil.addOrCheckedOverwriteSlot(eo, slots, XDSConstants.SLOT_NAME_HASH, storedDocs[i].getDigest(), true); if (oldValue != null) { throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Slot 'hash' already exists but has different value! old:"+oldValue+" new:"+storedDocs[i].getDigest(), null);
private List<ExtrinsicObjectType> checkRequest(ProvideAndRegisterDocumentSetRequestType req) throws XDSException { SubmitObjectsRequest sor = req.getSubmitObjectsRequest(); RegistryPackageType submissionSet = InfosetUtil.getRegistryPackage(sor, XDSConstants.UUID_XDSSubmissionSet); if ( submissionSet == null ) { log.error("No RegistryPackage id=SubmissionSet found!"); throw new XDSException( XDSException.XDS_ERR_REPOSITORY_ERROR, XDSException.XDS_ERR_MISSING_REGISTRY_PACKAGE, null); } else if (submissionSet.getId() == null || submissionSet.getId().trim().length() == 0) { throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Missing XDSSubmissionSet.entryUUID!", null); } List<ExtrinsicObjectType> extrObjs = InfosetUtil.getExtrinsicObjects(req.getSubmitObjectsRequest()); checkPatientIDs(req, submissionSet, extrObjs); Map<String, Document> docs = InfosetUtil.getDocuments(req); if ( extrObjs.size() > docs.size() ) { log.warn("Missing Documents! Found more ExtrinsicObjects("+extrObjs.size()+") than Documents("+docs.size()+")!"); throw new XDSException(XDSException.XDS_ERR_MISSING_DOCUMENT, "", null); } else if ( extrObjs.size() < docs.size() ) { log.warn("Missing Document Metadata! Found less ExtrinsicObjects("+extrObjs.size()+") than Documents("+docs.size()+")!"); throw new XDSException(XDSException.XDS_ERR_MISSING_DOCUMENT_METADATA, "", null); } return extrObjs; }
private String getSourceID(ProvideAndRegisterDocumentSetRequestType req) throws XDSException { List<JAXBElement<? extends IdentifiableType>> objs = req.getSubmitObjectsRequest().getRegistryObjectList().getIdentifiable(); IdentifiableType obj; for (int i = 0, len = objs.size() ; i < len ; i++) { obj = objs.get(i).getValue(); if (obj instanceof RegistryPackageType) { return InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSSubmissionSet_sourceId, (RegistryPackageType)obj); } } throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Missing XDSSubmissionSet.sourceId!", null); }
rsp = InfosetUtil.emptyAdhocQueryResponse(); if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException) x);
public static String addOrCheckedOverwriteSlot(RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String val, boolean ignoreCase) throws JAXBException { if (slots == null) slots = getSlotsFromRegistryObject(ro); SlotType1 oldSlot = (SlotType1)slots.get(slotName); if (oldSlot != null) { List<String> values = oldSlot.getValueList().getValue(); if (values != null && values.size() > 0 && ! (ignoreCase ? val.equalsIgnoreCase(values.get(0)) : val.equals(values.get(0))) ) { return values.get(0); } } addOrOverwriteSlot(ro, slots, slotName, val); return null; } public static void addOrOverwriteSlot(RegistryObjectType ro, Map<String, SlotType1> slots, String slotName, String... val) throws JAXBException {
private String checkPatientIDs(ProvideAndRegisterDocumentSetRequestType req, RegistryPackageType submissionSet, List<ExtrinsicObjectType> extrObjs) throws XDSException { String submissionPatId = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSSubmissionSet_patientId, submissionSet); String docPatId; ExtrinsicObjectType eo; for ( int i = 0, len = extrObjs.size() ; i < len ; i++ ) { eo = extrObjs.get(i); docPatId = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSDocumentEntry_patientId, eo); if ( docPatId != null && !docPatId.equals(submissionPatId)) { String msg = "XDSDocumentEntry.patientId ("+docPatId+")and XDSSubmissionSet.patientId ("+submissionPatId+") doesn't match! ExtrinsicObject.Id:"+eo.getId(); log.warn(msg); throw new XDSException(XDSException.XDS_ERR_PATID_DOESNOT_MATCH, msg, null); } } RegistryPackageType folder = InfosetUtil.getRegistryPackage(req.getSubmitObjectsRequest(), XDSConstants.UUID_XDSFolder); String folderPatId = folder == null ? null : InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSFolder_patientId, folder); if ( folderPatId != null && !folderPatId.equals(submissionPatId)) { String msg = "XDSFolder.patientId ("+folderPatId+")and XDSSubmissionSet.patientId ("+submissionPatId+") doesn't match!"; log.warn(msg); throw new XDSException(XDSException.XDS_ERR_PATID_DOESNOT_MATCH, msg, null); } return submissionPatId; }
rsp = InfosetUtil.emptyAdhocQueryResponse(); if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException) x);
rsp = InfosetUtil.emptyAdhocQueryResponse(); if (x instanceof XDSException) { XDSUtil.addError(rsp, (XDSException)x); rsp = InfosetUtil.emptyAdhocQueryResponse();