Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Alter ip column in events to for IPV6 and add event tracking to V2 #7019

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions orcid-persistence/src/main/resources/db-master.xml
Original file line number Diff line number Diff line change
Expand Up @@ -387,4 +387,5 @@
<include file="/db/updates/dw_views_with_4_months_interval.xml" />
<include file="/db/updates/dw_papi_event_stats.xml" />
<include file="/db/updates/add_ip_col_in_events.xml" />
<include file="/db/updates/alter_ip_col_in_events.xml" />
</databaseChangeLog>
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<changeSet id="ADD-FIELD-TO-EVENT" author="Daniel Palafox" dbms="hsqldb">
<preConditions onFail="MARK_RAN">
<columnExists tableName="event" columnName="ip"/>
</preConditions>
<sql>ALTER TABLE event ALTER COLUMN ip VARCHAR(60);</sql>
</changeSet>

<changeSet id="ADD-FIELD-TO-EVENT_STATS" author="Daniel Palafox" dbms="hsqldb">
<preConditions onFail="MARK_RAN">
<columnExists tableName="event_stats" columnName="ip"/>
</preConditions>
<sql>ALTER TABLE event_stats ALTER COLUMN ip VARCHAR(60);</sql>
</changeSet>

<changeSet id="ADD-FIELD-TO-EVENT" author="Daniel Palafox" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<columnExists tableName="event" columnName="ip"/>
</preConditions>
<sql>ALTER TABLE event ALTER COLUMN ip TYPE VARCHAR(60);</sql>
</changeSet>

<changeSet id="ADD-FIELD-TO-EVENT_STATS" author="Daniel Palafox" dbms="postgresql">
<preConditions onFail="MARK_RAN">
<columnExists tableName="event_stats" columnName="ip"/>
</preConditions>
<sql>ALTER TABLE event_stats ALTER COLUMN ip TYPE VARCHAR(60);</sql>
</changeSet>

