private void storeMetadataAndBulkdata(StoreSession session, MetaDataPathTSTuple part) { Attributes ds = null; if (creatorType == CreatorType.JSON_BULKDATA) { try { ds = parseJSON(part.getPath().toFile().getPath()); } catch (Exception e) { storageFailed(NOT_PARSEABLE_IUID, NOT_PARSEABLE_CUID, METADATA_NOT_PARSEABLE); return; } } else { try { ds = SAXReader.parse(part.getPath().toUri().toString()); } catch (Exception e) { storageFailed(NOT_PARSEABLE_IUID, NOT_PARSEABLE_CUID, METADATA_NOT_PARSEABLE); return; } } String iuid = ds.getString(Tag.SOPInstanceUID); String cuid = ds.getString(Tag.SOPClassUID); Attributes fmi = ds.createFileMetaInformation(part.getTransferSyntax()); if (!resolveBulkdata(session, fmi, ds)) { storageFailed(iuid, cuid, MISSING_BULKDATA); return; } try { checkStudyInstanceUID(ds.getString(Tag.StudyInstanceUID)); checkTransferCapability(cuid, fmi.getString(Tag.TransferSyntaxUID)); StoreContext context = storeService.createStoreContext(session); storeService.writeSpoolFile(context, fmi, ds); storeService.store(context); sopSequence.add(sopRef(context)); } catch (DicomServiceException e) { storageFailed(iuid, cuid, e.getStatus()); } }
private void storeDicomObject(StoreSession session, InputStream in) throws DicomServiceException { StoreContext context; try { context = storeService.createStoreContext(session); storeService.writeSpoolFile(context, null, in); storeService.parseSpoolFile(context); } catch (DicomServiceException e) { if (e.getStatus() == StoreService.DATA_SET_NOT_PARSEABLE) { storageFailed(NOT_PARSEABLE_IUID, NOT_PARSEABLE_CUID, METADATA_NOT_PARSEABLE); return; } throw e; } Attributes attrs = context.getAttributes(); try { checkStudyInstanceUID(attrs.getString(Tag.StudyInstanceUID)); checkTransferCapability(attrs.getString(Tag.SOPClassUID), context.getTransferSyntax()); storeService.store(context); sopSequence.add(sopRef(context)); } catch (DicomServiceException e) { storageFailed( attrs.getString(Tag.SOPInstanceUID), attrs.getString(Tag.SOPClassUID), e.getStatus()); } }