/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressTask.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/AddressTask.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2838 by torben, Sun Jan 24 21:48:55 2016 UTC revision 2856 by torben, Thu Jan 28 10:27:13 2016 UTC
# Line 1  Line 1 
1  package dk.daoas.adressevedligehold;  package dk.daoas.adressevedligehold;
2    
3    import org.apache.commons.lang3.exception.ExceptionUtils;
4    
5  import dk.daoas.adressevedligehold.tasks.Task;  import dk.daoas.adressevedligehold.tasks.Task;
6  import dk.daoas.adressevedligehold.util.TimingHelper;  import dk.daoas.adressevedligehold.util.TimingHelper;
7    
8    /*
9     * TODO: trigger indlæsning
10     *  
11     */
12    
13  public class AddressTask extends Task {  public class AddressTask extends Task {
14                    
15          AddressSource source;          AddressSource source;
# Line 13  public class AddressTask extends Task { Line 20  public class AddressTask extends Task {
20                  this.source = source;                  this.source = source;
21                  this.writeBack = writeBack;                  this.writeBack = writeBack;
22          }          }
23            
24            
25    
26          @Override          @Override
27          protected void taskRun() {          protected void taskRun() throws Exception {
28                                    
29                  try {                  try {
30                          TimingHelper timer = new TimingHelper();                          TimingHelper timer = new TimingHelper();
31                            
32                            System.out.println("Validating Source");
33                            source.validate();
34                            
35                          System.out.println("Reading data from DB");                          System.out.println("Reading data from DB");
36                          AddressManager addrManager = new AddressManager();                          AddressManager addrManager = new AddressManager();
37                                                    
# Line 55  public class AddressTask extends Task { Line 68  public class AddressTask extends Task {
68                                                    
69                                                    
70                                                    
71                  } catch (Exception e) {                  } catch(Exception e) {
72                          e.printStackTrace();                          
73                  }                          String subject = "Error loading data for " + source.getDistributor();
74                                            String body = "File: " + source.getFilename();
75                                            body += "<br><br>";
76                  try {                          body += "Exception:<br>";
77                          System.out.println("Cleaning up resources");                          body += ExceptionUtils.getStackTrace(e);
78                          source.close();                          AddressReport.sendMail(subject, body);
79                  } catch (Exception e) {                          
80                          System.out.println("Error during cleanup: " + e.getMessage() );                          throw e; //rethrow exception
81                    } finally  {
82                            
83                            try {
84                                    System.out.println("Cleaning up resources");
85                                    source.close();
86                            } catch (Exception e) {
87                                    System.out.println("Error during cleanup: " + e.getMessage() );
88                            }                      
89                  }                  }
90    
91          }          }
92    
93          @Override          @Override

Legend:
Removed from v.2838  
changed lines
  Added in v.2856

  ViewVC Help
Powered by ViewVC 1.1.20