Revisited the fromProductTitleToName according to #20828

This commit is contained in:
Francesco Mangiacrapa 2021-02-25 16:47:42 +01:00
parent 0070ebc06d
commit 00324b4809
2 changed files with 11 additions and 3 deletions

View File

@ -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

View File

@ -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;
}
/**