Remove Tabs, per Jococo
[aaf/authz.git] / auth / auth-core / src / main / java / org / onap / aaf / auth / org / FileMailer.java
index 6a648a8..9478832 100644 (file)
@@ -33,120 +33,120 @@ import org.onap.aaf.misc.env.APIException;
 import org.onap.aaf.misc.env.util.Chrono;
 
 public class FileMailer implements Mailer {
-       private Path dir;
-       private String mail_from;
-       private String testName;
-       private int count;
+    private Path dir;
+    private String mail_from;
+    private String testName;
+    private int count;
 
 
-       public FileMailer(Access access) throws APIException {
-               count = 0;
-               
-               mail_from = access.getProperty("MAIL_FROM", null);
-               if(mail_from==null) {
-                       throw new APIException("MAIL_FROM property is required for Email Notifications");
-               }
-               String env = access.getProperty("CASS_ENV", "UNKNOWN");
-               String logdir = access.getProperty("LOG_DIR",null);
-               if(logdir==null) {
-                       logdir=access.getProperty(env+".LOG_DIR", "logs/"+env);
-               }
-               dir = Paths.get(logdir+"/email/"+Chrono.dateOnlyStamp());
-               if(!Files.exists(dir)) {
-                       try {
-                               Files.createDirectories(dir);
-                       } catch (IOException e) {
-                               throw new APIException("Cannot create directory: " + dir.toString(),e);
-                       }
-               }
-               
-               boolean dryrun = Boolean.parseBoolean(access.getProperty("DRY_RUN","false"));
-               String str = access.getProperty("MAX_EMAIL", null);
-               int maxEmail = str==null || str.isEmpty()?Integer.MAX_VALUE:Integer.parseInt(str);
-               if(dryrun && maxEmail==1) {
-                       testName = "email_test";
-               } else {
-                       testName = null;
-               }
-       }
+    public FileMailer(Access access) throws APIException {
+        count = 0;
+        
+        mail_from = access.getProperty("MAIL_FROM", null);
+        if(mail_from==null) {
+            throw new APIException("MAIL_FROM property is required for Email Notifications");
+        }
+        String env = access.getProperty("CASS_ENV", "UNKNOWN");
+        String logdir = access.getProperty("LOG_DIR",null);
+        if(logdir==null) {
+            logdir=access.getProperty(env+".LOG_DIR", "logs/"+env);
+        }
+        dir = Paths.get(logdir+"/email/"+Chrono.dateOnlyStamp());
+        if(!Files.exists(dir)) {
+            try {
+                Files.createDirectories(dir);
+            } catch (IOException e) {
+                throw new APIException("Cannot create directory: " + dir.toString(),e);
+            }
+        }
+        
+        boolean dryrun = Boolean.parseBoolean(access.getProperty("DRY_RUN","false"));
+        String str = access.getProperty("MAX_EMAIL", null);
+        int maxEmail = str==null || str.isEmpty()?Integer.MAX_VALUE:Integer.parseInt(str);
+        if(dryrun && maxEmail==1) {
+            testName = "email_test";
+        } else {
+            testName = null;
+        }
+    }
 
-       @Override
-       public boolean sendEmail(AuthzTrans trans, String test, List<String> toList, List<String> ccList,
-                       String subject, String body, Boolean urgent) throws OrganizationException {
-               boolean status = false;
-               try {
-                       Path path;
-                       if(testName==null) {
-                               path = Files.createTempFile(dir, "email", ".hdr");
-                       } else {
-                               path = Paths.get(dir.toString(), "emailTEST"+test+".hdr");
-                       }
-                       BufferedWriter bw = Files.newBufferedWriter(path);
-                       try {
-                               bw.write("TO: ");
-                               boolean first = true;
-                               for(String to : toList) {
-                                       if(first) {
-                                               first = false;
-                                       } else {
-                                               bw.write(',');
-                                       }
-                                       bw.write(to);
-                               }
-                               bw.newLine();
-                               
-                               bw.write("CC: ");
-                               first = true;
-                               for(String cc : ccList) {
-                                       if(first) {
-                                               first = false;
-                                       } else {
-                                               bw.write(',');
-                                       }
-                                       bw.write(cc);
-                               }
-                               bw.newLine();
-                               
-                               bw.write("FROM: ");
-                               bw.write(mail_from);
-                               bw.newLine();
-                               
-                               bw.write("SUBJECT: ");
-                               bw.write(subject);
-                               bw.newLine();
-                               
-                               if(urgent) {
-                                       bw.write("Importance: High");  
-                                       bw.newLine();
-                               }
+    @Override
+    public boolean sendEmail(AuthzTrans trans, String test, List<String> toList, List<String> ccList,
+            String subject, String body, Boolean urgent) throws OrganizationException {
+        boolean status = false;
+        try {
+            Path path;
+            if(testName==null) {
+                path = Files.createTempFile(dir, "email", ".hdr");
+            } else {
+                path = Paths.get(dir.toString(), "emailTEST"+test+".hdr");
+            }
+            BufferedWriter bw = Files.newBufferedWriter(path);
+            try {
+                bw.write("TO: ");
+                boolean first = true;
+                for(String to : toList) {
+                    if(first) {
+                        first = false;
+                    } else {
+                        bw.write(',');
+                    }
+                    bw.write(to);
+                }
+                bw.newLine();
+                
+                bw.write("CC: ");
+                first = true;
+                for(String cc : ccList) {
+                    if(first) {
+                        first = false;
+                    } else {
+                        bw.write(',');
+                    }
+                    bw.write(cc);
+                }
+                bw.newLine();
+                
+                bw.write("FROM: ");
+                bw.write(mail_from);
+                bw.newLine();
+                
+                bw.write("SUBJECT: ");
+                bw.write(subject);
+                bw.newLine();
+                
+                if(urgent) {
+                    bw.write("Importance: High");  
+                    bw.newLine();
+                }
 
-                       } finally {
-                               bw.close();
-                       }
+            } finally {
+                bw.close();
+            }
 
-                       path = Paths.get(path.toString().replaceAll(".hdr", ".html"));
-                       bw = Files.newBufferedWriter(path);
-                       try {
-                               bw.write(body);
-                               bw.newLine();
-                       } finally {
-                               bw.close();
-                       }
-                       status = true;
-               } catch ( IOException e) {
-                       throw new OrganizationException(e);
-               }
-               ++count;
-               return status;
-       }
+            path = Paths.get(path.toString().replaceAll(".hdr", ".html"));
+            bw = Files.newBufferedWriter(path);
+            try {
+                bw.write(body);
+                bw.newLine();
+            } finally {
+                bw.close();
+            }
+            status = true;
+        } catch ( IOException e) {
+            throw new OrganizationException(e);
+        }
+        ++count;
+        return status;
+    }
 
-       @Override
-       public String mailFrom() {
-               return mail_from;
-       }
+    @Override
+    public String mailFrom() {
+        return mail_from;
+    }
 
-       @Override
-       public int count() {
-               return count;
-       }
+    @Override
+    public int count() {
+        return count;
+    }
 }