/** * @return a generated {@link File} with unique name located in temp folder. */ public static File createTempFile() { return createTempFile("temp"); }
/** * @return a generated {@link File} with unique name located in temp folder. */ public static File createTempFile() { return createTempFile("temp"); }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File temp = null; try { temp = WroUtil.createTempFile(); final Process process = createProcess(temp); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(process.getInputStream())); if (exitValue != 0) { throw new UnsupportedOperationException("Lessc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(temp); } }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File tempSource = null; File tempDest = null; try { tempSource = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); tempDest = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); final Process process = createProcess(tempSource, tempDest); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(process.getInputStream())); if (exitValue != 0) { throw new UnsupportedOperationException("Tsc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("Unsupported processor", e); LOG.warn("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(tempSource); FileUtils.deleteQuietly(tempDest); } }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File temp = null; try { temp = WroUtil.createTempFile(); final Process process = createProcess(temp); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(process.getInputStream())); if (exitValue != 0) { throw new UnsupportedOperationException("Lessc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(temp); } }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File temp = null; try { temp = WroUtil.createTempFile(); final Process process = createProcess(temp); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(process.getInputStream())); if (exitValue != 0) { throw new UnsupportedOperationException("Lessc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(temp); } }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File temp = null; try { temp = WroUtil.createTempFile(); final Process process = createProcess(temp); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(process.getInputStream())); if (exitValue != 0) { throw new UnsupportedOperationException("Lessc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(temp); } }
/** * @return true if the processor is supported on this environment. The implementation check if the required shell * utility is available. */ @Override public boolean isSupported() { File tempSource = null; File tempDest = null; try { tempSource = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); tempDest = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); final Process process = createProcess(tempSource, tempDest); final int exitValue = process.waitFor(); LOG.debug("exitValue {}. ErrorMessage: {}", exitValue, IOUtils.toString(new AutoCloseInputStream(process.getInputStream()))); if (exitValue != 0) { throw new UnsupportedOperationException("Tsc is not a supported operation on this platform"); } LOG.debug("The {} processor is supported.", getClass().getName()); return true; } catch (final Exception e) { LOG.debug("Unsupported processor", e); LOG.warn("The {} processor is not supported. Because: {}", getClass().getName(), e.getMessage()); return false; } finally { FileUtils.deleteQuietly(tempSource); FileUtils.deleteQuietly(tempDest); } }
private String process(final String resourceUri, final String content) { final InputStream shellIn = null; // the file holding the input file to process File temp = null; try { temp = WroUtil.createTempFile(); final String encoding = "UTF-8"; IOUtils.write(content, new FileOutputStream(temp), encoding); LOG.debug("absolute path: {}", temp.getAbsolutePath()); final Process process = createProcess(temp); final String result = IOUtils.toString(new AutoCloseInputStream(process.getInputStream()), encoding); final int exitStatus = process.waitFor();// this won't return till `out' stream being flushed! if (exitStatus != 0) { final String compileError = result; LOG.error("exitStatus: {}", exitStatus); // find a way to get rid of escape character found at the end (minor issue) final String errorMessage = MessageFormat.format("Error in CoffeeScript: \n{0}", compileError.replace(temp.getPath(), resourceUri)); throw new WroRuntimeException(errorMessage); } //the result is compiled in the same file return result; } catch (final Exception e) { throw WroRuntimeException.wrap(e); } finally { IOUtils.closeQuietly(shellIn); // always cleanUp FileUtils.deleteQuietly(temp); } }
File tempDest = null; try { tempSource = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); tempDest = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); final String encoding = "UTF-8"; IOUtils.write(content, new FileOutputStream(tempSource), encoding);
private String process(final String resourceUri, final String content) { final InputStream shellIn = null; // the file holding the input file to process File temp = null; try { temp = WroUtil.createTempFile(); final String encoding = "UTF-8"; IOUtils.write(content, new FileOutputStream(temp), encoding); LOG.debug("absolute path: {}", temp.getAbsolutePath()); final Process process = createProcess(temp); final String result = IOUtils.toString(new AutoCloseInputStream(process.getInputStream()), encoding); final int exitStatus = process.waitFor();// this won't return till `out' stream being flushed! if (exitStatus != 0) { final String compileError = result; LOG.error("exitStatus: {}", exitStatus); // find a way to get rid of escape character found at the end (minor issue) final String errorMessage = MessageFormat.format("Error in CoffeeScript: \n{0}", compileError.replace(temp.getPath(), resourceUri)); throw new WroRuntimeException(errorMessage); } //the result is compiled in the same file return result; } catch (final Exception e) { throw WroRuntimeException.wrap(e); } finally { IOUtils.closeQuietly(shellIn); // always cleanUp FileUtils.deleteQuietly(temp); } }
temp = WroUtil.createTempFile(); final String encoding = "UTF-8"; IOUtils.write(content, new FileOutputStream(temp), encoding);
temp = WroUtil.createTempFile(); final String encoding = "UTF-8"; IOUtils.write(content, new FileOutputStream(temp), encoding);
File tempDest = null; try { tempSource = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); tempDest = WroUtil.createTempFile(TYPESCRIPT_EXTENSION); final String encoding = "UTF-8"; IOUtils.write(content, tempSourceStream = new FileOutputStream(tempSource), encoding);