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 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | 0 | public class AddRecordMojo extends BaseDNSMEMojo { |
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
String domainName; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
GTDLocation gtdLocation; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
RecordType recordType; |
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
String recordName; |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
String recordValue; |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
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 | |
} |