Package com.dtolabs.rundeck.core.logging

Examples of com.dtolabs.rundeck.core.logging.ExecutionFileStorageException


    public boolean store(String filetype, InputStream stream, long length, Date lastModified) throws IOException,
            ExecutionFileStorageException {
        File storeFile = getDestinationFile(filetype);
        File tempFile = getDestinationTempFile(filetype);
        if (!storeFile.getParentFile().isDirectory() && !storeFile.getParentFile().mkdirs()) {
            throw new ExecutionFileStorageException(String.format("Failed creating dirs %s", storeFile.getParentFile()));
        }
        if (!tempFile.getParentFile().isDirectory() && !tempFile.getParentFile().mkdirs()) {
            throw new ExecutionFileStorageException(String.format("Failed creating dirs %s", storeFile.getParentFile()));
        }

        tempFile.deleteOnExit();
        OutputStream os = new FileOutputStream(tempFile);
        boolean finished = false;
        try {
            Streams.copyStream(stream, os);
            finished = true;
        } finally {
            os.close();
            if (!finished) {
                tempFile.delete();
            }
        }

        finished = tempFile.renameTo(storeFile);
        if (!finished) {
            tempFile.delete();
            throw new ExecutionFileStorageException(String.format("Failed to rename output to file %s ", storeFile));
        }
        return finished;
    }
View Full Code Here

TOP

Related Classes of com.dtolabs.rundeck.core.logging.ExecutionFileStorageException

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.