1 | |
package org.kuali.maven.plugins.dnsme.mojo; |
2 | |
|
3 | |
import java.util.List; |
4 | |
|
5 | |
import org.apache.maven.plugin.MojoExecutionException; |
6 | |
import org.apache.maven.plugin.MojoFailureException; |
7 | |
import org.kuali.maven.plugins.dnsme.DNSMEClient; |
8 | |
import org.kuali.maven.plugins.dnsme.beans.Domain; |
9 | |
import org.kuali.maven.plugins.dnsme.beans.GTDLocation; |
10 | |
import org.kuali.maven.plugins.dnsme.beans.Record; |
11 | |
import org.kuali.maven.plugins.dnsme.beans.RecordType; |
12 | |
import org.kuali.maven.plugins.dnsme.beans.Search; |
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | 0 | public class ShowRecordsMojo extends BaseDNSMEMojo { |
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
String domainName; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
GTDLocation gtdLocation; |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
RecordType recordType; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
String recordName; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
String recordNameContains; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
String recordValue; |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
String recordValueContains; |
71 | |
|
72 | |
@Override |
73 | |
public void performTasks(DNSMEClient client) throws MojoExecutionException, MojoFailureException { |
74 | 0 | Search search = new Search(); |
75 | 0 | search.setGtdLocation(gtdLocation); |
76 | 0 | search.setType(recordType); |
77 | 0 | search.setName(recordName); |
78 | 0 | search.setNameContains(recordNameContains); |
79 | 0 | search.setValue(recordValue); |
80 | 0 | search.setValueContains(recordValueContains); |
81 | |
|
82 | 0 | Domain domain = client.getDomain(domainName); |
83 | 0 | List<Record> records = client.getRecords(domain, search); |
84 | 0 | getLog().info("Showing records for: " + domainName); |
85 | 0 | for (Record record : records) { |
86 | 0 | getLog().info(getCompactLog(record)); |
87 | |
} |
88 | 0 | } |
89 | |
|
90 | |
protected String getCompactLog(Record record) { |
91 | 0 | StringBuilder sb = new StringBuilder(); |
92 | 0 | sb.append(record.getName()); |
93 | 0 | sb.append("->" + record.getData()); |
94 | 0 | sb.append("," + record.getType()); |
95 | 0 | sb.append(",ttl=" + record.getTtl() + "s"); |
96 | 0 | return sb.toString(); |
97 | |
} |
98 | |
|
99 | |
protected String getLog(Record record) { |
100 | 0 | StringBuilder sb = new StringBuilder(); |
101 | 0 | sb.append("Id:" + record.getId()); |
102 | 0 | sb.append(" Name:" + record.getName()); |
103 | 0 | sb.append(" Value:" + record.getData()); |
104 | 0 | sb.append(" Type:" + record.getType()); |
105 | 0 | sb.append(" TTL:" + record.getTtl()); |
106 | 0 | sb.append(" GTD:" + record.getGtdLocation()); |
107 | 0 | return sb.toString(); |
108 | |
} |
109 | |
|
110 | |
} |