From b4724f336495c81ad1f19b6c046a172132977a59 Mon Sep 17 00:00:00 2001 From: Emil Thies Date: Mon, 15 May 2023 15:26:37 +0200 Subject: [PATCH 1/4] add building jar & doc add signing and upload of build --- .github/workflows/deploy.yml | 25 ++++++++++ pom.xml | 47 ++++++++++++++++++- .../PhoneNumberAreaLabel.java | 10 ++-- .../PhoneNumberAreaLabelImpl.java | 12 +++-- .../PhoneNumberNormalizer.java | 6 ++- .../PhoneNumberNormalizerImpl.java | 4 +- .../dto/DeviceContext.java | 16 +++---- .../dto/DeviceContextLineType.java | 6 +-- .../numberplans/NumberPlan.java | 18 +++---- .../numberplans/PhoneLibWrapper.java | 30 +++++++----- 10 files changed, 128 insertions(+), 46 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4ca623a..3ca3557 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,3 +13,28 @@ jobs: cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import # Verify gpg secret key gpg --list-secret-keys --keyid-format LONG + - uses: actions/checkout@v3 + - name: Set up Maven Central Repository + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'adopt' + server-id: ossrh + server-username: MAVEN_USERNAME + server-password: MAVEN_PASSWORD + - name: Publish package + run: mvn --batch-mode deploy + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + - id: publish-to-central + name: Publish to Central Repository + env: + MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + run: | + mvn \ + --no-transfer-progress \ + --batch-mode \ + -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} \ + clean deploy \ No newline at end of file diff --git a/pom.xml b/pom.xml index abe1694..d04f206 100644 --- a/pom.xml +++ b/pom.xml @@ -164,7 +164,6 @@ - org.jacoco @@ -225,6 +224,52 @@ + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.2.0 + + + attach-javadoc + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-source + + jar + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + diff --git a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabel.java b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabel.java index cc25da2..e0b6c58 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabel.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabel.java @@ -29,16 +29,16 @@ public interface PhoneNumberAreaLabel { * Get a location name for a E164 formated number * * @param e164number number following E164 schema eg. +4961511234567 - * @return Optional - nullable optional with either a national label or if non is available a country label + * @return nullable optional with either a national label or if non is available a country label */ Optional getLocationByE164Number(String e164number); /** * Get a location name for a nationalnumber and region code * - * @param nationalNumber - number without the country prefix like 61511234567 (for number +4961511234567) - * @param regionCode - region code for the number plan like de, us - * @return Optional - nullable optional with location name if present + * @param nationalNumber number without the country prefix like 61511234567 (for number +4961511234567) + * @param regionCode region code for the number plan like de, us + * @return nullable optional with location name if present */ Optional getLocationByNationalNumberAndRegionCode(String nationalNumber, String regionCode); @@ -46,7 +46,7 @@ public interface PhoneNumberAreaLabel { * Get country name string by country code * * @param countryCode - specific telephony code of country (telephone number prefix) like 49 (Germany), 1 (US), - * @return Optional - nullable optional with country name if present + * @return nullable optional with country name if present */ Optional getCountryNameByCountryCode(String countryCode); } diff --git a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabelImpl.java b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabelImpl.java index f3c9645..c80445f 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabelImpl.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberAreaLabelImpl.java @@ -38,9 +38,9 @@ * Concrete implementation of {@link PhoneNumberAreaLabel}, which is using per default provided label configuration from resources folder: *
    *
  • Country Calling Code to German Country Names
  • - *
  • AU-NDC: "Weihnachtsinsel" & "Kokosinseln"
  • - *
  • DE-NDC: German City-Names replacing formal abbreviation with long name - *
  • RU-NDC: Country seperation "Russland" & "Kasachstan"
  • + *
  • AU-NDC: "Weihnachtsinsel" & "Kokosinseln"
  • + *
  • DE-NDC: German City-Names replacing formal abbreviation with long name
  • + *
  • RU-NDC: Country seperation "Russland" & "Kasachstan"
  • *
  • US-NDC: For US and CA just the state names
  • *
