Revision 1207 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.lib/org.gvsig.scripting.lib.impl/src/main/java/org/gvsig/scripting/impl/DefaultScriptingExternalFile.java

View differences:

DefaultScriptingExternalFile.java
5 5
import java.io.IOException;
6 6
import java.util.ArrayList;
7 7
import java.util.List;
8
import java.util.logging.Level;
9
import java.util.logging.Logger;
8 10
import org.apache.commons.io.FileUtils;
9 11
import org.apache.tika.Tika;
10 12
import org.gvsig.scripting.ScriptingExternalFile;
......
29 31

  
30 32
    @Override
31 33
    public boolean rename(String newId) {
32
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
34
      try {
35
        File newf = new File(this.externFile.getParentFile(),newId);
36
        FileUtils.moveFile(this.externFile, newf);
37
        return true;
38
      } catch (IOException ex) {
39
        throw new RuntimeException("Can't rename '"+this.id+"' to '"+newId+"'.", ex);
40
      }
33 41
    }
34 42

  
35 43
    @Override
......
49 57

  
50 58
    @Override
51 59
    public boolean remove() {
52
        return this.externFile.delete();
60
        return FileUtils.deleteQuietly(externFile);
53 61
    }
54 62

  
55 63
    @Override
56 64
    public boolean move(ScriptingFolder target) {
65
      File target_f = target.getFile();
66
      File source_f = this.getExternalFile();
67
      try {
68
        FileUtils.copyFile(source_f, target_f);
69
        return true;
70
      } catch (IOException ex) {
57 71
        return false;
72
      }
58 73
    }
59 74

  
60 75
    @Override
......
65 80
        };
66 81
    }
67 82
    
83
    @Override
68 84
    public File getExternalFile() {
69 85
        return this.externFile;
70 86
    }
71 87
    
72 88
    @Override
89
    public File getFile() {
90
        if (this.getId() == null) {
91
            return null;
92
        }
93
        if (this.getParent() == null) {
94
            return null;
95
        }
96
        if (this.getParent().getFile() == null) {
97
            return null;
98
        }
99
        return this.externFile;
100
    }
101

  
102
    @Override
73 103
    public List<File> getFiles() {
74 104
        List<File> l=new ArrayList<>();
75 105
        l.add(this.externFile);

Also available in: Unified diff