You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rave.apache.org by mf...@apache.org on 2011/08/10 02:18:19 UTC
svn commit: r1155978 [2/3] - in /incubator/rave/trunk:
rave-commons/src/main/java/org/apache/rave/util/
rave-commons/src/test/java/org/apache/rave/util/ rave-portal/ rave-shindig/
rave-shindig/src/main/java/org/apache/rave/gadgets/ rave-shindig/src/mai...
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Person.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Person.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Person.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Person.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,680 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.model;
+
+import org.apache.rave.persistence.BasicEntity;
+
+import javax.persistence.*;
+import java.util.*;
+
+/**
+ * Represents a person in the persistence context
+ */
+@Entity
+@Table(name = "person")
+@SequenceGenerator(name="personIdSeq", sequenceName = "person_id_seq")
+@NamedQueries(value = {
+ @NamedQuery(name = Person.FIND_BY_USERNAME, query = "select p from Person p where p.username like :username"),
+ @NamedQuery(name = Person.FIND_FRIENDS_BY_USERNAME, query = "select a.followed from PersonAssociation a where a.follower.username = :username")
+})
+public class Person implements BasicEntity {
+
+ public static final String FIND_BY_USERNAME = "Person.findByUsername";
+ public static final String FIND_FRIENDS_BY_USERNAME = "Person.findFriendsByUsername";
+ public static final String USERNAME_PARAM = "username";
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "personIdSeq")
+ @Column(name = "id")
+ private Long id;
+
+ @Basic
+ @Column(name = "username")
+ private String username;
+
+ @Basic
+ @Column(name = "display_name")
+ private String displayName;
+
+ @Basic
+ @Column(name = "about_me")
+ private String aboutMe;
+
+ @Basic
+ @Column(name = "age")
+ private Integer age;
+
+ @Enumerated(EnumType.STRING)
+ @Column(name = "gender")
+ private org.apache.shindig.social.opensocial.model.Person.Gender gender;
+
+ @Basic
+ @Temporal(TemporalType.DATE)
+ @Column(name = "birthday")
+ private Date birthday;
+
+ @Basic
+ @Column(name = "children")
+ private String children;
+
+ @Basic
+ @Column(name = "ethnicity")
+ private String ethnicity;
+
+ @Basic
+ @Column(name = "fashion")
+ private String fashion;
+
+ @Basic
+ @Column(name = "happiest_when")
+ private String happiestWhen;
+
+ @Basic
+ @Column(name = "humor")
+ private String humor;
+
+ @Basic
+ @Column(name = "job_interests")
+ private String jobInterests;
+
+ @Basic
+ @Temporal(TemporalType.TIMESTAMP)
+ @Column(name = "last-updated")
+ private Date lastUpdated;
+
+ @Basic
+ @Column(name = "living_arrangement")
+ private String livingArrangement;
+
+ @Basic
+ @Column(name = "nickname")
+ private String nickname;
+
+ @Basic
+ @Column(name = "pets")
+ private String pets;
+
+ @Basic
+ @Column(name = "political_views")
+ private String politicalViews;
+
+ @Basic
+ @Column(name = "preferred_username")
+ private String preferredUsername;
+
+ @Basic
+ @Column(name = "relationship_status")
+ private String relationshipStatus;
+
+ @Basic
+ @Column(name = "religion")
+ private String religion;
+
+ @Basic
+ @Column(name = "romance")
+ private String romance;
+
+ @Basic
+ @Column(name = "scared_of")
+ private String scaredOf;
+
+ @Basic
+ @Column(name = "sexual_orientation")
+ private String sexualOrientation;
+
+ @Basic
+ @Column(name = "status")
+ private String status;
+
+ @Basic
+ @Column(name = "utc_offset")
+ private Long utcOffset;
+
+ @Basic
+ @Column(name = "profile_url")
+ private String profileUrl;
+
+ @Basic
+ @Column(name = "thumbnail_url")
+ private String thumbnailUrl;
+
+ @Basic
+ @Column(name = "drinker")
+ private String drinker;
+
+ @Basic
+ @Column(name = "smoker")
+ private String smoker;
+
+ @Basic
+ @Column(name = "network_presence")
+ private String networkPresence;
+
+ @Embedded
+ private BodyType bodyType;
+
+ @Embedded
+ private Name name;
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+ @JoinColumn(name = "person_id", referencedColumnName = "id")
+ private List<Account> accounts;
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+ @JoinTable(name = "person_address_join",
+ joinColumns = @JoinColumn(name = "address_id", referencedColumnName = "id"),
+ inverseJoinColumns = @JoinColumn(name="person_id", referencedColumnName = "id"))
+ private List<Address> addresses;
+
+ @OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.ALL, orphanRemoval = true)
+ @JoinColumn(name = "person_id", referencedColumnName = "id")
+ private List<Organization> organizations;
+
+ @OneToMany(targetEntity = PersonProperty.class)
+ @JoinColumn(name = "person_id", referencedColumnName = "id")
+ private List<PersonProperty> properties;
+
+ @ManyToMany(fetch = FetchType.LAZY)
+ @JoinTable(name = "person_friends_jn",
+ joinColumns = @JoinColumn(name = "follower_id", referencedColumnName = "id"),
+ inverseJoinColumns = @JoinColumn(name = "followed_id", referencedColumnName = "id"))
+ private List<Person> friends;
+
+
+ @Transient
+ private Url profileSong;
+
+ @Transient
+ private Address currentLocation;
+
+ @Transient
+ private Url profileVideo;
+
+ @Transient
+ private List<Url> urls;
+
+ @Transient
+ private Map<String, List<PersonProperty>> mappedProperties;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public void setDisplayName(String displayName) {
+ this.displayName = displayName;
+ }
+
+ public String getAboutMe() {
+ return aboutMe;
+ }
+
+ public void setAboutMe(String aboutMe) {
+ this.aboutMe = aboutMe;
+ }
+
+ public Integer getAge() {
+ return age;
+ }
+
+ public void setAge(Integer age) {
+ this.age = age;
+ }
+
+ public org.apache.shindig.social.opensocial.model.Person.Gender getGender() {
+ return gender;
+ }
+
+ public void setGender(org.apache.shindig.social.opensocial.model.Person.Gender gender) {
+ this.gender = gender;
+ }
+
+ public Date getBirthday() {
+ return birthday;
+ }
+
+ public void setBirthday(Date birthday) {
+ this.birthday = birthday;
+ }
+
+ public String getChildren() {
+ return children;
+ }
+
+ public void setChildren(String children) {
+ this.children = children;
+ }
+
+ public String getEthnicity() {
+ return ethnicity;
+ }
+
+ public void setEthnicity(String ethnicity) {
+ this.ethnicity = ethnicity;
+ }
+
+ public String getFashion() {
+ return fashion;
+ }
+
+ public void setFashion(String fashion) {
+ this.fashion = fashion;
+ }
+
+ public String getHappiestWhen() {
+ return happiestWhen;
+ }
+
+ public void setHappiestWhen(String happiestWhen) {
+ this.happiestWhen = happiestWhen;
+ }
+
+ public String getHumor() {
+ return humor;
+ }
+
+ public void setHumor(String humor) {
+ this.humor = humor;
+ }
+
+ public String getJobInterests() {
+ return jobInterests;
+ }
+
+ public void setJobInterests(String jobInterests) {
+ this.jobInterests = jobInterests;
+ }
+
+ public Date getLastUpdated() {
+ return lastUpdated;
+ }
+
+ public void setLastUpdated(Date lastUpdated) {
+ this.lastUpdated = lastUpdated;
+ }
+
+ public String getLivingArrangement() {
+ return livingArrangement;
+ }
+
+ public void setLivingArrangement(String livingArrangement) {
+ this.livingArrangement = livingArrangement;
+ }
+
+ public String getNickname() {
+ return nickname;
+ }
+
+ public void setNickname(String nickname) {
+ this.nickname = nickname;
+ }
+
+ public String getPets() {
+ return pets;
+ }
+
+ public void setPets(String pets) {
+ this.pets = pets;
+ }
+
+ public String getPoliticalViews() {
+ return politicalViews;
+ }
+
+ public void setPoliticalViews(String politicalViews) {
+ this.politicalViews = politicalViews;
+ }
+
+ public String getPreferredUsername() {
+ return preferredUsername;
+ }
+
+ public void setPreferredUsername(String preferredUsername) {
+ this.preferredUsername = preferredUsername;
+ }
+
+ public String getRelationshipStatus() {
+ return relationshipStatus;
+ }
+
+ public void setRelationshipStatus(String relationshipStatus) {
+ this.relationshipStatus = relationshipStatus;
+ }
+
+ public String getReligion() {
+ return religion;
+ }
+
+ public void setReligion(String religion) {
+ this.religion = religion;
+ }
+
+ public String getRomance() {
+ return romance;
+ }
+
+ public void setRomance(String romance) {
+ this.romance = romance;
+ }
+
+ public String getScaredOf() {
+ return scaredOf;
+ }
+
+ public void setScaredOf(String scaredOf) {
+ this.scaredOf = scaredOf;
+ }
+
+ public String getSexualOrientation() {
+ return sexualOrientation;
+ }
+
+ public void setSexualOrientation(String sexualOrientation) {
+ this.sexualOrientation = sexualOrientation;
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ }
+
+ public Long getUtcOffset() {
+ return utcOffset;
+ }
+
+ public void setUtcOffset(Long utcOffset) {
+ this.utcOffset = utcOffset;
+ }
+
+ public String getProfileUrl() {
+ return profileUrl;
+ }
+
+ public void setProfileUrl(String profileUrl) {
+ this.profileUrl = profileUrl;
+ }
+
+ public String getThumbnailUrl() {
+ return thumbnailUrl;
+ }
+
+ public void setThumbnailUrl(String thumbnailUrl) {
+ this.thumbnailUrl = thumbnailUrl;
+ }
+
+ public String getDrinker() {
+ return drinker;
+ }
+
+ public void setDrinker(String drinker) {
+ this.drinker = drinker;
+ }
+
+ public String getSmoker() {
+ return smoker;
+ }
+
+ public void setSmoker(String smoker) {
+ this.smoker = smoker;
+ }
+
+ public String getNetworkPresence() {
+ return networkPresence;
+ }
+
+ public void setNetworkPresence(String networkPresence) {
+ this.networkPresence = networkPresence;
+ }
+
+ public Name getName() {
+ return name;
+ }
+
+ public void setName(Name name) {
+ this.name = name;
+ }
+
+ public Url getProfileSong() {
+ return profileSong;
+ }
+
+ public void setProfileSong(Url profileSong) {
+ this.profileSong = profileSong;
+ }
+
+ public BodyType getBodyType() {
+ return bodyType;
+ }
+
+ public void setBodyType(BodyType bodyType) {
+ this.bodyType = bodyType;
+ }
+
+ public Address getCurrentLocation() {
+ return currentLocation;
+ }
+
+ public void setCurrentLocation(Address currentLocation) {
+ this.currentLocation = currentLocation;
+ }
+
+ public Url getProfileVideo() {
+ return profileVideo;
+ }
+
+ public void setProfileVideo(Url profileVideo) {
+ this.profileVideo = profileVideo;
+ }
+
+ public List<Account> getAccounts() {
+ return accounts;
+ }
+
+ public void setAccounts(List<Account> accounts) {
+ this.accounts = accounts;
+ }
+
+ public List<Address> getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(List<Address> addresses) {
+ this.addresses = addresses;
+ }
+
+ public List<Organization> getOrganizations() {
+ return organizations;
+ }
+
+ public void setOrganizations(List<Organization> organizations) {
+ this.organizations = organizations;
+ }
+
+ public List<Url> getUrls() {
+ return urls;
+ }
+
+ public void setUrls(List<Url> urls) {
+ this.urls = urls;
+ }
+
+ public Map<String, List<PersonProperty>> getProperties() {
+ if(mappedProperties == null) {
+ mappedProperties = createPropertyMap(properties);
+ }
+ return mappedProperties;
+ }
+
+ public void setProperties(Map<String, List<PersonProperty>> properties) {
+ //this.properties = properties;
+ }
+
+ public List<Person> getFriends() {
+ return friends;
+ }
+
+ public void setFriends(List<Person> friends) {
+ this.friends = friends;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (username != null ? username.hashCode() : 0);
+ result = 31 * result + (displayName != null ? displayName.hashCode() : 0);
+ result = 31 * result + (aboutMe != null ? aboutMe.hashCode() : 0);
+ result = 31 * result + (age != null ? age.hashCode() : 0);
+ result = 31 * result + (gender != null ? gender.hashCode() : 0);
+ result = 31 * result + (birthday != null ? birthday.hashCode() : 0);
+ result = 31 * result + (children != null ? children.hashCode() : 0);
+ result = 31 * result + (ethnicity != null ? ethnicity.hashCode() : 0);
+ result = 31 * result + (fashion != null ? fashion.hashCode() : 0);
+ result = 31 * result + (happiestWhen != null ? happiestWhen.hashCode() : 0);
+ result = 31 * result + (humor != null ? humor.hashCode() : 0);
+ result = 31 * result + (jobInterests != null ? jobInterests.hashCode() : 0);
+ result = 31 * result + (lastUpdated != null ? lastUpdated.hashCode() : 0);
+ result = 31 * result + (livingArrangement != null ? livingArrangement.hashCode() : 0);
+ result = 31 * result + (nickname != null ? nickname.hashCode() : 0);
+ result = 31 * result + (pets != null ? pets.hashCode() : 0);
+ result = 31 * result + (politicalViews != null ? politicalViews.hashCode() : 0);
+ result = 31 * result + (preferredUsername != null ? preferredUsername.hashCode() : 0);
+ result = 31 * result + (relationshipStatus != null ? relationshipStatus.hashCode() : 0);
+ result = 31 * result + (religion != null ? religion.hashCode() : 0);
+ result = 31 * result + (romance != null ? romance.hashCode() : 0);
+ result = 31 * result + (scaredOf != null ? scaredOf.hashCode() : 0);
+ result = 31 * result + (sexualOrientation != null ? sexualOrientation.hashCode() : 0);
+ result = 31 * result + (status != null ? status.hashCode() : 0);
+ result = 31 * result + (utcOffset != null ? utcOffset.hashCode() : 0);
+ result = 31 * result + (profileUrl != null ? profileUrl.hashCode() : 0);
+ result = 31 * result + (thumbnailUrl != null ? thumbnailUrl.hashCode() : 0);
+ result = 31 * result + (drinker != null ? drinker.hashCode() : 0);
+ result = 31 * result + (smoker != null ? smoker.hashCode() : 0);
+ result = 31 * result + (networkPresence != null ? networkPresence.hashCode() : 0);
+ result = 31 * result + (bodyType != null ? bodyType.hashCode() : 0);
+ result = 31 * result + (name != null ? name.hashCode() : 0);
+ result = 31 * result + (profileSong != null ? profileSong.hashCode() : 0);
+ result = 31 * result + (currentLocation != null ? currentLocation.hashCode() : 0);
+ result = 31 * result + (profileVideo != null ? profileVideo.hashCode() : 0);
+ result = 31 * result + (accounts != null ? accounts.hashCode() : 0);
+ result = 31 * result + (addresses != null ? addresses.hashCode() : 0);
+ result = 31 * result + (organizations != null ? organizations.hashCode() : 0);
+ result = 31 * result + (urls != null ? urls.hashCode() : 0);
+ result = 31 * result + (properties != null ? properties.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ Person person = (Person) o;
+
+ if (aboutMe != null ? !aboutMe.equals(person.aboutMe) : person.aboutMe != null) return false;
+ if (accounts != null ? !accounts.equals(person.accounts) : person.accounts != null) return false;
+ if (addresses != null ? !addresses.equals(person.addresses) : person.addresses != null) return false;
+ if (age != null ? !age.equals(person.age) : person.age != null) return false;
+ if (birthday != null ? !birthday.equals(person.birthday) : person.birthday != null) return false;
+ if (bodyType != null ? !bodyType.equals(person.bodyType) : person.bodyType != null) return false;
+ if (children != null ? !children.equals(person.children) : person.children != null) return false;
+ if (currentLocation != null ? !currentLocation.equals(person.currentLocation) : person.currentLocation != null)
+ return false;
+ if (displayName != null ? !displayName.equals(person.displayName) : person.displayName != null) return false;
+ if (drinker != null ? !drinker.equals(person.drinker) : person.drinker != null) return false;
+ if (ethnicity != null ? !ethnicity.equals(person.ethnicity) : person.ethnicity != null) return false;
+ if (fashion != null ? !fashion.equals(person.fashion) : person.fashion != null) return false;
+ if (gender != person.gender) return false;
+ if (happiestWhen != null ? !happiestWhen.equals(person.happiestWhen) : person.happiestWhen != null)
+ return false;
+ if (humor != null ? !humor.equals(person.humor) : person.humor != null) return false;
+ if (id != null ? !id.equals(person.id) : person.id != null) return false;
+ if (jobInterests != null ? !jobInterests.equals(person.jobInterests) : person.jobInterests != null)
+ return false;
+ if (lastUpdated != null ? !lastUpdated.equals(person.lastUpdated) : person.lastUpdated != null) return false;
+ if (livingArrangement != null ? !livingArrangement.equals(person.livingArrangement) : person.livingArrangement != null)
+ return false;
+ if (name != null ? !name.equals(person.name) : person.name != null) return false;
+ if (networkPresence != null ? !networkPresence.equals(person.networkPresence) : person.networkPresence != null)
+ return false;
+ if (nickname != null ? !nickname.equals(person.nickname) : person.nickname != null) return false;
+ if (organizations != null ? !organizations.equals(person.organizations) : person.organizations != null)
+ return false;
+ if (pets != null ? !pets.equals(person.pets) : person.pets != null) return false;
+ if (politicalViews != null ? !politicalViews.equals(person.politicalViews) : person.politicalViews != null)
+ return false;
+ if (preferredUsername != null ? !preferredUsername.equals(person.preferredUsername) : person.preferredUsername != null)
+ return false;
+ if (profileSong != null ? !profileSong.equals(person.profileSong) : person.profileSong != null) return false;
+ if (profileUrl != null ? !profileUrl.equals(person.profileUrl) : person.profileUrl != null) return false;
+ if (profileVideo != null ? !profileVideo.equals(person.profileVideo) : person.profileVideo != null)
+ return false;
+ if (properties != null ? !properties.equals(person.properties) : person.properties != null) return false;
+ if (relationshipStatus != null ? !relationshipStatus.equals(person.relationshipStatus) : person.relationshipStatus != null)
+ return false;
+ if (religion != null ? !religion.equals(person.religion) : person.religion != null) return false;
+ if (romance != null ? !romance.equals(person.romance) : person.romance != null) return false;
+ if (scaredOf != null ? !scaredOf.equals(person.scaredOf) : person.scaredOf != null) return false;
+ if (sexualOrientation != null ? !sexualOrientation.equals(person.sexualOrientation) : person.sexualOrientation != null)
+ return false;
+ if (smoker != null ? !smoker.equals(person.smoker) : person.smoker != null) return false;
+ if (status != null ? !status.equals(person.status) : person.status != null) return false;
+ if (thumbnailUrl != null ? !thumbnailUrl.equals(person.thumbnailUrl) : person.thumbnailUrl != null)
+ return false;
+ if (urls != null ? !urls.equals(person.urls) : person.urls != null) return false;
+ if (username != null ? !username.equals(person.username) : person.username != null) return false;
+ if (utcOffset != null ? !utcOffset.equals(person.utcOffset) : person.utcOffset != null) return false;
+
+ return true;
+ }
+
+ private static Map<String, List<PersonProperty>> createPropertyMap(List<PersonProperty> properties) {
+ Map<String, List<PersonProperty>> map = new HashMap<String, List<PersonProperty>>();
+ for(PersonProperty property : properties) {
+ List<PersonProperty> propertyList;
+ String fieldType = property.getFieldType();
+ if(map.containsKey(fieldType)) {
+ propertyList = map.get(fieldType);
+ } else {
+ propertyList = new ArrayList<PersonProperty>();
+ map.put(fieldType, propertyList);
+ }
+ propertyList.add(property);
+ }
+ return map;
+ }
+
+}
\ No newline at end of file
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonAssociation.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonAssociation.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonAssociation.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonAssociation.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.model;
+
+import org.apache.rave.persistence.BasicEntity;
+
+import javax.persistence.*;
+
+/**
+ * Represents an association between people
+ *
+ */
+@Entity
+@Table(name = "person_association")
+@SequenceGenerator(name="personAssocIdSeq", sequenceName = "person_association_id_seq")
+public class PersonAssociation implements BasicEntity{
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "personAssocIdSeq")
+ @Column(name = "id")
+ private Long id;
+
+ @OneToOne
+ @JoinColumn(name="follower_id", referencedColumnName = "id")
+ Person follower;
+
+ @OneToOne
+ @JoinColumn(name="followed_id", referencedColumnName = "id")
+ Person followed;
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public Person getFollower() {
+ return follower;
+ }
+
+ public void setFollower(Person follower) {
+ this.follower = follower;
+ }
+
+ public Person getFollowed() {
+ return followed;
+ }
+
+ public void setFollowed(Person followed) {
+ this.followed = followed;
+ }
+}
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonProperty.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonProperty.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonProperty.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/PersonProperty.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.model;
+
+import org.apache.rave.persistence.BasicEntity;
+import org.apache.shindig.social.opensocial.model.ListField;
+
+import javax.lang.model.element.TypeElement;
+import javax.persistence.*;
+
+/**
+ * Defines a property of a person
+ */
+@Entity
+@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
+@DiscriminatorColumn(name="property_type")
+@DiscriminatorValue("basic")
+@Table(name = "person_property")
+@SequenceGenerator(name="personPropertyIdSeq", sequenceName = "person_property_id_seq")
+public class PersonProperty implements BasicEntity, ListField {
+
+ @Id
+ @Column(name = "id")
+ @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "personPropertyIdSeq")
+ private Long id;
+
+ @Basic
+ @Column(name = "field_type")
+ private String fieldType;
+
+ @Basic
+ @Column(name = "type")
+ private String type;
+
+ @Basic
+ @Column(name = "value")
+ private String value;
+
+ @Basic
+ @Column(name = "primary_value")
+ private Boolean primary;
+
+ public String getFieldType() {
+ return fieldType;
+ }
+
+ public void setFieldType(String fieldType) {
+ this.fieldType = fieldType;
+ }
+
+ @Override
+ public String getType() {
+ return type;
+ }
+
+ @Override
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ @Override
+ public String getValue() {
+ return value;
+ }
+
+ @Override
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public Boolean getPrimary() {
+ return primary;
+ }
+
+ @Override
+ public void setPrimary(Boolean primary) {
+ this.primary = primary;
+ }
+
+ @Override
+ public Long getId() {
+ return id;
+ }
+
+ @Override
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ PersonProperty that = (PersonProperty) o;
+
+ if (fieldType != null ? !fieldType.equals(that.fieldType) : that.fieldType != null) return false;
+ if (id != null ? !id.equals(that.id) : that.id != null) return false;
+ if (primary != null ? !primary.equals(that.primary) : that.primary != null) return false;
+ if (type != null ? !type.equals(that.type) : that.type != null) return false;
+ if (value != null ? !value.equals(that.value) : that.value != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = id != null ? id.hashCode() : 0;
+ result = 31 * result + (fieldType != null ? fieldType.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ result = 31 * result + (primary != null ? primary.hashCode() : 0);
+ return result;
+ }
+}
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Url.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Url.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Url.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/model/Url.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.model;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+
+/**
+ * Url Entity, extends the ListField object (and list_field table), joining on the object ID.
+ * Objects of this type will have "list_field_type" set to UrlDb in list_field
+ */
+@Entity
+@DiscriminatorValue("url")
+public class Url extends PersonProperty implements org.apache.shindig.social.opensocial.model.Url {
+
+ @Basic
+ @Column(name = "link_text")
+ private String linkText;
+
+ public String getLinkText() {
+ return linkText;
+ }
+
+ public void setLinkText(String linkText) {
+ this.linkText = linkText;
+ }
+}
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/PersonRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/PersonRepository.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/PersonRepository.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/PersonRepository.java Wed Aug 10 00:18:18 2011
@@ -19,8 +19,128 @@
package org.apache.rave.opensocial.repository;
+import org.apache.rave.opensocial.model.Person;
import org.apache.rave.persistence.Repository;
+import org.apache.shindig.protocol.model.FilterOperation;
+import org.apache.shindig.social.opensocial.spi.CollectionOptions;
+import java.util.List;
-public interface PersonRepository extends Repository {
+
+public interface PersonRepository extends Repository<Person> {
+ /**
+ * Gets a user by their username
+ *
+ *
+ * @param username string representing the username
+ * @return valid Person if found, null otherwise
+ */
+ Person findByUsername(String username);
+
+ /**
+ * Gets all people connected to the given user including friends, fellow group members, etc
+ * @param username the user to find connected individuals for
+ * @return valid List of people connected to the person
+ */
+ List<Person> findAllConnectedPeople(String username);
+
+ /**
+ * Gets all people connected to the given user including friends, fellow group members, etc who have the specified application
+ * @param username the user to find connected individuals for
+ * @param appId the ID of the application
+ * @return a list of connected people who have the specified application installed
+ */
+ List<Person> findAllConnectedPeople(String username, String appId);
+
+ /**
+ * Gets all people connected to the given user including friends, fellow group members, etc, filtered by the specified field
+ *
+ * @param username the username of the person to query for
+ * @param field the field to filter on
+ * @param operation the type of filter to apply
+ * @param value the value of the specified filter
+ * @return a filtered list of connected individuals
+ */
+ List<Person> findAllConnectedPeople(String username, String field, FilterOperation operation, String value);
+
+ /**
+ * Finds a list of all people connected to the given person who are friends with the second user
+ * @param username the user to find connected individuals for
+ * @param friendUsername the username of the person to filter connections by
+ * @return a list of people who are connected to the first user and friends with the second
+ */
+ List<Person> findAllConnectedPeopleWithFriend(String username, String friendUsername);
+
+ /**
+ * Finds the list of friends for a given person
+ * @param username the username of the user to find friends for
+ * @return a valid List of people that are explicit friends of the person
+ */
+ List<Person> findFriends(String username);
+
+ /**
+ * Finds a list of friends for the given person who have the given app installed on some page
+ *
+ * @param username the username of the user to find friends for
+ * @param appId the ID of the application
+ * @return a list of friends with the application
+ */
+ List<Person> findFriends(String username, String appId);
+
+ /**
+ * Finds the list of friends for the given person, filtered by the specified field
+ *
+ * @param username the username of the user to find friends for
+ * @param field the field to filter on
+ * @param operation the type of filter to apply
+ * @param value the value of the specified filter
+ * @return a filtered list of friends
+ */
+ List<Person> findFriends(String username, String field, FilterOperation operation, String value);
+
+ /**
+ * Finds the list of friends for the user who are also friends of the given person
+ *
+ * @param username the username of the user to find friends for
+ * @param friendUsername the username of the person to filter connections by
+ * @return a list of people who are friends of both individuals
+ */
+ List<Person> findFriendsWithFriend(String username, String friendUsername);
+
+ /**
+ * Finds a List of people based on their group membership
+ *
+ * @param groupId the Id of the group to query
+ * @return a valid List of people in the group
+ */
+ List<Person> findByGroup(String groupId);
+
+ /**
+ * Finds a List of people based on their group membership who have the specified app
+ * @param groupId the Id of the group to query
+ * @param appId the ID of the application
+ * @return a list of people in the group with the application
+ */
+ List<Person> findByGroup(String groupId, String appId);
+
+ /**
+ * Finds a subset of people in the specified group filtered by the specified field
+ *
+ * @param groupId the Id of the group to query
+ * @param field the field to filter on
+ * @param operation the type of filter to apply
+ * @param value the value of the specified filter
+ * @return a filtered list of group members
+ */
+ List<Person> findByGroup(String groupId, String field, FilterOperation operation, String value);
+
+ /**
+ * Finds a subset of people in teh specified group who have the given friend
+ *
+ * @param groupId the Id of the group to query
+ * @param friendUsername the username of the friend to filter the group by
+ * @return a list of people in the group who have the specified friend
+ */
+ List<Person> findByGroupWithFriend(String groupId, String friendUsername);
}
+
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/impl/JpaPersonRepository.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/impl/JpaPersonRepository.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/impl/JpaPersonRepository.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/repository/impl/JpaPersonRepository.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.repository.impl;
+
+import org.apache.rave.exception.NotSupportedException;
+import org.apache.rave.opensocial.model.Person;
+import org.apache.rave.opensocial.repository.PersonRepository;
+import org.apache.rave.persistence.jpa.AbstractJpaRepository;
+import org.apache.rave.persistence.jpa.util.JpaUtil;
+import org.apache.shindig.protocol.model.FilterOperation;
+import org.springframework.stereotype.Repository;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.TypedQuery;
+import java.util.ArrayList;
+import java.util.List;
+
+import static org.apache.rave.persistence.jpa.util.JpaUtil.getSingleResult;
+
+/**
+ *
+ */
+@Repository
+public class JpaPersonRepository extends AbstractJpaRepository<Person> implements PersonRepository{
+
+ @PersistenceContext
+ private EntityManager manager;
+
+ public JpaPersonRepository() {
+ super(Person.class);
+ }
+
+ @Override
+ public Person findByUsername(String username) {
+ TypedQuery<Person> query = manager.createNamedQuery(Person.FIND_BY_USERNAME, Person.class);
+ query.setParameter(Person.USERNAME_PARAM, username);
+ return getSingleResult(query.getResultList());
+ }
+
+ @Override
+ public List<Person> findAllConnectedPeople(String username) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findAllConnectedPeople(String username, String appId) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findAllConnectedPeople(String username, String field, FilterOperation operation, String value) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findAllConnectedPeopleWithFriend(String username, String friendUsername) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findFriends(String username) {
+ TypedQuery<Person> friends = manager.createNamedQuery(Person.FIND_FRIENDS_BY_USERNAME, Person.class);
+ friends.setParameter(Person.USERNAME_PARAM, username);
+ return friends.getResultList();
+ }
+
+ @Override
+ public List<Person> findFriends(String username, String appId) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findFriends(String username, String field, FilterOperation operation, String value) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findFriendsWithFriend(String username, String friendUsername) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findByGroup(String groupId) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findByGroup(String groupId, String appId) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findByGroup(String groupId, String field, FilterOperation operation, String value) {
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Person> findByGroupWithFriend(String groupId, String friendUsername) {
+ throw new NotSupportedException();
+ }
+}
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/DefaultPersonService.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/DefaultPersonService.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/DefaultPersonService.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/DefaultPersonService.java Wed Aug 10 00:18:18 2011
@@ -19,7 +19,11 @@
package org.apache.rave.opensocial.service.impl;
+import com.google.common.collect.Lists;
+import org.apache.rave.opensocial.repository.PersonRepository;
+import org.apache.rave.util.CollectionUtils;
import org.apache.shindig.auth.SecurityToken;
+import org.apache.shindig.common.util.ImmediateFuture;
import org.apache.shindig.protocol.ProtocolException;
import org.apache.shindig.protocol.RestfulCollection;
import org.apache.shindig.social.opensocial.model.Person;
@@ -27,22 +31,178 @@ import org.apache.shindig.social.opensoc
import org.apache.shindig.social.opensocial.spi.GroupId;
import org.apache.shindig.social.opensocial.spi.PersonService;
import org.apache.shindig.social.opensocial.spi.UserId;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Set;
import java.util.concurrent.Future;
/**
* Implementation of the {@link PersonService} SPI
*/
+@Service
public class DefaultPersonService implements PersonService {
+
+ private final PersonRepository repository;
+
+ @Autowired
+ public DefaultPersonService(PersonRepository repository) {
+ this.repository = repository;
+ }
+
@Override
- public Future<RestfulCollection<Person>> getPeople(Set<UserId> userIds, GroupId groupId, CollectionOptions collectionOptions, Set<String> fields, SecurityToken token) throws ProtocolException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ public Future<RestfulCollection<Person>> getPeople(Set<UserId> userIds,
+ GroupId groupId,
+ CollectionOptions collectionOptions,
+ Set<String> fields,
+ SecurityToken token) throws ProtocolException {
+
+ List<org.apache.rave.opensocial.model.Person> people = getPeopleFromRepository(userIds, groupId, token, collectionOptions);
+ return ImmediateFuture.newInstance(new RestfulCollection<Person>(convertPeople(people, fields)));
}
@Override
public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException {
- return null; //To change body of implemented methods use File | Settings | File Templates.
+ return ImmediateFuture.newInstance(convertPerson(getPersonForId(id, token), fields));
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getPeopleFromRepository(Set<UserId> userIds,
+ GroupId groupId,
+ SecurityToken token,
+ CollectionOptions collectionOptions) {
+ switch (groupId.getType()) {
+ case all:
+ return getUniqueListOfConnectedPeople(userIds, collectionOptions, token);
+ case friends:
+ return getUniqueListOfFriends(userIds, collectionOptions, token);
+ case groupId:
+ return getGroupMembersFromRepository(collectionOptions, groupId.getGroupId(), token.getAppId());
+ case self:
+ return Lists.newArrayList(getPersonForId(new UserId(UserId.Type.me, null), token));
+ case deleted:
+ throw new ProtocolException(HttpServletResponse.SC_NOT_IMPLEMENTED, "Deleted Friends are not tracked by the container");
+ default:
+ throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Invalid group id specified by request");
+ }
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getUniqueListOfFriends(Set<UserId> userIds,
+ CollectionOptions collectionOptions,
+ SecurityToken token) {
+
+ List<org.apache.rave.opensocial.model.Person> people = new ArrayList<org.apache.rave.opensocial.model.Person>();
+ for (UserId id : userIds) {
+ CollectionUtils.addUniqueValues(getFriendsFromRepository(collectionOptions, token.getAppId(), id.getUserId(token)), people);
+ }
+ return people;
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getUniqueListOfConnectedPeople(Set<UserId> userIds,
+ CollectionOptions collectionOptions,
+ SecurityToken token) {
+
+ List<org.apache.rave.opensocial.model.Person> people = new ArrayList<org.apache.rave.opensocial.model.Person>();
+ for (UserId id : userIds) {
+ CollectionUtils.addUniqueValues(getConnectedPeopleFromRepository(collectionOptions, token.getAppId(), id.getUserId(token)), people);
+ }
+ return people;
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getFriendsFromRepository(CollectionOptions collectionOptions,
+ String appId,
+ String userId) {
+
+ String filter = collectionOptions == null ? null : collectionOptions.getFilter();
+ List<org.apache.rave.opensocial.model.Person> current;
+ //Currently ignoring TOP FRIENDS as it hasn't been defined what a top friend is
+
+ if(filter == null || filter.equals(PersonService.TOP_FRIENDS_FILTER)) {
+ current = repository.findFriends(userId);
+
+ } else if(filter.equals(PersonService.HAS_APP_FILTER)) {
+ current = repository.findFriends(userId, appId);
+
+ } else if(filter.equals(PersonService.IS_WITH_FRIENDS_FILTER)) {
+ current = repository.findFriendsWithFriend(userId, collectionOptions.getFilterValue());
+
+ //Represents the default case (filter by field)
+ } else {
+ current = repository.findFriends(userId, filter, collectionOptions.getFilterOperation(), collectionOptions.getFilterValue());
+ }
+ return current;
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getConnectedPeopleFromRepository(CollectionOptions collectionOptions,
+ String appId,
+ String userId) {
+
+ String filter = collectionOptions == null ? null : collectionOptions.getFilter();
+ List<org.apache.rave.opensocial.model.Person> current;
+ //Currently ignoring TOP FRIENDS as it hasn't been defined what a top friend is
+
+ if(filter == null || filter.equals(PersonService.TOP_FRIENDS_FILTER)) {
+ current = repository.findAllConnectedPeople(userId);
+
+ } else if(filter.equals(PersonService.HAS_APP_FILTER)) {
+ current = repository.findAllConnectedPeople(userId, appId);
+
+ } else if(filter.equals(PersonService.IS_WITH_FRIENDS_FILTER)) {
+ current = repository.findAllConnectedPeopleWithFriend(userId, collectionOptions.getFilterValue());
+
+ //Represents the default case (filter by field)
+ } else {
+ current = repository.findAllConnectedPeople(userId, filter, collectionOptions.getFilterOperation(), collectionOptions.getFilterValue());
+ }
+ return current;
+ }
+
+ private List<org.apache.rave.opensocial.model.Person> getGroupMembersFromRepository(CollectionOptions collectionOptions,
+ String groupId,
+ String appId) {
+
+ String filter = collectionOptions == null ? null : collectionOptions.getFilter();
+ List<org.apache.rave.opensocial.model.Person> current;
+
+ if(filter == null || filter.equals(PersonService.TOP_FRIENDS_FILTER)) {
+ current = repository.findByGroup(groupId);
+
+ } else if(filter.equals(PersonService.HAS_APP_FILTER)) {
+ current = repository.findByGroup(groupId, appId);
+
+ } else if(filter.equals(PersonService.IS_WITH_FRIENDS_FILTER)) {
+ current = repository.findByGroupWithFriend(groupId, collectionOptions.getFilterValue());
+
+ //Represents the default case (filter by field)
+ } else {
+ current = repository.findByGroup(groupId, filter, collectionOptions.getFilterOperation(), collectionOptions.getFilterValue());
+ }
+ return current;
+ }
+
+ private org.apache.rave.opensocial.model.Person getPersonForId(UserId id, SecurityToken token) {
+ return getFromRepository(id.getUserId(token));
+ }
+
+ private org.apache.rave.opensocial.model.Person getFromRepository(String userId) {
+ org.apache.rave.opensocial.model.Person person = repository.findByUsername(userId);
+ if (person == null) {
+ throw new ProtocolException(HttpServletResponse.SC_NOT_FOUND, "The person with the id " + userId + " was not found.");
+ }
+ return person;
+ }
+
+ private static List<Person> convertPeople(List<org.apache.rave.opensocial.model.Person> people, Set<String> fields) {
+ List<Person> wrappedPeople = new ArrayList<Person>();
+ for (org.apache.rave.opensocial.model.Person person : people) {
+ wrappedPeople.add(convertPerson(person, fields));
+ }
+ return wrappedPeople;
+ }
+
+ private static Person convertPerson(org.apache.rave.opensocial.model.Person person, Set<String> fields) {
+ return new FieldRestrictingPerson(person, fields);
}
}
Added: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java?rev=1155978&view=auto
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java (added)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/opensocial/service/impl/FieldRestrictingPerson.java Wed Aug 10 00:18:18 2011
@@ -0,0 +1,750 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.rave.opensocial.service.impl;
+
+import org.apache.rave.exception.NotSupportedException;
+import org.apache.rave.opensocial.model.*;
+import org.apache.rave.util.CollectionUtils;
+import org.apache.shindig.protocol.model.Enum;
+import org.apache.shindig.protocol.model.EnumImpl;
+import org.apache.shindig.social.opensocial.model.*;
+import org.apache.shindig.social.opensocial.model.Account;
+import org.apache.shindig.social.opensocial.model.Address;
+import org.apache.shindig.social.opensocial.model.BodyType;
+import org.apache.shindig.social.opensocial.model.Name;
+import org.apache.shindig.social.opensocial.model.Organization;
+import org.apache.shindig.social.opensocial.model.Person;
+import org.apache.shindig.social.opensocial.model.Url;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * Wraps a {@link org.apache.rave.opensocial.model.Person} model object and returns values only if
+ * the field set contains the requested field
+ * <p/>
+ * Usage of this wrapper is made possible by Shindig's use of a getter based serialization model
+ */
+public class FieldRestrictingPerson implements org.apache.shindig.social.opensocial.model.Person, Serializable {
+
+ private org.apache.rave.opensocial.model.Person internal;
+ private Set<String> fields;
+ private Map<String, ?> appData;
+ private boolean isOwner;
+ private boolean isViewer;
+
+ public FieldRestrictingPerson(org.apache.rave.opensocial.model.Person internal, Set<String> fields) {
+ this.internal = internal;
+ this.fields = fields;
+ }
+
+ @Override
+ public String getDisplayName() {
+ return displayField(Field.DISPLAY_NAME) ? internal.getDisplayName() : null;
+ }
+
+ @Override
+ public void setDisplayName(String displayName) {
+ internal.setDisplayName(displayName);
+ }
+
+ @Override
+ public String getAboutMe() {
+ return displayField(Field.ABOUT_ME) ? internal.getAboutMe() : null;
+ }
+
+ @Override
+ public void setAboutMe(String aboutMe) {
+ internal.setAboutMe(aboutMe);
+ }
+
+ @Override
+ public List<Account> getAccounts() {
+ return displayField(Field.ACCOUNTS) ? CollectionUtils.<Account>toBaseTypedList(internal.getAccounts()) : null;
+ }
+
+ @Override
+ public void setAccounts(List<Account> accounts) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getActivities() {
+ return getValuesFromProperties(Field.ACTIVITIES);
+ }
+
+ @Override
+ public void setActivities(List<String> activities) {
+
+ }
+
+ @Override
+ public List<Address> getAddresses() {
+ return displayField(Field.ADDRESSES) ? CollectionUtils.<Address>toBaseTypedList(internal.getAddresses()) : null;
+ }
+
+ @Override
+ public void setAddresses(List<Address> addresses) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Integer getAge() {
+ return displayField(Field.AGE) ? internal.getAge() : null;
+ }
+
+ @Override
+ public void setAge(Integer age) {
+ internal.setAge(age);
+ }
+
+ @Override
+ public Map<String, ?> getAppData() {
+ return this.appData;
+ }
+
+ @Override
+ public void setAppData(Map<String, ?> appData) {
+ this.appData = appData;
+ }
+
+ @Override
+ public Date getBirthday() {
+ return displayField(Field.BIRTHDAY) ? internal.getBirthday() : null;
+ }
+
+ @Override
+ public void setBirthday(Date birthday) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public BodyType getBodyType() {
+ return displayField(Field.BODY_TYPE) ? internal.getBodyType() : null;
+ }
+
+ @Override
+ public void setBodyType(BodyType bodyType) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getBooks() {
+ return getValuesFromProperties(Field.BOOKS);
+ }
+
+ @Override
+ public void setBooks(List<String> books) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getCars() {
+ return getValuesFromProperties(Field.CARS);
+ }
+
+ @Override
+ public void setCars(List<String> cars) {
+ //TODO: Collection Reconciliation
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getChildren() {
+ return displayField(Field.CHILDREN) ? internal.getChildren() : null;
+ }
+
+ @Override
+ public void setChildren(String children) {
+ internal.setChildren(children);
+ }
+
+ @Override
+ public Address getCurrentLocation() {
+ return displayField(Field.CURRENT_LOCATION) ? internal.getCurrentLocation() : null;
+ }
+
+ @Override
+ public void setCurrentLocation(Address currentLocation) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public org.apache.shindig.protocol.model.Enum<Drinker> getDrinker() {
+ return displayField(Field.DRINKER) ? new EnumImpl<Drinker>(Drinker.valueOf(internal.getDrinker())) : null;
+ }
+
+ @Override
+ public void setDrinker(org.apache.shindig.protocol.model.Enum<Drinker> newDrinker) {
+ internal.setDrinker(newDrinker.getValue().toString());
+ }
+
+ @Override
+ public List<ListField> getEmails() {
+ return getListFromProperties(Field.EMAILS);
+ }
+
+ @Override
+ public void setEmails(List<ListField> emails) {
+ //TODO: Do setting
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getEthnicity() {
+ return displayField(Field.ETHNICITY) ? internal.getEthnicity() : null;
+ }
+
+ @Override
+ public void setEthnicity(String ethnicity) {
+ internal.setEthnicity(ethnicity);
+ }
+
+ @Override
+ public String getFashion() {
+ return displayField(Field.FASHION) ? internal.getFashion() : null;
+ }
+
+ @Override
+ public void setFashion(String fashion) {
+ internal.setFashion(fashion);
+ }
+
+ @Override
+ public List<String> getFood() {
+ return getValuesFromProperties(Field.FOOD);
+ }
+
+ @Override
+ public void setFood(List<String> food) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Gender getGender() {
+ return displayField(Field.GENDER) ? internal.getGender() : null;
+ }
+
+ @Override
+ public void setGender(Gender newGender) {
+ internal.setGender(newGender);
+ }
+
+ @Override
+ public String getHappiestWhen() {
+ return displayField(Field.HAPPIEST_WHEN) ? internal.getHappiestWhen() : null;
+ }
+
+ @Override
+ public void setHappiestWhen(String happiestWhen) {
+ internal.setHappiestWhen(happiestWhen);
+ }
+
+ @Override
+ public Boolean getHasApp() {
+ return displayField(Field.HAS_APP) ? false : null;
+ }
+
+ @Override
+ public void setHasApp(Boolean hasApp) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getHeroes() {
+ return getValuesFromProperties(Field.HEROES);
+ }
+
+ @Override
+ public void setHeroes(List<String> heroes) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getHumor() {
+ return displayField(Field.HUMOR) ? internal.getHumor() : null;
+ }
+
+ @Override
+ public void setHumor(String humor) {
+ internal.setHumor(humor);
+ }
+
+ @Override
+ public String getId() {
+ return displayField(Field.ID) ? internal.getUsername() : null;
+ }
+
+ @Override
+ public void setId(String id) {
+ internal.setUsername(id);
+ }
+
+ @Override
+ public List<ListField> getIms() {
+ return getListFromProperties(Field.IMS);
+ }
+
+ @Override
+ public void setIms(List<ListField> ims) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getInterests() {
+ return getValuesFromProperties(Field.INTERESTS);
+ }
+
+ @Override
+ public void setInterests(List<String> interests) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getJobInterests() {
+ return displayField(Field.JOB_INTERESTS) ? internal.getJobInterests() : null;
+ }
+
+ @Override
+ public void setJobInterests(String jobInterests) {
+ internal.setJobInterests(jobInterests);
+ }
+
+ @Override
+ public List<String> getLanguagesSpoken() {
+ return getValuesFromProperties(Field.LANGUAGES_SPOKEN);
+ }
+
+ @Override
+ public void setLanguagesSpoken(List<String> languagesSpoken) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Date getUpdated() {
+ return internal.getLastUpdated();
+ }
+
+ @Override
+ public void setUpdated(Date updated) {
+ internal.setLastUpdated(updated);
+ }
+
+ @Override
+ public String getLivingArrangement() {
+ return displayField(Field.LIVING_ARRANGEMENT) ? internal.getLivingArrangement() : null;
+ }
+
+ @Override
+ public void setLivingArrangement(String livingArrangement) {
+ internal.setLivingArrangement(livingArrangement);
+ }
+
+ @Override
+ public List<org.apache.shindig.protocol.model.Enum<LookingFor>> getLookingFor() {
+ return getEnumsFromValues(getValuesFromProperties(Field.LOOKING_FOR));
+ }
+
+ @Override
+ public void setLookingFor(List<Enum<LookingFor>> lookingFor) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getMovies() {
+ return getValuesFromProperties(Field.MOVIES);
+ }
+
+ @Override
+ public void setMovies(List<String> movies) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getMusic() {
+ return getValuesFromProperties(Field.MUSIC);
+ }
+
+ @Override
+ public void setMusic(List<String> music) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Name getName() {
+ return displayField(Field.NAME) ? internal.getName() : null;
+ }
+
+ @Override
+ public void setName(Name name) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Enum<NetworkPresence> getNetworkPresence() {
+ return displayField(Field.NETWORKPRESENCE) ? new EnumImpl<NetworkPresence>(NetworkPresence.valueOf(internal.getNetworkPresence())) : null;
+ }
+
+ @Override
+ public void setNetworkPresence(Enum<NetworkPresence> networkPresence) {
+ internal.setNetworkPresence(networkPresence.getValue().toString());
+ }
+
+ @Override
+ public String getNickname() {
+ return displayField(Field.NICKNAME) ? internal.getNickname() : null;
+ }
+
+ @Override
+ public void setNickname(String nickname) {
+ internal.setNickname(nickname);
+ }
+
+ @Override
+ public List<Organization> getOrganizations() {
+ return displayField(Field.ORGANIZATIONS) ? CollectionUtils.<Organization>toBaseTypedList(internal.getOrganizations()) : null;
+ }
+
+ @Override
+ public void setOrganizations(List<Organization> organizations) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getPets() {
+ return displayField(Field.PETS) ? internal.getPets() : null;
+ }
+
+ @Override
+ public void setPets(String pets) {
+ internal.setPets(pets);
+ }
+
+ @Override
+ public List<ListField> getPhoneNumbers() {
+ return getListFromProperties(Field.PHONE_NUMBERS);
+ }
+
+ @Override
+ public void setPhoneNumbers(List<ListField> phoneNumbers) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<ListField> getPhotos() {
+ return getListFromProperties(Field.PHOTOS);
+ }
+
+ @Override
+ public void setPhotos(List<ListField> photos) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getPoliticalViews() {
+ return displayField(Field.POLITICAL_VIEWS) ? internal.getPoliticalViews() : null;
+ }
+
+ @Override
+ public void setPoliticalViews(String politicalViews) {
+ internal.setPoliticalViews(politicalViews);
+ }
+
+ @Override
+ public String getPreferredUsername() {
+ return displayField(Field.PREFERRED_USERNAME) ? internal.getPreferredUsername() : null;
+ }
+
+ @Override
+ public void setPreferredUsername(String preferredString) {
+ internal.setPreferredUsername(preferredString);
+ }
+
+ @Override
+ public Url getProfileSong() {
+ return displayField(Field.PROFILE_SONG) ? internal.getProfileSong() : null;
+ }
+
+ @Override
+ public void setProfileSong(Url profileSong) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Url getProfileVideo() {
+ return displayField(Field.PROFILE_VIDEO) ? internal.getProfileVideo() : null;
+ }
+
+ @Override
+ public void setProfileVideo(Url profileVideo) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getQuotes() {
+ return getValuesFromProperties(Field.QUOTES);
+ }
+
+ @Override
+ public void setQuotes(List<String> quotes) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getRelationshipStatus() {
+ return displayField(Field.RELATIONSHIP_STATUS) ? internal.getRelationshipStatus() : null;
+ }
+
+ @Override
+ public void setRelationshipStatus(String relationshipStatus) {
+ internal.setRelationshipStatus(relationshipStatus);
+ }
+
+ @Override
+ public String getReligion() {
+ return displayField(Field.RELIGION) ? internal.getReligion() : null;
+ }
+
+ @Override
+ public void setReligion(String religion) {
+ internal.setReligion(religion);
+ }
+
+ @Override
+ public String getRomance() {
+ return displayField(Field.ROMANCE) ? internal.getRomance() : null;
+ }
+
+ @Override
+ public void setRomance(String romance) {
+ internal.setRomance(romance);
+ }
+
+ @Override
+ public String getScaredOf() {
+ return displayField(Field.SCARED_OF) ? internal.getScaredOf() : null;
+ }
+
+ @Override
+ public void setScaredOf(String scaredOf) {
+ internal.setScaredOf(scaredOf);
+ }
+
+ @Override
+ public String getSexualOrientation() {
+ return displayField(Field.SEXUAL_ORIENTATION) ? internal.getSexualOrientation() : null;
+ }
+
+ @Override
+ public void setSexualOrientation(String sexualOrientation) {
+ internal.setSexualOrientation(sexualOrientation);
+ }
+
+ @Override
+ public Enum<Smoker> getSmoker() {
+ return displayField(Field.SMOKER) ? new EnumImpl<Smoker>(Smoker.valueOf(internal.getSmoker())) : null;
+ }
+
+ @Override
+ public void setSmoker(Enum<Smoker> newSmoker) {
+ internal.setSmoker(newSmoker.getValue().toString());
+ }
+
+ @Override
+ public List<String> getSports() {
+ return getValuesFromProperties(Field.SPORTS);
+ }
+
+ @Override
+ public void setSports(List<String> sports) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public String getStatus() {
+ return displayField(Field.STATUS) ? internal.getStatus() : null;
+ }
+
+ @Override
+ public void setStatus(String status) {
+ internal.setStatus(status);
+ }
+
+ @Override
+ public List<String> getTags() {
+ return getValuesFromProperties(Field.TAGS);
+ }
+
+ @Override
+ public void setTags(List<String> tags) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public Long getUtcOffset() {
+ return displayField(Field.UTC_OFFSET) ? internal.getUtcOffset() : null;
+ }
+
+ @Override
+ public void setUtcOffset(Long utcOffset) {
+ internal.setUtcOffset(utcOffset);
+ }
+
+ @Override
+ public List<String> getTurnOffs() {
+ return getValuesFromProperties(Field.TURN_OFFS);
+ }
+
+ @Override
+ public void setTurnOffs(List<String> turnOffs) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getTurnOns() {
+ return getValuesFromProperties(Field.TURN_ONS);
+ }
+
+ @Override
+ public void setTurnOns(List<String> turnOns) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<String> getTvShows() {
+ return getValuesFromProperties(Field.TV_SHOWS);
+ }
+
+ @Override
+ public void setTvShows(List<String> tvShows) {
+ //TODO: Handle Setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public List<Url> getUrls() {
+ //return displayField(Field.URLS) ? internal.getUrls() : null;
+ return null;
+ }
+
+ @Override
+ public void setUrls(List<Url> urls) {
+ //TODO:Configure setter
+ throw new NotSupportedException();
+ }
+
+ @Override
+ public boolean getIsOwner() {
+ return isOwner;
+ }
+
+ @Override
+ public String getProfileUrl() {
+ return displayField(Field.PROFILE_URL) ? internal.getProfileUrl() : null;
+ }
+
+ @Override
+ public void setProfileUrl(String profileUrl) {
+ internal.setProfileUrl(profileUrl);
+ }
+
+ @Override
+ public String getThumbnailUrl() {
+ return displayField(Field.THUMBNAIL_URL) ? internal.getThumbnailUrl() : null;
+ }
+
+ @Override
+ public void setThumbnailUrl(String thumbnailUrl) {
+ internal.setThumbnailUrl(thumbnailUrl);
+ }
+
+ @Override
+ public void setIsOwner(boolean isOwner) {
+ this.isOwner = isOwner;
+ }
+
+ @Override
+ public boolean getIsViewer() {
+ return isViewer;
+ }
+
+ @Override
+ public void setIsViewer(boolean isViewer) {
+ this.isViewer = isViewer;
+ }
+
+ private boolean displayField(Field field) {
+ return fields == null || fields.isEmpty() || fields.contains(field.toString());
+ }
+
+ private List<? extends ListField> getFromProperties(Field field) {
+ return internal.getProperties().get(field.toString());
+ }
+
+ private List<String> getValuesFromProperties(Field field) {
+ return displayField(field) ? toValueList(getFromProperties(field)) : null;
+ }
+
+ private List<ListField> getListFromProperties(Field field) {
+ return displayField(field) ? CollectionUtils.<ListField>toBaseTypedList(getFromProperties(field)) : null;
+ }
+
+ private static List<Enum<LookingFor>> getEnumsFromValues(List<String> values) {
+ List<Enum<LookingFor>> looking = new ArrayList<Enum<LookingFor>>();
+ for (String value : values) {
+ looking.add(new EnumImpl<LookingFor>(LookingFor.valueOf(value)));
+ }
+ return looking;
+ }
+
+ private static List<String> toValueList(List<? extends ListField> properties) {
+ List<String> values = new ArrayList<String>();
+ for (ListField property : properties) {
+ values.add(property.getValue());
+ }
+ return values;
+ }
+}
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/JPAOpenSocialModule.java Wed Aug 10 00:18:18 2011
@@ -1,19 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you 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
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.rave.os;
@@ -40,7 +41,7 @@ public class JPAOpenSocialModule extends
bind(String.class).annotatedWith(Names.named("shindig.canonical.json.db"))
.toInstance("sampledata/canonicaldb.json");
- bind(PersonService.class).to(PersonServiceDb.class);
+ //bind(PersonService.class).to(PersonServiceDb.class);
bind(ActivityService.class).to(ActivityServiceDb.class);
bind(ActivityStreamService.class).to(JPAOpenSocialService.class);
bind(AlbumService.class).to(JPAOpenSocialService.class);
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/rave/os/SocialApiGuiceModule.java Wed Aug 10 00:18:18 2011
@@ -23,6 +23,7 @@ import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;
+import net.oauth.OAuthValidator;
import org.apache.shindig.auth.AnonymousAuthenticationHandler;
import org.apache.shindig.auth.AuthenticationHandler;
import org.apache.shindig.common.servlet.ParameterFetcher;
@@ -32,6 +33,7 @@ import org.apache.shindig.protocol.conve
import org.apache.shindig.protocol.conversion.BeanXStreamConverter;
import org.apache.shindig.protocol.conversion.xstream.XStreamConfiguration;
import org.apache.shindig.social.core.oauth.AuthenticationHandlerProvider;
+import org.apache.shindig.social.core.oauth.OAuthValidatorProvider;
import org.apache.shindig.social.core.util.BeanXStreamAtomConverter;
import org.apache.shindig.social.core.util.xstream.XStream081Configuration;
import org.apache.shindig.social.opensocial.service.ActivityHandler;
@@ -48,41 +50,46 @@ import java.util.Set;
*/
public class SocialApiGuiceModule extends AbstractModule {
- /** {@inheritDoc} */
- @Override
- protected void configure() {
- bind(ParameterFetcher.class).annotatedWith(Names.named("DataServiceServlet"))
- .to(DataServiceServletFetcher.class);
-
- bind(Boolean.class)
- .annotatedWith(Names.named(AnonymousAuthenticationHandler.ALLOW_UNAUTHENTICATED))
- .toInstance(Boolean.TRUE);
- bind(XStreamConfiguration.class).to(XStream081Configuration.class);
- bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.xml")).to(
- BeanXStreamConverter.class);
- bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to(
- BeanJsonConverter.class);
- bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.atom")).to(
- BeanXStreamAtomConverter.class);
-
- bind(new TypeLiteral<List<AuthenticationHandler>>(){}).toProvider(
- AuthenticationHandlerProvider.class);
-
- Multibinder<Object> handlerBinder = Multibinder.newSetBinder(binder(), Object.class,
- Names.named("org.apache.shindig.handlers"));
- for (Class handler : getHandlers()) {
- handlerBinder.addBinding().toInstance(handler);
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void configure() {
+ bind(ParameterFetcher.class).annotatedWith(Names.named("DataServiceServlet"))
+ .to(DataServiceServletFetcher.class);
+
+ bind(Boolean.class)
+ .annotatedWith(Names.named(AnonymousAuthenticationHandler.ALLOW_UNAUTHENTICATED))
+ .toInstance(Boolean.TRUE);
+ bind(XStreamConfiguration.class).to(XStream081Configuration.class);
+ bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.xml")).to(
+ BeanXStreamConverter.class);
+ bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.json")).to(
+ BeanJsonConverter.class);
+ bind(BeanConverter.class).annotatedWith(Names.named("shindig.bean.converter.atom")).to(
+ BeanXStreamAtomConverter.class);
+
+ bind(OAuthValidator.class).toProvider(OAuthValidatorProvider.class);
+
+ bind(new TypeLiteral<List<AuthenticationHandler>>() {
+ }).toProvider(
+ AuthenticationHandlerProvider.class);
+
+ Multibinder<Object> handlerBinder = Multibinder.newSetBinder(binder(), Object.class,
+ Names.named("org.apache.shindig.handlers"));
+ for (Class handler : getHandlers()) {
+ handlerBinder.addBinding().toInstance(handler);
+ }
}
- }
- /**
- * Hook to provide a Set of request handlers. Subclasses may override
- * to add or replace additional handlers.
- */
- protected Set<Class<?>> getHandlers() {
+ /**
+ * Hook to provide a Set of request handlers. Subclasses may override
+ * to add or replace additional handlers.
+ */
+ protected Set<Class<?>> getHandlers() {
// return ImmutableSet.of(ActivityHandler.class, AppDataHandler.class,
// PersonHandler.class, MessageHandler.class, AlbumHandler.class,
// MediaItemHandler.class, ActivityStreamHandler.class);
- return ImmutableSet.of(PersonHandler.class, ActivityHandler.class);
- }
+ return ImmutableSet.of(PersonHandler.class, ActivityHandler.class);
+ }
}
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/PersonServiceDb.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/PersonServiceDb.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/PersonServiceDb.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/PersonServiceDb.java Wed Aug 10 00:18:18 2011
@@ -1,19 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you 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
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.shindig.social.opensocial.jpa.spi;
Modified: incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/SPIUtils.java
URL: http://svn.apache.org/viewvc/incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/SPIUtils.java?rev=1155978&r1=1155977&r2=1155978&view=diff
==============================================================================
--- incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/SPIUtils.java (original)
+++ incubator/rave/trunk/rave-shindig/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/SPIUtils.java Wed Aug 10 00:18:18 2011
@@ -1,19 +1,20 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
+ * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
+ * regarding copyright ownership. The ASF licenses this file
* to you 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
+ * with the License. You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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.
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
package org.apache.shindig.social.opensocial.jpa.spi;