*/ @@ -85,8 +85,10 @@ public class PhoneNumberAreaLabelImpl implements PhoneNumberAreaLabel { private HashMap internationalCountryCodes; /** - * Loading {@link PhoneNumberAreaLabelImpl#internationalCountryCodes} from {@link PhoneNumberAreaLabelImpl#countryCodeResource}
- * Loading {@link PhoneNumberAreaLabelImpl#areaCodes} from {@link PhoneNumberAreaLabelImpl#numberPlanResources} + *
    + *
  • Loading {@link PhoneNumberAreaLabelImpl#internationalCountryCodes} from {@link PhoneNumberAreaLabelImpl#countryCodeResource}
  • + *
  • Loading {@link PhoneNumberAreaLabelImpl#areaCodes} from {@link PhoneNumberAreaLabelImpl#numberPlanResources}
  • + *
*/ @PostConstruct public void initFile() { diff --git a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizer.java b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizer.java index b80c9b7..290ea3b 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizer.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizer.java @@ -35,8 +35,9 @@ public interface PhoneNumberNormalizer { /** * Normalizes the number using PhoneLib with some additions to compensate. - *

+ *

* Preferable to {@link PhoneNumberNormalizer#normalizePhoneNumber(String, String)}, because default NDC can be provided, so that more compensation for generating a valid E164 can be done. + *

* @param number plain number to normalize * @param deviceContext information like CC, NDC and {@link de.telekom.phonenumbernormalizer.dto.DeviceContextLineType} from which the number is dialled * @return E164 formatted phone number or at least a dialable version of the number @@ -47,8 +48,9 @@ public interface PhoneNumberNormalizer { /** * Normalizes the number using PhoneLib with some additions to compensate. - *

+ *

* Not as powerful as {@link PhoneNumberNormalizer#normalizePhoneNumber(String, DeviceContext)}, because no default NDC can be set. + *

* @param number plain number to normalize * @param regionCode ISO2 code of the country, which number-plan is used for normalization * @return E164 formatted phone number or at least a dialable version of the number diff --git a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizerImpl.java b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizerImpl.java index 3ba01aa..3748e14 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizerImpl.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/PhoneNumberNormalizerImpl.java @@ -27,8 +27,10 @@ /** - * Concrete implementation of {@link PhoneNumberNormalizer} using {@link PhoneLibWrapper} to normalize a number by mitigating some inaccuracies when it comes to number plans of optional NDC and NAC as zero.
+ * Concrete implementation of {@link PhoneNumberNormalizer} using {@link PhoneLibWrapper} to normalize a number by mitigating some inaccuracies when it comes to number plans of optional NDC and NAC as zero. + *

* Also supports {@link DeviceContext} to enrich a phone number during normalization if the optional NDC is missing. + *

*/ @RequiredArgsConstructor @Component diff --git a/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContext.java b/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContext.java index b5dc2bb..0caa8fa 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContext.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContext.java @@ -55,9 +55,9 @@ public interface DeviceContext { /** * Getter for the Country (Calling) Code of the countries number plan, where the device is originated. * Without international dialing prefix nor trunc code. If not known or not set, it should return DeviceContext.UNKNOWN_VALUE. - *

+ *

* E.G. "49" for Germany - * + *

* @return either a string containing one to three digits representing a country calling code or "unknown" * * @see DeviceContext#getCountryCode() @@ -68,9 +68,9 @@ public interface DeviceContext { /** * Setter for the Country (Calling) Code of the countries number plan, where the device is originated. * Without international deailing prefix nor trunc code. If not known it should be set to DeviceContext.UNKNOWN_VALUE. - *

+ *

* E.G. "49" for Germany - * + *

* @param countryCode either a string containing one to three digits representing a country calling code or "unknown" * * @see DeviceContext#getCountryCode() @@ -81,9 +81,9 @@ public interface DeviceContext { /** * Getter for the National Destination Code (NDC) of the countries number plan, where the device is originated. * Without National Access Code (NAC) nor trunc code. If not known or not set, it should return DeviceContext.UNKNOWN_VALUE. - *

+ *

* E.G. "228" for Bonn in Germany where the Deutsche Telekom Headquarter is located - * + *

* @return either a string containing a variable amount of digits representing a country calling code or "unknown" * * @see DeviceContext#setNationalDestinationCode(String) @@ -94,9 +94,9 @@ public interface DeviceContext { /** * Setter for the National Destination Code (NDC) of the countries number plan, where the device is originated. * Without National Access Code (NAC) nor trunc code. If not known it should be set to DeviceContext.UNKNOWN_VALUE. - *

+ *

* E.G. "228" for Bonn in Germany where the Deutsche Telekom Headquarter is located - * + *

* @param nationalDestinationCode either a string containing a variable amount of digits representing a country calling code or "unknown" * * @see DeviceContext#getCountryCode() diff --git a/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContextLineType.java b/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContextLineType.java index 7d1438d..ce8f9fd 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContextLineType.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/dto/DeviceContextLineType.java @@ -26,9 +26,9 @@ /** * The enum values define the line-type in the context of a device involved in the call - *

+ *

* Currently supported values are for fixed-line, mobile and unknown (also for anything else). - * + *

* @see DeviceContextLineType#FIXEDLINE * @see DeviceContextLineType#MOBILE * @see DeviceContextLineType#UNKNOWN @@ -163,7 +163,7 @@ public static DeviceContextLineType of(String value) { /** * Return the string representation of a line-type enum value - * @return (String) - line-type string representation + * @return line-type string representation * * @see DeviceContextLineType#FIXEDLINE_VALUE * @see DeviceContextLineType#MOBILE_VALUE diff --git a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/NumberPlan.java b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/NumberPlan.java index c37fa47..1b45737 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/NumberPlan.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/NumberPlan.java @@ -28,13 +28,13 @@ /** * This class provides basic logic to check a given number against a simple set of rules to identify if it is short numbers, which does not need normalization. * It also needs to provide its country calling code, to specify where the rules apply. - *

+ *

* PhoneLib already provide a ShortNumbers, but for EU wide 116xxx range only a few countries are configured to support the range. * For Germany only currently assigned numbers are configured which is in contrast to Googles definition of checks, * but nevertheless the corresponding Issues has been rejected. - *

+ *

* Additionally, we designed the NumberPlanFactory to have a NumberPlan class for each DeviceContextLineType, so we can support short numbers which are valid only in fixed-line or mobile context. - * + *

* @see NumberPlanFactory * @see de.telekom.phonenumbernormalizer.dto.DeviceContextLineType */ @@ -42,13 +42,13 @@ public abstract class NumberPlan { private static final Logger LOGGER = LoggerFactory.getLogger(NumberPlan.class); /** - * A subclass needs to provide a Map as tbe rules to identify short numbers + * A subclass needs to provide a Map<String, Integer> as tbe rules to identify short numbers * The key (String) is representing a prefix for the number and the value (Integer) is the total length of the short code (including the prefix) - *

- * e.g. "110"; 3 - the total length is already the length of the prefix, so its exactly the short number - * e.g. "1100"; 5 - the total length is longer than the length of the prefix, so all number from 11000 to 11009 are coverd - * e.g. both rules above can be combined, because longer prefixes are evaluated first, so that partical ranges of rules with shorter prefix can be overriden. - * + *

    + *
  • e.g. "110"; 3 - the total length is already the length of the prefix, so its exactly the short number
  • + *
  • e.g. "1100"; 5 - the total length is longer than the length of the prefix, so all number from 11000 to 11009 are coverd
  • + *
  • e.g. both rules above can be combined, because longer prefixes are evaluated first, so that partical ranges of rules with shorter prefix can be overriden.
  • + *
* @return Map of rules for the short codes * * @see NumberPlan#isNumberPlanValid() diff --git a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java index b62b715..7774190 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java @@ -27,10 +27,11 @@ /** * Wrapper around the PhoneLib library from Google - *

- * Using reflection to access internal information to know if a region has a nation prefix & which one it is.
+ *

+ * Using reflection to access internal information to know if a region has a nation prefix & which one it is. + *

* Providing own NumberPlans logic as an alternative to PhoneLib ShortNumber. - * + *

* @see PhoneLibWrapper#getMetadata() * @see NumberPlan */ @@ -132,8 +133,9 @@ public boolean isNormalizingTried() { /** * Using PhoneLib short number utility if it identifies the given number as a short number, which would not need a NAC. - *

+ *

* This is a fallback for {@link PhoneLibWrapper#isShortNumber(NumberPlan)}, when we do not have an own number plan information. + *

* @return if PhoneLib identifies given number as a short number * * @see PhoneLibWrapper#PhoneLibWrapper(String, String) @@ -145,9 +147,9 @@ public boolean isShortNumber() { /** * Using own {@link NumberPlan} to identify if the given number is a short number, which would not need a NAC. - *

+ *

* If no number plan is given, {@link PhoneLibWrapper#isShortNumber} is used as fallback. - * + *

* @param numberplan the number plan we identified to be used for a check * @return if number plan or as fallback PhoneLib identifies given number as a short number * @@ -162,8 +164,9 @@ public boolean isShortNumber(NumberPlan numberplan) { /** * If we have a plain national number based on regions number plan and potential NAC logic. - *

+ *

* For a number plan without NAC logic, it will always return false! + *

* @return if given number could have CC and NAC, but does not have any of them. */ public boolean hasNoCountryCodeNorNationalAccessCode() { @@ -177,8 +180,9 @@ public boolean hasNoCountryCodeNorNationalAccessCode() { /** * Using PhoneLib to get a E164 formatted representation of the given number - *

+ *

* This is a straight invocation, so no compensation of some inaccuracy is done here. + *

* @return E164 format of the given phone number * * @see PhoneLibWrapper#PhoneLibWrapper(String, String) @@ -327,8 +331,9 @@ private static String nationalPhoneNumberWithoutNationalPrefix(Phonenumber.Phone /** * Using PhoneLib to get the Country Calling Code for a region code - *

- * e.g. "DE" -> "49" + *

+ * e.g. "DE" is "49" + *

* @param regionCode ISO2 code of a region * @return country calling code of the region or 0 if regionCode is invalid. */ @@ -338,8 +343,9 @@ public static int getCountryCodeForRegion(String regionCode) { /** * Using PhoneLib to get the region code for a Country Calling Code - *

- * e.g. "49" -> "DE" + *

+ * e.g. "49" is "DE" + *

* @param countryCode only digits without IDP * @return regionCode or {@link PhoneLibWrapper#UNKNOWN_REGIONCODE} if countryCode is invalid. */ From 3a03d3bc0bb1ec638f78d3767d8be0a779a78a48 Mon Sep 17 00:00:00 2001 From: Emil Thies Date: Mon, 15 May 2023 15:30:31 +0200 Subject: [PATCH 2/4] removed crosslinks in javadoc, because reference could not be established by maven builder --- .../numberplans/PhoneLibWrapper.java | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java index 7774190..cb80983 100644 --- a/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java +++ b/src/main/java/de/telekom/phonenumbernormalizer/numberplans/PhoneLibWrapper.java @@ -32,7 +32,6 @@ *

* Providing own NumberPlans logic as an alternative to PhoneLib ShortNumber. *

- * @see PhoneLibWrapper#getMetadata() * @see NumberPlan */ @Data @@ -95,9 +94,6 @@ public class PhoneLibWrapper { * Initialize the wrapper by giving a phone number to be analyzed against a number plan of a given region * @param number the phone number to be analyzed * @param regionCode the ISO2 Code of the Region / Country, which telephone number plan is used - * - * @see PhoneLibWrapper#getDialableNumber() - * @see PhoneLibWrapper#getSemiNormalizedNumber() */ public PhoneLibWrapper(String number, String regionCode) { this.regionCode = regionCode; @@ -125,7 +121,6 @@ public PhoneLibWrapper(String number, String regionCode) { * @return {@link PhoneLibWrapper#isNormalizingTried} * * @see PhoneLibWrapper#PhoneLibWrapper(String, String) - * @see PhoneLibWrapper#getSemiNormalizedNumber() */ public boolean isNormalizingTried() { return isNormalizingTried; @@ -196,10 +191,9 @@ public String getE164Formatted() { * so we could permanently add a default NDC and NAC to the given number and for this new value the method directly return a E164 formatted representation. * @param nationalAccessCode the NAC to be added e.g. for Germany it would be "0" * @param defaultNationalDestinationCode the NDC to be added depending on the use telephone line origination. - * @return if possible a E164 formatted representation or the {@link PhoneLibWrapper#getDialableNumber()} representation of the given number. + * @return if possible a E164 formatted representation or just the diallable representation of the given number. * * @see PhoneLibWrapper#PhoneLibWrapper(String, String) - * @see PhoneLibWrapper#getSemiNormalizedNumber() */ public String extendNumberByDefaultAreaCodeAndCountryCode(String nationalAccessCode, String defaultNationalDestinationCode) { String nationalPhoneNumberWithoutNationalAccessCode = this.getNationalPhoneNumberWithoutNationalAccessCode(); @@ -257,8 +251,6 @@ private static Phonenumber.PhoneNumber parseNumber(String number, String regionC /** * The National Access Code used before the National Destination Code in the given region from PhoneLib * @return NAC of given {@link PhoneLibWrapper#regionCode} - * - * @see PhoneLibWrapper#getMetadata() */ public String getNationalAccessCode() { if (metadata == null) { @@ -270,8 +262,6 @@ public String getNationalAccessCode() { /** * From PhoneLib, if a National Access Code is used before the National Destination Code in the given region * @return if given {@link PhoneLibWrapper#regionCode} is using NAC - * - * @see PhoneLibWrapper#getMetadata() */ public boolean hasRegionNationalAccessCode() { return metadata != null && metadata.hasNationalPrefix(); From b27de05e1e109aa94f65459e2901cc76a93d7eb9 Mon Sep 17 00:00:00 2001 From: Emil Thies Date: Mon, 15 May 2023 15:33:52 +0200 Subject: [PATCH 3/4] add distribution management settings --- pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pom.xml b/pom.xml index d04f206..e8993d4 100644 --- a/pom.xml +++ b/pom.xml @@ -344,4 +344,12 @@
+ + + + ossrh + Central Repository OSSRH + https://oss.sonatype.org/service/local/staging/deploy/maven2/ + + From 11c37d6d5b56f8382e2fbdd995304593c408a5d6 Mon Sep 17 00:00:00 2001 From: Emil Thies Date: Mon, 15 May 2023 15:48:44 +0200 Subject: [PATCH 4/4] add meta data about involved developers --- pom.xml | 58 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index e8993d4..ff9ccd2 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,6 @@ --> - 4.0.0 de.telekom.phonenumber @@ -25,6 +24,7 @@ Phonenumber Normalizer Library to work with phonenumbers, especially to fix googles PhoneLib ignoring German Landline specifics. 1.1.0-SNAPSHOT + jar @@ -33,6 +33,26 @@ repo + + + Emil Thies + E.Thies@telekom.de + Deutsche Telekom AG + https://github.com/telekom + + + Jens Hellwig + Jens.Hellwig@telekom.de + Deutsche Telekom AG + https://github.com/telekom + + + Kai Kreuzer + Kai.Kreuzer@telekom.de + Deutsche Telekom AG + https://github.com/telekom + + scm:git:https://github.com/telekom/phonenumber-normalizer.git @@ -120,15 +140,15 @@ 2.203 test - - org.codehaus.groovy - groovy-all - 3.0.17 - test - pom - - - + + org.codehaus.groovy + groovy-all + 3.0.17 + test + pom + + + org.testng testng @@ -213,14 +233,14 @@ 2023 - -
com/mycila/maven/plugin/license/templates/APACHE-2.txt
- - **/README - src/test/resources/** - src/main/resources/** - -
+ +
com/mycila/maven/plugin/license/templates/APACHE-2.txt
+ + **/README + src/test/resources/** + src/main/resources/** + +
@@ -352,4 +372,4 @@ https://oss.sonatype.org/service/local/staging/deploy/maven2/ -
+ \ No newline at end of file