19 package org.turro.elephant.web.context;
22 import java.util.Date;
23 import java.util.HashSet;
25 import java.util.Objects;
27 import java.util.TreeMap;
28 import org.turro.string.ObjectString;
36 private File resource;
39 private final TreeMap<String, File> editables =
new TreeMap<>();
50 editables.put(modified, file);
58 return editables.lastEntry().getValue();
77 private static final Long MAX_DIFFERENCE = (1000L * 60L * 60L * 3 );
80 Set<String> toRemove =
new HashSet<>();
81 Long previous = ((Date) ObjectString.parseString(current,
82 ObjectString.COMPRESSED_DATE_PATTERN, Date.class,
false)).getTime();
83 for(String modified : editables.descendingKeySet()) {
84 long modification = ((Date) ObjectString.parseString(modified,
85 ObjectString.COMPRESSED_DATE_PATTERN, Date.class,
false)).getTime();
86 if(previous !=
null) {
87 if(previous - modification < MAX_DIFFERENCE) {
88 toRemove.add(modified);
91 previous = modification;
93 toRemove.forEach(e -> {
94 editables.get(e).delete();
104 hash = 37 * hash + Objects.hashCode(this.resource);
116 if (getClass() != obj.getClass()) {
120 return Objects.
equals(this.resource, other.resource);
void addEditable(String modified, File file)
static WebResourceParts decompose(File file)
void addFile(WebResourceParts wrp, File file)
boolean equals(Object obj)
void setResource(File file)
File getCurrentEditable()
Map< String, File > getEditables()
void cleanEditables(String current)