/** {@inheritDoc} */ public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException { if (id != null && AnonymousSecurityToken.ANONYMOUS_ID.equals(id.getUserId())) { Person anonymous = new PersonImpl(); anonymous.setId(AnonymousSecurityToken.ANONYMOUS_ID); anonymous.setName(new NameImpl(ANONYMOUS_NAME)); anonymous.setNickname(ANONYMOUS_NAME); return Futures.immediateFuture(anonymous); } try { JSONArray people = db.getJSONArray(PEOPLE_TABLE); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) { Person personObj = filterFields(person, fields, Person.class); Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID .toString()), fields); personObj.setAppData(appData); return Futures.immediateFuture(personObj); } } throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found"); } catch (JSONException je) { throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je); } }
/** {@inheritDoc} */ public Future<Person> getPerson(UserId id, Set<String> fields, SecurityToken token) throws ProtocolException { if (id != null && AnonymousSecurityToken.ANONYMOUS_ID.equals(id.getUserId())) { Person anonymous = new PersonImpl(); anonymous.setId(AnonymousSecurityToken.ANONYMOUS_ID); anonymous.setName(new NameImpl(ANONYMOUS_NAME)); anonymous.setNickname(ANONYMOUS_NAME); return Futures.immediateFuture(anonymous); } try { JSONArray people = db.getJSONArray(PEOPLE_TABLE); for (int i = 0; i < people.length(); i++) { JSONObject person = people.getJSONObject(i); if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) { Person personObj = filterFields(person, fields, Person.class); Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID .toString()), fields); personObj.setAppData(appData); return Futures.immediateFuture(personObj); } } throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found"); } catch (JSONException je) { throw new ProtocolException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, je.getMessage(), je); } }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); activity.setUrl("http://foo.com/"); activity.setMediaItems(Lists.<MediaItem> newArrayList(new MediaItemImpl( "image/jpg", MediaItem.Type.IMAGE, "http://foo.bar"))); beanXmlConverter = new BeanXStreamConverter(new XStream081Configuration(injector)); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); activity.setUrl("http://foo.com/"); activity.setMediaItems(Lists.<MediaItem> newArrayList(new MediaItemImpl( "image/jpg", MediaItem.Type.IMAGE, "http://foo.bar"))); beanXmlConverter = new BeanXStreamConverter(new XStream081Configuration(injector)); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); activity.setUrl("http://foo.com/"); activity.setMediaItems(Lists.<MediaItem> newArrayList(new MediaItemImpl( "image/jpg", MediaItem.Type.IMAGE, "http://foo.bar"))); beanXmlConverter = new BeanXStreamConverter(new XStream081Configuration(injector)); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); MediaItemImpl mediaItem = new MediaItemImpl(); mediaItem.setMimeType("image/jpg"); mediaItem.setType(MediaItem.Type.IMAGE); mediaItem.setUrl("http://foo.bar"); mediaItem.setLocation(new AddressImpl("Foo bar address")); mediaItem.setNumViews("10000"); activity.setMediaItems(Lists.<MediaItem> newArrayList(mediaItem)); activity.setUrl("http://foo.com"); beanXmlConverter = new BeanXStreamAtomConverter( new XStream081Configuration(injector)); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); MediaItemImpl mediaItem = new MediaItemImpl(); mediaItem.setMimeType("image/jpg"); mediaItem.setType(MediaItem.Type.IMAGE); mediaItem.setUrl("http://foo.bar"); mediaItem.setLocation(new AddressImpl("Foo bar address")); mediaItem.setNumViews("10000"); activity.setMediaItems(Lists.<MediaItem> newArrayList(mediaItem)); activity.setUrl("http://foo.com"); beanXmlConverter = new BeanXStreamAtomConverter( new XStream081Configuration(injector)); }
@Before public void setUp() throws Exception { Injector injector = Guice.createInjector(new SocialApiTestsGuiceModule()); johnDoe = new PersonImpl("johnDoeId", "Johnny", new NameImpl("John Doe")); johnDoe.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl( "home", "+33H000000000"), new ListFieldImpl("mobile", "+33M000000000"), new ListFieldImpl("work", "+33W000000000"))); johnDoe.setAddresses(Lists.<Address> newArrayList(new AddressImpl( "My home address"))); johnDoe.setEmails(Lists.<ListField> newArrayList(new ListFieldImpl("work", "john.doe@work.bar"), new ListFieldImpl("home", "john.doe@home.bar"))); activity = new ActivityImpl("activityId", johnDoe.getId()); MediaItemImpl mediaItem = new MediaItemImpl(); mediaItem.setMimeType("image/jpg"); mediaItem.setType(MediaItem.Type.IMAGE); mediaItem.setUrl("http://foo.bar"); mediaItem.setLocation(new AddressImpl("Foo bar address")); mediaItem.setNumViews("10000"); activity.setMediaItems(Lists.<MediaItem> newArrayList(mediaItem)); activity.setUrl("http://foo.com"); beanXmlConverter = new BeanXStreamAtomConverter( new XStream081Configuration(injector)); }
@Before public void restfulxXmlPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
@Before public void restfulJsonPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
@Before public void restfulJsonPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
@Before public void restfulJsonPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
@Before public void restfulxXmlPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
@Before public void restfulxXmlPeopleTestBefore() throws Exception { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");
public static Person buildCanonicalPerson() { NameImpl name = new NameImpl("Sir Shin H. Digg Social Butterfly"); name.setAdditionalName("H"); name.setFamilyName("Digg");