• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 1041

Show
Ignore:
Timestamp:
10/16/06 12:20:13 (2 years ago)
Author:
callan
Message:

Fixes for changes put in place by on #427 by r1038. For the moment I'm setting the relevant methods to read/write. I'm also adding proper exception handling here so we can actually find out what the hell is going on when there is an exception thrown in the calling code.

Files:
1 modified

  • trunk/components/server/src/ome/services/RawPixelsBean.java (modified) (21 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/server/src/ome/services/RawPixelsBean.java

    r1038 r1041  
    3636import java.io.Serializable; 
    3737import java.nio.BufferOverflowException; 
     38import java.nio.ByteBuffer; 
    3839import java.nio.MappedByteBuffer; 
    3940 
    … …  
    6061import ome.api.ServiceInterface; 
    6162import ome.conditions.ApiUsageException; 
     63import ome.conditions.ResourceError; 
    6264import ome.io.nio.DimensionsOutOfBoundsException; 
    6365import ome.io.nio.PixelBuffer; 
    … …  
    8183 */ 
    8284@TransactionManagement(TransactionManagementType.BEAN) 
    83 @Transactional 
     85@Transactional(readOnly=false) 
    8486@Stateful 
    8587@Remote(RawPixelsStore.class) 
    … …  
    149151     
    150152    @RolesAllowed("user") 
    151     @Transactional( readOnly = true ) 
    152153    public void setPixelsId( long pixelsId ) 
    153154    { 
    … …  
    187188        { 
    188189            return buffer.calculateMessageDigest(); 
    189         } catch (IOException e) 
    190         { 
    191             e.printStackTrace(); 
    192             throw new RuntimeException("Unimplemented exception."); 
    193         } 
     190        } 
     191        catch (Exception e) 
     192        { 
     193                handleException(e); 
     194        } 
     195                return null; 
    194196    } 
    195197 
    … …  
    199201        errorIfNotLoaded(); 
    200202         
    201         MappedByteBuffer plane; 
     203        MappedByteBuffer plane = null; 
    202204                try 
    203205                { 
    … …  
    206208                catch (Exception e) 
    207209                { 
    208                         throw new RuntimeException(e); 
     210                        handleException(e); 
    209211                } 
    210212 
    211         return bufferAsByteArrayWithExceptionIfNull( plane ); 
     213                return bufferAsByteArrayWithExceptionIfNull(plane); 
    212214    } 
    213215 
    … …  
    220222        { 
    221223            return buffer.getPlaneOffset(arg0, arg1, arg2); 
    222         } catch (DimensionsOutOfBoundsException e) 
    223         { 
    224             e.printStackTrace(); 
    225             throw new RuntimeException("Unimplemented exception."); 
    226         } 
     224        } 
     225        catch (Exception e) 
     226        { 
     227                        handleException(e); 
     228        } 
     229        return null; 
    227230    } 
    228231 
    … …  
    240243        errorIfNotLoaded(); 
    241244         
    242         MappedByteBuffer region; 
     245        MappedByteBuffer region = null; 
    243246        try 
    244247        { 
    245248            region = buffer.getRegion(arg0, arg1); 
    246         } catch (IOException e) 
    247         { 
    248             e.printStackTrace(); 
    249             throw new RuntimeException("Unimplemented exception."); 
    250         } 
    251         return bufferAsByteArrayWithExceptionIfNull( region );  
     249        } catch (Exception e) 
     250        { 
     251                        handleException(e); 
     252        } 
     253        return bufferAsByteArrayWithExceptionIfNull(region);  
    252254    } 
    253255 
    … …  
    257259        errorIfNotLoaded(); 
    258260         
    259         MappedByteBuffer row; 
     261        MappedByteBuffer row = null; 
    260262        try 
    261263        { 
    262264            row = buffer.getRow(arg0, arg1, arg2, arg3); 
    263         } catch (IOException e) 
    264         { 
    265             e.printStackTrace(); 
    266             throw new RuntimeException("Unimplemented exception."); 
    267         } catch (DimensionsOutOfBoundsException e) 
    268         { 
    269             e.printStackTrace(); 
    270             throw new RuntimeException("Unimplemented exception."); 
     265        } 
     266        catch (Exception e) 
     267        { 
     268                        handleException(e); 
    271269        } 
    272270        return bufferAsByteArrayWithExceptionIfNull( row );  
    … …  
    282280        { 
    283281            return buffer.getRowOffset(arg0, arg1, arg2, arg3); 
    284         } catch (DimensionsOutOfBoundsException e) 
    285         { 
    286             e.printStackTrace(); 
    287             throw new RuntimeException("Unimplemented exception."); 
    288         } 
     282        } 
     283        catch (Exception e) 
     284        { 
     285                        handleException(e); 
     286        } 
     287        return null; 
    289288    } 
    290289 
    … …  
    302301        errorIfNotLoaded(); 
    303302         
    304         MappedByteBuffer stack; 
     303        MappedByteBuffer stack = null; 
    305304        try 
    306305        { 
    307306            stack = buffer.getStack(arg0, arg1); 
    308         } catch (IOException e) 
    309         { 
    310             e.printStackTrace(); 
    311             throw new RuntimeException("Unimplemented exception."); 
    312         } catch (DimensionsOutOfBoundsException e) 
    313         { 
    314             e.printStackTrace(); 
    315             throw new RuntimeException("Unimplemented exception."); 
     307        } 
     308        catch (Exception e) 
     309        { 
     310                        handleException(e); 
    316311        } 
    317312        return bufferAsByteArrayWithExceptionIfNull( stack ); 
    … …  
    326321        { 
    327322            return buffer.getStackOffset(arg0, arg1); 
    328         } catch (DimensionsOutOfBoundsException e) 
    329         { 
    330             e.printStackTrace(); 
    331             throw new RuntimeException("Unimplemented exception."); 
    332         } 
     323        } 
     324        catch (Exception e) 
     325        { 
     326                        handleException(e); 
     327        } 
     328        return null; 
    333329    } 
    334330 
    … …  
    346342        errorIfNotLoaded(); 
    347343         
    348         MappedByteBuffer timepoint; 
     344        MappedByteBuffer timepoint = null; 
    349345        try 
    350346        { 
    351347            timepoint = buffer.getTimepoint(arg0); 
    352         } catch (IOException e) 
    353         { 
    354             e.printStackTrace(); 
    355             throw new RuntimeException("Unimplemented exception."); 
    356         } catch (DimensionsOutOfBoundsException e) 
    357         { 
    358             e.printStackTrace(); 
    359             throw new RuntimeException("Unimplemented exception."); 
    360         } 
    361         return bufferAsByteArrayWithExceptionIfNull( timepoint ); 
     348        } 
     349        catch (Exception e) 
     350        { 
     351                        handleException(e); 
     352        } 
     353        return bufferAsByteArrayWithExceptionIfNull(timepoint); 
    362354    } 
    363355 
    … …  
    370362        { 
    371363            return buffer.getTimepointOffset(arg0); 
    372         } catch (DimensionsOutOfBoundsException e) 
    373         { 
    374             e.printStackTrace(); 
    375             throw new RuntimeException("Unimplemented exception."); 
    376         } 
     364        } 
     365        catch (Exception e) 
     366        { 
     367                        handleException(e); 
     368        } 
     369        return null; 
    377370    } 
    378371 
    … …  
    401394        { 
    402395            buffer.setPlane(arg0, arg1, arg2, arg3); 
    403         } catch (BufferOverflowException e) 
    404         { 
    405             e.printStackTrace(); 
    406             throw new RuntimeException("Unimplemented exception."); 
    407         } catch (IOException e) 
    408         { 
    409             e.printStackTrace(); 
    410             throw new RuntimeException("Unimplemented exception."); 
    411         } catch (DimensionsOutOfBoundsException e) 
    412         { 
    413             e.printStackTrace(); 
    414             throw new RuntimeException("Unimplemented exception."); 
     396        } 
     397        catch (Exception e) 
     398        { 
     399                        handleException(e); 
    415400        } 
    416401    } 
    … …  
    424409        { 
    425410            buffer.setRegion(arg0, arg1, arg2); 
    426         } catch (BufferOverflowException e) 
    427         { 
    428             e.printStackTrace(); 
    429             throw new RuntimeException("Unimplemented exception."); 
    430         } catch (IOException e) 
    431         { 
    432             e.printStackTrace(); 
    433             throw new RuntimeException("Unimplemented exception."); 
     411        } 
     412        catch (Exception e) 
     413        { 
     414                        handleException(e); 
    434415        } 
    435416    } 
    … …  
    440421        errorIfNotLoaded(); 
    441422         
    442         // FIXME buffer.setRow(arg0, arg1, arg2, arg3, arg4); 
    443         throw new RuntimeException("Not implemented yet."); 
     423        try 
     424        { 
     425                ByteBuffer buf = ByteBuffer.wrap(arg0); 
     426                buffer.setRow(buf, arg1, arg2, arg3, arg4); 
     427        } 
     428        catch (Exception e) 
     429        { 
     430                handleException(e); 
     431        } 
    444432    } 
    445433 
    … …  
    452440        { 
    453441            buffer.setStack(arg0, arg1, arg2, arg3); 
    454         } catch (BufferOverflowException e) 
    455         { 
    456             e.printStackTrace(); 
    457             throw new RuntimeException("Unimplemented exception."); 
    458         } catch (IOException e) 
    459         { 
    460             e.printStackTrace(); 
    461             throw new RuntimeException("Unimplemented exception."); 
    462         } catch (DimensionsOutOfBoundsException e) 
    463         { 
    464             e.printStackTrace(); 
    465             throw new RuntimeException("Unimplemented exception."); 
     442        } 
     443        catch (Exception e) 
     444        { 
     445                handleException(e); 
    466446        } 
    467447    } 
    … …  
    475455        { 
    476456            buffer.setTimepoint(arg0, arg1); 
    477         } catch (BufferOverflowException e) 
    478         { 
    479             e.printStackTrace(); 
    480             throw new RuntimeException("Unimplemented exception."); 
    481         } catch (IOException e) 
    482         { 
    483             e.printStackTrace(); 
    484             throw new RuntimeException("Unimplemented exception."); 
    485         } catch (DimensionsOutOfBoundsException e) 
    486         { 
    487             e.printStackTrace(); 
    488             throw new RuntimeException("Unimplemented exception."); 
     457        } 
     458        catch (Exception e) 
     459        { 
     460                handleException(e); 
    489461        } 
    490462    } 
    … …  
    499471                return b; 
    500472    } 
     473     
     474    private void handleException(Exception e) 
     475    { 
     476                e.printStackTrace(); 
     477                 
     478        if (e instanceof IOException) 
     479                { 
     480                        throw new ResourceError(e.getMessage()); 
     481                } 
     482        if (e instanceof DimensionsOutOfBoundsException) 
     483                { 
     484                        throw new ApiUsageException(e.getMessage()); 
     485                } 
     486        if (e instanceof BufferOverflowException) 
     487        { 
     488                throw new ResourceError(e.getMessage()); 
     489        } 
     490 
     491        // Fallthrough 
     492        throw new RuntimeException(e); 
     493    } 
    501494} 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/