Fix review comments in PR
@@ -23,8 +23,6 @@ package org.wso2.carbon.identity.mgt.endpoint.util.client;
import org.apache.axis2.transport.http.HTTPConstants;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.apache.http.HttpStatus;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -34,6 +32,7 @@ import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import org.json.JSONTokener;
@@ -58,7 +57,7 @@ import java.nio.charset.StandardCharsets;
public class SelfRegistrationMgtClient {
private static final String CLIENT = "Client ";
- private static final Log log = LogFactory.getLog(SelfRegistrationMgtClient.class);
+ private static final Logger log = Logger.getLogger(SelfRegistrationMgtClient.class);
private static final String CONSENT_API_RELATIVE_PATH = "/api/identity/consent-mgt/v1.0";
private static final String USERNAME_VALIDATE_API_RELATIVE_PATH = "/api/identity/user/v1.0/validate-username";
private static final String PURPOSE_ID = "purposeId";
@@ -207,7 +206,7 @@ public class SelfRegistrationMgtClient {
* tenant.
* @return An integer with status code.
* @throws SelfRegistrationMgtClientException Self Registration Management Exception.
- * @Deprecated Use {@link #checkUsernameValidity(User user, boolean skipSignUpCheck)}
+ * @deprecated Use {@link #checkUsernameValidity(User user, boolean skipSignUpCheck)}
*/
@Deprecated
public Integer checkUsernameValidity(String username, boolean skipSignUpCheck) throws
@@ -231,8 +230,8 @@ public class SelfRegistrationMgtClient {
SelfRegistrationMgtClientException {
if (log.isDebugEnabled()) {
- log.debug("Checking username validating for username: " + user.getUsername() +
- ". SkipSignUpCheck flag is set to " + skipSignUpCheck + ".");
+ log.debug("Checking username validating for username: {}. SkipSignUpCheck flag is set to {}.",
+ user.getUsername(), skipSignUpCheck);
}
try (CloseableHttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build()) {
@@ -265,23 +264,23 @@ public class SelfRegistrationMgtClient {
try (CloseableHttpResponse response = httpclient.execute(post)) {
if (log.isDebugEnabled()) {
- log.debug("HTTP status " + response.getStatusLine().getStatusCode() + " when validating username: "
- + user.getUsername());
+ log.debug("HTTP status {} when validating username: {}." ,
+ response.getStatusLine().getStatusCode(), user.getUsername());
}
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
JSONObject jsonResponse = new JSONObject(
new JSONTokener(new InputStreamReader(response.getEntity().getContent())));
if (log.isDebugEnabled()) {
- log.debug("Username validation response: " + jsonResponse.toString(2)
- + " for username: " + user.getUsername());
+ log.debug("Username validation response: {} for username: {}.",
+ jsonResponse.toString(2), user.getUsername());
}
return jsonResponse.getInt("statusCode");
} else {
// Logging and throwing since this is a client
if (log.isDebugEnabled()) {
- log.debug("Unexpected response code found: " + response.getStatusLine().getStatusCode()
- + " when validating username: " + user.getUsername());
+ log.debug("Unexpected response code found: {} when validating username: {}.",
+ response.getStatusLine().getStatusCode(), user.getUsername());
}
throw new SelfRegistrationMgtClientException("Error while checking username validity for user : "
+ user.getUsername());
