private void checkMimetype(ExtrinsicObjectType obj, String[] mimes) throws XDSException { String mime = obj.getMimeType(); boolean unknownMime = true; for (int j = 0; j < mimes.length ; j++) { if (mimes[j].equals(mime)) { unknownMime = false; break; } } if (unknownMime) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "Mimetype is not suppoerted! mimetype:"+mime, null); } }
/** * Create an instance of {@link ExtrinsicObjectType } * */ public ExtrinsicObjectType createExtrinsicObjectType() { return new ExtrinsicObjectType(); }
public DocumentEntry(PnRRequest pnrReq, String uniqueID, byte[] content, String mime) { this.pnrRequest = pnrReq; doc = PnRRequest.iheFactory.createProvideAndRegisterDocumentSetRequestTypeDocument(); ProvideAndRegisterDocumentSetRequestType pnr = pnrRequest.getProvideAndRegisterDocumentSetRequest(); pnr.getDocument().add(doc); id = pnrReq.nextDocumentID(); doc.setId(id); doc.setValue(content); metadata = Util.rimFactory.createExtrinsicObjectType(); metadata.setObjectType(XDSConstants.UUID_XDSDocumentEntry); metadata.setId(id); metadata.setMimeType(mime); List<JAXBElement<? extends IdentifiableType>> list = pnrRequest.getRegistryObjectList().getIdentifiable(); list.add(Util.rimFactory.createExtrinsicObject(metadata)); metadata.getExternalIdentifier().add(Util.createExternalIdentifier(pnrRequest.nextID(), XDSConstants.UUID_XDSDocumentEntry_patientId, id, pnrRequest.getPatientID(), XDS_DOCUMENT_ENTRY_PATIENT_ID)); metadata.getSlot().add(pnrRequest.getSrcPatIDSlot()); if (pnrRequest.getSrcPatInfo() != null) { metadata.getSlot().add(pnrRequest.getSrcPatInfo()); } metadata.getExternalIdentifier().add(Util.createExternalIdentifier(pnrRequest.nextID(), XDSConstants.UUID_XDSDocumentEntry_uniqueId, id, uniqueID, XDS_DOCUMENT_ENTRY_UNIQUE_ID)); this.uniqueID = uniqueID; assoc = pnrReq.addAssociation(PnRRequest.SUBMISSION_SET_ID, id, XDSConstants.HAS_MEMBER); }
public static void checkDocumentEntryMetadata(ExtrinsicObjectType eoType) throws XDSException { if (eoType.getId() == null || eoType.getId().trim().length() < 2) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "DocumentEntry: Missing entryUUID attribute!", null); if (eoType.getMimeType() == null || eoType.getMimeType().trim().length() < 2) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_METADATA_ERROR, "DocumentEntry: Missing mimeType attribute! ExtrinsicObject:"+eoType.getId(), null);
public ExtrinsicObject toExtrinsicObject(ExtrinsicObjectType eoType) throws XDSException { ExtrinsicObject eo; XDSDocumentEntry doc = null; if (XDSConstants.UUID_XDSDocumentEntry.equals(eoType.getObjectType())) { XDSValidator.checkDocumentEntryMetadata(eoType); doc = new XDSDocumentEntry(); eo = doc; List<ExternalIdentifierType> list = eoType.getExternalIdentifier(); if (list != null) { for (ExternalIdentifierType eiType : list) { if (XDSConstants.UUID_XDSDocumentEntry_patientId.equals(eiType.getIdentificationScheme())) { doc.setPatient(getPatient(eiType)); } else if (XDSConstants.UUID_XDSDocumentEntry_uniqueId.equals(eiType.getIdentificationScheme())) { XDSValidator.checkAlreadyExists(eiType.getValue(), eoType, session); doc.setUniqueId(eiType.getValue()); } } } doc.setSourcePatient(getPatient(getSlotValue(eoType, XDSConstants.SLOT_NAME_SOURCE_PATIENT_ID), true)); } else { eo = new ExtrinsicObject(); } toPersistenceObj(eoType, eo); eo.setMimeType(eoType.getMimeType()); return eo; }
private JAXBElement<? extends IdentifiableType> toJAXBExtrinsicObject( ExtrinsicObject eo) { ExtrinsicObjectType eoType = factory.createExtrinsicObjectType(); toEbXmlObj(eo, eoType); eoType.setMimeType(eo.getMimeType()); eoType.setIsOpaque(eo.isOpaque()); return factory.createExtrinsicObject(eoType); } private JAXBElement<? extends IdentifiableType> toJAXBRegistryPackage(
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; }
public static void checkAlreadyExists(String uniqueId, ExtrinsicObjectType eoType, XDSRegistryBean session) throws XDSException { List<XDSDocumentEntry> docs = session.getDocumentEntriesByUniqueId(uniqueId); if (docs.size() > 0) { List<String> hash1 = getSlotTypeValues(eoType.getSlot(), "hash");; if (hash1 == null || hash1.isEmpty()) { throw new XDSException(XDSException.XDS_ERR_REGISTRY_ERROR, "Slot 'hash' missing in DocumentEntry uniqueId:"+uniqueId, null); } else if (!hash1.get(0).equals(docs.get(0).getHash())) { throw new XDSException(XDSException.XDS_ERR_NON_IDENTICAL_HASH, "DocumentEntry uniqueId:"+uniqueId+ " already exists but has different hash value! hash:'"+hash1+ "' vs. '"+docs.get(0).getHash()+"'", null); } } }
for (int i = 0, len = extrObjs.size() ; i < len ; i++ ) { eo = extrObjs.get(i); doc = docs.get(eo.getId()); docUID = InfosetUtil.getExternalIdentifierValue(XDSConstants.UUID_XDSDocumentEntry_uniqueId, eo); if (mimetypes != null) { boolean unsupportedMimetype = true; for (int j = 0 ; j < mimetypes.length ; j++) { if (mimetypes[j].equals(eo.getMimeType())) { unsupportedMimetype = false; break; throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Mimetype not supported:"+eo.getMimeType(), null); xdsDoc = (XDSDocument) ManagementFactory.getPlatformMBeanServer().invoke(new ObjectName("dcm4chee.xds2:service=Store"), "storeDocument", new Object[]{docUID, doc.getValue(), eo.getMimeType()}, new String[]{String.class.getName(), byte[].class.getName(), String.class.getName()}); if ( xdsDoc != null ) {
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; }
for (int i = 0, len = extrObjs.size() ; i < len ; i++ ) { eo = extrObjs.get(i); if (eo.getId() == null || eo.getId().trim().length() == 0) 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) boolean unsupportedMimetype = true; for (int j = 0 ; j < mimetypes.length ; j++) { if (mimetypes[j].equals(eo.getMimeType())) { unsupportedMimetype = false; break; throw new XDSException(XDSException.XDS_ERR_REPOSITORY_METADATA_ERROR, "Mimetype not supported:"+eo.getMimeType(), null); storedDocs[i] = storage.storeDocument(groupID, docUID, doc.getValue(), eo.getMimeType()); if (storedDocs[i].isCommitted()) { log.warn("Document already exists! docUid:"+docUID);