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

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

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

revision 2840 by torben, Mon Jan 25 10:25:22 2016 UTC revision 2897 by torben, Mon Feb 1 08:51: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    
# Line 18  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 59  public class AddressTask extends Task { Line 67  public class AddressTask extends Task {
67                          report.sendRapport();                          report.sendRapport();
68                                                    
69                                                    
70                            if (writeBack) {
71                                    ReloadHelper.triggerReload( "Indlaesning/" + source.getDistributor() );
72                            }
73                                                    
74                  } catch (Exception e) {                          
75                          e.printStackTrace();                          
76                  }                  } catch(Exception e) {
77                                            
78                                            String subject = "Error loading data for " + source.getDistributor();
79                  try {                          String body = "File: " + source.getFilename();
80                          System.out.println("Cleaning up resources");                          body += "<br><br>";
81                          source.close();                          body += "Exception:<br>";
82                  } catch (Exception e) {                          body += ExceptionUtils.getStackTrace(e);
83                          System.out.println("Error during cleanup: " + e.getMessage() );                          AddressReport.sendMail(subject, body);
84                            
85                            throw e; //rethrow exception
86                    } finally  {
87                            
88                            try {
89                                    System.out.println("Cleaning up resources");
90                                    source.close();
91                            } catch (Exception e) {
92                                    System.out.println("Error during cleanup: " + e.getMessage() );
93                            }                      
94                  }                  }
95    
96          }          }
97    
98          @Override          @Override
# Line 79  public class AddressTask extends Task { Line 101  public class AddressTask extends Task {
101          }          }
102    
103          @Override          @Override
104          public short getPercentCompleted() {          public double getPercentCompleted() {
105                  return 0;                  return -1;
106          }          }
107    
108          @Override          @Override

Legend:
Removed from v.2840  
changed lines
  Added in v.2897

  ViewVC Help
Powered by ViewVC 1.1.20