6
6
import java .net .URI ;
7
7
import java .util .Arrays ;
8
8
import java .util .Map ;
9
+ import java .util .logging .Level ;
10
+ import java .util .logging .Logger ;
9
11
10
12
import javax .xml .bind .DatatypeConverter ;
11
13
30
32
*
31
33
*/
32
34
public class ConfluenceUtils {
33
-
35
+
36
+ private static final Logger LOGGER = Logger .getLogger (ConfluenceUtils .class .getName ());
37
+
38
+
34
39
private static final String EXPAND = "expand" ;
35
40
private static final String ID = "id" ;
36
41
private static final String SPACE_KEY = "spaceKey" ;
@@ -53,11 +58,15 @@ public boolean isPageExists(ConfluenceVo confluenceVo) {
53
58
.queryParam (SPACE_KEY , confluenceVo .getSpaceKey ()).queryParam (TITLE , confluenceVo .getTitle ())
54
59
.queryParam (EXPAND , "body.storage,version,ancestors" ).build ().toUri ();
55
60
61
+ LOGGER .log (java .util .logging .Level .FINEST , "Method GET: " +targetUrl );
62
+
56
63
final ResponseEntity <String > responseEntity = new RestTemplate ().exchange (targetUrl , HttpMethod .GET ,
57
64
requestEntity , String .class );
58
-
65
+
59
66
final String jsonBody = responseEntity .getBody ();
60
67
68
+ LOGGER .log (java .util .logging .Level .FINEST , "Response: " +jsonBody );
69
+
61
70
try {
62
71
final String id = JsonPath .read (jsonBody , "$.results[0].id" );
63
72
final Integer version = JsonPath .read (jsonBody , "$.results[0].version.number" );
@@ -97,6 +106,11 @@ public String createPage(ConfluenceVo confluenceVo) {
97
106
confluenceVo .getContent (), confluenceVo .getSpaceKey ()).toJSONString ();
98
107
99
108
final HttpEntity <String > requestEntity = new HttpEntity <>(jsonPostBody , httpHeaders );
109
+
110
+ LOGGER .log (java .util .logging .Level .FINEST , "Method GET: " +targetUrl );
111
+ LOGGER .log (Level .FINEST , "jsonPostBody" +jsonPostBody );
112
+ LOGGER .log (Level .FINEST , "httpHeaders " + httpHeaders .toString ());
113
+
100
114
final HttpEntity <String > responseEntity = new RestTemplate ().exchange (targetUrl , HttpMethod .POST , requestEntity ,
101
115
String .class );
102
116
@@ -198,11 +212,6 @@ private String getAuthenticationString(String userName, String password) {
198
212
new StringBuilder ().append (userName ).append (":" ).append (password ).toString ().getBytes ());
199
213
}
200
214
201
- /**
202
- *
203
- * @param confluenceAuthentication
204
- * @return
205
- */
206
215
private HttpHeaders buildHttpHeaders (final String confluenceAuthentication ) {
207
216
final HttpHeaders headers = new HttpHeaders ();
208
217
headers .set ("Authorization" , String .format ("Basic %s" , confluenceAuthentication ));
0 commit comments