Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding search groups and get group feature
- Loading branch information
Showing
12 changed files
with
888 additions
and
2 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
src/main/java/org/springframework/social/viadeo/api/Group.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api; | ||
|
||
import java.io.Serializable; | ||
import java.util.Date; | ||
|
||
/** | ||
* Model class representing a group. | ||
*/ | ||
public class Group implements Serializable { | ||
|
||
private static final long serialVersionUID = -3375820553217281636L; | ||
|
||
private final String id; | ||
|
||
private final String name; | ||
|
||
private final String link; | ||
|
||
private final Date updatedDate; | ||
|
||
private String access; | ||
|
||
private Integer memberCount; | ||
|
||
private String description; | ||
|
||
private String keywords; | ||
|
||
private String country; | ||
|
||
private Boolean isAdmin; | ||
|
||
public Group(String id, String name, String link, Date updatedDate) { | ||
this.id = id; | ||
this.name = name; | ||
this.link = link; | ||
this.updatedDate = updatedDate; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public String getLink() { | ||
return link; | ||
} | ||
|
||
public Date getUpdatedDate() { | ||
return updatedDate; | ||
} | ||
|
||
public String getAccess() { | ||
return access; | ||
} | ||
|
||
public void setAccess(String access) { | ||
this.access = access; | ||
} | ||
|
||
public Integer getMemberCount() { | ||
return memberCount; | ||
} | ||
|
||
public void setMemberCount(Integer memberCount) { | ||
this.memberCount = memberCount; | ||
} | ||
|
||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
public String getKeywords() { | ||
return keywords; | ||
} | ||
|
||
public void setKeywords(String keywords) { | ||
this.keywords = keywords; | ||
} | ||
|
||
public String getCountry() { | ||
return country; | ||
} | ||
|
||
public void setCountry(String country) { | ||
this.country = country; | ||
} | ||
|
||
public Boolean getIsAdmin() { | ||
return isAdmin; | ||
} | ||
|
||
public void setIsAdmin(Boolean isAdmin) { | ||
this.isAdmin = isAdmin; | ||
} | ||
|
||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/org/springframework/social/viadeo/api/GroupOperations.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api; | ||
|
||
import java.util.List; | ||
|
||
public interface GroupOperations { | ||
|
||
/** | ||
* Search a group on viadeo. | ||
* | ||
* @param query a group on a keyword. | ||
* @return a list of groups | ||
*/ | ||
List<Group> search(String query); | ||
|
||
/** | ||
* Retrieve the detail for a group. | ||
* | ||
* @param objectId the id of the group | ||
* @return the detailled group | ||
*/ | ||
Group getGroup(String objectId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/org/springframework/social/viadeo/api/impl/GroupTemplate.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api.impl; | ||
|
||
import java.net.URI; | ||
import java.util.List; | ||
|
||
import org.springframework.social.viadeo.api.Group; | ||
import org.springframework.social.viadeo.api.GroupOperations; | ||
|
||
public class GroupTemplate extends AbstractViadeoOperations implements | ||
GroupOperations { | ||
|
||
public GroupTemplate(ViadeoTemplate viadeoTemplate, boolean isAuthorized) { | ||
super(viadeoTemplate, isAuthorized); | ||
} | ||
|
||
@Override | ||
public List<Group> search(String query) { | ||
requireAuthorization(); | ||
URI uri = buildUri("search/groups").queryParam("q", query).queryParam( | ||
"limit", "50").build(); | ||
return get(uri, GroupsResult.class).getGroups(); | ||
} | ||
|
||
@Override | ||
public Group getGroup(String objectId) { | ||
requireAuthorization(); | ||
return get(objectId, Group.class); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
src/main/java/org/springframework/social/viadeo/api/impl/GroupsResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api.impl; | ||
|
||
import java.io.Serializable; | ||
import java.util.List; | ||
|
||
import org.springframework.social.viadeo.api.Group; | ||
|
||
public class GroupsResult implements Serializable { | ||
|
||
private static final long serialVersionUID = 680503605687489167L; | ||
|
||
private final List<Group> groups; | ||
|
||
public List<Group> getGroups() { | ||
return groups; | ||
} | ||
|
||
public GroupsResult(List<Group> groups) { | ||
this.groups = groups; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/org/springframework/social/viadeo/api/impl/json/GroupMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api.impl.json; | ||
|
||
import java.util.Date; | ||
|
||
import org.codehaus.jackson.annotate.JsonCreator; | ||
import org.codehaus.jackson.annotate.JsonIgnoreProperties; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
|
||
/** | ||
* Annotated mixin to add Jackson annotations to Group. | ||
*/ | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
abstract class GroupMixin { | ||
|
||
@JsonCreator | ||
GroupMixin(@JsonProperty("id") String id, @JsonProperty("name") String name, | ||
@JsonProperty("link") String link, | ||
@JsonProperty("updated_time") Date updatedDate) { | ||
} | ||
|
||
@JsonProperty("access") | ||
String access; | ||
|
||
@JsonProperty("member_count") | ||
Integer memberCount; | ||
|
||
@JsonProperty("Description") | ||
String description; | ||
|
||
@JsonProperty("keywords") | ||
String keywords; | ||
|
||
@JsonProperty("country") | ||
String country; | ||
|
||
@JsonProperty("is_administrator") | ||
Boolean isAdmin; | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/org/springframework/social/viadeo/api/impl/json/GroupsResultMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2011 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.social.viadeo.api.impl.json; | ||
|
||
import java.util.List; | ||
|
||
import org.codehaus.jackson.annotate.JsonCreator; | ||
import org.codehaus.jackson.annotate.JsonIgnoreProperties; | ||
import org.codehaus.jackson.annotate.JsonProperty; | ||
import org.springframework.social.viadeo.api.Group; | ||
|
||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
abstract class GroupsResultMixin { | ||
|
||
@JsonCreator | ||
GroupsResultMixin(@JsonProperty("data") List<Group> groups) { | ||
} | ||
} |
Oops, something went wrong.