<%@ page import="com.google.appengine.repackaged.com.google.gson.Gson" %> <%@ page import="com.google.common.collect.ImmutableList" %> <%@ page import="com.google.phonenumbers.ServletMain" %> <%@ page import="com.google.phonenumbers.migrator.MigrationEntry" %> <%@ page import="com.google.phonenumbers.migrator.MigrationResult" %> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <% final String E164_NUMBERS_LINK = "https://support.twilio.com/hc/en-us/articles/223183008-Formatting-International-Phone-Numbers"; final String COUNTRY_CODE_LINK = "https://countrycode.org/"; // TODO: use documentation link from base repository when forked repository has been merged in final String DOCUMENTATION_LINK = "https://github.com/TomiwaOke/libphonenumber/tree/master/migrator/README.md"; final String ISSUE_TRACKER_LINK = "https://issuetracker.google.com/issues/new?component=192347"; final String GUIDELINES_LINK = "https://github.com/google/libphonenumber/blob/master/CONTRIBUTING.md#filing-a-code-issue"; final Gson gson = new Gson(); ImmutableList validMigrations = (ImmutableList) request.getAttribute("validMigrations"); ImmutableList invalidMigrations = (ImmutableList) request.getAttribute("invalidMigrations"); ImmutableList validUntouchedNums = (ImmutableList) request.getAttribute("validUntouchedNumbers"); ImmutableList invalidUntouchedNums = (ImmutableList) request.getAttribute("invalidUntouchedNumbers"); %> Migrator

Phone Number Migrator

The migrator is a tool which takes in a given E.164 phone number(s) input as well as the corresponding BCP-47 country code. The tool will then check the validity of the phone number based on the country code and if possible, will convert the number into a valid, dialable format.

The following are the two available migration types that can be performed:

  • Single Number Migration: input a single E.164 phone number with its corresponding BCP-47 country code. If there is an available migration that can be performed on the number, it will be converted to the new format based on the specified migration rules.

  • File Migration: input a text file containing one E.164 number per line along with the BCP-47 country code that corresponds to the numbers in the text file. All numbers in the text file that match available migrations will be migrated and there will be the option of downloading a new text file containing the updated numbers. By default, invalid migrations and numbers that did not go through a process of migration will be written to file in their original text file format.

For more information on the capabilities of the migrator as well as instructions on how to install the command line tool, please view the documentation.

<% if (request.getAttribute("numberError") == null && request.getAttribute("number") != null) { if (request.getAttribute("validMigration") != null) { out.print("

Valid +" + request.getAttribute("numberCountryCode") + " Phone Number Produced!

"); out.print("

The stale number '" + request.getAttribute("number") + "' was successfully migrated into the" + " phone number: +" + request.getAttribute("validMigration") + "

"); } else if (request.getAttribute("invalidMigration") != null) { out.print("

Invalid +" + request.getAttribute("numberCountryCode") + " Migration

"); out.print("

The stale number '" + request.getAttribute("number") + "' was migrated into the phone number:" + " +" + request.getAttribute("invalidMigration") + ". However this was not seen as valid using our internal" + " metadata for country code +" + request.getAttribute("numberCountryCode") + ".

"); } else if (request.getAttribute("alreadyValidNumber") != null) { out.print("

Already Valid +" + request.getAttribute("numberCountryCode") + " Phone Number!

"); out.print("

The entered phone number was already seen as being in a valid, dialable format based on our" + " metadata for country code +" + request.getAttribute("numberCountryCode") + ". Here is the number in" + " its clean E.164 format: +" + request.getAttribute("alreadyValidNumber") + "

"); } else { out.print("

Non-migratable +" + request.getAttribute("numberCountryCode") + " Phone Number

"); out.print("

The phone number '" + request.getAttribute("number") + "' was not seen as a valid number and" + " no migration recipe could be found for country code +" + request.getAttribute("numberCountryCode") + " to migrate it. This may be because you have entered a country code which does not correctly correspond" + " to the given phone number or the specified number has never been valid.

"); } out.print("

Think there's an issue? File one here following the given guidelines.

"); } else if (request.getAttribute("fileError") == null && request.getAttribute("fileName") != null) { out.print("

'" + request.getAttribute("fileName") + "' Migration Report for Country Code: +" + request.getAttribute("fileCountryCode") + "

"); out.print("

Below is a chart showing the ratio of numbers from the entered file that were able to be migrated" + " using '+" + request.getAttribute("fileCountryCode") + "' migration recipes. To understand more," + " select a given segment from the chart below.

"); out.print("
"); out.print("
"); out.print(""); out.print(""); out.print(""); out.print(""); out.print("
"); } %>

Single Number Migration

<%=request.getAttribute("numberError") == null ? "" : request.getAttribute("numberError")%>

Enter a phone number in E.164 format. Inputted numbers can include spaces, curved brackets and hyphens

"/>

Enter the BCP-47 country code in which the specified E.164 phone number belongs to

"/>

(Optional) Upload a csv file containing a custom recipes table to be used for migrations. To understand how to create a custom recipe file, please view the documentation.

File Migration

<%=request.getAttribute("fileError") == null ? "" : request.getAttribute("fileError")%>

Upload a file containing one E.164 phone number per line. Numbers can include spaces, curved brackets and hyphens

Enter the BCP-47 country code in which the E.164 phone numbers from the specified file belong to

(Optional) Upload a csv file containing a custom recipes table to be used for migrations. To understand how to create a custom recipe file, please view the documentation.