From f819b0f10a833234b4ef203cff2b580a89a5211b Mon Sep 17 00:00:00 2001 From: "francesco.mangiacrapa" Date: Thu, 31 Aug 2023 15:24:06 +0200 Subject: [PATCH] Reduced/Optimized some LOGs, done [#25539] --- CHANGELOG.md | 4 ++ pom.xml | 2 +- .../ConvertToDataValueObjectModel.java | 58 ++++++++++++++----- .../geoportalcommon/SerializerUtil.java | 2 +- .../geoportal/GeoportalConfigUtil.java | 2 +- .../geoportalcommon/util/StringUtil.java | 27 +++++++++ 6 files changed, 77 insertions(+), 18 deletions(-) create mode 100644 src/main/java/org/gcube/application/geoportalcommon/util/StringUtil.java diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f1f9da..993fde1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.2.1-SNAPSHOT] + +- Reduced/Optimized some LOGs [#25539] + ## [v2.2.0] - Integrated the cross-filtering configuration [#25074] diff --git a/pom.xml b/pom.xml index 351dcad..1a34f1c 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ org.gcube.application geoportal-data-common - 2.2.0 + 2.2.1-SNAPSHOT GeoPortal Data Common is common library used by GUI components developed for GeoNA diff --git a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java index e6af43d..6b08a01 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java +++ b/src/main/java/org/gcube/application/geoportalcommon/ConvertToDataValueObjectModel.java @@ -66,6 +66,7 @@ import org.gcube.application.geoportalcommon.shared.geoportal.ucd.HandlerDeclara import org.gcube.application.geoportalcommon.shared.geoportal.ucd.RelationshipDefinitionDV; import org.gcube.application.geoportalcommon.shared.geoportal.ucd.UseCaseDescriptorDV; import org.gcube.application.geoportalcommon.util.DateUtils; +import org.gcube.application.geoportalcommon.util.StringUtil; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; @@ -94,6 +95,8 @@ import com.jayway.jsonpath.Option; */ public class ConvertToDataValueObjectModel { + public static final int _MAX_LENGHT_STRING_AT_INFO = 200; + private static Logger LOG = LoggerFactory.getLogger(ConvertToDataValueObjectModel.class); private static final String NO_TIME = "T00:00"; @@ -174,7 +177,9 @@ public class ConvertToDataValueObjectModel { } ucdVO.setHandlers(listHandlersDV); - LOG.info("returning {}", ucdVO); + LOG.info("returning {}", StringUtil.ellipsize(ucdVO.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", ucdVO); return ucdVO; } @@ -313,7 +318,10 @@ public class ConvertToDataValueObjectModel { dDV.setConfiguration(listGcubeProfiles); dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles hdDV.setConfiguration(dDV); - LOG.info("returning {}", hdDV); + LOG.info("Found config {}", GEOPORTAL_CONFIGURATION_TYPE.gcube_profiles); + LOG.info("returning {}", StringUtil.ellipsize(hdDV.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", hdDV); return hdDV; } case item_fields: { @@ -332,7 +340,10 @@ public class ConvertToDataValueObjectModel { dDV.setConfiguration(listItemFields); dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.item_fields hdDV.setConfiguration(dDV); - LOG.info("returning {}", hdDV); + LOG.info("Found config {}", GEOPORTAL_CONFIGURATION_TYPE.item_fields); + LOG.info("returning {}", StringUtil.ellipsize(hdDV.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", hdDV); return hdDV; } @@ -375,7 +386,10 @@ public class ConvertToDataValueObjectModel { dDV.setConfiguration(listActionsDef); dDV.setConfigurationType(geoportalConfigType); // -> GEOPORTAL_CONFIGURATION_TYPE.actions_definition hdDV.setConfiguration(dDV); - LOG.info("returning {}", hdDV); + LOG.info("Found config {}", GEOPORTAL_CONFIGURATION_TYPE.actions_definition); + LOG.info("returning {}", StringUtil.ellipsize(hdDV.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", hdDV); return hdDV; } @@ -388,7 +402,8 @@ public class ConvertToDataValueObjectModel { ObjectMapper mapper = new ObjectMapper(); for (String asJSONString : jsonConfigurations) { LOG.debug(++i + ") the " + GroupedLayersDV.class.getSimpleName() + " is: " + asJSONString); - TypeReference> typeRef = new TypeReference>() {}; + TypeReference> typeRef = new TypeReference>() { + }; GroupedLayersDV profile = mapper.readValue(asJSONString, typeRef); // GroupedLayersDV profile = org.gcube.application.geoportal.client.utils.Serialization // .read(asJSONString, typeRef); @@ -401,7 +416,10 @@ public class ConvertToDataValueObjectModel { dDV.setConfiguration(listGroupedCL); dDV.setConfigurationType(geoportalConfigType); hdDV.setConfiguration(dDV); - LOG.info("returning {}", hdDV); + LOG.info("Found config {}", GEOPORTAL_CONFIGURATION_TYPE.grouped_overlay_layers); + LOG.info("returning {}", StringUtil.ellipsize(hdDV.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", hdDV); return hdDV; } @@ -414,7 +432,8 @@ public class ConvertToDataValueObjectModel { ObjectMapper mapper = new ObjectMapper(); for (String asJSONString : jsonConfigurations) { LOG.debug(++i + ") the " + GroupedLayersDV.class.getSimpleName() + " is: " + asJSONString); - TypeReference> typeRef = new TypeReference>() {}; + TypeReference> typeRef = new TypeReference>() { + }; GroupedLayersDV profile = mapper.readValue(asJSONString, typeRef); // GroupedLayersDV profile = org.gcube.application.geoportal.client.utils.Serialization // .read(asJSONString, GroupedLayersDV.class); @@ -427,7 +446,10 @@ public class ConvertToDataValueObjectModel { dDV.setConfiguration(listGroupedCL); dDV.setConfigurationType(geoportalConfigType); hdDV.setConfiguration(dDV); - LOG.info("returning {}", hdDV); + LOG.info("Found config {}", GEOPORTAL_CONFIGURATION_TYPE.grouped_cross_filtering_layers); + LOG.info("returning {}", StringUtil.ellipsize(hdDV.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", hdDV); return hdDV; } @@ -457,7 +479,7 @@ public class ConvertToDataValueObjectModel { LOG.trace("toGcubeProfileDV called"); if (gCubeProfile == null) { - LOG.warn(GcubeProfile.class.getSimpleName() + " is null"); + LOG.info(GcubeProfile.class.getSimpleName() + " is null"); return null; } @@ -481,7 +503,9 @@ public class ConvertToDataValueObjectModel { gpVO.setFilePaths(filePathsVO); } - LOG.info("returning: " + gpVO); + LOG.info("returning {}", StringUtil.ellipsize(gpVO.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", gpVO); return gpVO; } @@ -495,7 +519,7 @@ public class ConvertToDataValueObjectModel { LOG.trace("toItemFieldDV called"); if (itemField == null) { - LOG.warn(ItemField.class.getSimpleName() + " is null"); + LOG.info(ItemField.class.getSimpleName() + " is null"); return null; } @@ -507,7 +531,7 @@ public class ConvertToDataValueObjectModel { ifDV.setSearchable(itemField.isSearchable()); ifDV.setSortable(itemField.isSortable()); - LOG.info("returning: " + ifDV); + LOG.debug("returning: " + ifDV); return ifDV; } @@ -534,7 +558,9 @@ public class ConvertToDataValueObjectModel { actDef.setTitle(actionDefinition.getTitle()); actDef.setRoles(roles); - LOG.info("returning: " + actionDefinition); + LOG.info("returning {}", StringUtil.ellipsize(actionDefinition.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", actionDefinition); return actDef; } @@ -548,7 +574,7 @@ public class ConvertToDataValueObjectModel { LOG.trace("toFilePathDV called"); if (filePath == null) { - LOG.warn("List of " + FilePath.class.getSimpleName() + " is null"); + LOG.info("List of " + FilePath.class.getSimpleName() + " is null for {}", filePath); return null; } @@ -557,7 +583,9 @@ public class ConvertToDataValueObjectModel { fpVO.setFieldDefinition(filePath.getFieldDefinition()); fpVO.setGcubeProfileFieldName(filePath.getGcubeProfileFieldName()); - LOG.info("returning: " + fpVO); + LOG.info("returning {}", StringUtil.ellipsize(fpVO.toString(), _MAX_LENGHT_STRING_AT_INFO)); + if (LOG.isDebugEnabled()) + LOG.debug("returning {}", fpVO); return fpVO; } diff --git a/src/main/java/org/gcube/application/geoportalcommon/SerializerUtil.java b/src/main/java/org/gcube/application/geoportalcommon/SerializerUtil.java index 1e73e9a..28fb6bd 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/SerializerUtil.java +++ b/src/main/java/org/gcube/application/geoportalcommon/SerializerUtil.java @@ -97,7 +97,7 @@ public class SerializerUtil { @Override public GeoServerPlatformInfoDV[] deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { - LOG.info("Sono qui: " +jp.getValueAsString()); + LOG.info("deserialize: " +jp.getValueAsString()); return jp.readValueAs(GeoServerPlatformInfoDV[].class); //return jp.readValueAs(GeoServerPlatformInfoDV[].class); //List listPlatform = jp.readValueAs(new TypeReference>() {}); diff --git a/src/main/java/org/gcube/application/geoportalcommon/geoportal/GeoportalConfigUtil.java b/src/main/java/org/gcube/application/geoportalcommon/geoportal/GeoportalConfigUtil.java index c0de725..fc0e3d2 100644 --- a/src/main/java/org/gcube/application/geoportalcommon/geoportal/GeoportalConfigUtil.java +++ b/src/main/java/org/gcube/application/geoportalcommon/geoportal/GeoportalConfigUtil.java @@ -57,7 +57,7 @@ public class GeoportalConfigUtil { JSONArray arrayRoles = new JSONArray(data.get(0).toString()); for (int i = 0; i < arrayRoles.length(); i++) { String role = arrayRoles.get(i).toString(); - LOG.info("for STEP_ID {} read role {}", stepID, role); + LOG.debug("for STEP_ID {} read role {}", stepID, role); listdata.add(role); } }catch (Exception e) { diff --git a/src/main/java/org/gcube/application/geoportalcommon/util/StringUtil.java b/src/main/java/org/gcube/application/geoportalcommon/util/StringUtil.java new file mode 100644 index 0000000..b656494 --- /dev/null +++ b/src/main/java/org/gcube/application/geoportalcommon/util/StringUtil.java @@ -0,0 +1,27 @@ +package org.gcube.application.geoportalcommon.util; + +/** + * The Class StringUtil. + * + * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it + * + * Aug 31, 2023 + */ +public class StringUtil { + + /** + * Ellipsize. + * + * @param input the input + * @param maxLength the max length + * @return the string + */ + public static String ellipsize(String input, int maxLength) { + String ellip = "..."; + if (input == null || input.length() <= maxLength || input.length() < ellip.length()) { + return input; + } + return input.substring(0, maxLength - ellip.length()).concat(ellip); + } + +}