Skip to content

Commit

Permalink
Merge pull request #2445 from telefonicaid/task/remove_new_line_chars…
Browse files Browse the repository at this point in the history
…_in_arcgis_logs

Task/remove new line chars from arcgis logs
  • Loading branch information
fgalan authored Nov 20, 2024
2 parents 9deed4b + 9847edf commit eb0eb4c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 23 deletions.
2 changes: 1 addition & 1 deletion CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1 @@

- [cygnus-ngsi][cygnus-common] Remove new line chars from Arcgis logs
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ protected ArcgisFeatureTable() {
public ArcgisFeatureTable(String url, String user, String password, String tokenGenUrl,
boolean readOnly, int connectionTimeout, int readTimeout) {
this();
LOGGER.debug("Arcgis constructor.. " + url);

LOGGER.debug("Arcgis url.. " + url);
LOGGER.debug("Arcgis tokenGenUrl.. " + tokenGenUrl);
LOGGER.debug("Arcgis readOnly.. " + readOnly);
LOGGER.debug("ArcgisFeatureTable constructor. Url: " + url + " tokenGenUrl: " + tokenGenUrl + " readOnly: " + readOnly);

Credential credential = new UserCredential(user, password);
try {
Expand All @@ -104,8 +100,8 @@ public ArcgisFeatureTable(String url, String user, String password, String token
connected = true;
} catch (ArcgisException e) {
LOGGER.error("Arcgis error while connecting to Feature Table: (" + e.getMessage() + ")"
+ "\n\t URL: " + url
+ "\n\t tokenGenURL: " + tokenGenUrl);
+ "\t URL: " + url
+ "\t tokenGenURL: " + tokenGenUrl);
connected = false;
setError(e);
this.errorDesc += " " + url + " - " + tokenGenUrl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ public CredentialRestApi(String tokenGenUrl, Credential credential, String refer
* @throws ArcgisException
*/
public Credential getCredential() throws ArcgisException {
LOGGER.debug("------------------ getCredential() " + "\n\t tokenGenUrl: " + tokenGenUrl
+ "\n\t credential: " + credential + "\n\t credential.isExpired(): "
LOGGER.debug("------------------ getCredential() " + "\t tokenGenUrl: " + tokenGenUrl
+ "\t credential: " + credential + "\t credential.isExpired(): "
+ (credential != null ? credential.isExpired() : null));
if (tokenGenUrl != null && (credential == null || credential.isExpired())) {
LOGGER.debug("Creating/Refreshing token.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,12 @@ public boolean verify(String hostname, SSLSession session) {

} catch (UnknownHostException e) {
httpResponse.setResponseCode(HttpURLConnection.HTTP_NOT_FOUND);
httpResponse.setResponseMessage(e.getClass() + "\n" + e.getMessage());
httpResponse.setResponseMessage(e.getClass() + " error message: " + e.getMessage());
} catch (IllegalArgumentException e) {
httpResponse.setResponseMessage("Check url, it may have 'http:/' instead of 'http://' "
+ e.getClass() + "\n" + e.getMessage());
+ e.getClass() + " error message: " + e.getMessage());
} catch (Exception e) {
httpResponse.setResponseMessage(e.getClass() + "\n" + e.getMessage());
httpResponse.setResponseMessage(e.getClass() + " error message: " + e.getMessage());
} finally {
LOGGER.debug("Disposing connection objects");
if (rd != null) {
Expand Down Expand Up @@ -357,7 +357,7 @@ protected static void checkHttpResponse(String httpResponse) throws ArcgisExcept
throw new ArcgisException("Unexpected response format" + httpResponse);
} catch (IllegalStateException | ClassCastException e) {
throw new ArcgisException("checkHttpResponse, Unexpected exception" + e.getMessage()
+ " \n\t" + httpResponse);
+ " httpResponse: " + httpResponse);
} catch (NullPointerException e) {
throw new ArcgisException(
"checkHttpResponse, Null Body recived from server." + httpResponse);
Expand Down Expand Up @@ -470,7 +470,7 @@ protected static void checkHttpSingleResponse(JsonObject node) throws ArcgisExce
}

throw new ArcgisException(errorCode,
"Response Error " + errorCode + " " + message + "\n" + details);
"Response ErrorCode: " + errorCode + " message: " + message + " details: " + details);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ public ResultPage<Feature> getFeatureList(String whereClause, int pageOffset, St
}

HttpResponse response = httpGet(fullUrl, params, this.connectionTimeout, this.readTimeout);
LOGGER.debug("Response code: " + response.getResponseCode() + "\n\t" + response.getBody());
LOGGER.debug("Response code: " + response.getResponseCode() + "\t response body: " + response.getBody());

checkResponse(response);

Expand All @@ -238,7 +238,7 @@ public ResultPage<Feature> getFeatureList(String whereClause, int pageOffset, St
*/
protected void checkResponse(HttpResponse response) throws ArcgisException {
if (!checkHttpResponse(response)) {
String errorMsg = "Error: " + response.getErrorCode() + "\n"
String errorMsg = "Error code: " + response.getErrorCode() + " error message: "
+ response.getErrorMessage();
LOGGER.error(errorMsg);
throw new ArcgisException(errorMsg);
Expand Down Expand Up @@ -274,7 +274,7 @@ public void sendFeatureList(List<Feature> featureList, String action) throws Arc
}

HttpResponse response = httpPost(fullUrl, params, bodyParams, this.connectionTimeout, this.readTimeout);
LOGGER.debug("Response code: " + response.getResponseCode() + "\n\t" + response.getBody());
LOGGER.debug("Response code: " + response.getResponseCode() + "\t response body: " + response.getBody());

checkResponse(response);
}
Expand Down Expand Up @@ -359,7 +359,7 @@ public void deleteEntities(List<String> objectIdList) throws ArcgisException {
}

HttpResponse response = httpPost(fullUrl, params, bodyParams, this.connectionTimeout, this.readTimeout);
LOGGER.debug("Response code: " + response.getResponseCode() + "\n\t" + response.getBody());
LOGGER.debug("Response code: " + response.getResponseCode() + "\t response body: " + response.getBody());

checkResponse(response);

Expand Down Expand Up @@ -406,7 +406,7 @@ public void getTableAttributesInfo() throws ArcgisException {

LOGGER.debug("HttpGet " + fullUrl.toString() + " number of params: " + params.size());
HttpResponse response = httpGet(fullUrl, params, this.connectionTimeout, this.readTimeout);
LOGGER.debug("Response code: " + response.getResponseCode() + "\n\t" + response.getBody());
LOGGER.debug("Response code: " + response.getResponseCode() + "\t response body: " + response.getBody());

checkResponse(response);

Expand All @@ -421,8 +421,8 @@ public void getTableAttributesInfo() throws ArcgisException {

} else {
String errorMsg = "getTableAttributesInfo: Unexpected server response, Error: "
+ response.getErrorCode() + "\n" + response.getErrorMessage();
errorMsg += " \n\t token: " + token;
+ response.getErrorCode() + " error message: " + response.getErrorMessage();
errorMsg += " \t token: " + token;
LOGGER.error(errorMsg);
throw new ArcgisException(errorMsg);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public void aggregate(NGSIEvent event) throws CygnusRuntimeError {
throw new CygnusRuntimeError(e.getMessage());
} catch (Exception e) {
LOGGER.error("[NGSIArcgisAggregator] aggregate - Unexpected Error" + e.getMessage()
+ "\n contextElement: " + contextElement.toString());
+ " contextElement: " + contextElement.toString());
throw new CygnusRuntimeError(e.getMessage());
}

Expand Down

0 comments on commit eb0eb4c

Please sign in to comment.