diff --git a/CHANGELOG.md b/CHANGELOG.md index b428509..6735224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,4 +7,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [v1.0.0-SNAPSHOT] - 2021-02-17 +[#20828] Revisited title size and format [#19378] First Release + diff --git a/src/main/java/org/gcube/datacatalogue/utillibrary/server/utils/CatalogueUtilMethods.java b/src/main/java/org/gcube/datacatalogue/utillibrary/server/utils/CatalogueUtilMethods.java index 716dcea..b75d934 100644 --- a/src/main/java/org/gcube/datacatalogue/utillibrary/server/utils/CatalogueUtilMethods.java +++ b/src/main/java/org/gcube/datacatalogue/utillibrary/server/utils/CatalogueUtilMethods.java @@ -11,12 +11,13 @@ import org.slf4j.LoggerFactory; /** * Some utility methods used within the library. * @author Costantino Perciante at ISTI-CNR (costantino.perciante@isti.cnr.it) + * + * @author updated by Francesco Mangiacrapa at ISTI-CNR */ public class CatalogueUtilMethods { + public static final int MAX_SIZE_OF_CKAN_DATASET_NAME = 100; private static final Logger logger = LoggerFactory.getLogger(CatalogueUtilMethods.class); - private final static String HTTPS = "https"; - private final static String HTTP = "http"; /** * Maps the scope name to the ckan organization name @@ -75,7 +76,12 @@ public class CatalogueUtilMethods { return null; String regexTitleNameTransform = "[^A-Za-z0-9_-]"; - return title.trim().replaceAll(regexTitleNameTransform, "_").replaceAll("_+", "_").toLowerCase(); + title = title.trim().replaceAll(regexTitleNameTransform, "_").replaceAll("_+", "_").toLowerCase(); + if(title.length()>MAX_SIZE_OF_CKAN_DATASET_NAME) { + return title.substring(0,MAX_SIZE_OF_CKAN_DATASET_NAME-1); + } + return title; + } /**