Skip to content

Commit

Permalink
Handle a possible null pointer
Browse files Browse the repository at this point in the history
  • Loading branch information
pamodaaw committed Aug 18, 2020
1 parent 5f91c1b commit 1865c00
Showing 1 changed file with 46 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,19 @@ protected String createUser(ProvisioningEntity provisioningEntity) throws Identi
jsonResponse.toString());
}
} else {
String errorMessage = jsonResponse.getJSONObject("error").getString("message");
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while creating the user " + user.getString(Office365ConnectorConstants.OFFICE365_UPN) +
" in the Azure Active Directory.");
if (jsonResponse.has("error")) {
String errorMessage = jsonResponse.getJSONObject("error").getString("message");
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while creating the user " + user.getString(Office365ConnectorConstants
.OFFICE365_UPN) + " in the Azure Active Directory.");

} else {
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " while creating the user " + user
.getString(Office365ConnectorConstants.OFFICE365_UPN) + " in the Azure Active " +
"Directory.");
}

if (log.isDebugEnabled()) {
log.debug("The response received from server : " + jsonResponse.toString());
Expand Down Expand Up @@ -211,12 +219,18 @@ protected void updateUser(ProvisioningEntity provisioningEntity) throws Identity
} else {
JSONObject jsonResponse = new JSONObject(new JSONTokener(new InputStreamReader(
response.getEntity().getContent())));
String errorMessage = jsonResponse.getJSONObject("error").getString("message");

log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while updating the user with id " + provisionedUserId + " in the Azure Active " +
"Directory.");
if (jsonResponse.has("error")) {
String errorMessage = jsonResponse.getJSONObject("error").getString("message");
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while updating the user with id " + provisionedUserId + " in the Azure Active " +
"Directory.");
} else {
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " while updating the user with id " +
provisionedUserId + " in the Azure Active " + "Directory.");
}

if (log.isDebugEnabled()) {
log.debug("The response received from server : " + jsonResponse.toString());
Expand Down Expand Up @@ -259,12 +273,18 @@ protected void deleteUser(ProvisioningEntity provisioningEntity) throws Identity
} else {
JSONObject jsonResponse = new JSONObject(new JSONTokener(new InputStreamReader(
response.getEntity().getContent())));
String errorMessage = jsonResponse.getJSONObject("error").getString("message");

log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while deleting the user with id " + provisionedUserId + " from the Azure Active " +
"Directory.");
if (jsonResponse.has("error")) {
String errorMessage = jsonResponse.getJSONObject("error").getString("message");
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while deleting the user with id " + provisionedUserId + " from the Azure Active " +
"Directory.");
} else {
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " while deleting the user with id " +
provisionedUserId + " from the Azure Active Directory.");
}

if (log.isDebugEnabled()) {
log.debug("The response received from server : " + jsonResponse.toString());
Expand Down Expand Up @@ -307,12 +327,18 @@ protected void deleteUserPermanently(ProvisioningEntity provisioningEntity) thro
} else {
JSONObject jsonResponse = new JSONObject(new JSONTokener(new InputStreamReader(
response.getEntity().getContent())));
String errorMessage = jsonResponse.getJSONObject("error").getString("message");

log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while permanently removing the user with id " + provisionedUserId +
" in the Azure Active Directory.");
if (jsonResponse.has("error")) {
String errorMessage = jsonResponse.getJSONObject("error").getString("message");
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " with the message '" + errorMessage +
"' while permanently removing the user with id " + provisionedUserId +
" in the Azure Active Directory.");
} else {
log.error("Received response status code: " + response.getStatusLine().getStatusCode() + " "
+ response.getStatusLine().getReasonPhrase() + " while permanently removing the user" +
" with id " + provisionedUserId + " in the Azure Active Directory.");
}

if (log.isDebugEnabled()) {
log.debug("The response received from server : " + jsonResponse.toString());
Expand Down

0 comments on commit 1865c00

Please sign in to comment.