Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #4 from habuma/master

Fix for SOCIALLI-14 and improper placement of ampersands in profile search URL (as well as other URLs)
  • Loading branch information...
commit b7233a523314c728478728fe75dd813da3b2e28b 2 parents d148b61 + 58d8284
@habuma habuma authored
2  buildSrc
@@ -1 +1 @@
-Subproject commit 308ed0ee908d4e46f0ed4c4494fb44564ba0a6ff
+Subproject commit db443164bf02a122f771a2bf4ed72df932779652
View
48 ...cial-linkedin/src/main/java/org/springframework/social/linkedin/api/SearchParameters.java
@@ -2,34 +2,45 @@
/**
* Profile search parameters
- *
* @author Robert Drysdale
- *
*/
public class SearchParameters {
+
private String keywords;
+
private String firstName;
+
private String lastName;
+
private String companyName;
+
private Boolean currentCompany;
+
private String title;
+
private Boolean currentTitle;
+
private String schoolName;
+
private Boolean currentSchool;
+
private String countryCode;
+
private String postalCode;
+
private Integer distance;
+
private int start;
+
private int count = 10;
+
private Sort sort;
public SearchParameters() {}
- public SearchParameters(String keywords, String firstName, String lastName,
- String companyName, Boolean currentCompany, String title,
- Boolean currentTitle, String schoolName, Boolean currentSchool,
- String countryCode, String postalCode, Integer distance, int start,
- int count, Sort sort) {
+ public SearchParameters(String keywords, String firstName, String lastName, String companyName, Boolean currentCompany,
+ String title, Boolean currentTitle, String schoolName, Boolean currentSchool, String countryCode, String postalCode,
+ Integer distance, int start, int count, Sort sort) {
super();
this.keywords = keywords;
this.firstName = firstName;
@@ -51,66 +62,87 @@ public SearchParameters(String keywords, String firstName, String lastName,
public String getKeywords() {
return keywords;
}
+
public void setKeywords(String keywords) {
this.keywords = keywords;
}
+
public String getFirstName() {
return firstName;
}
+
public void setFirstName(String firstName) {
this.firstName = firstName;
}
+
public String getLastName() {
return lastName;
}
+
public void setLastName(String lastName) {
this.lastName = lastName;
}
+
public String getCompanyName() {
return companyName;
}
+
public void setCompanyName(String companyName) {
this.companyName = companyName;
}
+
public String getTitle() {
return title;
}
+
public void setTitle(String title) {
this.title = title;
}
+
public String getSchoolName() {
return schoolName;
}
+
public void setSchoolName(String schoolName) {
this.schoolName = schoolName;
}
+
public String getCountryCode() {
return countryCode;
}
+
public void setCountryCode(String countryCode) {
this.countryCode = countryCode;
}
+
public String getPostalCode() {
return postalCode;
}
+
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
+
public Integer getDistance() {
return distance;
}
+
public void setDistance(Integer distance) {
this.distance = distance;
}
+
public int getStart() {
return start;
}
+
public void setStart(int start) {
this.start = start;
}
+
public int getCount() {
return count;
}
+
public void setCount(int count) {
this.count = count;
}
@@ -149,7 +181,7 @@ public void setSort(Sort sort) {
public static enum Sort {
CONNECTIONS,
- RECOMMENDORS,
+ RECOMMENDERS,
DISTANCE,
RELEVANCE;
View
6 ...linkedin/src/main/java/org/springframework/social/linkedin/api/impl/AbstractTemplate.java
@@ -20,13 +20,15 @@ protected URI expand(String url, Object[] variables, boolean encode) {
Matcher matcher = NAMES_PATTERN.matcher(url);
StringBuffer buffer = new StringBuffer();
int i = 0;
+ String separator = "";
while (matcher.find()) {
Object uriVariable = variables[i++];
String replacement = Matcher.quoteReplacement(uriVariable != null ? (encode ? encode(uriVariable.toString()): uriVariable.toString()) : "");
String key = matcher.group();
if (key.charAt(1) == '&' && replacement != null && replacement.length() > 0) {
- key = key.substring(1, key.length()-1);
- matcher.appendReplacement(buffer, key + '=' + replacement);
+ key = key.substring(2, key.length()-1);
+ matcher.appendReplacement(buffer, separator + key + '=' + replacement);
+ separator = "&";
}
else {
matcher.appendReplacement(buffer, replacement);
View
2  ...din/src/main/java/org/springframework/social/linkedin/api/impl/NetworkUpdateTemplate.java
@@ -165,7 +165,7 @@ else if (parameters.getUpdateTypes() != null && parameters.getUpdateTypes().size
return expand(url, variables, false);
}
- static final String UPDATES_URL = BASE_URL + "{id}/network/updates?format=json{&count}{&start}{&scope}{type}{&before}{&after}{&show-hidden-members}";
+ static final String UPDATES_URL = BASE_URL + "{id}/network/updates?{&count}{&start}{&scope}{type}{&before}{&after}{&show-hidden-members}&format=json";
static final String UPDATE_COMMENTS_URL = BASE_URL + "~/network/updates/key={key}/update-comments?format=json";
View
4 ...-linkedin/src/main/java/org/springframework/social/linkedin/api/impl/ProfileTemplate.java
@@ -93,7 +93,7 @@ public SearchResultPeople search(SearchParameters parameters) {
}
}
-
+
private URI expand(String url, SearchParameters parameters) {
Object[] variables = new Object[] {
parameters.getKeywords(),
@@ -119,6 +119,6 @@ private URI expand(String url, SearchParameters parameters) {
static final String PROFILE_URL_FULL;
- static final String PEOPLE_SEARCH_URL = "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary,api-standard-profile-request))?{&keywords}{&first-name}{&last-name}{&company-name}&{current-company}{&title}{&current-title}{&school-name}{&current-school}{&country-code}{&postal-code}{&distance}{&start}{&count}{&sort}";
+ static final String PEOPLE_SEARCH_URL = "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary,api-standard-profile-request))?{&keywords}{&first-name}{&last-name}{&company-name}{&current-company}{&title}{&current-title}{&school-name}{&current-school}{&country-code}{&postal-code}{&distance}{&start}{&count}{&sort}";
}
View
6 ...-linkedin/src/test/java/org/springframework/social/linkedin/api/impl/JobTemplateTest.java
@@ -27,7 +27,7 @@
@Test
public void search() {
mockServer.expect(requestTo(JobTemplate.SEARCH_URL
- .replaceFirst("\\{\\&keywords\\}", "&keywords=j2ee")
+ .replaceFirst("\\{\\&keywords\\}", "keywords=j2ee")
.replaceFirst("\\{\\&company-name\\}", "")
.replaceFirst("\\{\\&job-title\\}", "")
.replaceFirst("\\{\\&country-code\\}", "&country-code=ie")
@@ -78,7 +78,7 @@ public void search() {
@Test
public void getSuggestions() {
mockServer.expect(requestTo(JobTemplate.SUGGESTED_URL
- .replaceFirst("\\{\\&start\\}", "&start=0")
+ .replaceFirst("\\{\\&start\\}", "start=0")
.replaceFirst("\\{\\&count\\}", "&count=10"))).andExpect(method(GET))
.andRespond(withResponse(new ClassPathResource("testdata/job_suggestions.json", getClass()), responseHeaders));
@@ -162,7 +162,7 @@ public void getJob() {
@Test
public void getBookmarks() {
mockServer.expect(requestTo(JobTemplate.BOOKMARKS_URL
- .replaceFirst("\\{\\&start\\}", "&start=0")
+ .replaceFirst("\\{\\&start\\}", "start=0")
.replaceFirst("\\{\\&count\\}", "&count=10"))).andExpect(method(GET))
.andRespond(withResponse(new ClassPathResource("testdata/job_bookmarks.json", getClass()), responseHeaders));
View
2  ...src/test/java/org/springframework/social/linkedin/api/impl/NetworkUpdateTemplateTest.java
@@ -98,7 +98,7 @@ public void getCurrentShare() {
@Test
public void getUpdates() {
- mockServer.expect(requestTo("https://api.linkedin.com/v1/people/~/network/updates?format=json&count=10&start=0&type=ANSW&type=APPS&type=CMPY&type=CONN&type=JOBS&type=JGRP&type=PICT&type=PRFX&type=RECU&type=PRFU&type=QSTN&type=SHAR&type=VIRL")).andExpect(method(GET))
+ mockServer.expect(requestTo("https://api.linkedin.com/v1/people/~/network/updates?count=10&start=0&type=ANSW&type=APPS&type=CMPY&type=CONN&type=JOBS&type=JGRP&type=PICT&type=PRFX&type=RECU&type=PRFU&type=QSTN&type=SHAR&type=VIRL&format=json")).andExpect(method(GET))
.andRespond(withResponse(new ClassPathResource("testdata/updates.json", getClass()), responseHeaders));
List<LinkedInNetworkUpdate> updates = linkedIn.networkUpdateOperations().getNetworkUpdates();
assertEquals(9, updates.size());
View
2  ...kedin/src/test/java/org/springframework/social/linkedin/api/impl/ProfileTemplateTest.java
@@ -120,7 +120,7 @@ public void getProfileUrl() {
@Test
public void search() {
mockServer.expect(requestTo(
- "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary,api-standard-profile-request))?&keywords=Java%20J2EE&&country-code=ie&start=0&count=10"
+ "https://api.linkedin.com/v1/people-search:(people:(id,first-name,last-name,headline,industry,site-standard-profile-request,public-profile-url,picture-url,summary,api-standard-profile-request))?keywords=Java%20J2EE&country-code=ie&start=0&count=10"
)).andExpect(method(GET))
.andRespond(withResponse(new ClassPathResource("testdata/search.json", getClass()), responseHeaders));
Please sign in to comment.
Something went wrong with that request. Please try again.