</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void createPapiEventStats() {
assertEquals(Integer.valueOf(10), eventStatsEntityList.get(1).getCount());

assertNull(eventStatsEntityList.get(2).getClientId());
assertEquals("104.20.228.70", eventStatsEntityList.get(2).getIp());
assertEquals("2001:db8:85a3:8d3:1319:8a2e:370:7348", eventStatsEntityList.get(2).getIp());
assertEquals(Integer.valueOf(1100), eventStatsEntityList.get(2).getCount());


Expand Down Expand Up @@ -99,7 +99,7 @@ private void createPapiEvents() {
for (int i = 0; i < 1100; i++) {
EventEntity eventEntity = new EventEntity();
eventEntity.setEventType(EventType.PAPI.getValue());
eventEntity.setIp("104.20.228.70");
eventEntity.setIp("2001:db8:85a3:8d3:1319:8a2e:370:7348");
eventEntity.setLabel("anonymous");
LocalDate date = LocalDate.now().minusDays(1);
Instant instant = date.atStartOfDay(ZoneId.systemDefault()).toInstant();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ public class PublicV2ApiServiceImplV2_0 {
@Resource
protected SwaggerUIBuilder swaggerUIBuilder;

@Context
private HttpServletRequest httpRequest;

public void setServiceDelegator(
PublicV2ApiServiceDelegator<Education, Employment, PersonExternalIdentifier, Funding, GroupIdRecord, OtherName, PeerReview, ResearcherUrl, Work> serviceDelegator) {
this.serviceDelegator = serviceDelegator;
Expand Down Expand Up @@ -110,6 +113,7 @@ public Response viewStatusText() {
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(ACTIVITIES)
public Response viewActivities(@PathParam("orcid") String orcid, @Context HttpServletRequest httpRequest) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewActivities(orcid);
}

Expand All @@ -118,6 +122,7 @@ public Response viewActivities(@PathParam("orcid") String orcid, @Context HttpSe
OrcidApiConstants.APPLICATION_CITEPROC })
@Path(WORK + PUTCODE)
public Response viewWork(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode, @Context HttpServletRequest httpRequest) {
serviceDelegator.trackEvents(httpRequest);
if (OrcidApiConstants.APPLICATION_CITEPROC.equals(httpRequest.getHeader("Accept")))
return serviceDelegator.viewWorkCitation(orcid, putCode);
return serviceDelegator.viewWork(orcid, putCode);
Expand All @@ -127,202 +132,231 @@ public Response viewWork(@PathParam("orcid") String orcid, @PathParam("putCode")
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(WORK_SUMMARY + PUTCODE)
public Response viewWorkSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewWorkSummary(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(WORKS)
public Response viewWorks(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewWorks(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(BULK_WORKS)
public Response viewSpecifiedWorks(@PathParam("orcid") String orcid, @PathParam("putCodes") String putCodes) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewBulkWorks(orcid, putCodes);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDING + PUTCODE)
public Response viewFunding(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewFunding(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDING_SUMMARY + PUTCODE)
public Response viewFundingSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewFundingSummary(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(FUNDINGS)
public Response viewFundings(@PathParam("orcid") String orcid) {
public Response viewFundings(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewFundings(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATION + PUTCODE)
public Response viewEducation(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEducation(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATION_SUMMARY + PUTCODE)
public Response viewEducationSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEducationSummary(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EDUCATIONS)
public Response viewEducations(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEducations(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENT + PUTCODE)
public Response viewEmployment(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEmployment(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENT_SUMMARY + PUTCODE)
public Response viewEmploymentSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEmploymentSummary(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMPLOYMENTS)
public Response viewEmployments(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEmployments(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEW + PUTCODE)
public Response viewPeerReview(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewPeerReview(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEW_SUMMARY + PUTCODE)
public Response viewPeerReviewSummary(@PathParam("orcid") String orcid, @PathParam("putCode") Long putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewPeerReviewSummary(orcid, putCode);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PEER_REVIEWS)
public Response viewPeerReviews(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewPeerReviews(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(RESEARCHER_URLS)
public Response viewResearcherUrls(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewResearcherUrls(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(RESEARCHER_URLS + PUTCODE)
public Response viewResearcherUrl(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewResearcherUrl(orcid, Long.valueOf(putCode));
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EMAIL)
public Response viewEmails(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewEmails(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PERSONAL_DETAILS)
public Response viewPersonalDetails(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewPersonalDetails(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(OTHER_NAMES)
public Response viewOtherNames(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewOtherNames(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(OTHER_NAMES + PUTCODE)
public Response viewOtherName(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewOtherName(orcid, Long.valueOf(putCode));
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EXTERNAL_IDENTIFIERS)
public Response viewExternalIdentifiers(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewExternalIdentifiers(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(EXTERNAL_IDENTIFIERS + PUTCODE)
public Response viewExternalIdentifier(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewExternalIdentifier(orcid, Long.valueOf(putCode));
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(KEYWORDS)
public Response viewKeywords(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewKeywords(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(KEYWORDS + PUTCODE)
public Response viewKeyword(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewKeyword(orcid, Long.valueOf(putCode));
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(ADDRESS)
public Response viewAddresses(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewAddresses(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(ADDRESS + PUTCODE)
public Response viewAddress(@PathParam("orcid") String orcid, @PathParam("putCode") String putCode) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewAddress(orcid, Long.valueOf(putCode));
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(BIOGRAPHY)
public Response viewBiography(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewBiography(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(PERSON)
public Response viewPerson(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewPerson(orcid);
}

Expand All @@ -331,6 +365,7 @@ public Response viewPerson(@PathParam("orcid") String orcid) {
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON , JSON_LD})
@Path(OrcidApiConstants.RECORD_SIMPLE)
public Response viewRecord(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewRecord(orcid);
}

Expand All @@ -339,13 +374,15 @@ public Response viewRecord(@PathParam("orcid") String orcid) {
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(OrcidApiConstants.RECORD_RECORD)
public Response viewRecordRecord(@PathParam("orcid") String orcid) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewRecord(orcid);
}

@GET
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
@Path(SEARCH_PATH)
public Response searchByQuery(@QueryParam("q") @DefaultValue("") String query, @Context UriInfo uriInfo) {
serviceDelegator.trackEvents(httpRequest);
Map<String, List<String>> solrParams = new HashMap<>(uriInfo.getQueryParameters());
Response jsonQueryResults = serviceDelegator.searchByQuery(solrParams);
return jsonQueryResults;
Expand All @@ -355,6 +392,7 @@ public Response searchByQuery(@QueryParam("q") @DefaultValue("") String query, @
@Path(CLIENT_PATH)
@Produces(value = { VND_ORCID_XML, ORCID_XML, MediaType.APPLICATION_XML, VND_ORCID_JSON, ORCID_JSON, MediaType.APPLICATION_JSON })
public Response viewClient(@PathParam("client_id") String clientId) {
serviceDelegator.trackEvents(httpRequest);
return serviceDelegator.viewClient(clientId);
}

Expand Down
Loading
Loading