1818import org .springframework .web .client .RestTemplate ;
1919
2020import java .io .IOException ;
21- import java .io .StringReader ;
2221import java .io .StringWriter ;
2322import java .net .URI ;
2423import java .util .ArrayList ;
@@ -37,41 +36,39 @@ public class ManageClient extends LoggingObject {
3736 private PayloadParser payloadParser ;
3837
3938 public ManageClient (ManageConfig config ) {
40- setManageConfig (config );
39+ this .manageConfig = config ;
40+ if (logger .isInfoEnabled ()) {
41+ logger .info ("Initializing ManageClient with manage config of: {}" , config );
42+ }
4143 }
4244
4345 /**
44- * Uses the given ManageConfig instance to construct a Spring RestTemplate for communicating with the Manage API.
45- * In addition, if adminUsername on the ManageConfig instance differs from username, then a separate RestTemplate is
46- * constructed for making calls to the Manage API that need user with the manage-admin and security roles, which is
47- * often an admin user.
46+ * Deprecated in 6.0.1 with the intention of removing in 7.0.0 so that the underlying ManageConfig can be declared
47+ * as final.
4848 *
49- * @param config
49+ * @deprecated
5050 */
51+ @ Deprecated (since = "6.0.1" , forRemoval = true )
5152 public void setManageConfig (ManageConfig config ) {
5253 this .manageConfig = config ;
53- if (logger .isInfoEnabled ()) {
54- logger .info ("Initializing ManageClient with manage config of: " + config );
55- }
5654 }
5755
5856 /**
59- * Use this when you want to provide your own RestTemplate as opposed to using the one that's constructed via a
60- * ManageConfig instance.
61- *
62- * @param restTemplate
57+ * Deprecated in 6.0.1 as it will not work without a ManageConfig instance being set, which is then unlikely to
58+ * be consistent with the given RestTemplate.
59+ * @deprecated
6360 */
61+ @ Deprecated (since = "6.0.1" , forRemoval = true )
6462 public ManageClient (RestTemplate restTemplate ) {
6563 this (restTemplate , restTemplate );
6664 }
6765
6866 /**
69- * Use this when you want to provide your own RestTemplate as opposed to using the one that's constructed via a
70- * ManageConfig instance.
71- *
72- * @param restTemplate
73- * @param adminRestTemplate
67+ * Deprecated in 6.0.1 as it will not work without a ManageConfig instance being set, which is then unlikely to
68+ * be consistent with the given RestTemplate.
69+ * @deprecated
7470 */
71+ @ Deprecated (since = "6.0.1" , forRemoval = true )
7572 public ManageClient (RestTemplate restTemplate , RestTemplate adminRestTemplate ) {
7673 this .restTemplate = restTemplate ;
7774 this .securityUserRestTemplate = adminRestTemplate ;
@@ -257,8 +254,10 @@ public HttpEntity<String> buildXmlEntity(String xml) {
257254
258255 protected void logRequest (String path , String contentType , String method ) {
259256 if (logger .isInfoEnabled ()) {
260- String username = String .format ("as user '%s' " , manageConfig .getUsername ());
261- logger .info ("Sending {} {} request {}to path: {}" , contentType , method , username , buildUri (path ));
257+ String username = manageConfig != null && StringUtils .hasText (manageConfig .getUsername ()) ?
258+ String .format ("as user '%s' " , manageConfig .getUsername ()) : "" ;
259+ URI uri = buildUri (path );
260+ logger .info ("Sending {} {} request {}to path: {}" , contentType , method , username , uri );
262261 }
263262 }
264263
@@ -268,7 +267,8 @@ protected void logSecurityUserRequest(String path, String contentType, String me
268267 if (!"" .equals (username )) {
269268 username = String .format ("as user '%s' (who should have the 'manage-admin' and 'security' roles) " , username );
270269 }
271- logger .info ("Sending {} {} request {}to path: {}" , contentType , method , username , buildUri (path ));
270+ URI uri = buildUri (path );
271+ logger .info ("Sending {} {} request {}to path: {}" , contentType , method , username , uri );
272272 }
273273 }
274274
@@ -307,6 +307,7 @@ private void initializeSecurityUserRestTemplate() {
307307 }
308308
309309 public URI buildUri (String path ) {
310+ Objects .requireNonNull (manageConfig , "A ManageConfig instance must be provided" );
310311 return manageConfig .buildUri (path );
311312 }
312313
@@ -321,6 +322,7 @@ public ManageConfig getManageConfig() {
321322 return manageConfig ;
322323 }
323324
325+ @ Deprecated (since = "6.0.1" , forRemoval = true )
324326 public void setRestTemplate (RestTemplate restTemplate ) {
325327 this .restTemplate = restTemplate ;
326328 }
@@ -332,6 +334,7 @@ public RestTemplate getSecurityUserRestTemplate() {
332334 return securityUserRestTemplate ;
333335 }
334336
337+ @ Deprecated (since = "6.0.1" , forRemoval = true )
335338 public void setSecurityUserRestTemplate (RestTemplate restTemplate ) {
336339 this .securityUserRestTemplate = restTemplate ;
337340 }
0 commit comments