9 |
import org.apache.commons.fileupload.FileItem; |
import org.apache.commons.fileupload.FileItem; |
10 |
|
|
11 |
import dk.daoas.adressevedligehold.AddressSourceEntry.EntryType; |
import dk.daoas.adressevedligehold.AddressSourceEntry.EntryType; |
|
import dk.daoas.adressevedligehold.util.DeduplicateHelper; |
|
12 |
|
|
13 |
public class AddressSourceNS implements AddressSource { |
public class AddressSourceNS extends AbstractAddressSource { |
14 |
|
|
15 |
enum NextUgedag { |
enum NextUgedag { |
16 |
MANDAG,TIRSDAG,ONSDAG,TORSDAG,FREDAG,LORDAG,SONDAG |
MANDAG,TIRSDAG,ONSDAG,TORSDAG,FREDAG,LORDAG,SONDAG |
17 |
} |
} |
18 |
|
|
|
DeduplicateHelper<String> dirigeringsCache = new DeduplicateHelper<String>(); |
|
|
|
|
|
FileItem file; |
|
|
|
|
|
InputStream is; |
|
|
InputStreamReader isr; |
|
|
BufferedReader br; |
|
|
|
|
19 |
String parts[]; |
String parts[]; |
20 |
|
|
|
int lineCount = 0; |
|
21 |
|
|
22 |
NextUgedag nextUgedag = NextUgedag.MANDAG; |
NextUgedag nextUgedag = NextUgedag.MANDAG; |
23 |
|
|
24 |
public AddressSourceNS(FileItem file) throws Exception { |
public AddressSourceNS(FileItem file) throws Exception { |
25 |
this.file = file; |
super(file); |
26 |
} |
} |
27 |
|
|
|
@Override |
|
|
public String getFilename() { |
|
|
return file.getName(); |
|
|
} |
|
28 |
|
|
29 |
@Override |
@Override |
30 |
public void validate() throws IOException { |
public void validate() throws IOException { |
144 |
return "NS"; |
return "NS"; |
145 |
} |
} |
146 |
|
|
|
@Override //AutoCloseable |
|
|
public void close() throws Exception { |
|
|
System.out.println("Closing NS after lines " + lineCount); |
|
|
try { |
|
|
br.close(); |
|
|
isr.close(); |
|
|
is.close(); |
|
|
|
|
|
file.delete(); |
|
|
|
|
|
} catch (Exception e) { |
|
|
System.out.println("Error on closing " + e.getMessage() ); |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
147 |
} |
} |