Produced by Araxis Merge on 12/5/2017 12:06:51 PM Central Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VixGuiImageDisplayApplet\main\src\java\gov\va\med\imaging\dicom\io | Part10DataSetLoader.java | Mon Dec 4 21:35:04 2017 UTC |
| 2 | IV-eHMP_CIF.zip\IMAG_Source\VISA\Java\VixGuiImageDisplayApplet\main\src\java\gov\va\med\imaging\dicom\io | Part10DataSetLoader.java | Mon Dec 4 22:07:23 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 504 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /** | |
| 2 | * Package : MAG - Vi stA Imagin g | |
| 3 | * WARNING : Per VHA Directive 2004-038, this routi ne should not be mod ified. | |
| 4 | * Date Cr eated: Jul 23, 2008 | |
| 5 | * Site Na me: Washi ngton OI F ield Offic e, Silver Spring, MD | |
| 6 | * @author
|
|
| 7 | * @versio n 1.0 | |
| 8 | * | |
| 9 | * ------- ---------- ---------- ---------- ---------- ---------- ------- | |
| 10 | * Propert y of the U S Governme nt. | |
| 11 | * No perm ission to copy or re distribute this soft ware is gi ven. | |
| 12 | * Use of unreleased versions of this so ftware req uires the user | |
| 13 | * to exec ute a writ ten test a greement w ith the Vi stA Imagin g | |
| 14 | * Develop ment Offic e of the D epartment of Veteran s Affairs, | |
| 15 | * telepho ne (301) 7 34-0100. | |
| 16 | * | |
| 17 | * The Foo d and Drug Administr ation clas sifies thi s software as | |
| 18 | * a Class II medica l device. As such, it may not be change d | |
| 19 | * in any way. Modi fications to this so ftware may result in an | |
| 20 | * adulter ated medic al device under 21CF R820, the use of whi ch | |
| 21 | * is cons idered to be a viola tion of US Federal S tatutes. | |
| 22 | * ------- ---------- ---------- ---------- ---------- ---------- ------- | |
| 23 | */ | |
| 24 | package go v.va.med.i maging.dic om.io; | |
| 25 | ||
| 26 | import gov .va.med.im aging.dico m.DataElem ent; | |
| 27 | import gov .va.med.im aging.dico m.DataElem entFactory ; | |
| 28 | import gov .va.med.im aging.dico m.DataSet; | |
| 29 | import gov .va.med.im aging.dico m.Transfer SyntaxUid; | |
| 30 | import gov .va.med.im aging.dico m.exceptio ns.DicomFo rmatExcept ion; | |
| 31 | import gov .va.med.im aging.dico m.exceptio ns.Incompa tibleValue LengthFiel d; | |
| 32 | import gov .va.med.im aging.dico m.exceptio ns.Invalid VRExceptio n; | |
| 33 | import gov .va.med.im aging.dico m.exceptio ns.Invalid VRModeExce ption; | |
| 34 | import gov .va.med.im aging.dico m.exceptio ns.Missing DicmPreamb leExceptio n; | |
| 35 | import gov .va.med.im aging.dico m.exceptio ns.Missing DicmPrefix Exception; | |
| 36 | import gov .va.med.im aging.dico m.exceptio ns.ValueRe presentati onInterpre tationExce ption; | |
| 37 | import gov .va.med.im aging.dico mviewer.Se curityCont ext; | |
| 38 | ||
| 39 | import jav a.io.Buffe redInputSt ream; | |
| 40 | import jav a.io.DataI nputStream ; | |
| 41 | import jav a.io.EOFEx ception; | |
| 42 | import jav a.io.File; | |
| 43 | import jav a.io.FileI nputStream ; | |
| 44 | import jav a.io.FileN otFoundExc eption; | |
| 45 | import jav a.io.IOExc eption; | |
| 46 | import jav a.io.Input Stream; | |
| 47 | import jav a.net.Http URLConnect ion; | |
| 48 | import jav a.net.URL; | |
| 49 | import jav a.net.URLC onnection; | |
| 50 | import org .apache.lo gging.log4 j.LogManag er; | |
| 51 | import org .apache.lo gging.log4 j.Logger; | |
| 52 | ||
| 53 | /** | |
| 54 | * @author
|
|
| 55 | * | |
| 56 | */ | |
| 57 | public cla ss Part10D ataSetLoad er | |
| 58 | { | |
| 59 | pr ivate stat ic Logger logger = L ogManager. getLogger( Part10Data SetLoader. class.getN ame()); | |
| 60 | ||
| 61 | /* * | |
| 62 | * | |
| 63 | * @param di comFile | |
| 64 | * @return | |
| 65 | * @throws I nvalidVREx ception | |
| 66 | * @throws I nvalidVRMo deExceptio n | |
| 67 | * @throws D icomFormat Exception | |
| 68 | * @throws U nsupported OperationE xception | |
| 69 | * @throws V alueRepres entationIn terpretati onExceptio n | |
| 70 | * @throws I ncompatibl eValueLeng thField | |
| 71 | * / | |
| 72 | pu blic stati c DataSet load(File dicomFile) | |
| 73 | th rows Unsup portedOper ationExcep tion, Dico mFormatExc eption, | |
| 74 | In validVRMod eException , InvalidV RException , ValueRep resentatio nInterpret ationExcep tion, Inco mpatibleVa lueLengthF ield | |
| 75 | { | |
| 76 | Data InputStrea m din = nu ll; | |
| 77 | try | |
| 78 | { | |
| 79 | System .out.print ln("Openin g DICOM fi le '" + di comFile.to String() + "'."); | |
| 80 | din = new Data InputStrea m( new Bu fferedInpu tStream( n ew FileInp utStream(d icomFile) ) ); | |
| 81 | System .out.print ln("DICOM file '" + dicomFile. toString() + "' open ed."); | |
| 82 | ||
| 83 | Data Set dicomD ata = load (din); | |
| 84 | ||
| 85 | retu rn dicomDa ta; | |
| 86 | } | |
| 87 | catc h (FileNot FoundExcep tion e) | |
| 88 | { | |
| 89 | e.pr intStackTr ace(); | |
| 90 | } | |
| 91 | catc h (IOExcep tion e) | |
| 92 | { | |
| 93 | e.pr intStackTr ace(); | |
| 94 | } | |
| 95 | fina lly | |
| 96 | { | |
| 97 | try{di n.close(); }catch(Thr owable t){ } | |
| 98 | } | |
| 99 | ||
| 100 | retu rn null; | |
| 101 | } | |
| 102 | ||
| 103 | /* * | |
| 104 | * | |
| 105 | * @param im ageUrl | |
| 106 | * @return | |
| 107 | * / | |
| 108 | pu blic stati c DataSet load(URL i mageUrl) | |
| 109 | { | |
| 110 | Data InputStrea m din = nu ll; | |
| 111 | try | |
| 112 | { | |
| 113 | URLCon nection co nnection = imageUrl. openConnec tion(); | |
| 114 | HttpUR LConnectio n httpConn ection = n ull; | |
| 115 | if (co nnection i nstanceof HttpURLCon nection) | |
| 116 | { | |
| 117 | httpConn ection = ( HttpURLCon nection) c onnection; | |
| 118 | // httpC onnection. setRequest Method("GE T"); | |
| 119 | // httpC onnection. setRequest Property(" Accept", | |
| 120 | // MimeT ypes.build HttpAccept String(mim eType == n ull, mimeT ype) | |
| 121 | // ); | |
| 122 | ||
| 123 | // Autho rization: Basic QWxh ZGRpbjpvcG VuIHNlc2Ft ZQ== | |
| 124 | Security Context se curityCont ext = Secu rityContex t.get(); | |
| 125 | String a uthenticat ion = secu rityContex t == null ? null : s ecurityCon text.getAs Base64(); | |
| 126 | if (auth entication != null) | |
| 127 | httpConnec tion.setRe questPrope rty("Autho rization", "Basic " + authenti cation); | |
| 128 | } | |
| 129 | System .out.print ln("Connec ting to UR L '" + ima geUrl.toSt ring() + " '."); | |
| 130 | connec tion.conne ct(); | |
| 131 | System .out.print ln("Connec ted to URL '" + imag eUrl.toStr ing() + "' , reading from input stream.") ; | |
| 132 | ||
| 133 | // Inp utStream | |
| 134 | // Buf feredInput Stream | |
| 135 | // Inp utStream i nS = urlCo nn.openStr eam(); | |
| 136 | din = new DataIn putStream( new Buffe redInputSt ream(conne ction.getI nputStream ()) ); | |
| 137 | ||
| 138 | // }el se{ | |
| 139 | // Sys tem.out.pr intln("fil e"); | |
| 140 | // Fin S = new Fi leInputStr eam(imgURL ); | |
| 141 | // inS = new Buf feredInput Stream(Fin S); | |
| 142 | // din = new Dat aInputStre am(inS); | |
| 143 | // Sys tem.out.pr intln("fil e"); | |
| 144 | // } | |
| 145 | ||
| 146 | return load(din) ; | |
| 147 | } | |
| 148 | catc h (EOFExce ption eof) | |
| 149 | { | |
| 150 | System .out.print ln("DicomF ile.EOFExc eption: " + eof.getM essage()); | |
| 151 | } | |
| 152 | catc h (IOExcep tion ioe) | |
| 153 | { | |
| 154 | System .out.print ln("DicomF ile.IOExce ption: " + ioe.getMe ssage()); | |
| 155 | } | |
| 156 | catc h (Excepti on e) | |
| 157 | { | |
| 158 | System .out.print ln("DicomF ile.Except ion: " + e .getMessag e()); | |
| 159 | } | |
| 160 | fina lly | |
| 161 | { | |
| 162 | try{di n.close(); }catch(Thr owable x){ } | |
| 163 | } | |
| 164 | ||
| 165 | retu rn null; | |
| 166 | } | |
| 167 | ||
| 168 | /* * | |
| 169 | * | |
| 170 | * @param in putStream | |
| 171 | * @return | |
| 172 | * @throws I OException | |
| 173 | * @throws D icomFormat Exception | |
| 174 | * @throws U nsupported OperationE xception | |
| 175 | * @throws I nvalidVRMo deExceptio n | |
| 176 | * @throws I nvalidVREx ception | |
| 177 | * @throws V alueRepres entationIn terpretati onExceptio n | |
| 178 | * @throws I ncompatibl eValueLeng thField | |
| 179 | * / | |
| 180 | public static Da taSet load (InputStre am inputSt ream) | |
| 181 | throws IOExcepti on, | |
| 182 | DicomFor matExcepti on, | |
| 183 | Unsuppor tedOperati onExceptio n, | |
| 184 | InvalidV RModeExcep tion, Inva lidVRExcep tion, Valu eRepresent ationInter pretationE xception, Incompatib leValueLen gthField | |
| 185 | { | |
| 186 | if (inputStre am instanc eof DataEl ementLimit edInputStr eam) | |
| 187 | retu rn load((D ataElement LimitedInp utStream)i nputStream ); | |
| 188 | ||
| 189 | re turn load( new DataEl ementLimit edInputStr eam( new D ataInputSt ream(input Stream), T ransferSyn taxUid.RAW _EXPLICIT_ VR_LITTLEE NDIAN)); | |
| 190 | } | |
| 191 | ||
| 192 | /* * | |
| 193 | * @pa ram dicomI nputStream | |
| 194 | * @th rows IOExc eption | |
| 195 | * @throws D icomFormat Exception | |
| 196 | * @throws I nvalidVREx ception | |
| 197 | * @throws I nvalidVRMo deExceptio n | |
| 198 | * @throws U nsupported OperationE xception | |
| 199 | * @throws V alueRepres entationIn terpretati onExceptio n | |
| 200 | * @throws I ncompatibl eValueLeng thField | |
| 201 | */ | |
| 202 | public static Da taSet load (DataEleme ntLimitedI nputStream dicomInpu tStream) | |
| 203 | throws IOExcepti on, | |
| 204 | DicomF ormatExcep tion, | |
| 205 | Unsupp ortedOpera tionExcept ion, | |
| 206 | Invali dVRModeExc eption, In validVRExc eption, Va lueReprese ntationInt erpretatio nException , Incompat ibleValueL engthField | |
| 207 | { | |
| 208 | // read the header (th e 128 byte s and the 'DICM') | |
| 209 | re adPreamble AndPrefix( dicomInput Stream); | |
| 210 | ||
| 211 | Pa rt10DataSe tReader pa rt10Reader = new Par t10DataSet Reader(dic omInputStr eam); | |
| 212 | Da taSet head erDataSet = part10Re ader.readP art10DataS et(); | |
| 213 | Da taElement< ?> transfe rSyntaxEle ment = hea derDataSet .getTransf erSyntaxUI D(); | |
| 214 | if (transferS yntaxEleme nt == null ) | |
| 215 | { | |
| 216 | logg er.warn("T he Part 10 header ha d no trans fer syntax specified ."); | |
| 217 | retu rn null; | |
| 218 | } | |
| 219 | ||
| 220 | lo gger.info( "Header da ta set rea d, reading data set using '" + | |
| 221 | new St ring(trans ferSyntaxE lement.get RawValue() ) + "' tra nsfer synt ax."); | |
| 222 | Tr ansferSynt axUid tran sferSyntax = Transfe rSyntaxUid .getByUid( (String)t ransferSyn taxElement .getValue( ) ); | |
| 223 | ||
| 224 | Da taElementF actory dat aElementFa ctory = Da taElementF actory.get DataElemen tFactory(t ransferSyn tax); | |
| 225 | Da taSetReade r dataSetR eader = ne w DataSetR eader(dico mInputStre am, dataEl ementFacto ry); | |
| 226 | ||
| 227 | Da taSet data Set = data SetReader. readDataSe t(); | |
| 228 | ||
| 229 | re turn dataS et; | |
| 230 | } | |
| 231 | ||
| 232 | /** | |
| 233 | * Exc ept for th e 128 byte preamble and the 4 byte prefi x, the Fil e Meta Inf ormation | |
| 234 | * sha ll be enco ded using the Explic it VR Litt le Endian Transfer S yntax (UID =1.2.840.1 0008.1.2.1 ) | |
| 235 | * as defined in DICOM PS 3.5. | |
| 236 | * Val ues of eac h File Met a Element shall be p added when necessary to achiev e an even length as | |
| 237 | * spe cified in PS 3.5 by their corr esponding Value Repr esentation . For comp atibility with futur e versions | |
| 238 | * of this Stand ard, any T ag (0002,x xxx) not d efined in Table 7.1- 1 shall be ignored. | |
| 239 | * @pa ram dicomI nputStream | |
| 240 | * @pa ram dataSe t | |
| 241 | * @th rows IOExc eption | |
| 242 | */ | |
| 243 | protec ted static void read PreambleAn dPrefix(Da taElementL imitedInpu tStream di comInputSt ream) | |
| 244 | th rows IOExc eption, Di comFormatE xception | |
| 245 | { | |
| 246 | byte [] preambl e = new by te[128]; | |
| 247 | try{ dicomInput Stream.rea dFully(pre amble);} // read this into a buffer, we may add some anal ysis later | |
| 248 | catc h(IOExcept ion ioX){t hrow new M issingDicm PreambleEx ception(); } | |
| 249 | ||
| 250 | byte [] dicmPre fix = new byte[4]; | |
| 251 | try{ dicomInput Stream.rea dFully(dic mPrefix);} | |
| 252 | catc h(IOExcept ion ioX){t hrow new M issingDicm PrefixExce ption();} | |
| 253 | } | |
| 254 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.