Coverage Report - org.kuali.maven.plugins.dnsme.mojo.AddRecordMojo
 
Classes in this File Line Coverage Branch Coverage Complexity
AddRecordMojo
0%
0/26
N/A
1
 
 1  
 package org.kuali.maven.plugins.dnsme.mojo;
 2  
 
 3  
 import org.apache.maven.plugin.MojoExecutionException;
 4  
 import org.apache.maven.plugin.MojoFailureException;
 5  
 import org.kuali.maven.plugins.dnsme.DNSMEClient;
 6  
 import org.kuali.maven.plugins.dnsme.beans.Domain;
 7  
 import org.kuali.maven.plugins.dnsme.beans.GTDLocation;
 8  
 import org.kuali.maven.plugins.dnsme.beans.Record;
 9  
 import org.kuali.maven.plugins.dnsme.beans.RecordType;
 10  
 
 11  
 /**
 12  
  * Add a dns record to a domain name managed by a DNSME account
 13  
  *
 14  
  * @author Jeff Caddel
 15  
  * @goal addrecord
 16  
  */
 17  0
 public class AddRecordMojo extends BaseDNSMEMojo {
 18  
     /**
 19  
      * The domain to add a record to
 20  
      *
 21  
      * @parameter expression="${dnsme.domainName}"
 22  
      * @required
 23  
      */
 24  
     String domainName;
 25  
 
 26  
     /**
 27  
      * DEFAULT, US_EAST, US_WEST, ASIA
 28  
      *
 29  
      * @parameter expression="${dnsme.gtdLocation}"
 30  
      */
 31  
     GTDLocation gtdLocation;
 32  
 
 33  
     /**
 34  
      * A, CNAME, MX, NS, PTR, SRV, AAAA, HTTPRED, TXT
 35  
      *
 36  
      * @parameter expression="${dnsme.recordType}"
 37  
      * @required
 38  
      */
 39  
     RecordType recordType;
 40  
 
 41  
     /**
 42  
      * The record name
 43  
      *
 44  
      * @parameter expression="${dnsme.recordName}"
 45  
      * @required
 46  
      */
 47  
     String recordName;
 48  
 
 49  
     /**
 50  
      * The record value
 51  
      *
 52  
      * @parameter expression="${dnsme.recordValue}"
 53  
      * @required
 54  
      */
 55  
     String recordValue;
 56  
 
 57  
     /**
 58  
      * Time to live in seconds
 59  
      *
 60  
      * @parameter expression="${dnsme.ttl}"
 61  
      * @required
 62  
      */
 63  
     int ttl;
 64  
 
 65  
     @Override
 66  
     public void performTasks(DNSMEClient client) throws MojoExecutionException, MojoFailureException {
 67  0
         Record record = new Record();
 68  0
         record.setData(recordValue);
 69  0
         record.setType(recordType);
 70  0
         record.setGtdLocation(gtdLocation);
 71  0
         record.setName(recordName);
 72  0
         record.setTtl(ttl);
 73  
 
 74  0
         Domain domain = client.getDomain(domainName);
 75  0
         Record addedRecord = client.addRecord(domain, record);
 76  0
         getLog().info("Adding a record to '" + domainName + "'");
 77  0
         getLog().info(getLog(addedRecord));
 78  0
     }
 79  
 
 80  
     protected String getCompactLog(Record record) {
 81  0
         StringBuilder sb = new StringBuilder();
 82  0
         sb.append(record.getName());
 83  0
         sb.append("->" + record.getData());
 84  0
         sb.append("," + record.getType());
 85  0
         sb.append(",ttl=" + record.getTtl() + "s");
 86  0
         return sb.toString();
 87  
     }
 88  
 
 89  
     protected String getLog(Record record) {
 90  0
         StringBuilder sb = new StringBuilder();
 91  0
         sb.append("Id:" + record.getId());
 92  0
         sb.append(" Name:" + record.getName());
 93  0
         sb.append(" Value:" + record.getData());
 94  0
         sb.append(" Type:" + record.getType());
 95  0
         sb.append(" TTL:" + record.getTtl());
 96  0
         sb.append(" GTD:" + record.getGtdLocation());
 97  0
         return sb.toString();
 98  
     }
 99  
 
 100  
 }