+ public String getAsOsPath(Resource resource, Boolean overwrite) {
+ File file = null;
+ try {
+ file = resource.getFile();
+ return file.getCanonicalPath();
+ } catch (IOException e) {
+ if (log.isTraceEnabled())
+ log
+ .trace("Resource "
+ + resource
+ + " is not available on the file system. Retrieving it...");
+ }
+
+ InputStream in = null;
+ OutputStream out = null;
+ try {
+ String path = resource.getURL().getPath();
+ file = getFile(path);
+ if (file.exists() && !overwrite)
+ return file.getCanonicalPath();
+
+ file.getParentFile().mkdirs();
+ in = resource.getInputStream();
+ out = new FileOutputStream(file);
+ IOUtils.copy(in, out);
+ if (log.isDebugEnabled())
+ log.debug("Retrieved " + resource + " to OS file " + file);
+ return file.getCanonicalPath();
+ } catch (IOException e) {
+ throw new SlcException("Could not make resource " + resource
+ + " an OS file.", e);
+ } finally {
+ IOUtils.closeQuietly(in);
+ IOUtils.closeQuietly(out);
+ }
+ }
+