Package com.documents4j.throwables

Examples of com.documents4j.throwables.FileSystemInteractionException


        try {
            FileInputStream fileInputStream = new FileInputStream(file);
            fileInputStream.getChannel().lock(0L, Long.MAX_VALUE, true);
            return fileInputStream;
        } catch (FileNotFoundException e) {
            throw new FileSystemInteractionException(String.format("Could not find file %s", file), e);
        } catch (IOException e) {
            throw new FileSystemInteractionException(String.format("Could not read file %s", file), e);
        }
    }
View Full Code Here


    private void close(InputStream inputStream) {
        try {
            Closeables.close(inputStream, false);
        } catch (IOException e) {
            throw new FileSystemInteractionException(String.format("Could not close stream for file %s", file), e);
        }
    }
View Full Code Here

                Closeables.close(inputStream, true);
                // Note: This will implicitly release the file lock.
                Closeables.close(fileOutputStream, false);
            }
        } catch (IOException e) {
            throw new FileSystemInteractionException(String.format("Could not copy result to %s", file), e);
        }
        fileConsumer.onComplete(file);
    }
View Full Code Here

        try {
            if (close) {
                Closeables.close(inputStream, false);
            }
        } catch (IOException e) {
            throw new FileSystemInteractionException("Could not close input stream", e);
        }
    }
View Full Code Here

            } finally {
                // Note: This will implicitly release the file lock.
                Closeables.close(fileOutputStream, true);
            }
        } catch (IOException e) {
            throw new FileSystemInteractionException(String.format("Could not write stream to file %s", tempStorage), e);
        }
    }
View Full Code Here

    @Override
    public void onComplete(InputStream inputStream) {
        try {
            ByteStreams.copy(inputStream, outputStream);
        } catch (IOException e) {
            throw new FileSystemInteractionException("Could not write result to output stream", e);
        } finally {
            try {
                closeStreamIfApplicable();
            } finally {
                try {
View Full Code Here

    private void closeStreamIfApplicable() {
        if (closeMark.compareAndSet(false, true)) {
            try {
                Closeables.close(outputStream, false);
            } catch (IOException e) {
                throw new FileSystemInteractionException("Could not close output stream", e);
            }
        }
    }
View Full Code Here

    @Override
    public void onComplete(File file) {
        try {
            inputStreamConsumer.onComplete(new DeleteFileOnCloseInputStream(file));
        } catch (IOException e) {
            throw new FileSystemInteractionException(String.format("Could not process file: %s", file), e);
        }
    }
View Full Code Here

            File renamedTarget = makeRenamedTarget();
            LOGGER.trace("Rename file {} to {}", renamedTarget, target);
            tryCleanTarget(renamedTarget);
            if (!renamedTarget.renameTo(target)) {
                LOGGER.error("Failed to rename {} to {}", renamedTarget, target);
                throw new FileSystemInteractionException(String.format("Could not write target file %s", target));
            }
        }
    }
View Full Code Here

        if ((target.isFile() && !target.delete()) || target.isDirectory()) {
            // Try to clean up such that the converted file with file name extension does not get orphaned.
            if (renamedTarget.exists() && !renamedTarget.delete()) {
                LOGGER.warn("Could not delete target file {} after failed renaming attempt", renamedTarget);
            }
            throw new FileSystemInteractionException(String.format("Cannot write converted file to %s", target));
        }
    }
View Full Code Here

TOP

Related Classes of com.documents4j.throwables.FileSystemInteractionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.