Skip to content

Commit d08c76b

Browse files
committed
Improve code documentation
1 parent f0dc078 commit d08c76b

File tree

4 files changed

+57
-22
lines changed

4 files changed

+57
-22
lines changed

Diff for: sdk-client/src/main/java/org/domainrobot/sdk/client/Domainrobot.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class Domainrobot {
2626
*/
2727
public DomainStudioClient domainStudio;
2828

29+
private String version = "0.1.0";
30+
2931
/**
3032
* <p>
3133
* Creates a new instance of the domainrobot provider, that gives access to the
@@ -46,9 +48,8 @@ public class Domainrobot {
4648
* @param baseUrl : The base url for the api
4749
*/
4850
public Domainrobot(String user, String context, String password, String baseUrl) {
49-
String packageVersion = getClass().getPackage().getImplementationVersion();
50-
certificate = new CertificateClient(user, context, password, baseUrl, packageVersion);
51-
domainStudio = new DomainStudioClient(user, context, password, baseUrl, packageVersion, getRestTemplate());
51+
certificate = new CertificateClient(user, context, password, baseUrl, version, getRestTemplate());
52+
domainStudio = new DomainStudioClient(user, context, password, baseUrl, version, getRestTemplate());
5253
}
5354

5455
public CertificateClient getCertificate() {

Diff for: sdk-client/src/main/java/org/domainrobot/sdk/client/clients/AbstractClient.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,19 @@ public <T> RequestEntity<T> buildRequestEntity(T body, HttpMethod method, String
109109
}
110110
}
111111

112-
public void handleException(HttpClientErrorException e) throws DomainrobotApiException, IOException {
112+
public void handleException(HttpClientErrorException e) throws DomainrobotApiException {
113113
String bodyAsString = e.getResponseBodyAsString();
114-
JsonResponseData body = JsonUtils.deserialize(bodyAsString.getBytes(), JsonResponseData.class);
115-
String message = body.getMessages().get(0).getText();
116-
String errorCode = body.getMessages().get(0).getCode();
117-
String stid = body.getStid();
114+
String message = "";
115+
String errorCode = "";
116+
String stid = "";
117+
try {
118+
JsonResponseData body = JsonUtils.deserialize(bodyAsString.getBytes(), JsonResponseData.class);
119+
message = body.getMessages().get(0).getText();
120+
errorCode = body.getMessages().get(0).getCode();
121+
stid = body.getStid();
122+
} catch (IOException ioException) {
123+
// Can't parse the response body to JsonResponseData model
124+
}
118125

119126
throw new DomainrobotApiException(message, bodyAsString, errorCode, stid,
120127
e.getResponseHeaders().toSingleValueMap());

Diff for: sdk-client/src/main/java/org/domainrobot/sdk/client/clients/CertificateClient.java

+25-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.domainrobot.sdk.client.clients;
22

3-
import java.io.IOException;
43
import java.util.Map;
54

65
import org.domainrobot.sdk.models.DomainrobotApiException;
@@ -23,22 +22,28 @@ public class CertificateClient extends AbstractClient {
2322

2423
RestTemplate template;
2524

26-
public CertificateClient(String userName, String context, String password, String baseUrl, String version) {
25+
public CertificateClient(String userName, String context, String password, String baseUrl, String version,
26+
RestTemplate template) {
2727
this.userName = userName;
2828
this.context = context;
2929
this.password = password;
3030
this.baseUrl = baseUrl;
3131
this.version = version;
32-
this.template = new RestTemplate();
32+
this.template = template;
3333
}
3434

3535
/**
3636
*
37-
* @return
38-
* @throws IOException
37+
* Orders a certificate in realtime. The prepareOrder tasks should be called
38+
* before to generate the necessary DCV data. <br>
39+
* <br>
40+
* <b>Note:</b> This works only for certain DV certificate products and dcv
41+
* methods.
42+
*
43+
* @return Certificate
44+
* @throws DomainrobotApiException
3945
*/
40-
public Certificate realtime(Certificate body, Map<String, String> customHeaders)
41-
throws DomainrobotApiException, IOException {
46+
public Certificate realtime(Certificate body, Map<String, String> customHeaders) throws DomainrobotApiException {
4247
RequestEntity<Certificate> request = buildRequestEntity(body, HttpMethod.POST,
4348
baseUrl + "/certificate/realtime", customHeaders);
4449
ResponseEntity<JsonResponseDataCertificate> response = null;
@@ -52,11 +57,21 @@ public Certificate realtime(Certificate body, Map<String, String> customHeaders)
5257

5358
/**
5459
*
55-
* @return
56-
* @throws IOException
60+
* Check the csr and generate DCV data for an order, renew and reissue. This
61+
* should be called everytime before the following tasks :
62+
* <ul>
63+
* <li>realtime</li>
64+
* <li>create</li>
65+
* <li>reissue</li>
66+
* <li>renew</li>
67+
* </ul>
68+
* <br>
69+
*
70+
* @return CertificateData
71+
* @throws DomainrobotApiException
5772
*/
5873
public CertificateData prepareOrder(CertificateData body, Map<String, String> customHeaders)
59-
throws DomainrobotApiException, IOException {
74+
throws DomainrobotApiException {
6075
RequestEntity<CertificateData> request = buildRequestEntity(body, HttpMethod.POST,
6176
baseUrl + "/certificate/prepareOrder", customHeaders);
6277
ResponseEntity<JsonResponseDataCertificateData> response = null;

Diff for: sdk-client/src/main/java/org/domainrobot/sdk/client/clients/DomainStudioClient.java

+16-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.domainrobot.sdk.client.clients;
22

3-
import java.io.IOException;
43
import java.util.List;
54
import java.util.Map;
65

@@ -35,12 +34,25 @@ public DomainStudioClient(String userName, String context, String password, Stri
3534
}
3635

3736
/**
37+
* Sends a domainstudio search request. <br>
38+
* <br>
39+
* <b>Note:</b> By default, search results are provided synchronously: the
40+
* search response contains all the additional data for each domain name
41+
* created. With the following header the asynchronous mode can be activated:
42+
* <br>
43+
* <br>
44+
* <b>X-Domainrobot-WS : ASYNC</b> <br>
45+
* <br>
46+
* The additional domain data will then be delivered via websocket. <br>
47+
* See the official <a href=
48+
* "https://help.internetx.com/display/APIADDITIONALEN/DomainStudio+Guide">domainstudio
49+
* guide</a> for more information.
3850
*
39-
* @return
40-
* @throws IOException
51+
* @return List of DomainEnvelope
52+
* @throws DomainrobotApiException
4153
*/
4254
public List<DomainEnvelope> search(DomainEnvelopeSearchRequest body, Map<String, String> customHeaders)
43-
throws DomainrobotApiException, IOException {
55+
throws DomainrobotApiException {
4456
RequestEntity<DomainEnvelopeSearchRequest> request = buildRequestEntity(body, HttpMethod.POST,
4557
baseUrl + "/domainstudio", customHeaders);
4658
ResponseEntity<JsonResponseDataDomainEnvelope> response = null;

0 commit comments

Comments
 (0)