package com.jvm_bloggers.core.rss.fetchers;

import com.rometools.rome.feed.synd.SyndFeed;
import com.rometools.rome.io.SyndFeedInput;

import javaslang.control.Option;

import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Component;

import java.io.File;
import java.util.UUID;

@Component
@Slf4j
public class WgetFetcher implements Fetcher {

    @Override
    public Option<SyndFeed> fetch(String rssUrl) {
        String uid = UUID.randomUUID().toString();
        try {
            Process process = new ProcessBuilder("wget", rssUrl, "-O", "/tmp/" + uid).start();
            process.waitFor();
            File file = new File("/tmp/" + uid);
            Option<SyndFeed> feed = Option.of(new SyndFeedInput().build(file));
            file.delete();
            return feed;
        } catch (Exception exc) {
            log.warn("Exception during wget execution for url {}: {}", rssUrl, exc.getMessage());
            return Option.none();
        }
    }
}

@@ -272,31 +272,8 @@
 ile;
-%0Aimport java.util.UUID;
 %0A%0A@C
@@ -412,48 +412,107 @@
     
-String uid = UUID.randomUUID().toString(
+File tempFile = null;%0A        try %7B%0A            tempFile = File.createTempFile(%22jvm-bloggers%22, null
 );%0A 
@@ -510,37 +510,80 @@
  null);%0A        
+ 
-try %7B
+   String tmpPath = tempFile.getAbsolutePath();
 %0A            Pro
@@ -638,29 +638,23 @@
 , %22-O%22, 
-%22/
 tmp
-/%22 + uid
+Path
 ).start(
@@ -703,175 +703,61 @@
     
-File file = new File(%22/tmp/%22 + uid);%0A            Option%3CSyndFeed%3E feed = Option.of(new SyndFeedInput().build(file));%0A            file.delete();%0A            return feed
+return Option.of(new SyndFeedInput().build(tempFile))
 ;%0A  
@@ -916,24 +916,129 @@
 ion.none();%0A
+        %7D finally %7B%0A            if (tempFile != null) %7B%0A                tempFile.delete();%0A            %7D%0A
         %7D%0A  

Make wget use system dependent temp folder location