Commits

Kevin A. Archie  committed 264a734

XNAT-2518: DicomEdit 4.0.0 uses longs for stop tag comparisons

  • Participants
  • Parent commits f264edb

Comments (0)

Files changed (4)

                     <groupId>dcm4che</groupId>
                 </exclusion>
             </exclusions>
-            <version>3.1.0</version>
+            <version>4.0.0</version>
         </dependency>
         <dependency>
             <groupId>org.nrg</groupId>

File src/main/java/org/nrg/io/UploadStatisticsReporter.java

             } else {
                 assert bytesSent > 0;
                 assert bytesSent/SCALE <= kToSend;
-                progress.setProgress(this.toString(), (int)(bytesSent/SCALE), (int)kToSend);
+                try {
+                    progress.setProgress(this.toString(), (int)(bytesSent/SCALE), (int)kToSend);
+                } catch (Throwable t) {
+                    logger.error("failed to set progress indicator", t);
+                }
             }
         } else {
             progress.setBusy(this.toString());

File src/main/java/org/nrg/io/dcm/ZipSeriesUploader.java

     private String removeCompressionSuffix(final String path) {
         return path.replaceAll("\\.[gG][zZ]$", "");
     }
-
-    private int getTopTag() {
-        int top = Tag.SOPInstanceUID;
+    
+    private StopTagInputHandler getStopTagInputHandler() {
+        long top = Tag.SOPInstanceUID;
         for (final ScriptApplicator a : applicators) {
-            final int atop = a.getTopTag();
+            final long atop = 0xffffffffL & a.getTopTag();
             if (atop > top) {
-                top = atop;
+                if (0xffffffffL == atop) {  // this means no stop tag
+                    return null;
+                } else {
+                    top = atop;
+                }
             }
         }
-        return top;
+        return new StopTagInputHandler((int)(top+1));
     }
 
     private void addFileToZip(final File f, final ZipOutputStream zos, final DicomInputHandler handler)
         try {
             final DicomInputStream dis = new DicomInputStream(bis);
             try {
-                dis.setHandler(handler);
+                if (null != handler) {
+                    dis.setHandler(handler);
+                }
                 final DicomObject o = dis.readDicomObject();
                 for (final ScriptApplicator a : applicators) {
                     a.apply(f, o);
     
     public Set<String> sendFixedSize()
     throws AttributeException,HttpUploadException,IOException,ScriptEvaluationException {
-        final StopTagInputHandler stopHandler = new StopTagInputHandler(getTopTag() + 1);
+        final StopTagInputHandler stopHandler = getStopTagInputHandler();
         final File tempzip = File.createTempFile("scan-upload", ".zip");
         try {
             logger.debug("creating zip file {}", tempzip);
         }
         c.connect();
 
-        final StopTagInputHandler stopHandler = new StopTagInputHandler(getTopTag() + 1);
+        final StopTagInputHandler stopHandler = getStopTagInputHandler();
 
         try {
             logger.trace("connection open; starting data send");

File src/test/java/org/nrg/dcm/DicomSessionVariableTest.java

 	 */
 	@Test
 	public void testGetTagsWithInitialValue() {
-		final SortedSet<Integer> tags = new TreeSet<Integer>(ImmutableSet.of(1, 2, 3, 4));
+		final SortedSet<Long> tags = new TreeSet<Long>(ImmutableSet.of(1L, 2L, 3L, 4L));
 		final Variable v = mock(Variable.class);
 		final Value iv = mock(Value.class);
 		when(v.getInitialValue()).thenReturn(iv);