This is an automated email from the ASF dual-hosted git repository. sblackmon pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/streams.git
The following commit(s) were added to refs/heads/master by this push: new e6fce17 STREAMS-646 support new Multi-Field requests in streams-processor-fullcontact new 700bc22 Merge pull request #484 from steveblackmon/STREAMS-646 e6fce17 is described below commit e6fce17a75a788f7b3fa74a01d22c1834f57a867 Author: Steve Blackmon <sblack...@apache.org> AuthorDate: Thu Jul 11 16:43:41 2019 -0500 STREAMS-646 support new Multi-Field requests in streams-processor-fullcontact --- .../streams-processor-fullcontact/pom.xml | 24 +++++++------- .../apache/streams/fullcontact/FullContact.java | 24 ++++++++++---- .../fullcontact/api/EnrichPersonRequest.json | 37 ++++++++++++++++++---- .../streams/fullcontact/api/LocationQuery.json | 35 ++++++++++++++++++++ .../apache/streams/fullcontact/api/NameQuery.json | 23 ++++++++++++++ .../streams/fullcontact/api/ProfileQuery.json | 26 +++++++++++++++ .../config/FullContactConfiguration.json | 3 ++ 7 files changed, 145 insertions(+), 27 deletions(-) diff --git a/streams-contrib/streams-processor-fullcontact/pom.xml b/streams-contrib/streams-processor-fullcontact/pom.xml index dc9440c..5a0c6cd 100644 --- a/streams-contrib/streams-processor-fullcontact/pom.xml +++ b/streams-contrib/streams-processor-fullcontact/pom.xml @@ -87,20 +87,10 @@ </testResource> </testResources> <plugins> - <!--<plugin>--> - <!--<groupId>org.apache.streams.plugins</groupId>--> - <!--<artifactId>streams-plugin-pojo</artifactId>--> - <!--<version>${project.version}</version>--> - <!--<configuration>--> - <!--<sourcePaths>--> - <!--<sourcePath>${project.basedir}/src/main/jsonschema</sourcePath>--> - <!--</sourcePaths>--> - <!--</configuration>--> - <!--</plugin>--> <plugin> <groupId>org.jsonschema2pojo</groupId> <artifactId>jsonschema2pojo-maven-plugin</artifactId> - <version>0.5.1</version> + <version>1.0.1</version> <executions> <execution> <phase>generate-sources</phase> @@ -110,7 +100,9 @@ </execution> </executions> <configuration> - <annotationStyle>none</annotationStyle> + <annotationStyle>jackson2</annotationStyle> + <customAnnotator>org.apache.streams.plugins.JuneauPojoAnnotator</customAnnotator> + <generateBuilders>true</generateBuilders> <includeAdditionalProperties>false</includeAdditionalProperties> <includeHashcodeAndEquals>true</includeHashcodeAndEquals> <outputDirectory>${project.basedir}/target/generated-sources/pojo</outputDirectory> @@ -120,10 +112,16 @@ <sourcePaths> <sourcePath>${project.basedir}/src/main/jsonschema</sourcePath> </sourcePaths> - <useCommonsLang3>true</useCommonsLang3> <useDoubleNumbers>true</useDoubleNumbers> <useLongIntegers>true</useLongIntegers> </configuration> + <dependencies> + <dependency> + <groupId>org.apache.streams.plugins</groupId> + <artifactId>streams-plugin-pojo</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> diff --git a/streams-contrib/streams-processor-fullcontact/src/main/java/org/apache/streams/fullcontact/FullContact.java b/streams-contrib/streams-processor-fullcontact/src/main/java/org/apache/streams/fullcontact/FullContact.java index e153825..0d0eff8 100644 --- a/streams-contrib/streams-processor-fullcontact/src/main/java/org/apache/streams/fullcontact/FullContact.java +++ b/streams-contrib/streams-processor-fullcontact/src/main/java/org/apache/streams/fullcontact/FullContact.java @@ -34,6 +34,7 @@ import org.apache.juneau.rest.client.RestClientBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.StringReader; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.TimeUnit; @@ -47,11 +48,11 @@ public class FullContact implements CompanyEnrichment, PersonEnrichment { private FullContactConfiguration configuration; - JsonParser parser; - JsonSerializer serializer; + protected JsonParser parser; + protected JsonSerializer serializer; - RestClientBuilder restClientBuilder; - RestClient restClient; + protected RestClientBuilder restClientBuilder; + protected RestClient restClient; private static Map<FullContactConfiguration, FullContact> INSTANCE_MAP = new ConcurrentHashMap<>(); @@ -88,6 +89,9 @@ public class FullContact implements CompanyEnrichment, PersonEnrichment { .parser(parser) .serializer(serializer) .rootUrl(baseUrl()); + if(configuration.getDebug() == true) { + this.restClientBuilder.debug(); + } this.restClient = restClientBuilder.build(); } @@ -98,9 +102,12 @@ public class FullContact implements CompanyEnrichment, PersonEnrichment { @Override public CompanySummary enrichCompany(EnrichCompanyRequest request) { try { + String requestJson = serializer.serialize(request); RestCall call = restClient .doPost(baseUrl() + "company.enrich") - .input(request); + .accept("application/json") + .contentType("application/json") + .body(new StringReader(requestJson)); String responseJson = call.getResponseAsString(); CompanySummary result = parser.parse(responseJson, CompanySummary.class); return result; @@ -115,9 +122,12 @@ public class FullContact implements CompanyEnrichment, PersonEnrichment { @Override public PersonSummary enrichPerson(EnrichPersonRequest request) { try { + String requestJson = serializer.serialize(request); RestCall call = restClient - .doPost(baseUrl() + "company.enrich") - .input(request); + .doPost(baseUrl() + "person.enrich") + .accept("application/json") + .contentType("application/json") + .body(new StringReader(requestJson)); String responseJson = call.getResponseAsString(); PersonSummary result = parser.parse(responseJson, PersonSummary.class); return result; diff --git a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/EnrichPersonRequest.json b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/EnrichPersonRequest.json index 1e7d2a9..b4862c2 100644 --- a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/EnrichPersonRequest.json +++ b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/EnrichPersonRequest.json @@ -9,19 +9,42 @@ "properties": { "email": { "type": "string", - "description": "The email address of the contact. (Queryable)" + "description": "One email addresses of the contact. Can accept cleartext, an MD5 or SHA-256 hash representation of the email address to query. Be certain to lowercase and trim the email address prior to hashing. There is a limit of 10 hashed emails (Queryable)" }, - "emailHash": { + "emails": { + "type": "array", + "description": "One or many email addresses of the contact. Can accept cleartext, an MD5 or SHA-256 hash representation of the email address to query. Be certain to lowercase and trim the email address prior to hashing. (Queryable)", + "items": { + "type": "string" + } + }, + "phone": { "type": "string", - "description": "Either an MD5 or SHA-256 hash representation of the email address to query. Be certain to lowercase and trim the email address prior to hashing. (Queryable)" + "description": "Phone number of the contact. (Queryable)" + }, + "phones": { + "type": "array", + "description": "One or many phone numbers of the contact. (Queryable)", + "items": { + "type": "string" + } + }, + "location": { + "$ref": "./LocationQuery.json" + }, + "name": { + "$ref": "./NameQuery.json" + }, + "profiles": { + "type": "array", + "description": "URLs, IDs and usernames to the profiles on the social platform. (Queryable)", + "items": { + "$ref": "./ProfileQuery.json" + } }, "twitter": { "type": "string", "description": "Twitter handle of the contact. Acceptable formats include handle (with or without \"@\"), as well as the URL to the profile. (Queryable)" - }, - "phone": { - "type": "string", - "description": "Phone number of the contact. (Queryable)" } } } \ No newline at end of file diff --git a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/LocationQuery.json b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/LocationQuery.json new file mode 100644 index 0000000..7143ee6 --- /dev/null +++ b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/LocationQuery.json @@ -0,0 +1,35 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.fullcontact.api.LocationQuery", + "properties": { + "addressLine1": { + "type": "string", + "description": "The first address line for each location. Only queryable when provided in conjunction with name." + }, + "addressLine2": { + "type": "string", + "description": "The second address line for each location. Only queryable when provided in conjunction with name." + }, + "city": { + "type": "string", + "description": "The city of each location. Only queryable when provided in conjunction with name." + }, + "region": { + "type": "string", + "description": "The region of each location. This is often the state or province. Only queryable when provided in conjunction with name." + }, + "regionCode": { + "type": "string", + "description": "The region code of each location. Only queryable when provided in conjunction with name." + }, + "postalCode": { + "type": "string", + "description": "The postal or ZIP code for each location. Can accept Zip + 4 or Zip. Only queryable when provided in conjunction with name." + } + } +} \ No newline at end of file diff --git a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/NameQuery.json b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/NameQuery.json new file mode 100644 index 0000000..d8ce3fe --- /dev/null +++ b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/NameQuery.json @@ -0,0 +1,23 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.fullcontact.api.NameQuery", + "properties": { + "full": { + "type": "string", + "description": "Full name of the contact (givenName, familyName). Only queryable when provided in conjunction with postal address." + }, + "given": { + "type": "string", + "description": "The given name (first name) of the individual. Only queryable when provided in conjunction with postal address." + }, + "family": { + "type": "string", + "description": "The family name (last name) of the individual. Only queryable when provided in conjunction with postal address." + } + } +} \ No newline at end of file diff --git a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/ProfileQuery.json b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/ProfileQuery.json new file mode 100644 index 0000000..404ebbc --- /dev/null +++ b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/api/ProfileQuery.json @@ -0,0 +1,26 @@ +{ + "type": "object", + "$schema": "http://json-schema.org/draft-03/schema", + "$license": [ + "http://www.apache.org/licenses/LICENSE-2.0" + ], + "id": "#", + "javaType": "org.apache.streams.fullcontact.api.ProfileQuery", + "properties": { + "service": { + "type": "string" + }, + "url": { + "type": "string", + "description": "URL to the profile on the social platform." + }, + "userid": { + "type": "string", + "description": "User ID associated with the profile." + }, + "username": { + "type": "string", + "description": "Displayable username of the profile." + } + } +} \ No newline at end of file diff --git a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/config/FullContactConfiguration.json b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/config/FullContactConfiguration.json index 7ca3ac6..075e7d7 100644 --- a/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/config/FullContactConfiguration.json +++ b/streams-contrib/streams-processor-fullcontact/src/main/jsonschema/org/apache/streams/fullcontact/config/FullContactConfiguration.json @@ -8,6 +8,9 @@ "javaInterfaces": ["java.io.Serializable"], "javaType": "org.apache.streams.fullcontact.config.FullContactConfiguration", "properties": { + "debug": { + "type": "boolean" + }, "token": { "type": "string" }