@RolesAllowed("user") public void write(byte[] buf, long position, int length) { errorIfNotLoaded(); ByteBuffer nioBuffer = MappedByteBuffer.wrap(buf); nioBuffer.limit(length); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { do { position += buffer.write(nioBuffer, position); } while (nioBuffer.hasRemaining()); // Write was successful, update state. modified(); } catch (NonWritableChannelException nwce) { throw new SecurityViolation("File not writeable!"); } catch (IOException e) { if (log.isDebugEnabled()) { log.debug("Buffer write did not occur.", e); } throw new ResourceError(e.getMessage()); } }
@RolesAllowed("user") public synchronized void setRow(byte[] arg0, int arg1, int arg2, int arg3, int arg4) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { ByteBuffer buf = ByteBuffer.wrap(arg0); buffer.setRow(buf, arg1, arg2, arg3, arg4); modified(); } catch (Exception e) { handleException(e); } }
@RolesAllowed("user") public synchronized void setPlane(byte[] arg0, int arg1, int arg2, int arg3) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { buffer.setPlane(arg0, arg1, arg2, arg3); modified(); } catch (Exception e) { handleException(e); } }
@RolesAllowed("user") public synchronized void setTimepoint(byte[] arg0, int arg1) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { buffer.setTimepoint(arg0, arg1); modified(); } catch (Exception e) { handleException(e); } }
@RolesAllowed("user") public synchronized void setRegion(int arg0, long arg1, byte[] arg2) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { buffer.setRegion(arg0, arg1, arg2); modified(); } catch (Exception e) { handleException(e); } }
@RolesAllowed("user") public synchronized void setStack(byte[] arg0, int arg1, int arg2, int arg3) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { buffer.setStack(arg0, arg1, arg2, arg3); modified(); } catch (Exception e) { handleException(e); } }
@RolesAllowed("user") public synchronized void setTile(byte[] data, int z, int c, int t, int x, int y, int w, int h) { errorIfNotLoaded(); if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try { buffer.setTile(data, z, c, t, x, y, w, h); modified(); } catch (Exception e) { handleException(e); } }
/** * Compresses a buffered image thumbnail to disk. * * @param metadata the thumbnail metadata. * @param image the thumbnail's buffered image. * @param inProgress if set to true, writes inProgressImageResource to disk * @throws ResourceError if there is a problem writing to disk. */ private void compressThumbnailToDisk(Thumbnail metadata, BufferedImage image, boolean inProgress) throws IOException, ResourceError { if (diskSpaceChecking) { iRepositoryInfo.sanityCheckRepository(); } try (FileOutputStream stream = ioService.getThumbnailOutputStream(metadata)) { if (inProgress) { compressInProgressImageToStream(metadata.getSizeX(), metadata.getSizeY(), stream, inProgressImageResource); } else { compressionService.compressToStream(image, stream); } } }